diff options
| author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-08-20 12:50:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 12:50:19 +0200 |
| commit | 7e8644430c644ca01f891639b0de9592d9d267c5 (patch) | |
| tree | bc0e5ed198e696cc5835b7e6eb50d6af4f6562f9 /launcher/ui/pages/instance/ModFolderPage.cpp | |
| parent | 70a8f6743a99a72a68ede1a63f66100749d4d106 (diff) | |
| parent | a8aa86291965ddd3cdfa2bb5f5fc7a34170559ed (diff) | |
| download | PrismLauncher-7e8644430c644ca01f891639b0de9592d9d267c5.tar.gz PrismLauncher-7e8644430c644ca01f891639b0de9592d9d267c5.tar.bz2 PrismLauncher-7e8644430c644ca01f891639b0de9592d9d267c5.zip | |
Merge pull request #1007 from Gingeh/disable-update-button
Diffstat (limited to 'launcher/ui/pages/instance/ModFolderPage.cpp')
| -rw-r--r-- | launcher/ui/pages/instance/ModFolderPage.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 14e1f1e5..1b2cde0c 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -84,18 +84,31 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem); connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); - connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, - [this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); }); + auto check_allow_update = [this] { + return (!m_instance || !m_instance->isRunning()) && + (ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); + }; - connect(mods.get(), &ModFolderModel::rowsInserted, this, - [this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); }); - - connect(mods.get(), &ModFolderModel::updateFinished, this, [this, mods] { - ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); + connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] { + ui->actionUpdateItem->setEnabled(check_allow_update()); + }); + + connect(mods.get(), &ModFolderModel::rowsInserted, this, [this, check_allow_update] { + ui->actionUpdateItem->setEnabled(check_allow_update()); + }); + + connect(mods.get(), &ModFolderModel::rowsRemoved, this, [this, check_allow_update] { + ui->actionUpdateItem->setEnabled(check_allow_update()); + }); + + connect(mods.get(), &ModFolderModel::updateFinished, this, [this, check_allow_update, mods] { + ui->actionUpdateItem->setEnabled(check_allow_update()); // Prevent a weird crash when trying to open the mods page twice in a session o.O disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0); }); + + ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning()); } } @@ -103,6 +116,13 @@ CoreModFolderPage::CoreModFolderPage(BaseInstance* inst, std::shared_ptr<ModFold : ModFolderPage(inst, mods, parent) {} +void ModFolderPage::runningStateChanged(bool running) +{ + ExternalResourcesPage::runningStateChanged(running); + ui->actionDownloadItem->setEnabled(!running); + ui->actionUpdateItem->setEnabled(!running); +} + bool ModFolderPage::shouldDisplay() const { return true; |
