summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-05 16:53:51 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-05 16:53:51 +0100
commitced640f68c25c1ea40f86be5af736aa0263dd3ee (patch)
treebab0b570ba00204d2a9d9afcf69ce4cb36dd4afa
parenta64eebf8eb758971b090b2e87212c2458424797e (diff)
parentebc14a9d9d55b64d490ab07d3f11835f2f1f36b1 (diff)
downloadMultiMC-ced640f68c25c1ea40f86be5af736aa0263dd3ee.tar
MultiMC-ced640f68c25c1ea40f86be5af736aa0263dd3ee.tar.gz
MultiMC-ced640f68c25c1ea40f86be5af736aa0263dd3ee.tar.lz
MultiMC-ced640f68c25c1ea40f86be5af736aa0263dd3ee.tar.xz
MultiMC-ced640f68c25c1ea40f86be5af736aa0263dd3ee.zip
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
-rw-r--r--CMakeLists.txt4
-rw-r--r--MultiMC.cpp4
-rw-r--r--MultiMCVersion.h2
-rw-r--r--gui/MainWindow.cpp27
-rw-r--r--gui/MainWindow.h2
-rw-r--r--gui/dialogs/SettingsDialog.cpp90
-rw-r--r--gui/dialogs/SettingsDialog.h18
-rw-r--r--gui/dialogs/SettingsDialog.ui55
-rw-r--r--logic/updater/UpdateChecker.cpp7
-rw-r--r--logic/updater/UpdateChecker.h2
10 files changed, 173 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index df7ebc64..1a9bd32c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,7 +126,7 @@ SET(MultiMC_NEWS_RSS_URL "http://multimc.org/rss.xml" CACHE STRING "URL to fetch
######## Set version numbers ########
-SET(MultiMC_VERSION_MAJOR 1)
+SET(MultiMC_VERSION_MAJOR 0)
SET(MultiMC_VERSION_MINOR 0)
# Build number
@@ -148,7 +148,7 @@ SET(MultiMC_UPDATER false CACHE BOOL "Whether or not the update system is enable
SET(MultiMC_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.")
# Build a version string to display in the configure logs.
-SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}")
+SET(MultiMC_VERSION_STRING "5.${MultiMC_VERSION_MAJOR}.${MultiMC_VERSION_MINOR}")
IF (MultiMC_VERSION_BUILD GREATER -1)
SET(MultiMC_VERSION_STRING "${MultiMC_VERSION_STRING}.${MultiMC_VERSION_BUILD}")
ENDIF ()
diff --git a/MultiMC.cpp b/MultiMC.cpp
index 2bc77e0f..a13ad794 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -346,8 +346,10 @@ void MultiMC::initGlobalSettings()
{
m_settings.reset(new INISettingsObject("multimc.cfg", this));
// Updates
- m_settings->registerSetting("UseDevBuilds", false);
+ m_settings->registerSetting("UpdateChannel", version().channel);
m_settings->registerSetting("AutoUpdate", true);
+
+ // Notifications
m_settings->registerSetting("ShownNotifications", QString());
// FTB
diff --git a/MultiMCVersion.h b/MultiMCVersion.h
index 8978516b..75e017df 100644
--- a/MultiMCVersion.h
+++ b/MultiMCVersion.h
@@ -28,7 +28,7 @@ struct MultiMCVersion
*/
QString toString() const
{
- QString vstr = QString("%1.%2").arg(
+ QString vstr = QString("5.%1.%2").arg(
QString::number(major),
QString::number(minor));
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 35c4ee15..968fecb7 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -166,6 +166,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
view->setFrameShape(QFrame::NoFrame);
view->setModel(proxymodel);
+ view->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(view, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(showInstanceContextMenu(const QPoint&)));
+
ui->horizontalLayout->addWidget(view);
}
// The cat background
@@ -315,6 +319,29 @@ MainWindow::~MainWindow()
delete drawer;
}
+void MainWindow::showInstanceContextMenu(const QPoint& pos)
+{
+ if(!view->indexAt(pos).isValid())
+ {
+ return;
+ }
+
+ QList<QAction *> actions = ui->instanceToolBar->actions();
+
+ // HACK: Filthy rename button hack because the instance view is getting rewritten anyway
+ QAction *actionRename;
+ actionRename = new QAction(tr("Rename"), this);
+ actionRename->setToolTip(ui->actionRenameInstance->toolTip());
+
+ connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));
+
+ actions.replace(1, actionRename);
+
+ QMenu myMenu;
+ myMenu.addActions(actions);
+ myMenu.exec(view->mapToGlobal(pos));
+}
+
void MainWindow::repopulateAccountsMenu()
{
accountMenu->clear();
diff --git a/gui/MainWindow.h b/gui/MainWindow.h
index 7089b98b..af2f1dca 100644
--- a/gui/MainWindow.h
+++ b/gui/MainWindow.h
@@ -145,6 +145,8 @@ slots:
// called when an icon is changed in the icon model.
void iconUpdated(QString);
+ void showInstanceContextMenu(const QPoint&);
+
public
slots:
void instanceActivated(QModelIndex);
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 9362075e..549b11b0 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -27,6 +27,8 @@
#include "logic/lists/JavaVersionList.h"
#include <logic/JavaChecker.h>
+#include "logic/updater/UpdateChecker.h"
+
#include <settingsobject.h>
#include <pathutils.h>
#include <QFileDialog>
@@ -48,6 +50,17 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
loadSettings(MMC->settings().get());
updateCheckboxStuff();
+
+ QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &SettingsDialog::refreshUpdateChannelList);
+
+ if (MMC->updateChecker()->hasChannels())
+ {
+ refreshUpdateChannelList();
+ }
+ else
+ {
+ MMC->updateChecker()->updateChanList();
+ }
}
SettingsDialog::~SettingsDialog()
@@ -197,30 +210,72 @@ void SettingsDialog::on_buttonBox_rejected()
MMC->settings()->set("SettingsGeometry", saveGeometry().toBase64());
}
-void SettingsDialog::applySettings(SettingsObject *s)
+void SettingsDialog::refreshUpdateChannelList()
{
- // Special cases
-
- // Warn about dev builds.
- if (!ui->devBuildsCheckBox->isChecked())
+ // 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++)
{
- 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)
+ 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)
{
- s->set("UseDevBuilds", true);
+ 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)
+{
// Updates
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
+ s->set("UpdateChannel", m_currentUpdateChannel);
// FTB
s->set("TrackFTBInstances", ui->trackFtbBox->isChecked());
@@ -288,7 +343,7 @@ void SettingsDialog::loadSettings(SettingsObject *s)
{
// Updates
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
- ui->devBuildsCheckBox->setChecked(s->get("UseDevBuilds").toBool());
+ m_currentUpdateChannel = s->get("UpdateChannel").toString();
// FTB
ui->trackFtbBox->setChecked(s->get("TrackFTBInstances").toBool());
@@ -392,3 +447,4 @@ void SettingsDialog::checkFinished(JavaCheckResult result)
"or set the path to the java executable."));
}
}
+
diff --git a/gui/dialogs/SettingsDialog.h b/gui/dialogs/SettingsDialog.h
index 11fdb696..df67d492 100644
--- a/gui/dialogs/SettingsDialog.h
+++ b/gui/dialogs/SettingsDialog.h
@@ -74,7 +74,25 @@ slots:
void on_javaBrowseBtn_clicked();
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:
Ui::SettingsDialog *ui;
std::shared_ptr<JavaChecker> checker;
+
+ /*!
+ * Stores the currently selected update channel.
+ */
+ QString m_currentUpdateChannel;
};
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index dbc8ca88..7d2708cb 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>526</width>
- <height>628</height>
+ <height>639</height>
</rect>
</property>
<property name="sizePolicy">
@@ -77,14 +77,7 @@
<property name="title">
<string>Update Settings</string>
</property>
- <layout class="QVBoxLayout" name="updateSettingsBoxLayout">
- <item>
- <widget class="QCheckBox" name="devBuildsCheckBox">
- <property name="text">
- <string>Use development builds?</string>
- </property>
- </widget>
- </item>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="autoUpdateCheckBox">
<property name="text">
@@ -92,6 +85,31 @@
</property>
</widget>
</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>
</widget>
</item>
@@ -644,18 +662,25 @@
</layout>
</widget>
<tabstops>
- <tabstop>settingsTab</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>sortLastLaunchedBtn</tabstop>
<tabstop>sortByNameBtn</tabstop>
- <tabstop>devBuildsCheckBox</tabstop>
<tabstop>autoUpdateCheckBox</tabstop>
+ <tabstop>trackFtbBox</tabstop>
+ <tabstop>ftbLauncherBox</tabstop>
+ <tabstop>ftbLauncherBrowseBtn</tabstop>
+ <tabstop>ftbBox</tabstop>
+ <tabstop>ftbBrowseBtn</tabstop>
<tabstop>instDirTextBox</tabstop>
- <tabstop>modsDirTextBox</tabstop>
- <tabstop>lwjglDirTextBox</tabstop>
<tabstop>instDirBrowseBtn</tabstop>
+ <tabstop>modsDirTextBox</tabstop>
<tabstop>modsDirBrowseBtn</tabstop>
+ <tabstop>lwjglDirTextBox</tabstop>
<tabstop>lwjglDirBrowseBtn</tabstop>
+ <tabstop>iconsDirTextBox</tabstop>
+ <tabstop>iconsDirBrowseBtn</tabstop>
+ <tabstop>jsonEditorTextBox</tabstop>
+ <tabstop>jsonEditorBrowseBtn</tabstop>
<tabstop>maximizedCheckBox</tabstop>
<tabstop>windowWidthSpinBox</tabstop>
<tabstop>windowHeightSpinBox</tabstop>
@@ -665,9 +690,13 @@
<tabstop>maxMemSpinBox</tabstop>
<tabstop>permGenSpinBox</tabstop>
<tabstop>javaPathTextBox</tabstop>
+ <tabstop>javaBrowseBtn</tabstop>
+ <tabstop>javaDetectBtn</tabstop>
+ <tabstop>javaTestBtn</tabstop>
<tabstop>jvmArgsTextBox</tabstop>
<tabstop>preLaunchCmdTextBox</tabstop>
<tabstop>postExitCmdTextBox</tabstop>
+ <tabstop>settingsTabs</tabstop>
</tabstops>
<resources>
<include location="../../graphics.qrc"/>
diff --git a/logic/updater/UpdateChecker.cpp b/logic/updater/UpdateChecker.cpp
index 9af11cab..489e7769 100644
--- a/logic/updater/UpdateChecker.cpp
+++ b/logic/updater/UpdateChecker.cpp
@@ -23,6 +23,8 @@
#include <QJsonArray>
#include <QJsonValue>
+#include <settingsobject.h>
+
#define API_VERSION 0
#define CHANLIST_FORMAT 0
@@ -69,9 +71,8 @@ void UpdateChecker::checkForUpdate(bool notifyNoUpdate)
m_updateChecking = true;
- // Get the URL for the channel we're using.
- // TODO: Allow user to select channels. For now, we'll just use the current channel.
- QString updateChannel = m_currentChannel;
+ // Get the channel we're checking.
+ QString updateChannel = MMC->settings()->get("UpdateChannel").toString();
// Find the desired channel within the channel list and get its repo URL. If if cannot be
// found, error.
diff --git a/logic/updater/UpdateChecker.h b/logic/updater/UpdateChecker.h
index a47e8903..7840cedc 100644
--- a/logic/updater/UpdateChecker.h
+++ b/logic/updater/UpdateChecker.h
@@ -54,7 +54,7 @@ public:
QList<ChannelListEntry> getChannelList() const;
/*!
- * Returns true if the channel list is empty.
+ * Returns false if the channel list is empty.
*/
bool hasChannels() const;