Qt: Fix grid scale resetting on theme change

Closes #8044.
This commit is contained in:
Stenzek 2023-09-09 13:30:53 +10:00 committed by Connor McLaughlin
parent 96f0d65f7d
commit 9dde599e00
5 changed files with 15 additions and 9 deletions

View File

@ -132,13 +132,14 @@ GameListModel::GameListModel(QObject* parent /* = nullptr */)
, m_cover_pixmap_cache(MIN_COVER_CACHE_SIZE)
{
loadCommonImages();
setCoverScale(1.0f);
setColumnDisplayNames();
}
GameListModel::~GameListModel() = default;
void GameListModel::refreshImages()
void GameListModel::reloadThemeSpecificImages()
{
loadCommonImages();
loadThemeSpecificImages();
refresh();
}
@ -562,20 +563,24 @@ QIcon GameListModel::getIconForRegion(GameList::Region region)
QStringLiteral("%1/icons/flags/%2.png").arg(QtHost::GetResourcesBasePath()).arg(GameList::RegionToString(region)));
}
void GameListModel::loadCommonImages()
void GameListModel::loadThemeSpecificImages()
{
for (u32 type = 0; type < static_cast<u32>(GameList::EntryType::Count); type++)
m_type_pixmaps[type] = getIconForType(static_cast<GameList::EntryType>(type)).pixmap(QSize(24, 24));
for (u32 i = 0; i < static_cast<u32>(GameList::Region::Count); i++)
m_region_pixmaps[i] = getIconForRegion(static_cast<GameList::Region>(i)).pixmap(QSize(42, 30));
}
void GameListModel::loadCommonImages()
{
loadThemeSpecificImages();
const QString base_path(QtHost::GetResourcesBasePath());
for (u32 i = 1; i < GameList::CompatibilityRatingCount; i++)
m_compatibility_pixmaps[i].load(QStringLiteral("%1/icons/star-%2.png").arg(base_path).arg(i - 1));
m_placeholder_pixmap.load(QStringLiteral("%1/cover-placeholder.png").arg(base_path));
setCoverScale(1.0f);
}
void GameListModel::setColumnDisplayNames()

View File

@ -66,7 +66,7 @@ public:
__fi const QString& getColumnDisplayName(int column) { return m_column_display_names[column]; }
void refresh();
void refreshImages();
void reloadThemeSpecificImages();
bool titlesLessThan(int left_row, int right_row) const;
@ -85,6 +85,7 @@ public:
private:
void loadCommonImages();
void loadThemeSpecificImages();
void setColumnDisplayNames();
void loadOrGenerateCover(const GameList::Entry* ge);
void invalidateCoverForPath(const std::string& path);

View File

@ -260,9 +260,9 @@ void GameListWidget::cancelRefresh()
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
}
void GameListWidget::refreshImages()
void GameListWidget::reloadThemeSpecificImages()
{
m_model->refreshImages();
m_model->reloadThemeSpecificImages();
}
void GameListWidget::onRefreshProgress(const QString& status, int current, int total)

View File

@ -59,7 +59,7 @@ public:
void refresh(bool invalidate_cache);
void cancelRefresh();
void refreshImages();
void reloadThemeSpecificImages();
bool isShowingGameList() const;
bool isShowingGameGrid() const;

View File

@ -1478,7 +1478,7 @@ void MainWindow::onToolsCoverDownloaderTriggered()
void MainWindow::updateTheme()
{
QtHost::UpdateApplicationTheme();
m_game_list_widget->refreshImages();
m_game_list_widget->reloadThemeSpecificImages();
}
void MainWindow::updateLanguage()