Qt: Set game icon as window icon in Game Properties

This commit is contained in:
Stenzek
2025-11-16 01:40:33 +10:00
parent b3385094f9
commit c396f0ab8d
3 changed files with 11 additions and 1 deletions

View File

@@ -671,7 +671,7 @@ void MainWindow::onSystemGameChanged(const QString& path, const QString& game_se
s_current_game_path = path; s_current_game_path = path;
s_current_game_title = game_title; s_current_game_title = game_title;
s_current_game_serial = game_serial; s_current_game_serial = game_serial;
s_current_game_icon = m_game_list_widget->getModel()->getIconForGame(path); s_current_game_icon = getIconForGame(path);
updateWindowTitle(); updateWindowTitle();
} }
@@ -3027,6 +3027,11 @@ void MainWindow::cancelGameListRefresh()
m_game_list_widget->cancelRefresh(); m_game_list_widget->cancelRefresh();
} }
QIcon MainWindow::getIconForGame(const QString& path)
{
return m_game_list_widget->getModel()->getIconForGame(path);
}
void MainWindow::runOnUIThread(const std::function<void()>& func) void MainWindow::runOnUIThread(const std::function<void()>& func)
{ {
func(); func();

View File

@@ -123,6 +123,7 @@ public:
void refreshGameList(bool invalidate_cache); void refreshGameList(bool invalidate_cache);
void refreshGameListModel(); void refreshGameListModel();
void cancelGameListRefresh(); void cancelGameListRefresh();
QIcon getIconForGame(const QString& path);
void runOnUIThread(const std::function<void()>& func); void runOnUIThread(const std::function<void()>& func);
void requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety, void requestShutdown(bool allow_confirm, bool allow_save_to_state, bool save_state, bool check_safety,

View File

@@ -57,6 +57,10 @@ SettingsWindow::SettingsWindow(const GameList::Entry* entry, std::unique_ptr<INI
m_hash(entry->hash) m_hash(entry->hash)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
if (const QIcon icon = g_main_window->getIconForGame(QString::fromStdString(entry->path)); !icon.isNull())
setWindowIcon(icon);
setGameTitle(entry->GetDisplayTitle(GameList::ShouldShowLocalizedTitles())); setGameTitle(entry->GetDisplayTitle(GameList::ShouldShowLocalizedTitles()));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);