summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-07-15 23:16:34 +0200
committerPetr Mrázek <peterix@gmail.com>2019-07-15 23:16:34 +0200
commit6fde775b9017401351425186deffd685827df3d3 (patch)
treecd8b37944c7dec955f9e21f32755596070f64308 /application
parent80b3efff11a34e2df7d1bc4cc3187e6aaf57e687 (diff)
downloadMultiMC-6fde775b9017401351425186deffd685827df3d3.tar
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.gz
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.lz
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.xz
MultiMC-6fde775b9017401351425186deffd685827df3d3.zip
NOISSUE Show Version page while the instancer is running.
All controls are disabled.
Diffstat (limited to 'application')
-rw-r--r--application/pages/instance/VersionPage.cpp85
-rw-r--r--application/pages/instance/VersionPage.h2
2 files changed, 41 insertions, 46 deletions
diff --git a/application/pages/instance/VersionPage.cpp b/application/pages/instance/VersionPage.cpp
index ed300e77..ed2f1391 100644
--- a/application/pages/instance/VersionPage.cpp
+++ b/application/pages/instance/VersionPage.cpp
@@ -97,7 +97,7 @@ QIcon VersionPage::icon() const
}
bool VersionPage::shouldDisplay() const
{
- return !m_inst->isRunning();
+ return true;
}
QMenu * VersionPage::createPopupMenu()
@@ -140,9 +140,11 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
auto smodel = ui->packageView->selectionModel();
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
+ connect(m_profile.get(), &ComponentList::minecraftChanged, this, &VersionPage::updateVersionControls);
+ controlsEnabled = !m_inst->isRunning();
updateVersionControls();
preselect(0);
- connect(m_profile.get(), &ComponentList::minecraftChanged, this, &VersionPage::updateVersionControls);
+ connect(m_inst, &BaseInstance::runningStatusChanged, this, &VersionPage::updateRunningStatus);
}
VersionPage::~VersionPage()
@@ -192,28 +194,47 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
ui->frame->setModDescription(problemOut);
}
+void VersionPage::updateRunningStatus(bool running)
+{
+ if(controlsEnabled == running) {
+ controlsEnabled = !running;
+ updateVersionControls();
+ }
+}
void VersionPage::updateVersionControls()
{
// FIXME: this is a dirty hack
- if(m_profile) {
- auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
- bool newCraft = minecraftVersion >= Version("1.14");
- bool oldCraft = minecraftVersion <= Version("1.12.2");
- ui->actionInstall_Fabric->setEnabled(newCraft);
- ui->actionInstall_Forge->setEnabled(oldCraft);
- ui->actionInstall_LiteLoader->setEnabled(oldCraft);
- ui->actionReload->setEnabled(true);
- }
- else {
- ui->actionInstall_Fabric->setEnabled(false);
- ui->actionInstall_Forge->setEnabled(false);
- ui->actionInstall_LiteLoader->setEnabled(false);
- ui->actionReload->setEnabled(false);
- }
+ auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
+ bool newCraft = controlsEnabled && (minecraftVersion >= Version("1.14"));
+ bool oldCraft = controlsEnabled && (minecraftVersion <= Version("1.12.2"));
+ ui->actionInstall_Fabric->setEnabled(newCraft);
+ ui->actionInstall_Forge->setEnabled(oldCraft);
+ ui->actionInstall_LiteLoader->setEnabled(oldCraft);
+ ui->actionReload->setEnabled(true);
updateButtons();
}
+void VersionPage::updateButtons(int row)
+{
+ if(row == -1)
+ row = currentRow();
+ auto patch = m_profile->getComponent(row);
+ ui->actionRemove->setEnabled(controlsEnabled && patch && patch->isRemovable());
+ ui->actionMove_down->setEnabled(controlsEnabled && patch && patch->isMoveable());
+ ui->actionMove_up->setEnabled(controlsEnabled && patch && patch->isMoveable());
+ ui->actionChange_version->setEnabled(controlsEnabled && patch && patch->isVersionChangeable());
+ ui->actionEdit->setEnabled(controlsEnabled && patch && patch->isCustom());
+ ui->actionCustomize->setEnabled(controlsEnabled && patch && patch->isCustomizable());
+ ui->actionRevert->setEnabled(controlsEnabled && patch && patch->isRevertible());
+ ui->actionDownload_All->setEnabled(controlsEnabled);
+ ui->actionAdd_Empty->setEnabled(controlsEnabled);
+ ui->actionReload->setEnabled(controlsEnabled);
+ ui->actionInstall_mods->setEnabled(controlsEnabled);
+ ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled);
+ ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled);
+}
+
bool VersionPage::reloadComponentList()
{
try
@@ -515,37 +536,9 @@ void VersionPage::preselect(int row)
updateButtons(row);
}
-void VersionPage::updateButtons(int row)
-{
- if(row == -1)
- row = currentRow();
- auto patch = m_profile->getComponent(row);
- if (!patch)
- {
- ui->actionRemove->setDisabled(true);
- ui->actionMove_down->setDisabled(true);
- ui->actionMove_up->setDisabled(true);
- ui->actionChange_version->setDisabled(true);
- ui->actionEdit->setDisabled(true);
- ui->actionCustomize->setDisabled(true);
- ui->actionRevert->setDisabled(true);
- }
- else
- {
- ui->actionRemove->setEnabled(patch->isRemovable());
- ui->actionMove_down->setEnabled(patch->isMoveable());
- ui->actionMove_up->setEnabled(patch->isMoveable());
- ui->actionChange_version->setEnabled(patch->isVersionChangeable());
- ui->actionEdit->setEnabled(patch->isCustom());
- ui->actionCustomize->setEnabled(patch->isCustomizable());
- ui->actionRevert->setEnabled(patch->isRevertible());
- }
-}
-
void VersionPage::onGameUpdateError(QString error)
{
- CustomMessageBox::selectable(this, tr("Error updating instance"), error,
- QMessageBox::Warning)->show();
+ CustomMessageBox::selectable(this, tr("Error updating instance"), error, QMessageBox::Warning)->show();
}
Component * VersionPage::current()
diff --git a/application/pages/instance/VersionPage.h b/application/pages/instance/VersionPage.h
index 6f5285ac..553c6ae3 100644
--- a/application/pages/instance/VersionPage.h
+++ b/application/pages/instance/VersionPage.h
@@ -86,11 +86,13 @@ private:
std::shared_ptr<ComponentList> m_profile;
MinecraftInstance *m_inst;
int currentIdx = 0;
+ bool controlsEnabled = false;
public slots:
void versionCurrent(const QModelIndex &current, const QModelIndex &previous);
private slots:
+ void updateRunningStatus(bool running);
void onGameUpdateError(QString error);
void packageCurrent(const QModelIndex &current, const QModelIndex &previous);