From 5510f66a123de34eb2fad1aa0a575ef9628e31cc Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 24 Jul 2022 23:29:20 +1000 Subject: [PATCH] Qt: Support changing theme without reopening window --- src/duckstation-qt/gamelistmodel.cpp | 6 ++++++ src/duckstation-qt/gamelistmodel.h | 1 + src/duckstation-qt/gamelistwidget.cpp | 5 +++++ src/duckstation-qt/gamelistwidget.h | 1 + src/duckstation-qt/mainwindow.cpp | 5 ++--- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/duckstation-qt/gamelistmodel.cpp b/src/duckstation-qt/gamelistmodel.cpp index 92b60b025..0a495ea9b 100644 --- a/src/duckstation-qt/gamelistmodel.cpp +++ b/src/duckstation-qt/gamelistmodel.cpp @@ -146,6 +146,12 @@ void GameListModel::updateCacheSize(int width, int height) m_cover_pixmap_cache.SetMaxCapacity(static_cast(std::max(num_columns * num_rows, MIN_COVER_CACHE_SIZE))); } +void GameListModel::reloadCommonImages() +{ + loadCommonImages(); + refresh(); +} + void GameListModel::loadOrGenerateCover(const GameList::Entry* ge) { QFuture future = diff --git a/src/duckstation-qt/gamelistmodel.h b/src/duckstation-qt/gamelistmodel.h index da02eca2d..b7db5eda7 100644 --- a/src/duckstation-qt/gamelistmodel.h +++ b/src/duckstation-qt/gamelistmodel.h @@ -63,6 +63,7 @@ public: int getCoverArtSpacing() const; void refreshCovers(); void updateCacheSize(int width, int height); + void reloadCommonImages(); private: void loadCommonImages(); diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index 5f13f616e..6193940f2 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -455,6 +455,11 @@ void GameListWidget::resizeTableViewColumnsToFit() }); } +void GameListWidget::reloadCommonImages() +{ + m_model->reloadCommonImages(); +} + static TinyString getColumnVisibilitySettingsKeyName(int column) { return TinyString::FromFormat("Show%s", GameListModel::getColumnName(static_cast(column))); diff --git a/src/duckstation-qt/gamelistwidget.h b/src/duckstation-qt/gamelistwidget.h index 785c445c4..87e14fd06 100644 --- a/src/duckstation-qt/gamelistwidget.h +++ b/src/duckstation-qt/gamelistwidget.h @@ -38,6 +38,7 @@ public: void initialize(); void resizeTableViewColumnsToFit(); + void reloadCommonImages(); void refresh(bool invalidate_cache); void cancelRefresh(); diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 23ab64583..17ba96aeb 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -1957,9 +1957,8 @@ void MainWindow::setTheme(const QString& theme) { Host::SetBaseStringSettingValue("UI", "Theme", theme.toUtf8().constData()); updateApplicationTheme(); - - // Sadly we need to recreate here, because otherwise the icon theme doesn't update. - recreate(); + updateMenuSelectedTheme(); + m_game_list_widget->reloadCommonImages(); } void MainWindow::setStyleFromSettings()