From a5b0b4800a592172ba4ff6c6421bc0f0abdef5e0 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 27 Nov 2022 23:10:32 +0100 Subject: [PATCH] fix: make resource buttons work when instance is running Signed-off-by: Sefa Eyeoglu --- launcher/ui/pages/instance/ExternalResourcesPage.cpp | 11 ----------- launcher/ui/pages/instance/ExternalResourcesPage.h | 1 - launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- launcher/ui/pages/instance/ModFolderPage.h | 2 +- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index b6c873cc..5c919573 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -14,8 +14,6 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared { ui->setupUi(this); - ExternalResourcesPage::runningStateChanged(m_instance && m_instance->isRunning()); - ui->actionsToolbar->insertSpacer(ui->actionViewConfigs); m_filterModel = model->createFilterProxyModel(this); @@ -45,7 +43,6 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared auto selection_model = ui->treeView->selectionModel(); connect(selection_model, &QItemSelectionModel::currentChanged, this, &ExternalResourcesPage::current); connect(ui->filterEdit, &QLineEdit::textChanged, this, &ExternalResourcesPage::filterTextChanged); - connect(m_instance, &BaseInstance::runningStatusChanged, this, &ExternalResourcesPage::runningStateChanged); } ExternalResourcesPage::~ExternalResourcesPage() @@ -97,14 +94,6 @@ void ExternalResourcesPage::filterTextChanged(const QString& newContents) m_filterModel->setFilterRegularExpression(m_viewFilter); } -void ExternalResourcesPage::runningStateChanged(bool running) -{ - if (m_controlsEnabled == !running) - return; - - m_controlsEnabled = !running; -} - bool ExternalResourcesPage::shouldDisplay() const { return true; diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h index 8e352cef..11058bf6 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.h +++ b/launcher/ui/pages/instance/ExternalResourcesPage.h @@ -47,7 +47,6 @@ class ExternalResourcesPage : public QMainWindow, public BasePage { protected slots: void itemActivated(const QModelIndex& index); void filterTextChanged(const QString& newContents); - virtual void runningStateChanged(bool running); virtual void addItem(); virtual void removeItem(); diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index f0106066..0a2e6155 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -108,13 +108,13 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0); }); + connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged); ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning()); } } void ModFolderPage::runningStateChanged(bool running) { - ExternalResourcesPage::runningStateChanged(running); ui->actionDownloadItem->setEnabled(!running); ui->actionUpdateItem->setEnabled(!running); ui->actionAddItem->setEnabled(!running); diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h index c9a55bde..f20adf34 100644 --- a/launcher/ui/pages/instance/ModFolderPage.h +++ b/launcher/ui/pages/instance/ModFolderPage.h @@ -53,12 +53,12 @@ class ModFolderPage : public ExternalResourcesPage { virtual QString helpPage() const override { return "Loader-mods"; } virtual bool shouldDisplay() const override; - void runningStateChanged(bool running) override; public slots: bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override; private slots: + void runningStateChanged(bool running); void removeItem() override; void installMods();