Check for running instance when re-opening the mod folder page and when selecting mods

Signed-off-by: Gingeh <39150378+Gingeh@users.noreply.github.com>
This commit is contained in:
Gingeh 2022-08-02 14:14:45 +10:00
parent 0d10ebb7ca
commit f33b31e048
2 changed files with 18 additions and 9 deletions

View File

@ -101,7 +101,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
{
ui->setupUi(this);
runningStateChanged(m_instance && m_instance->isRunning());
ExternalResourcesPage::runningStateChanged(m_instance && m_instance->isRunning());
ui->actionsToolbar->insertSpacer(ui->actionViewConfigs);

View File

@ -84,21 +84,30 @@ 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()); });
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this] {
ui->actionUpdateItem->setEnabled(!(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::rowsInserted, this, [this] {
ui->actionUpdateItem->setEnabled(!(m_instance && m_instance->isRunning()) &&
(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()));
});
connect(mods.get(), &ModFolderModel::rowsRemoved, this, [this] {
ui->actionUpdateItem->setEnabled(!(m_instance && m_instance->isRunning()) &&
(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()));
});
connect(mods.get(), &ModFolderModel::rowsRemoved, 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());
ui->actionUpdateItem->setEnabled(!(m_instance && m_instance->isRunning()) &&
(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()));
// 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());
}
}