Skip to content

Commit

Permalink
Make Theme Setup wizard Functional
Browse files Browse the repository at this point in the history
Signed-off-by: Tayou <tayou@gmx.net>
  • Loading branch information
Tayou committed Nov 6, 2022
1 parent ae4617e commit 2f356a7
Show file tree
Hide file tree
Showing 17 changed files with 699 additions and 400 deletions.
14 changes: 8 additions & 6 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
});

{
setIconTheme(settings()->get("IconTheme").toString());
qDebug() << "<> Icon theme set.";
setApplicationTheme(settings()->get("ApplicationTheme").toString(), true);
qDebug() << "<> Application theme set.";
applyCurrentlySelectedTheme();
}

updateCapabilities();
Expand Down Expand Up @@ -1120,9 +1117,14 @@ QList<ITheme*> Application::getValidApplicationThemes()
return m_themeManager->getValidApplicationThemes();
}

void Application::setApplicationTheme(const QString& name, bool initial)
void Application::applyCurrentlySelectedTheme()
{
m_themeManager->setApplicationTheme(name, initial);
m_themeManager->applyCurrentlySelectedTheme();
}

void Application::setApplicationTheme(const QString& name)
{
m_themeManager->setApplicationTheme(name);
}

void Application::setIconTheme(const QString& name)
Expand Down
4 changes: 3 additions & 1 deletion launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ class Application : public QApplication

void setIconTheme(const QString& name);

void applyCurrentlySelectedTheme();

QList<ITheme*> getValidApplicationThemes();

void setApplicationTheme(const QString& name, bool initial);
void setApplicationTheme(const QString& name);

shared_qobject_ptr<UpdateChecker> updateChecker() {
return m_updateChecker;
Expand Down
3 changes: 3 additions & 0 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ SET(LAUNCHER_SOURCES
ui/widgets/ProgressWidget.cpp
ui/widgets/WideBar.h
ui/widgets/WideBar.cpp
ui/widgets/ThemeCustomizationWidget.h
ui/widgets/ThemeCustomizationWidget.cpp

# GUI - instance group view
ui/instanceview/InstanceProxyModel.cpp
Expand Down Expand Up @@ -929,6 +931,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/widgets/CustomCommands.ui
ui/widgets/InfoFrame.ui
ui/widgets/ModFilterWidget.ui
ui/widgets/ThemeCustomizationWidget.ui
ui/dialogs/CopyInstanceDialog.ui
ui/dialogs/ProfileSetupDialog.ui
ui/dialogs/ProgressDialog.ui
Expand Down
88 changes: 0 additions & 88 deletions launcher/ui/pages/global/LauncherPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,66 +286,6 @@ void LauncherPage::applySettings()
}

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", "OSX");
break;
case 5:
s->set("IconTheme", "iOS");
break;
case 6:
s->set("IconTheme", "flat");
break;
case 7:
s->set("IconTheme", "flat_white");
break;
case 8:
s->set("IconTheme", "multimc");
break;
case 9:
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;
}

s->set("MenuBarInsteadOfToolBar", ui->preferMenuBarCheckBox->isChecked());

Expand Down Expand Up @@ -395,34 +335,6 @@ void LauncherPage::loadSettings()
}

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", "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);
}

{
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());
Expand Down
151 changes: 13 additions & 138 deletions launcher/ui/pages/global/LauncherPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<width>511</width>
<height>629</height>
</rect>
</property>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -243,140 +243,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>&amp;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 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>&amp;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&amp;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>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="ThemeCustomizationWidget" name="themeCustomizationWidget" native="true"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -560,6 +429,14 @@
</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>
Expand All @@ -572,8 +449,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>
Expand Down

0 comments on commit 2f356a7

Please sign in to comment.