Qt: Update icons on dark/light mode switch

This commit is contained in:
Stenzek 2023-09-09 15:55:38 +10:00 committed by Connor McLaughlin
parent 126c6e1b6c
commit 3e79a86008
4 changed files with 21 additions and 1 deletions

View File

@ -1504,6 +1504,11 @@ void MainWindow::onToolsEditCheatsPatchesTriggered(bool cheats)
void MainWindow::updateTheme()
{
QtHost::UpdateApplicationTheme();
reloadThemeSpecificImages();
}
void MainWindow::reloadThemeSpecificImages()
{
m_game_list_widget->reloadThemeSpecificImages();
}
@ -1789,6 +1794,17 @@ void MainWindow::closeEvent(QCloseEvent* event)
m_is_closing = true;
}
void MainWindow::changeEvent(QEvent* event)
{
QMainWindow::changeEvent(event);
if (event->type() == QEvent::StyleChange)
{
QtHost::SetIconThemeFromStyle();
reloadThemeSpecificImages();
}
}
static QString getFilenameFromMimeData(const QMimeData* md)
{
QString filename;

View File

@ -167,6 +167,7 @@ private Q_SLOTS:
void onToolsCoverDownloaderTriggered();
void onToolsEditCheatsPatchesTriggered(bool cheats);
void updateTheme();
void reloadThemeSpecificImages();
void updateLanguage();
void onScreenshotActionTriggered();
void onSaveGSDumpActionTriggered();
@ -199,6 +200,7 @@ private Q_SLOTS:
protected:
void showEvent(QShowEvent* event) override;
void closeEvent(QCloseEvent* event) override;
void changeEvent(QEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;

View File

@ -238,6 +238,9 @@ namespace QtHost
/// Sets application theme according to settings.
void UpdateApplicationTheme();
/// Sets the icon theme, based on the current style (light/dark).
void SetIconThemeFromStyle();
/// Sets batch mode (exit after game shutdown).
bool InBatchMode();

View File

@ -29,7 +29,6 @@
namespace QtHost
{
static void SetStyleFromSettings();
static void SetIconThemeFromStyle();
} // namespace QtHost
static QString s_unthemed_style_name;