Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into develop
This commit is contained in:
@@ -44,14 +44,13 @@
|
||||
#include <QTextCharFormat>
|
||||
#include <QMenuBar>
|
||||
|
||||
#include "updater/UpdateChecker.h"
|
||||
|
||||
#include "settings/SettingsObject.h"
|
||||
#include <FileSystem.h>
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "DesktopServices.h"
|
||||
#include "ui/themes/ITheme.h"
|
||||
#include "updater/ExternalUpdater.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QProcess>
|
||||
@@ -80,32 +79,12 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
|
||||
m_languageModel = APPLICATION->translations();
|
||||
loadSettings();
|
||||
|
||||
if(BuildConfig.UPDATER_ENABLED)
|
||||
{
|
||||
QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList);
|
||||
ui->updateSettingsBox->setHidden(!APPLICATION->updater());
|
||||
|
||||
if (APPLICATION->updateChecker()->hasChannels())
|
||||
{
|
||||
refreshUpdateChannelList();
|
||||
}
|
||||
else
|
||||
{
|
||||
APPLICATION->updateChecker()->updateChanList(false);
|
||||
}
|
||||
|
||||
if (APPLICATION->updateChecker()->getExternalUpdater())
|
||||
{
|
||||
ui->updateChannelComboBox->setVisible(false);
|
||||
ui->updateChannelDescLabel->setVisible(false);
|
||||
ui->updateChannelLabel->setVisible(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->updateSettingsBox->setHidden(true);
|
||||
}
|
||||
connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview()));
|
||||
connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview()));
|
||||
|
||||
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, APPLICATION, &Application::currentCatChanged);
|
||||
}
|
||||
|
||||
LauncherPage::~LauncherPage()
|
||||
@@ -198,162 +177,14 @@ void LauncherPage::on_metadataDisableBtn_clicked()
|
||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||
}
|
||||
|
||||
void LauncherPage::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 = APPLICATION->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)
|
||||
{
|
||||
qDebug() << "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 LauncherPage::updateChannelSelectionChanged(int index)
|
||||
{
|
||||
refreshUpdateChannelDesc();
|
||||
}
|
||||
|
||||
void LauncherPage::refreshUpdateChannelDesc()
|
||||
{
|
||||
// Get the channel list.
|
||||
QList<UpdateChecker::ChannelListEntry> channelList = APPLICATION->updateChecker()->getChannelList();
|
||||
int selectedIndex = ui->updateChannelComboBox->currentIndex();
|
||||
if (selectedIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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 LauncherPage::applySettings()
|
||||
{
|
||||
auto s = APPLICATION->settings();
|
||||
|
||||
// Updates
|
||||
if (BuildConfig.UPDATER_ENABLED && APPLICATION->updateChecker()->getExternalUpdater())
|
||||
if (APPLICATION->updater())
|
||||
{
|
||||
APPLICATION->updateChecker()->getExternalUpdater()->setAutomaticallyChecksForUpdates(
|
||||
ui->autoUpdateCheckBox->isChecked());
|
||||
}
|
||||
else
|
||||
{
|
||||
s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked());
|
||||
}
|
||||
|
||||
s->set("UpdateChannel", m_currentUpdateChannel);
|
||||
auto original = s->get("IconTheme").toString();
|
||||
//FIXME: make generic
|
||||
switch (ui->themeComboBox->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
s->set("IconTheme", "pe_colored");
|
||||
break;
|
||||
case 1:
|
||||
s->set("IconTheme", "pe_light");
|
||||
break;
|
||||
case 2:
|
||||
s->set("IconTheme", "pe_dark");
|
||||
break;
|
||||
case 3:
|
||||
s->set("IconTheme", "pe_blue");
|
||||
break;
|
||||
case 4:
|
||||
s->set("IconTheme", "breeze_light");
|
||||
break;
|
||||
case 5:
|
||||
s->set("IconTheme", "breeze_dark");
|
||||
break;
|
||||
case 6:
|
||||
s->set("IconTheme", "OSX");
|
||||
break;
|
||||
case 7:
|
||||
s->set("IconTheme", "iOS");
|
||||
break;
|
||||
case 8:
|
||||
s->set("IconTheme", "flat");
|
||||
break;
|
||||
case 9:
|
||||
s->set("IconTheme", "flat_white");
|
||||
break;
|
||||
case 10:
|
||||
s->set("IconTheme", "multimc");
|
||||
break;
|
||||
case 11:
|
||||
s->set("IconTheme", "custom");
|
||||
break;
|
||||
}
|
||||
|
||||
if(original != s->get("IconTheme"))
|
||||
{
|
||||
APPLICATION->setIconTheme(s->get("IconTheme").toString());
|
||||
}
|
||||
|
||||
auto originalAppTheme = s->get("ApplicationTheme").toString();
|
||||
auto newAppTheme = ui->themeComboBoxColors->currentData().toString();
|
||||
if(originalAppTheme != newAppTheme)
|
||||
{
|
||||
s->set("ApplicationTheme", newAppTheme);
|
||||
APPLICATION->setApplicationTheme(newAppTheme, false);
|
||||
}
|
||||
|
||||
switch (ui->themeBackgroundCat->currentIndex()) {
|
||||
case 0: // original cat
|
||||
s->set("BackgroundCat", "kitteh");
|
||||
break;
|
||||
case 1: // rory the cat
|
||||
s->set("BackgroundCat", "rory");
|
||||
break;
|
||||
case 2: // rory the cat flat edition
|
||||
s->set("BackgroundCat", "rory-flat");
|
||||
break;
|
||||
case 3: // polly the parrot
|
||||
s->set("BackgroundCat", "polly");
|
||||
break;
|
||||
APPLICATION->updater()->setAutomaticallyChecksForUpdates(ui->autoUpdateCheckBox->isChecked());
|
||||
}
|
||||
|
||||
s->set("MenuBarInsteadOfToolBar", ui->preferMenuBarCheckBox->isChecked());
|
||||
@@ -393,58 +224,11 @@ void LauncherPage::loadSettings()
|
||||
{
|
||||
auto s = APPLICATION->settings();
|
||||
// Updates
|
||||
if (BuildConfig.UPDATER_ENABLED && APPLICATION->updateChecker()->getExternalUpdater())
|
||||
if (APPLICATION->updater())
|
||||
{
|
||||
ui->autoUpdateCheckBox->setChecked(
|
||||
APPLICATION->updateChecker()->getExternalUpdater()->getAutomaticallyChecksForUpdates());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool());
|
||||
ui->autoUpdateCheckBox->setChecked(APPLICATION->updater()->getAutomaticallyChecksForUpdates());
|
||||
}
|
||||
|
||||
m_currentUpdateChannel = s->get("UpdateChannel").toString();
|
||||
//FIXME: make generic
|
||||
auto theme = s->get("IconTheme").toString();
|
||||
QStringList iconThemeOptions{"pe_colored",
|
||||
"pe_light",
|
||||
"pe_dark",
|
||||
"pe_blue",
|
||||
"breeze_light",
|
||||
"breeze_dark",
|
||||
"OSX",
|
||||
"iOS",
|
||||
"flat",
|
||||
"flat_white",
|
||||
"multimc",
|
||||
"custom"};
|
||||
ui->themeComboBox->setCurrentIndex(iconThemeOptions.indexOf(theme));
|
||||
|
||||
auto cat = s->get("BackgroundCat").toString();
|
||||
if (cat == "kitteh") {
|
||||
ui->themeBackgroundCat->setCurrentIndex(0);
|
||||
} else if (cat == "rory") {
|
||||
ui->themeBackgroundCat->setCurrentIndex(1);
|
||||
} else if (cat == "rory-flat") {
|
||||
ui->themeBackgroundCat->setCurrentIndex(2);
|
||||
} else if (cat == "polly") {
|
||||
ui->themeBackgroundCat->setCurrentIndex(3);
|
||||
}
|
||||
|
||||
{
|
||||
auto currentTheme = s->get("ApplicationTheme").toString();
|
||||
auto themes = APPLICATION->getValidApplicationThemes();
|
||||
int idx = 0;
|
||||
for(auto &theme: themes)
|
||||
{
|
||||
ui->themeComboBoxColors->addItem(theme->name(), theme->id());
|
||||
if(currentTheme == theme->id())
|
||||
{
|
||||
ui->themeComboBoxColors->setCurrentIndex(idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
// Toolbar/menu bar settings (not applicable if native menu bar is present)
|
||||
ui->toolsBox->setEnabled(!QMenuBar().isNativeMenuBar());
|
||||
|
@@ -90,23 +90,11 @@ slots:
|
||||
void on_iconsDirBrowseBtn_clicked();
|
||||
void on_metadataDisableBtn_clicked();
|
||||
|
||||
/*!
|
||||
* Updates the list of update channels in the combo box.
|
||||
*/
|
||||
void refreshUpdateChannelList();
|
||||
|
||||
/*!
|
||||
* Updates the channel description label.
|
||||
*/
|
||||
void refreshUpdateChannelDesc();
|
||||
|
||||
/*!
|
||||
* Updates the font preview
|
||||
*/
|
||||
void refreshFontPreview();
|
||||
|
||||
void updateChannelSelectionChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::LauncherPage *ui;
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>514</width>
|
||||
<width>511</width>
|
||||
<height>629</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -38,7 +38,7 @@
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="featuresTab">
|
||||
<attribute name="title">
|
||||
@@ -58,33 +58,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="updateChannelLabel">
|
||||
<property name="text">
|
||||
<string>Up&date Channel:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>updateChannelComboBox</cstring>
|
||||
</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>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -243,155 +216,9 @@
|
||||
<property name="title">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>&Icons</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>themeComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="themeComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Simple (Colored Icons)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Simple (Light Icons)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Simple (Dark Icons)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Simple (Blue Icons)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Breeze Light</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Breeze Dark</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">OSX</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">iOS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat (White)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Legacy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>&Colors</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>themeComboBoxColors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="themeComboBoxColors">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>C&at</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>themeBackgroundCat</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="themeBackgroundCat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Background Cat (from MultiMC)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rory ID 11 (drawn by Ashtaka)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rory ID 11 (flat edition, drawn by Ashtaka)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Polly Parrot (drawn by anoraktrend)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="ThemeCustomizationWidget" name="themeCustomizationWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -575,10 +402,17 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ThemeCustomizationWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/widgets/ThemeCustomizationWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>autoUpdateCheckBox</tabstop>
|
||||
<tabstop>updateChannelComboBox</tabstop>
|
||||
<tabstop>instDirTextBox</tabstop>
|
||||
<tabstop>instDirBrowseBtn</tabstop>
|
||||
<tabstop>modsDirTextBox</tabstop>
|
||||
@@ -587,8 +421,6 @@
|
||||
<tabstop>iconsDirBrowseBtn</tabstop>
|
||||
<tabstop>sortLastLaunchedBtn</tabstop>
|
||||
<tabstop>sortByNameBtn</tabstop>
|
||||
<tabstop>themeComboBox</tabstop>
|
||||
<tabstop>themeComboBoxColors</tabstop>
|
||||
<tabstop>showConsoleCheck</tabstop>
|
||||
<tabstop>autoCloseConsoleCheck</tabstop>
|
||||
<tabstop>showConsoleErrorCheck</tabstop>
|
||||
|
Reference in New Issue
Block a user