Implement changing update channels
Allow the user to select which update channel they would like to download updates from.
This commit is contained in:
parent
116a6458b5
commit
d30962bf00
@ -352,8 +352,10 @@ void MultiMC::initGlobalSettings()
|
|||||||
{
|
{
|
||||||
m_settings.reset(new INISettingsObject("multimc.cfg", this));
|
m_settings.reset(new INISettingsObject("multimc.cfg", this));
|
||||||
// Updates
|
// Updates
|
||||||
m_settings->registerSetting("UseDevBuilds", false);
|
m_settings->registerSetting("UpdateChannel", version().channel);
|
||||||
m_settings->registerSetting("AutoUpdate", true);
|
m_settings->registerSetting("AutoUpdate", true);
|
||||||
|
|
||||||
|
// Notifications
|
||||||
m_settings->registerSetting("ShownNotifications", QString());
|
m_settings->registerSetting("ShownNotifications", QString());
|
||||||
|
|
||||||
// FTB
|
// FTB
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "logic/lists/JavaVersionList.h"
|
#include "logic/lists/JavaVersionList.h"
|
||||||
#include <logic/JavaChecker.h>
|
#include <logic/JavaChecker.h>
|
||||||
|
|
||||||
|
#include "logic/updater/UpdateChecker.h"
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include <settingsobject.h>
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -48,6 +50,17 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
|
|||||||
|
|
||||||
loadSettings(MMC->settings().get());
|
loadSettings(MMC->settings().get());
|
||||||
updateCheckboxStuff();
|
updateCheckboxStuff();
|
||||||
|
|
||||||
|
QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &SettingsDialog::refreshUpdateChannelList);
|
||||||
|
|
||||||
|
if (MMC->updateChecker()->hasChannels())
|
||||||
|
{
|
||||||
|
refreshUpdateChannelList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MMC->updateChecker()->updateChanList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog()
|
SettingsDialog::~SettingsDialog()
|
||||||
@ -197,30 +210,72 @@ void SettingsDialog::on_buttonBox_rejected()
|
|||||||
MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64());
|
MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::refreshUpdateChannelList()
|
||||||
|
{
|
||||||
|
// Stop listening for selection changes. It's going to change a lot while we update it and we don't need to update the
|
||||||
|
// description label constantly.
|
||||||
|
QObject::disconnect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChannelSelectionChanged(int)));
|
||||||
|
|
||||||
|
QList<UpdateChecker::ChannelListEntry> channelList = MMC->updateChecker()->getChannelList();
|
||||||
|
ui->updateChannelComboBox->clear();
|
||||||
|
int selection = -1;
|
||||||
|
for (int i = 0; i < channelList.count(); i++)
|
||||||
|
{
|
||||||
|
UpdateChecker::ChannelListEntry entry = channelList.at(i);
|
||||||
|
|
||||||
|
// When it comes to selection, we'll rely on the indexes of a channel entry being the same in the
|
||||||
|
// combo box as it is in the update checker's channel list.
|
||||||
|
// This probably isn't very safe, but the channel list doesn't change often enough (or at all) for
|
||||||
|
// this to be a big deal. Hope it doesn't break...
|
||||||
|
ui->updateChannelComboBox->addItem(entry.name);
|
||||||
|
|
||||||
|
// If the update channel we just added was the selected one, set the current index in the combo box to it.
|
||||||
|
if (entry.id == m_currentUpdateChannel)
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "Selected index" << i << "channel id" << m_currentUpdateChannel;
|
||||||
|
selection = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->updateChannelComboBox->setCurrentIndex(selection);
|
||||||
|
|
||||||
|
// Start listening for selection changes again and update the description label.
|
||||||
|
QObject::connect(ui->updateChannelComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChannelSelectionChanged(int)));
|
||||||
|
refreshUpdateChannelDesc();
|
||||||
|
|
||||||
|
// Now that we've updated the channel list, we can enable the combo box.
|
||||||
|
// It starts off disabled so that if the channel list hasn't been loaded, it will be disabled.
|
||||||
|
ui->updateChannelComboBox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::updateChannelSelectionChanged(int index)
|
||||||
|
{
|
||||||
|
refreshUpdateChannelDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::refreshUpdateChannelDesc()
|
||||||
|
{
|
||||||
|
// Get the channel list.
|
||||||
|
QList<UpdateChecker::ChannelListEntry> channelList = MMC->updateChecker()->getChannelList();
|
||||||
|
int selectedIndex = ui->updateChannelComboBox->currentIndex();
|
||||||
|
if (selectedIndex < channelList.count())
|
||||||
|
{
|
||||||
|
// Find the channel list entry with the given index.
|
||||||
|
UpdateChecker::ChannelListEntry selected = channelList.at(selectedIndex);
|
||||||
|
|
||||||
|
// Set the description text.
|
||||||
|
ui->updateChannelDescLabel->setText(selected.description);
|
||||||
|
|
||||||
|
// Set the currently selected channel ID.
|
||||||
|
m_currentUpdateChannel = selected.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::applySettings(SettingsObject *s)
|
void SettingsDialog::applySettings(SettingsObject *s)
|
||||||
{
|
{
|
||||||
// Special cases
|
|
||||||
|
|
||||||
// Warn about dev builds.
|
|
||||||
if (!ui->devBuildsCheckBox->isChecked())
|
|
||||||
{
|
|
||||||
s->set("UseDevBuilds", false);
|
|
||||||
}
|
|
||||||
else if (!s->get("UseDevBuilds").toBool())
|
|
||||||
{
|
|
||||||
auto response = CustomMessageBox::selectable(
|
|
||||||
this, tr("Development builds"),
|
|
||||||
tr("Development builds contain experimental features "
|
|
||||||
"and may be unstable. Are you sure you want to enable them?"),
|
|
||||||
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec();
|
|
||||||
if (response == QMessageBox::Yes)
|
|
||||||
{
|
|
||||||
s->set("UseDevBuilds", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
||||||
|
s->set("UpdateChannel", m_currentUpdateChannel);
|
||||||
|
|
||||||
// FTB
|
// FTB
|
||||||
s->set("TrackFTBInstances", ui->trackFtbBox->isChecked());
|
s->set("TrackFTBInstances", ui->trackFtbBox->isChecked());
|
||||||
@ -288,7 +343,7 @@ void SettingsDialog::loadSettings(SettingsObject *s)
|
|||||||
{
|
{
|
||||||
// Updates
|
// Updates
|
||||||
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
||||||
ui->devBuildsCheckBox->setChecked(s->get("UseDevBuilds").toBool());
|
m_currentUpdateChannel = s->get("UpdateChannel").toString();
|
||||||
|
|
||||||
// FTB
|
// FTB
|
||||||
ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool());
|
ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool());
|
||||||
@ -392,3 +447,4 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
|
|||||||
"or set the path to the java executable."));
|
"or set the path to the java executable."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,25 @@ slots:
|
|||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
|
||||||
void checkFinished(JavaCheckResult result);
|
void checkFinished(JavaCheckResult result);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Updates the list of update channels in the combo box.
|
||||||
|
*/
|
||||||
|
void refreshUpdateChannelList();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Updates the channel description label.
|
||||||
|
*/
|
||||||
|
void refreshUpdateChannelDesc();
|
||||||
|
|
||||||
|
void updateChannelSelectionChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SettingsDialog *ui;
|
Ui::SettingsDialog *ui;
|
||||||
std::shared_ptr<JavaChecker> checker;
|
std::shared_ptr<JavaChecker> checker;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Stores the currently selected update channel.
|
||||||
|
*/
|
||||||
|
QString m_currentUpdateChannel;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>526</width>
|
<width>526</width>
|
||||||
<height>628</height>
|
<height>639</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -77,14 +77,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Update Settings</string>
|
<string>Update Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="updateSettingsBoxLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="devBuildsCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use development builds?</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoUpdateCheckBox">
|
<widget class="QCheckBox" name="autoUpdateCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -92,6 +85,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="channelVerticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="updateChannelLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update Channel:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="updateChannelComboBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="updateChannelDescLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>No channel selected.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -644,11 +662,9 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>settingsTab</tabstop>
|
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
<tabstop>sortLastLaunchedBtn</tabstop>
|
<tabstop>sortLastLaunchedBtn</tabstop>
|
||||||
<tabstop>sortByNameBtn</tabstop>
|
<tabstop>sortByNameBtn</tabstop>
|
||||||
<tabstop>devBuildsCheckBox</tabstop>
|
|
||||||
<tabstop>autoUpdateCheckBox</tabstop>
|
<tabstop>autoUpdateCheckBox</tabstop>
|
||||||
<tabstop>instDirTextBox</tabstop>
|
<tabstop>instDirTextBox</tabstop>
|
||||||
<tabstop>modsDirTextBox</tabstop>
|
<tabstop>modsDirTextBox</tabstop>
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
#include <settingsobject.h>
|
||||||
|
|
||||||
#define API_VERSION 0
|
#define API_VERSION 0
|
||||||
#define CHANLIST_FORMAT 0
|
#define CHANLIST_FORMAT 0
|
||||||
|
|
||||||
@ -70,9 +72,8 @@ void UpdateChecker::checkForUpdate(bool notifyNoUpdate)
|
|||||||
|
|
||||||
m_updateChecking = true;
|
m_updateChecking = true;
|
||||||
|
|
||||||
// Get the URL for the channel we're using.
|
// Get the channel we're checking.
|
||||||
// TODO: Allow user to select channels. For now, we'll just use the current channel.
|
QString updateChannel = MMC->settings()->get("UpdateChannel").toString();
|
||||||
QString updateChannel = m_currentChannel;
|
|
||||||
|
|
||||||
// Find the desired channel within the channel list and get its repo URL. If if cannot be
|
// Find the desired channel within the channel list and get its repo URL. If if cannot be
|
||||||
// found, error.
|
// found, error.
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
QList<ChannelListEntry> getChannelList() const;
|
QList<ChannelListEntry> getChannelList() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if the channel list is empty.
|
* Returns false if the channel list is empty.
|
||||||
*/
|
*/
|
||||||
bool hasChannels() const;
|
bool hasChannels() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user