Skip to content

Commit b9d4293

Browse files
committed
NOISSUE update component buttons some more when the versions change
1 parent 5110b58 commit b9d4293

5 files changed

Lines changed: 32 additions & 38 deletions

File tree

api/logic/minecraft/ComponentList.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ void ComponentList::componentDataChanged()
635635
qWarning() << "ComponentList got dataChenged signal from a non-Component!";
636636
return;
637637
}
638+
if(objPtr->getID() == "net.minecraft") {
639+
emit minecraftChanged();
640+
}
638641
// figure out which one is it... in a seriously dumb way.
639642
int index = 0;
640643
for (auto component: d->components)

api/logic/minecraft/ComponentList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class MULTIMC_LOGIC_EXPORT ComponentList : public QAbstractListModel
104104
/// if there is a save scheduled, do it now.
105105
void saveNow();
106106

107+
signals:
108+
void minecraftChanged();
109+
107110
public:
108111
/// get the profile component by id
109112
Component * getComponent(const QString &id);

api/logic/minecraft/MinecraftInstance.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ class MULTIMC_LOGIC_EXPORT MinecraftInstance: public BaseInstance
113113

114114
virtual JavaVersion getJavaVersion() const;
115115

116-
signals:
117-
void versionReloaded();
118-
119116
protected:
120117
QMap<QString, QString> createCensorFilterFromSession(AuthSessionPtr session);
121118
QStringList validLaunchMethods();

application/pages/instance/VersionPage.cpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,18 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
109109

110110
reloadComponentList();
111111

112-
if (m_profile)
113-
{
114-
auto proxy = new IconProxy(ui->packageView);
115-
proxy->setSourceModel(m_profile.get());
116-
ui->packageView->setModel(proxy);
117-
ui->packageView->installEventFilter(this);
118-
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
119-
connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
120-
auto smodel = ui->packageView->selectionModel();
121-
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
122-
updateVersionControls();
123-
// select first item.
124-
preselect(0);
125-
}
126-
else
127-
{
128-
disableVersionControls();
129-
}
130-
connect(m_inst, &MinecraftInstance::versionReloaded, this, &VersionPage::updateVersionControls);
112+
auto proxy = new IconProxy(ui->packageView);
113+
proxy->setSourceModel(m_profile.get());
114+
ui->packageView->setModel(proxy);
115+
ui->packageView->installEventFilter(this);
116+
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
117+
connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
118+
auto smodel = ui->packageView->selectionModel();
119+
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
120+
121+
updateVersionControls();
122+
preselect(0);
123+
connect(m_profile.get(), &ComponentList::minecraftChanged, this, &VersionPage::updateVersionControls);
131124
}
132125

133126
VersionPage::~VersionPage()
@@ -181,21 +174,20 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
181174
void VersionPage::updateVersionControls()
182175
{
183176
// FIXME: this is a dirty hack
184-
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
185-
bool newCraft = minecraftVersion >= Version("1.14");
186-
bool oldCraft = minecraftVersion <= Version("1.12.2");
187-
ui->fabricBtn->setEnabled(newCraft);
188-
ui->forgeBtn->setEnabled(oldCraft);
189-
ui->liteloaderBtn->setEnabled(oldCraft);
190-
updateButtons();
191-
}
192-
193-
void VersionPage::disableVersionControls()
194-
{
195-
ui->fabricBtn->setEnabled(false);
196-
ui->forgeBtn->setEnabled(false);
197-
ui->liteloaderBtn->setEnabled(false);
198-
ui->reloadBtn->setEnabled(false);
177+
if(m_profile) {
178+
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
179+
bool newCraft = minecraftVersion >= Version("1.14");
180+
bool oldCraft = minecraftVersion <= Version("1.12.2");
181+
ui->fabricBtn->setEnabled(newCraft);
182+
ui->forgeBtn->setEnabled(oldCraft);
183+
ui->liteloaderBtn->setEnabled(oldCraft);
184+
}
185+
else {
186+
ui->fabricBtn->setEnabled(false);
187+
ui->forgeBtn->setEnabled(false);
188+
ui->liteloaderBtn->setEnabled(false);
189+
ui->reloadBtn->setEnabled(false);
190+
}
199191
updateButtons();
200192
}
201193

application/pages/instance/VersionPage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ private slots:
6666
void on_downloadBtn_clicked();
6767

6868
void updateVersionControls();
69-
void disableVersionControls();
7069
void on_changeVersionBtn_clicked();
7170

7271
private:

0 commit comments

Comments
 (0)