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() void MainWindow::updateTheme()
{ {
QtHost::UpdateApplicationTheme(); QtHost::UpdateApplicationTheme();
reloadThemeSpecificImages();
}
void MainWindow::reloadThemeSpecificImages()
{
m_game_list_widget->reloadThemeSpecificImages(); m_game_list_widget->reloadThemeSpecificImages();
} }
@ -1789,6 +1794,17 @@ void MainWindow::closeEvent(QCloseEvent* event)
m_is_closing = true; 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) static QString getFilenameFromMimeData(const QMimeData* md)
{ {
QString filename; QString filename;

View File

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

View File

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

View File

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