diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-07-15 01:07:21 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-07-15 01:07:21 +0200 |
commit | 80b3efff11a34e2df7d1bc4cc3187e6aaf57e687 (patch) | |
tree | 0e09e162ccc24decf6e10397b2fb3963da1d364d /application/pages/instance/ModFolderPage.cpp | |
parent | e4273d6a174ffb771728f32b5e2a8a36096c4e21 (diff) | |
download | MultiMC-80b3efff11a34e2df7d1bc4cc3187e6aaf57e687.tar MultiMC-80b3efff11a34e2df7d1bc4cc3187e6aaf57e687.tar.gz MultiMC-80b3efff11a34e2df7d1bc4cc3187e6aaf57e687.tar.lz MultiMC-80b3efff11a34e2df7d1bc4cc3187e6aaf57e687.tar.xz MultiMC-80b3efff11a34e2df7d1bc4cc3187e6aaf57e687.zip |
NOISSUE Do not hide mods list pages when the instance is running.
Instead, disable (most of) the controls.
Diffstat (limited to 'application/pages/instance/ModFolderPage.cpp')
-rw-r--r-- | application/pages/instance/ModFolderPage.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/application/pages/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp index 15dd55a2..590a65b1 100644 --- a/application/pages/instance/ModFolderPage.cpp +++ b/application/pages/instance/ModFolderPage.cpp @@ -39,6 +39,7 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> ui->setupUi(this); ui->tabWidget->tabBar()->hide(); m_inst = inst; + on_RunningState_changed(m_inst && m_inst->isRunning()); m_mods = mods; m_id = id; m_displayName = displayName; @@ -57,6 +58,7 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> auto smodel = ui->modTreeView->selectionModel(); connect(smodel, &QItemSelectionModel::currentChanged, this, &ModFolderPage::modCurrent); connect(ui->filterEdit, &QLineEdit::textChanged, this, &ModFolderPage::on_filterTextChanged ); + connect(m_inst, &BaseInstance::runningStatusChanged, this, &ModFolderPage::on_RunningState_changed); } void ModFolderPage::openedImpl() @@ -89,10 +91,20 @@ ModFolderPage::~ModFolderPage() delete ui; } +void ModFolderPage::on_RunningState_changed(bool running) +{ + if(m_controlsEnabled == !running) { + return; + } + m_controlsEnabled = !running; + ui->addModBtn->setEnabled(m_controlsEnabled); + ui->disableModBtn->setEnabled(m_controlsEnabled); + ui->enableModBtn->setEnabled(m_controlsEnabled); + ui->rmModBtn->setEnabled(m_controlsEnabled); +} + bool ModFolderPage::shouldDisplay() const { - if (m_inst) - return !m_inst->isRunning(); return true; } @@ -152,6 +164,9 @@ bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev) void ModFolderPage::on_addModBtn_clicked() { + if(!m_controlsEnabled) { + return; + } auto list = GuiUtil::BrowseForFiles( m_helpName, tr("Select %1", @@ -170,18 +185,27 @@ void ModFolderPage::on_addModBtn_clicked() void ModFolderPage::on_enableModBtn_clicked() { + if(!m_controlsEnabled) { + return; + } auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection()); m_mods->enableMods(selection.indexes(), true); } void ModFolderPage::on_disableModBtn_clicked() { + if(!m_controlsEnabled) { + return; + } auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection()); m_mods->enableMods(selection.indexes(), false); } void ModFolderPage::on_rmModBtn_clicked() { + if(!m_controlsEnabled) { + return; + } auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection()); m_mods->deleteMods(selection.indexes()); } |