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:
parent
0d10ebb7ca
commit
f33b31e048
@ -101,7 +101,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
runningStateChanged(m_instance && m_instance->isRunning());
|
ExternalResourcesPage::runningStateChanged(m_instance && m_instance->isRunning());
|
||||||
|
|
||||||
ui->actionsToolbar->insertSpacer(ui->actionViewConfigs);
|
ui->actionsToolbar->insertSpacer(ui->actionViewConfigs);
|
||||||
|
|
||||||
|
@ -84,21 +84,30 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
|||||||
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem);
|
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem);
|
||||||
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
|
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
|
||||||
|
|
||||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this] {
|
||||||
[this] { 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()));
|
||||||
|
});
|
||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::rowsInserted, this,
|
connect(mods.get(), &ModFolderModel::rowsInserted, this, [this] {
|
||||||
[this] { 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()));
|
||||||
|
});
|
||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::rowsRemoved, this,
|
connect(mods.get(), &ModFolderModel::rowsRemoved, this, [this] {
|
||||||
[this] { 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()));
|
||||||
|
});
|
||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::updateFinished, this, [this, mods] {
|
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
|
// Prevent a weird crash when trying to open the mods page twice in a session o.O
|
||||||
disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0);
|
disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user