Use same UI for appearance page and wizard

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2025-03-22 22:31:57 +00:00
parent a1baa5ff47
commit 411161fe49
No known key found for this signature in database
GPG key ID: 5E39D70B4C93C38E
9 changed files with 361 additions and 889 deletions

View file

@ -843,7 +843,6 @@ SET(LAUNCHER_SOURCES
ui/setupwizard/LanguageWizardPage.h
ui/setupwizard/PasteWizardPage.cpp
ui/setupwizard/PasteWizardPage.h
ui/setupwizard/ThemeWizardPage.cpp
ui/setupwizard/ThemeWizardPage.h
ui/setupwizard/AutoJavaWizardPage.cpp
ui/setupwizard/AutoJavaWizardPage.h
@ -937,7 +936,6 @@ SET(LAUNCHER_SOURCES
ui/pages/global/MinecraftPage.h
ui/pages/global/LauncherPage.cpp
ui/pages/global/LauncherPage.h
ui/pages/global/AppearancePage.cpp
ui/pages/global/AppearancePage.h
ui/pages/global/ProxyPage.cpp
ui/pages/global/ProxyPage.h
@ -1132,8 +1130,8 @@ SET(LAUNCHER_SOURCES
ui/widgets/ProgressWidget.cpp
ui/widgets/WideBar.h
ui/widgets/WideBar.cpp
ui/widgets/ThemeCustomizationWidget.h
ui/widgets/ThemeCustomizationWidget.cpp
ui/widgets/AppearanceWidget.h
ui/widgets/AppearanceWidget.cpp
ui/widgets/MinecraftSettingsWidget.h
ui/widgets/MinecraftSettingsWidget.cpp
ui/widgets/JavaSettingsWidget.h
@ -1175,11 +1173,9 @@ qt_wrap_ui(LAUNCHER_UI
ui/setupwizard/PasteWizardPage.ui
ui/setupwizard/AutoJavaWizardPage.ui
ui/setupwizard/LoginWizardPage.ui
ui/setupwizard/ThemeWizardPage.ui
ui/pages/global/AccountListPage.ui
ui/pages/global/JavaPage.ui
ui/pages/global/LauncherPage.ui
ui/pages/global/AppearancePage.ui
ui/pages/global/APIPage.ui
ui/pages/global/ProxyPage.ui
ui/pages/global/ExternalToolsPage.ui
@ -1210,7 +1206,7 @@ qt_wrap_ui(LAUNCHER_UI
ui/widgets/InfoFrame.ui
ui/widgets/ModFilterWidget.ui
ui/widgets/SubTaskProgressBar.ui
ui/widgets/ThemeCustomizationWidget.ui
ui/widgets/AppearanceWidget.ui
ui/widgets/MinecraftSettingsWidget.ui
ui/widgets/JavaSettingsWidget.ui
ui/dialogs/CopyInstanceDialog.ui

View file

@ -40,43 +40,29 @@
#include <Application.h>
#include <translations/TranslationsModel.h>
#include <ui/widgets/AppearanceWidget.h>
#include "java/JavaChecker.h"
#include "ui/pages/BasePage.h"
class QTextCharFormat;
class SettingsObject;
namespace Ui {
class AppearancePage;
}
class AppearancePage : public QWidget, public BasePage {
class AppearancePage : public AppearanceWidget, public BasePage {
Q_OBJECT
public:
explicit AppearancePage(QWidget* parent = 0);
~AppearancePage();
explicit AppearancePage(QWidget *parent = nullptr) : AppearanceWidget(false, parent) {}
QString displayName() const override { return tr("Appearance"); }
QIcon icon() const override { return APPLICATION->getThemedIcon("appearance"); }
QString id() const override { return "appearance-settings"; }
QString helpPage() const override { return "Launcher-settings"; }
bool apply() override;
void retranslate() override;
private:
void applySettings();
void loadSettings();
bool apply() override
{
applySettings();
return true;
}
void applyIconTheme(int index);
void applyWidgetTheme(int index);
void applyCatTheme(int index);
void loadThemeSettings();
void updateConsolePreview();
void updateCatPreview();
private:
Ui::AppearancePage* m_ui;
QTextCharFormat* defaultFormat;
void retranslate() override { retranslateUi(); }
};

View file

@ -34,37 +34,6 @@ ThemeWizardPage::ThemeWizardPage(QWidget* parent) : BaseWizardPage(parent), ui(n
updateIcons();
updateCat();
}
ThemeWizardPage::~ThemeWizardPage()
{
delete ui;
}
void ThemeWizardPage::updateIcons()
{
qDebug() << "Setting Icons";
ui->previewIconButton0->setIcon(APPLICATION->getThemedIcon("new"));
ui->previewIconButton1->setIcon(APPLICATION->getThemedIcon("centralmods"));
ui->previewIconButton2->setIcon(APPLICATION->getThemedIcon("viewfolder"));
ui->previewIconButton3->setIcon(APPLICATION->getThemedIcon("launch"));
ui->previewIconButton4->setIcon(APPLICATION->getThemedIcon("copy"));
ui->previewIconButton5->setIcon(APPLICATION->getThemedIcon("export"));
ui->previewIconButton6->setIcon(APPLICATION->getThemedIcon("delete"));
ui->previewIconButton7->setIcon(APPLICATION->getThemedIcon("about"));
ui->previewIconButton8->setIcon(APPLICATION->getThemedIcon("settings"));
ui->previewIconButton9->setIcon(APPLICATION->getThemedIcon("cat"));
update();
repaint();
parentWidget()->update();
}
void ThemeWizardPage::updateCat()
{
qDebug() << "Setting Cat";
ui->catImagePreviewButton->setIcon(QIcon(QString(R"(%1)").arg(APPLICATION->themeManager()->getCatPack())));
}
void ThemeWizardPage::retranslate()
{
ui->retranslateUi(this);
}

View file

@ -17,27 +17,30 @@
*/
#pragma once
#include <ui/widgets/AppearanceWidget.h>
#include <QHBoxLayout>
#include <QWidget>
#include "BaseWizardPage.h"
namespace Ui {
class ThemeWizardPage;
}
class ThemeWizardPage : public BaseWizardPage {
Q_OBJECT
public:
explicit ThemeWizardPage(QWidget* parent = nullptr);
~ThemeWizardPage();
ThemeWizardPage(QWidget* parent = nullptr) : BaseWizardPage(parent)
{
auto layout = new QVBoxLayout(this);
layout->addWidget(&widget);
layout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout);
setTitle(tr("Appearance"));
setSubTitle(tr("Select theme and icons to use"));
}
bool validatePage() override { return true; };
void retranslate() override;
private slots:
void updateIcons();
void updateCat();
void retranslate() override { widget.retranslateUi(); }
private:
Ui::ThemeWizardPage* ui;
AppearanceWidget widget{true};
};

View file

@ -1,371 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ThemeWizardPage</class>
<widget class="QWizardPage" name="ThemeWizardPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>552</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select the Theme you wish to use</string>
</property>
</widget>
</item>
<item>
<widget class="ThemeCustomizationWidget" name="themeCustomizationWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Hint: The cat appears in the background and is not shown by default. It is only made visible when pressing the Cat button in the Toolbar.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string> Preview:</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="iconPreview">
<item row="0" column="2">
<widget class="QPushButton" name="previewIconButton2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="previewIconButton5">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="previewIconButton7">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="previewIconButton4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="previewIconButton1">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="centralmods">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="previewIconButton0">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="previewIconButton9">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="viewfolder">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="previewIconButton6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="new">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="previewIconButton3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="previewIconButton8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="icon">
<iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="catImagePreviewButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>256</height>
</size>
</property>
<property name="toolTip">
<string>The cat appears in the background and does not serve a purpose, it is purely visual.</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>193</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ThemeCustomizationWidget</class>
<extends>QWidget</extends>
<header>ui/widgets/ThemeCustomizationWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -1,5 +1,41 @@
#include "AppearancePage.h"
#include "ui_AppearancePage.h"
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2025 TheKodeToad <TheKodeToad@proton.me>
* Copyright (C) 2022 Tayou <git@tayou.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2013-2021 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "AppearanceWidget.h"
#include "ui_AppearanceWidget.h"
#include <DesktopServices.h>
#include <QGraphicsOpacityEffect>
@ -7,27 +43,38 @@
#include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h"
AppearancePage::AppearancePage(QWidget* parent) : QWidget(parent), m_ui(new Ui::AppearancePage)
AppearanceWidget::AppearanceWidget(bool themesOnly, QWidget* parent)
: QWidget(parent), m_ui(new Ui::AppearanceWidget), m_themesOnly(themesOnly)
{
m_ui->setupUi(this);
m_ui->catPreview->setGraphicsEffect(new QGraphicsOpacityEffect(this));
defaultFormat = new QTextCharFormat(m_ui->consolePreview->currentCharFormat());
m_defaultFormat = new QTextCharFormat(m_ui->consolePreview->currentCharFormat());
if (themesOnly) {
m_ui->catPackLabel->hide();
m_ui->catPackComboBox->hide();
m_ui->catPackFolder->hide();
m_ui->settingsBox->hide();
m_ui->consolePreview->hide();
m_ui->catPreview->hide();
loadThemeSettings();
} else {
loadSettings();
loadThemeSettings();
updateConsolePreview();
updateCatPreview();
}
connect(m_ui->fontSizeBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AppearancePage::updateConsolePreview);
connect(m_ui->consoleFont, &QFontComboBox::currentFontChanged, this, &AppearancePage::updateConsolePreview);
connect(m_ui->fontSizeBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AppearanceWidget::updateConsolePreview);
connect(m_ui->consoleFont, &QFontComboBox::currentFontChanged, this, &AppearanceWidget::updateConsolePreview);
connect(m_ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearancePage::applyIconTheme);
connect(m_ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearancePage::applyWidgetTheme);
connect(m_ui->catPackComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearancePage::applyCatTheme);
connect(m_ui->catOpacitySlider, &QAbstractSlider::valueChanged, this, &AppearancePage::updateCatPreview);
connect(m_ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearanceWidget::applyIconTheme);
connect(m_ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearanceWidget::applyWidgetTheme);
connect(m_ui->catPackComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AppearanceWidget::applyCatTheme);
connect(m_ui->catOpacitySlider, &QAbstractSlider::valueChanged, this, &AppearanceWidget::updateCatPreview);
connect(m_ui->iconsFolder, &QPushButton::clicked, this,
[] { DesktopServices::openPath(APPLICATION->themeManager()->getIconThemesFolder().path()); });
@ -35,26 +82,15 @@ AppearancePage::AppearancePage(QWidget* parent) : QWidget(parent), m_ui(new Ui::
[] { DesktopServices::openPath(APPLICATION->themeManager()->getApplicationThemesFolder().path()); });
connect(m_ui->catPackFolder, &QPushButton::clicked, this,
[] { DesktopServices::openPath(APPLICATION->themeManager()->getCatPacksFolder().path()); });
connect(m_ui->reloadThemesButton, &QPushButton::pressed, this, &AppearancePage::loadThemeSettings);
connect(m_ui->reloadThemesButton, &QPushButton::pressed, this, &AppearanceWidget::loadThemeSettings);
}
AppearancePage::~AppearancePage()
AppearanceWidget::~AppearanceWidget()
{
delete m_ui;
}
bool AppearancePage::apply()
{
applySettings();
return true;
}
void AppearancePage::retranslate()
{
m_ui->retranslateUi(this);
}
void AppearancePage::applySettings()
void AppearanceWidget::applySettings()
{
SettingsObjectPtr settings = APPLICATION->settings();
QString consoleFontFamily = m_ui->consoleFont->currentFont().family();
@ -63,7 +99,7 @@ void AppearancePage::applySettings()
settings->set("CatOpacity", m_ui->catOpacitySlider->value());
}
void AppearancePage::loadSettings()
void AppearanceWidget::loadSettings()
{
QString fontFamily = APPLICATION->settings()->get("ConsoleFont").toString();
QFont consoleFont(fontFamily);
@ -79,7 +115,12 @@ void AppearancePage::loadSettings()
m_ui->catOpacitySlider->setValue(APPLICATION->settings()->get("CatOpacity").toInt());
}
void AppearancePage::applyIconTheme(int index)
void AppearanceWidget::retranslateUi()
{
m_ui->retranslateUi(this);
}
void AppearanceWidget::applyIconTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalIconTheme = settings->get("IconTheme").toString();
@ -90,7 +131,7 @@ void AppearancePage::applyIconTheme(int index)
}
}
void AppearancePage::applyWidgetTheme(int index)
void AppearanceWidget::applyWidgetTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalAppTheme = settings->get("ApplicationTheme").toString();
@ -103,7 +144,7 @@ void AppearancePage::applyWidgetTheme(int index)
updateConsolePreview();
}
void AppearancePage::applyCatTheme(int index)
void AppearanceWidget::applyCatTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalCat = settings->get("BackgroundCat").toString();
@ -116,7 +157,7 @@ void AppearancePage::applyCatTheme(int index)
updateCatPreview();
}
void AppearancePage::loadThemeSettings()
void AppearanceWidget::loadThemeSettings()
{
APPLICATION->themeManager()->refresh();
@ -157,6 +198,7 @@ void AppearancePage::loadThemeSettings()
m_ui->widgetStyleComboBox->setCurrentIndex(i);
}
if (!m_themesOnly) {
const QString currentCat = settings->get("BackgroundCat").toString();
const auto cats = APPLICATION->themeManager()->getValidCatPacks();
for (int i = 0; i < cats.count(); ++i) {
@ -168,23 +210,24 @@ void AppearancePage::loadThemeSettings()
if (currentCat == cat->id())
m_ui->catPackComboBox->setCurrentIndex(i);
}
}
m_ui->iconsComboBox->blockSignals(false);
m_ui->widgetStyleComboBox->blockSignals(false);
m_ui->catPackComboBox->blockSignals(false);
}
void AppearancePage::updateConsolePreview()
void AppearanceWidget::updateConsolePreview()
{
const LogColors& colors = APPLICATION->themeManager()->getLogColors();
int fontSize = m_ui->fontSizeBox->value();
QString fontFamily = m_ui->consoleFont->currentFont().family();
m_ui->consolePreview->clear();
defaultFormat->setFont(QFont(fontFamily, fontSize));
m_defaultFormat->setFont(QFont(fontFamily, fontSize));
auto print = [this, colors](const QString& message, MessageLevel::Enum level) {
QTextCharFormat format(*defaultFormat);
QTextCharFormat format(*m_defaultFormat);
QColor bg = colors.background.value(level);
QColor fg = colors.foreground.value(level);
@ -202,24 +245,24 @@ void AppearancePage::updateConsolePreview()
workCursor.insertBlock();
};
print(QString("%1 version: %2 (%3)\n")
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM),
print(QString("%1 version: %2\n")
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString()),
MessageLevel::Launcher);
QDate today = QDate::currentDate();
if (today.month() == 10 && today.day() == 31)
print(tr("[Test/ERROR] OOoooOOOoooo! A spooky error!"), MessageLevel::Error);
print(tr("[ERROR] OOoooOOOoooo! A spooky error!"), MessageLevel::Error);
else
print(tr("[Test/ERROR] A spooky error!"), MessageLevel::Error);
print(tr("[ERROR] A spooky error!"), MessageLevel::Error);
print(tr("[Test/INFO] A harmless message..."), MessageLevel::Info);
print(tr("[Test/WARN] A not so spooky warning."), MessageLevel::Warning);
print(tr("[Test/DEBUG] A secret debugging message..."), MessageLevel::Debug);
print(tr("[Test/FATAL] A terrifying fatal error!"), MessageLevel::Fatal);
print(tr("[INFO] A harmless message..."), MessageLevel::Info);
print(tr("[WARN] A not so spooky warning."), MessageLevel::Warning);
print(tr("[DEBUG] A secret debugging message..."), MessageLevel::Debug);
print(tr("[FATAL] A terrifying fatal error!"), MessageLevel::Fatal);
}
void AppearancePage::updateCatPreview()
void AppearanceWidget::updateCatPreview()
{
QIcon catPackIcon(APPLICATION->themeManager()->getCatPack());
m_ui->catPreview->setIcon(catPackIcon);

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2025 TheKodeToad <TheKodeToad@proton.me>
* Copyright (C) 2022 Tayou <git@tayou.org>
*
* This program is free software: you can redistribute it and/or modify
@ -15,40 +16,46 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <QWidget>
#include "translations/TranslationsModel.h"
#include <QDialog>
#include <memory>
enum ThemeFields { NONE = 0b0000, ICONS = 0b0001, WIDGETS = 0b0010, CAT = 0b0100 };
#include <Application.h>
#include <translations/TranslationsModel.h>
#include "java/JavaChecker.h"
#include "ui/pages/BasePage.h"
class QTextCharFormat;
class SettingsObject;
namespace Ui {
class ThemeCustomizationWidget;
class AppearanceWidget;
}
class ThemeCustomizationWidget : public QWidget {
class AppearanceWidget : public QWidget {
Q_OBJECT
public:
explicit ThemeCustomizationWidget(QWidget* parent = nullptr);
~ThemeCustomizationWidget() override;
explicit AppearanceWidget(bool simple, QWidget* parent = 0);
virtual ~AppearanceWidget();
public:
void applySettings();
void loadSettings();
void retranslate();
void retranslateUi();
private slots:
private:
void applyIconTheme(int index);
void applyWidgetTheme(int index);
void applyCatTheme(int index);
void refresh();
void loadThemeSettings();
signals:
int currentIconThemeChanged(int index);
int currentWidgetThemeChanged(int index);
int currentCatChanged(int index);
void updateConsolePreview();
void updateCatPreview();
private:
Ui::ThemeCustomizationWidget* ui;
Ui::AppearanceWidget* m_ui;
QTextCharFormat* m_defaultFormat;
bool m_themesOnly;
};

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearancePage</class>
<widget class="QWidget" name="AppearancePage">
<class>AppearanceWidget</class>
<widget class="QWidget" name="AppearanceWidget">
<property name="geometry">
<rect>
<x>0</x>
@ -16,10 +16,7 @@
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<item>
<widget class="QGroupBox" name="themingBox">
<property name="title">
@ -269,6 +266,35 @@
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="catPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>128</width>
<height>256</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -456,8 +482,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QTextEdit" name="consolePreview">
<property name="sizePolicy">
@ -477,30 +501,7 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="catPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>128</width>
<height>256</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</layout>
</item>
</layout>
</item>
@ -516,6 +517,7 @@
<tabstop>iconsFolder</tabstop>
<tabstop>catPackComboBox</tabstop>
<tabstop>catPackFolder</tabstop>
<tabstop>reloadThemesButton</tabstop>
<tabstop>consoleFont</tabstop>
<tabstop>fontSizeBox</tabstop>
<tabstop>catOpacitySlider</tabstop>

View file

@ -1,163 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2024 Tayou <git@tayou.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ThemeCustomizationWidget.h"
#include "ui_ThemeCustomizationWidget.h"
#include "Application.h"
#include "DesktopServices.h"
#include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h"
ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
{
ui->setupUi(this);
loadSettings();
ThemeCustomizationWidget::refresh();
connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ThemeCustomizationWidget::applyWidgetTheme);
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
connect(ui->iconsFolder, &QPushButton::clicked, this,
[] { DesktopServices::openPath(APPLICATION->themeManager()->getIconThemesFolder().path()); });
connect(ui->widgetStyleFolder, &QPushButton::clicked, this,
[] { DesktopServices::openPath(APPLICATION->themeManager()->getApplicationThemesFolder().path()); });
connect(ui->catPackFolder, &QPushButton::clicked, this,
[] { DesktopServices::openPath(APPLICATION->themeManager()->getCatPacksFolder().path()); });
connect(ui->refreshButton, &QPushButton::clicked, this, &ThemeCustomizationWidget::refresh);
}
ThemeCustomizationWidget::~ThemeCustomizationWidget()
{
delete ui;
}
void ThemeCustomizationWidget::applyIconTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalIconTheme = settings->get("IconTheme").toString();
auto newIconTheme = ui->iconsComboBox->itemData(index).toString();
if (originalIconTheme != newIconTheme) {
settings->set("IconTheme", newIconTheme);
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
}
emit currentIconThemeChanged(index);
}
void ThemeCustomizationWidget::applyWidgetTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalAppTheme = settings->get("ApplicationTheme").toString();
auto newAppTheme = ui->widgetStyleComboBox->itemData(index).toString();
if (originalAppTheme != newAppTheme) {
settings->set("ApplicationTheme", newAppTheme);
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
}
emit currentWidgetThemeChanged(index);
}
void ThemeCustomizationWidget::applyCatTheme(int index)
{
auto settings = APPLICATION->settings();
auto originalCat = settings->get("BackgroundCat").toString();
auto newCat = ui->backgroundCatComboBox->itemData(index).toString();
if (originalCat != newCat) {
settings->set("BackgroundCat", newCat);
}
emit currentCatChanged(index);
}
void ThemeCustomizationWidget::applySettings()
{
applyIconTheme(ui->iconsComboBox->currentIndex());
applyWidgetTheme(ui->widgetStyleComboBox->currentIndex());
applyCatTheme(ui->backgroundCatComboBox->currentIndex());
}
void ThemeCustomizationWidget::loadSettings()
{
auto settings = APPLICATION->settings();
{
auto currentIconTheme = settings->get("IconTheme").toString();
auto iconThemes = APPLICATION->themeManager()->getValidIconThemes();
int idx = 0;
for (auto iconTheme : iconThemes) {
QIcon iconForComboBox = QIcon(iconTheme->path() + "/scalable/settings");
ui->iconsComboBox->addItem(iconForComboBox, iconTheme->name(), iconTheme->id());
if (currentIconTheme == iconTheme->id()) {
ui->iconsComboBox->setCurrentIndex(idx);
}
idx++;
}
}
{
auto currentTheme = settings->get("ApplicationTheme").toString();
auto themes = APPLICATION->themeManager()->getValidApplicationThemes();
int idx = 0;
for (auto& theme : themes) {
ui->widgetStyleComboBox->addItem(theme->name(), theme->id());
if (theme->tooltip() != "") {
int index = ui->widgetStyleComboBox->count() - 1;
ui->widgetStyleComboBox->setItemData(index, theme->tooltip(), Qt::ToolTipRole);
}
if (currentTheme == theme->id()) {
ui->widgetStyleComboBox->setCurrentIndex(idx);
}
idx++;
}
}
auto cat = settings->get("BackgroundCat").toString();
for (auto& catFromList : APPLICATION->themeManager()->getValidCatPacks()) {
QIcon catIcon = QIcon(QString("%1").arg(catFromList->path()));
ui->backgroundCatComboBox->addItem(catIcon, catFromList->name(), catFromList->id());
if (cat == catFromList->id()) {
ui->backgroundCatComboBox->setCurrentIndex(ui->backgroundCatComboBox->count() - 1);
}
}
}
void ThemeCustomizationWidget::retranslate()
{
ui->retranslateUi(this);
}
void ThemeCustomizationWidget::refresh()
{
applySettings();
disconnect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
disconnect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ThemeCustomizationWidget::applyWidgetTheme);
disconnect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ThemeCustomizationWidget::applyCatTheme);
APPLICATION->themeManager()->refresh();
ui->iconsComboBox->clear();
ui->widgetStyleComboBox->clear();
ui->backgroundCatComboBox->clear();
loadSettings();
connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ThemeCustomizationWidget::applyWidgetTheme);
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
};