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) {
return;
}
m_current_item = item; // Store current item
SetListBackgroundImage(item);
PlayBackgroundMusic(item);
}
@ -388,3 +389,7 @@ QString GameListFrame::GetPlayTime(const std::string& serial) {
file.close();
return playTime;
}
QTableWidgetItem* GameListFrame::GetCurrentItem() {
return m_current_item;
}

View File

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

View File

@ -292,6 +292,19 @@ void MainWindow::CreateConnects() {
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
&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();
});

View File

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

View File

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