summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
Diffstat (limited to 'application/pages')
-rw-r--r--application/pages/instance/ModFolderPage.cpp28
-rw-r--r--application/pages/instance/ModFolderPage.h8
2 files changed, 31 insertions, 5 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());
}
diff --git a/application/pages/instance/ModFolderPage.h b/application/pages/instance/ModFolderPage.h
index 2c9dd2d3..77fe877d 100644
--- a/application/pages/instance/ModFolderPage.h
+++ b/application/pages/instance/ModFolderPage.h
@@ -67,18 +67,19 @@ protected:
bool modListFilter(QKeyEvent *ev);
protected:
- BaseInstance *m_inst;
+ BaseInstance *m_inst = nullptr;
protected:
- Ui::ModFolderPage *ui;
+ Ui::ModFolderPage *ui = nullptr;
std::shared_ptr<SimpleModList> m_mods;
- QSortFilterProxyModel *m_filterModel;
+ QSortFilterProxyModel *m_filterModel = nullptr;
QString m_iconName;
QString m_id;
QString m_displayName;
QString m_helpName;
QString m_fileSelectionFilter;
QString m_viewFilter;
+ bool m_controlsEnabled = true;
public
slots:
@@ -87,6 +88,7 @@ slots:
private
slots:
void on_filterTextChanged(const QString & newContents);
+ void on_RunningState_changed(bool running);
void on_addModBtn_clicked();
void on_rmModBtn_clicked();
void on_viewModBtn_clicked();