summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-07-11 01:01:47 +0200
committerPetr Mrázek <peterix@gmail.com>2019-07-11 01:01:47 +0200
commitb9d429355255d10541fd14799c419a1b5aeeb128 (patch)
treea6842c81878ae32abf42c0bca6f635acbefac72c
parent5110b58def7e3e3118e6624959d6e5d561002c74 (diff)
downloadMultiMC-b9d429355255d10541fd14799c419a1b5aeeb128.tar
MultiMC-b9d429355255d10541fd14799c419a1b5aeeb128.tar.gz
MultiMC-b9d429355255d10541fd14799c419a1b5aeeb128.tar.lz
MultiMC-b9d429355255d10541fd14799c419a1b5aeeb128.tar.xz
MultiMC-b9d429355255d10541fd14799c419a1b5aeeb128.zip
NOISSUE update component buttons some more when the versions change
-rw-r--r--api/logic/minecraft/ComponentList.cpp3
-rw-r--r--api/logic/minecraft/ComponentList.h3
-rw-r--r--api/logic/minecraft/MinecraftInstance.h3
-rw-r--r--application/pages/instance/VersionPage.cpp60
-rw-r--r--application/pages/instance/VersionPage.h1
5 files changed, 32 insertions, 38 deletions
diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/ComponentList.cpp
index e5c373a4..b2afdb17 100644
--- a/api/logic/minecraft/ComponentList.cpp
+++ b/api/logic/minecraft/ComponentList.cpp
@@ -635,6 +635,9 @@ void ComponentList::componentDataChanged()
qWarning() << "ComponentList got dataChenged signal from a non-Component!";
return;
}
+ if(objPtr->getID() == "net.minecraft") {
+ emit minecraftChanged();
+ }
// figure out which one is it... in a seriously dumb way.
int index = 0;
for (auto component: d->components)
diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/ComponentList.h
index 18beaf60..cb20c559 100644
--- a/api/logic/minecraft/ComponentList.h
+++ b/api/logic/minecraft/ComponentList.h
@@ -104,6 +104,9 @@ public:
/// if there is a save scheduled, do it now.
void saveNow();
+signals:
+ void minecraftChanged();
+
public:
/// get the profile component by id
Component * getComponent(const QString &id);
diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h
index fac309c2..501697f7 100644
--- a/api/logic/minecraft/MinecraftInstance.h
+++ b/api/logic/minecraft/MinecraftInstance.h
@@ -113,9 +113,6 @@ public:
virtual JavaVersion getJavaVersion() const;
-signals:
- void versionReloaded();
-
protected:
QMap<QString, QString> createCensorFilterFromSession(AuthSessionPtr session);
QStringList validLaunchMethods();
diff --git a/application/pages/instance/VersionPage.cpp b/application/pages/instance/VersionPage.cpp
index 6f1b9206..f27d562a 100644
--- a/application/pages/instance/VersionPage.cpp
+++ b/application/pages/instance/VersionPage.cpp
@@ -109,25 +109,18 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
reloadComponentList();
- if (m_profile)
- {
- auto proxy = new IconProxy(ui->packageView);
- proxy->setSourceModel(m_profile.get());
- ui->packageView->setModel(proxy);
- ui->packageView->installEventFilter(this);
- ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
- connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
- auto smodel = ui->packageView->selectionModel();
- connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
- updateVersionControls();
- // select first item.
- preselect(0);
- }
- else
- {
- disableVersionControls();
- }
- connect(m_inst, &MinecraftInstance::versionReloaded, this, &VersionPage::updateVersionControls);
+ auto proxy = new IconProxy(ui->packageView);
+ proxy->setSourceModel(m_profile.get());
+ ui->packageView->setModel(proxy);
+ ui->packageView->installEventFilter(this);
+ ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
+ connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
+ auto smodel = ui->packageView->selectionModel();
+ connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
+
+ updateVersionControls();
+ preselect(0);
+ connect(m_profile.get(), &ComponentList::minecraftChanged, this, &VersionPage::updateVersionControls);
}
VersionPage::~VersionPage()
@@ -181,21 +174,20 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
void VersionPage::updateVersionControls()
{
// FIXME: this is a dirty hack
- auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
- bool newCraft = minecraftVersion >= Version("1.14");
- bool oldCraft = minecraftVersion <= Version("1.12.2");
- ui->fabricBtn->setEnabled(newCraft);
- ui->forgeBtn->setEnabled(oldCraft);
- ui->liteloaderBtn->setEnabled(oldCraft);
- updateButtons();
-}
-
-void VersionPage::disableVersionControls()
-{
- ui->fabricBtn->setEnabled(false);
- ui->forgeBtn->setEnabled(false);
- ui->liteloaderBtn->setEnabled(false);
- ui->reloadBtn->setEnabled(false);
+ 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->fabricBtn->setEnabled(newCraft);
+ ui->forgeBtn->setEnabled(oldCraft);
+ ui->liteloaderBtn->setEnabled(oldCraft);
+ }
+ else {
+ ui->fabricBtn->setEnabled(false);
+ ui->forgeBtn->setEnabled(false);
+ ui->liteloaderBtn->setEnabled(false);
+ ui->reloadBtn->setEnabled(false);
+ }
updateButtons();
}
diff --git a/application/pages/instance/VersionPage.h b/application/pages/instance/VersionPage.h
index 4957c9ea..2d64120a 100644
--- a/application/pages/instance/VersionPage.h
+++ b/application/pages/instance/VersionPage.h
@@ -66,7 +66,6 @@ private slots:
void on_downloadBtn_clicked();
void updateVersionControls();
- void disableVersionControls();
void on_changeVersionBtn_clicked();
private: