From 973c4327e39bb78e95ecc4abf5ee7d366c7776fc Mon Sep 17 00:00:00 2001 From: dada513 Date: Sat, 11 Jun 2022 19:41:02 +0200 Subject: [PATCH] Merge pull request #773 from vancez/fix-launch-button --- launcher/ui/MainWindow.cpp | 11 +++++++++++ launcher/ui/MainWindow.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 7e152b96b..0a5f20007 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2101,6 +2101,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & selectionBad(); return; } + if (m_selectedInstance) { + disconnect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance); + } QString id = current.data(InstanceList::InstanceIDRole).toString(); m_selectedInstance = APPLICATION->instances()->getInstanceById(id); if (m_selectedInstance) @@ -2127,6 +2130,8 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & updateToolsMenu(); APPLICATION->settings()->set("SelectedInstance", m_selectedInstance->id()); + + connect(m_selectedInstance.get(), &BaseInstance::runningStatusChanged, this, &MainWindow::refreshCurrentInstance); } else { @@ -2216,3 +2221,9 @@ void MainWindow::updateStatusCenter() m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed))); } } + +void MainWindow::refreshCurrentInstance(bool running) +{ + auto current = view->selectionModel()->currentIndex(); + instanceChanged(current, current); +} diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 2032acbaf..61a75c450 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -192,6 +192,8 @@ private slots: void keyReleaseEvent(QKeyEvent *event) override; #endif + void refreshCurrentInstance(bool running); + private: void retranslateUi();