Background image update on apply/save

This commit is contained in:
Pablo Santana 2025-02-03 18:29:12 +01:00
parent 224aece029
commit 91ff7e743c
5 changed files with 22 additions and 3 deletions

View File

@ -89,6 +89,7 @@ void GameListFrame::onCurrentCellChanged(int currentRow, int currentColumn, int
if (!item) { if (!item) {
return; return;
} }
m_current_item = item; // Store current item
SetListBackgroundImage(item); SetListBackgroundImage(item);
PlayBackgroundMusic(item); PlayBackgroundMusic(item);
} }
@ -388,3 +389,7 @@ QString GameListFrame::GetPlayTime(const std::string& serial) {
file.close(); file.close();
return playTime; return playTime;
} }
QTableWidgetItem* GameListFrame::GetCurrentItem() {
return m_current_item;
}

View File

@ -44,11 +44,12 @@ private:
QList<QAction*> m_columnActs; QList<QAction*> m_columnActs;
GameInfoClass* game_inf_get = nullptr; GameInfoClass* game_inf_get = nullptr;
bool ListSortedAsc = true; bool ListSortedAsc = true;
QTableWidgetItem* m_current_item = nullptr;
public: public:
void PopulateGameList(bool isInitialPopulation = true); void PopulateGameList(bool isInitialPopulation = true);
void ResizeIcons(int iconSize); void ResizeIcons(int iconSize);
QTableWidgetItem* GetCurrentItem();
QImage backgroundImage; QImage backgroundImage;
GameListUtils m_game_list_utils; GameListUtils m_game_list_utils;
GuiContextMenus m_gui_context_menus; GuiContextMenus m_gui_context_menus;

View File

@ -292,6 +292,19 @@ void MainWindow::CreateConnects() {
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this, connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
&MainWindow::RefreshGameTable); &MainWindow::RefreshGameTable);
// Connect background opacity changes to refresh both frames
connect(
settingsDialog, &SettingsDialog::BackgroundOpacityChanged, this, [this](int opacity) {
Config::setBackgroundImageOpacity(opacity);
if (m_game_list_frame) {
m_game_list_frame->SetListBackgroundImage(m_game_list_frame->GetCurrentItem());
}
if (m_game_grid_frame) {
m_game_grid_frame->SetGridBackgroundImage(m_game_grid_frame->crtRow,
m_game_grid_frame->crtColumn);
}
});
settingsDialog->exec(); settingsDialog->exec();
}); });

View File

@ -176,8 +176,6 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
connect(ui->showBackgroundImageCheckBox, &QCheckBox::stateChanged, this, connect(ui->showBackgroundImageCheckBox, &QCheckBox::stateChanged, this,
[](int state) { Config::setShowBackgroundImage(state == Qt::Checked); }); [](int state) { Config::setShowBackgroundImage(state == Qt::Checked); });
connect(ui->backgroundImageOpacitySlider, &QSlider::valueChanged, this,
[](int value) { Config::setBackgroundImageOpacity(value); });
} }
// Input TAB // Input TAB
{ {
@ -649,6 +647,7 @@ void SettingsDialog::UpdateSettings() {
Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked()); Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked());
Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked()); Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked());
Config::setBackgroundImageOpacity(ui->backgroundImageOpacitySlider->value()); Config::setBackgroundImageOpacity(ui->backgroundImageOpacitySlider->value());
emit BackgroundOpacityChanged(ui->backgroundImageOpacitySlider->value());
Config::setShowBackgroundImage(ui->showBackgroundImageCheckBox->isChecked()); Config::setShowBackgroundImage(ui->showBackgroundImageCheckBox->isChecked());
#ifdef ENABLE_DISCORD_RPC #ifdef ENABLE_DISCORD_RPC

View File

@ -33,6 +33,7 @@ public:
signals: signals:
void LanguageChanged(const std::string& locale); void LanguageChanged(const std::string& locale);
void CompatibilityChanged(); void CompatibilityChanged();
void BackgroundOpacityChanged(int opacity);
private: private:
void LoadValuesFromConfig(); void LoadValuesFromConfig();