Merge pull request #1007 from Gingeh/disable-update-button
This commit is contained in:
commit
7e8644430c
@ -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);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
|
|||||||
protected slots:
|
protected slots:
|
||||||
void itemActivated(const QModelIndex& index);
|
void itemActivated(const QModelIndex& index);
|
||||||
void filterTextChanged(const QString& newContents);
|
void filterTextChanged(const QString& newContents);
|
||||||
void runningStateChanged(bool running);
|
virtual void runningStateChanged(bool running);
|
||||||
|
|
||||||
virtual void addItem();
|
virtual void addItem();
|
||||||
virtual void removeItem();
|
virtual void removeItem();
|
||||||
|
@ -84,18 +84,31 @@ 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,
|
auto check_allow_update = [this] {
|
||||||
[this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); });
|
return (!m_instance || !m_instance->isRunning()) &&
|
||||||
|
(ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
|
||||||
|
};
|
||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::rowsInserted, this,
|
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
|
||||||
[this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); });
|
ui->actionUpdateItem->setEnabled(check_allow_update());
|
||||||
|
});
|
||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::updateFinished, this, [this, mods] {
|
connect(mods.get(), &ModFolderModel::rowsInserted, this, [this, check_allow_update] {
|
||||||
ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
|
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
|
// 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +116,13 @@ CoreModFolderPage::CoreModFolderPage(BaseInstance* inst, std::shared_ptr<ModFold
|
|||||||
: ModFolderPage(inst, mods, parent)
|
: ModFolderPage(inst, mods, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void ModFolderPage::runningStateChanged(bool running)
|
||||||
|
{
|
||||||
|
ExternalResourcesPage::runningStateChanged(running);
|
||||||
|
ui->actionDownloadItem->setEnabled(!running);
|
||||||
|
ui->actionUpdateItem->setEnabled(!running);
|
||||||
|
}
|
||||||
|
|
||||||
bool ModFolderPage::shouldDisplay() const
|
bool ModFolderPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -53,6 +53,7 @@ class ModFolderPage : public ExternalResourcesPage {
|
|||||||
virtual QString helpPage() const override { return "Loader-mods"; }
|
virtual QString helpPage() const override { return "Loader-mods"; }
|
||||||
|
|
||||||
virtual bool shouldDisplay() const override;
|
virtual bool shouldDisplay() const override;
|
||||||
|
void runningStateChanged(bool running) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void installMods();
|
void installMods();
|
||||||
|
Loading…
Reference in New Issue
Block a user