CRLF -> LF

damn you visual studio for creating CRLF files everywhere...
Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
Tayou 2023-01-09 17:01:33 +01:00
parent 7d440402ad
commit 689fe1e2c7
No known key found for this signature in database
GPG Key ID: 02CA43C1CB6E9887
8 changed files with 1012 additions and 1012 deletions

View File

@ -1,70 +1,70 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "ThemeWizardPage.h" #include "ThemeWizardPage.h"
#include "ui_ThemeWizardPage.h" #include "ui_ThemeWizardPage.h"
#include "Application.h" #include "Application.h"
#include "ui/themes/ITheme.h" #include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h" #include "ui/themes/ThemeManager.h"
#include "ui/widgets/ThemeCustomizationWidget.h" #include "ui/widgets/ThemeCustomizationWidget.h"
#include "ui_ThemeCustomizationWidget.h" #include "ui_ThemeCustomizationWidget.h"
ThemeWizardPage::ThemeWizardPage(QWidget* parent) : BaseWizardPage(parent), ui(new Ui::ThemeWizardPage) ThemeWizardPage::ThemeWizardPage(QWidget* parent) : BaseWizardPage(parent), ui(new Ui::ThemeWizardPage)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentIconThemeChanged, this, &ThemeWizardPage::updateIcons); connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentIconThemeChanged, this, &ThemeWizardPage::updateIcons);
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, this, &ThemeWizardPage::updateCat); connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, this, &ThemeWizardPage::updateCat);
updateIcons(); updateIcons();
updateCat(); updateCat();
} }
ThemeWizardPage::~ThemeWizardPage() ThemeWizardPage::~ThemeWizardPage()
{ {
delete ui; delete ui;
} }
void ThemeWizardPage::updateIcons() void ThemeWizardPage::updateIcons()
{ {
qDebug() << "Setting Icons"; qDebug() << "Setting Icons";
ui->previewIconButton0->setIcon(APPLICATION->getThemedIcon("new")); ui->previewIconButton0->setIcon(APPLICATION->getThemedIcon("new"));
ui->previewIconButton1->setIcon(APPLICATION->getThemedIcon("centralmods")); ui->previewIconButton1->setIcon(APPLICATION->getThemedIcon("centralmods"));
ui->previewIconButton2->setIcon(APPLICATION->getThemedIcon("viewfolder")); ui->previewIconButton2->setIcon(APPLICATION->getThemedIcon("viewfolder"));
ui->previewIconButton3->setIcon(APPLICATION->getThemedIcon("launch")); ui->previewIconButton3->setIcon(APPLICATION->getThemedIcon("launch"));
ui->previewIconButton4->setIcon(APPLICATION->getThemedIcon("copy")); ui->previewIconButton4->setIcon(APPLICATION->getThemedIcon("copy"));
ui->previewIconButton5->setIcon(APPLICATION->getThemedIcon("export")); ui->previewIconButton5->setIcon(APPLICATION->getThemedIcon("export"));
ui->previewIconButton6->setIcon(APPLICATION->getThemedIcon("delete")); ui->previewIconButton6->setIcon(APPLICATION->getThemedIcon("delete"));
ui->previewIconButton7->setIcon(APPLICATION->getThemedIcon("about")); ui->previewIconButton7->setIcon(APPLICATION->getThemedIcon("about"));
ui->previewIconButton8->setIcon(APPLICATION->getThemedIcon("settings")); ui->previewIconButton8->setIcon(APPLICATION->getThemedIcon("settings"));
ui->previewIconButton9->setIcon(APPLICATION->getThemedIcon("cat")); ui->previewIconButton9->setIcon(APPLICATION->getThemedIcon("cat"));
update(); update();
repaint(); repaint();
parentWidget()->update(); parentWidget()->update();
} }
void ThemeWizardPage::updateCat() void ThemeWizardPage::updateCat()
{ {
qDebug() << "Setting Cat"; qDebug() << "Setting Cat";
ui->catImagePreviewButton->setIcon(QIcon(QString(R"(:/backgrounds/%1)").arg(ThemeManager::getCatImage()))); ui->catImagePreviewButton->setIcon(QIcon(QString(R"(:/backgrounds/%1)").arg(ThemeManager::getCatImage())));
} }
void ThemeWizardPage::retranslate() void ThemeWizardPage::retranslate()
{ {
ui->retranslateUi(this); ui->retranslateUi(this);
} }

View File

@ -1,43 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <QWidget> #include <QWidget>
#include "BaseWizardPage.h" #include "BaseWizardPage.h"
namespace Ui { namespace Ui {
class ThemeWizardPage; class ThemeWizardPage;
} }
class ThemeWizardPage : public BaseWizardPage { class ThemeWizardPage : public BaseWizardPage {
Q_OBJECT Q_OBJECT
public: public:
explicit ThemeWizardPage(QWidget* parent = nullptr); explicit ThemeWizardPage(QWidget* parent = nullptr);
~ThemeWizardPage(); ~ThemeWizardPage();
bool validatePage() override { return true; }; bool validatePage() override { return true; };
void retranslate() override; void retranslate() override;
private slots: private slots:
void updateIcons(); void updateIcons();
void updateCat(); void updateCat();
private: private:
Ui::ThemeWizardPage* ui; Ui::ThemeWizardPage* ui;
}; };

View File

@ -1,358 +1,358 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ThemeWizardPage</class> <class>ThemeWizardPage</class>
<widget class="QWizardPage" name="ThemeWizardPage"> <widget class="QWizardPage" name="ThemeWizardPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>510</width> <width>510</width>
<height>552</height> <height>552</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>WizardPage</string> <string>WizardPage</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Select the Theme you wish to use</string> <string>Select the Theme you wish to use</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="ThemeCustomizationWidget" name="themeCustomizationWidget" native="true"> <widget class="ThemeCustomizationWidget" name="themeCustomizationWidget" native="true">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>100</height> <height>100</height>
</size> </size>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Icon Preview:</string> <string>Icon Preview:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="iconPreview"> <layout class="QGridLayout" name="iconPreview">
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="previewIconButton2"> <widget class="QPushButton" name="previewIconButton2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="0" column="5">
<widget class="QPushButton" name="previewIconButton5"> <widget class="QPushButton" name="previewIconButton5">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="7"> <item row="0" column="7">
<widget class="QPushButton" name="previewIconButton7"> <widget class="QPushButton" name="previewIconButton7">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="0" column="4">
<widget class="QPushButton" name="previewIconButton4"> <widget class="QPushButton" name="previewIconButton4">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="previewIconButton1"> <widget class="QPushButton" name="previewIconButton1">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="centralmods"> <iconset theme="centralmods">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="previewIconButton0"> <widget class="QPushButton" name="previewIconButton0">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="9"> <item row="0" column="9">
<widget class="QPushButton" name="previewIconButton9"> <widget class="QPushButton" name="previewIconButton9">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="viewfolder"> <iconset theme="viewfolder">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6"> <item row="0" column="6">
<widget class="QPushButton" name="previewIconButton6"> <widget class="QPushButton" name="previewIconButton6">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="new"> <iconset theme="new">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QPushButton" name="previewIconButton3"> <widget class="QPushButton" name="previewIconButton3">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="8"> <item row="0" column="8">
<widget class="QPushButton" name="previewIconButton8"> <widget class="QPushButton" name="previewIconButton8">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>30</width> <width>30</width>
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="applications-engineering"> <iconset theme="applications-engineering">
<normaloff>.</normaloff>.</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QPushButton" name="catImagePreviewButton"> <widget class="QPushButton" name="catImagePreviewButton">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>256</height> <height>256</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>256</width> <width>256</width>
<height>256</height> <height>256</height>
</size> </size>
</property> </property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>193</height> <height>193</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>ThemeCustomizationWidget</class> <class>ThemeCustomizationWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>ui/widgets/ThemeCustomizationWidget.h</header> <header>ui/widgets/ThemeCustomizationWidget.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,155 +1,155 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "ThemeManager.h" #include "ThemeManager.h"
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
#include <QDirIterator> #include <QDirIterator>
#include <QIcon> #include <QIcon>
#include "ui/themes/BrightTheme.h" #include "ui/themes/BrightTheme.h"
#include "ui/themes/CustomTheme.h" #include "ui/themes/CustomTheme.h"
#include "ui/themes/DarkTheme.h" #include "ui/themes/DarkTheme.h"
#include "ui/themes/SystemTheme.h" #include "ui/themes/SystemTheme.h"
#include "Application.h" #include "Application.h"
ThemeManager::ThemeManager(MainWindow* mainWindow) ThemeManager::ThemeManager(MainWindow* mainWindow)
{ {
m_mainWindow = mainWindow; m_mainWindow = mainWindow;
initializeThemes(); initializeThemes();
} }
/// @brief Adds the Theme to the list of themes /// @brief Adds the Theme to the list of themes
/// @param theme The Theme to add /// @param theme The Theme to add
/// @return Theme ID /// @return Theme ID
QString ThemeManager::addTheme(std::unique_ptr<ITheme> theme) QString ThemeManager::addTheme(std::unique_ptr<ITheme> theme)
{ {
QString id = theme->id(); QString id = theme->id();
m_themes.emplace(id, std::move(theme)); m_themes.emplace(id, std::move(theme));
return id; return id;
} }
/// @brief Gets the Theme from the List via ID /// @brief Gets the Theme from the List via ID
/// @param themeId Theme ID of theme to fetch /// @param themeId Theme ID of theme to fetch
/// @return Theme at themeId /// @return Theme at themeId
ITheme* ThemeManager::getTheme(QString themeId) ITheme* ThemeManager::getTheme(QString themeId)
{ {
return m_themes[themeId].get(); return m_themes[themeId].get();
} }
void ThemeManager::initializeThemes() void ThemeManager::initializeThemes()
{ {
// Icon themes // Icon themes
{ {
// TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies!
// set icon theme search path! // set icon theme search path!
auto searchPaths = QIcon::themeSearchPaths(); auto searchPaths = QIcon::themeSearchPaths();
searchPaths.append("iconthemes"); searchPaths.append("iconthemes");
QIcon::setThemeSearchPaths(searchPaths); QIcon::setThemeSearchPaths(searchPaths);
themeDebugLog() << "<> Icon themes initialized."; themeDebugLog() << "<> Icon themes initialized.";
} }
// Initialize widget themes // Initialize widget themes
{ {
themeDebugLog() << "<> Initializing Widget Themes"; themeDebugLog() << "<> Initializing Widget Themes";
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>()); themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>());
auto darkThemeId = addTheme(std::make_unique<DarkTheme>()); auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId; themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>()); themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
// TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in // TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in
// dropdown?) // dropdown?)
QString themeFolder = QDir("./themes/").absoluteFilePath(""); QString themeFolder = QDir("./themes/").absoluteFilePath("");
themeDebugLog() << "Theme Folder Path: " << themeFolder; themeDebugLog() << "Theme Folder Path: " << themeFolder;
QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (directoryIterator.hasNext()) { while (directoryIterator.hasNext()) {
QDir dir(directoryIterator.next()); QDir dir(directoryIterator.next());
QFileInfo themeJson(dir.absoluteFilePath("theme.json")); QFileInfo themeJson(dir.absoluteFilePath("theme.json"));
if (themeJson.exists()) { if (themeJson.exists()) {
// Load "theme.json" based themes // Load "theme.json" based themes
themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath(); themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath();
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), themeJson, true)); addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), themeJson, true));
} else { } else {
// Load pure QSS Themes // Load pure QSS Themes
QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files); QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files);
while (stylesheetFileIterator.hasNext()) { while (stylesheetFileIterator.hasNext()) {
QFile customThemeFile(stylesheetFileIterator.next()); QFile customThemeFile(stylesheetFileIterator.next());
QFileInfo customThemeFileInfo(customThemeFile); QFileInfo customThemeFileInfo(customThemeFile);
themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath(); themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath();
addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), customThemeFileInfo, false)); addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), customThemeFileInfo, false));
} }
} }
} }
themeDebugLog() << "<> Widget themes initialized."; themeDebugLog() << "<> Widget themes initialized.";
} }
} }
QList<ITheme*> ThemeManager::getValidApplicationThemes() QList<ITheme*> ThemeManager::getValidApplicationThemes()
{ {
QList<ITheme*> ret; QList<ITheme*> ret;
ret.reserve(m_themes.size()); ret.reserve(m_themes.size());
for (auto&& [id, theme] : m_themes) { for (auto&& [id, theme] : m_themes) {
ret.append(theme.get()); ret.append(theme.get());
} }
return ret; return ret;
} }
void ThemeManager::setIconTheme(const QString& name) void ThemeManager::setIconTheme(const QString& name)
{ {
QIcon::setThemeName(name); QIcon::setThemeName(name);
} }
void ThemeManager::applyCurrentlySelectedTheme() void ThemeManager::applyCurrentlySelectedTheme()
{ {
setIconTheme(APPLICATION->settings()->get("IconTheme").toString()); setIconTheme(APPLICATION->settings()->get("IconTheme").toString());
themeDebugLog() << "<> Icon theme set."; themeDebugLog() << "<> Icon theme set.";
setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString()); setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString());
themeDebugLog() << "<> Application theme set."; themeDebugLog() << "<> Application theme set.";
} }
void ThemeManager::setApplicationTheme(const QString& name) void ThemeManager::setApplicationTheme(const QString& name)
{ {
auto systemPalette = qApp->palette(); auto systemPalette = qApp->palette();
auto themeIter = m_themes.find(name); auto themeIter = m_themes.find(name);
if (themeIter != m_themes.end()) { if (themeIter != m_themes.end()) {
auto& theme = themeIter->second; auto& theme = themeIter->second;
themeDebugLog() << "applying theme" << theme->name(); themeDebugLog() << "applying theme" << theme->name();
theme->apply(); theme->apply();
} else { } else {
themeWarningLog() << "Tried to set invalid theme:" << name; themeWarningLog() << "Tried to set invalid theme:" << name;
} }
} }
QString ThemeManager::getCatImage(QString catName) QString ThemeManager::getCatImage(QString catName)
{ {
QDateTime now = QDateTime::currentDateTime(); QDateTime now = QDateTime::currentDateTime();
QDateTime birthday(QDate(now.date().year(), 11, 30), QTime(0, 0)); QDateTime birthday(QDate(now.date().year(), 11, 30), QTime(0, 0));
QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0)); QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
QDateTime halloween(QDate(now.date().year(), 10, 31), QTime(0, 0)); QDateTime halloween(QDate(now.date().year(), 10, 31), QTime(0, 0));
QString cat = !catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString(); QString cat = !catName.isEmpty() ? catName : APPLICATION->settings()->get("BackgroundCat").toString();
if (std::abs(now.daysTo(xmas)) <= 4) { if (std::abs(now.daysTo(xmas)) <= 4) {
cat += "-xmas"; cat += "-xmas";
} else if (std::abs(now.daysTo(halloween)) <= 4) { } else if (std::abs(now.daysTo(halloween)) <= 4) {
cat += "-spooky"; cat += "-spooky";
} else if (std::abs(now.daysTo(birthday)) <= 12) { } else if (std::abs(now.daysTo(birthday)) <= 12) {
cat += "-bday"; cat += "-bday";
} }
return cat; return cat;
} }

View File

@ -1,57 +1,57 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <QString> #include <QString>
#include "ui/MainWindow.h" #include "ui/MainWindow.h"
#include "ui/themes/ITheme.h" #include "ui/themes/ITheme.h"
inline auto themeDebugLog() inline auto themeDebugLog()
{ {
return qDebug() << "[Theme]"; return qDebug() << "[Theme]";
} }
inline auto themeWarningLog() inline auto themeWarningLog()
{ {
return qWarning() << "[Theme]"; return qWarning() << "[Theme]";
} }
class ThemeManager { class ThemeManager {
public: public:
ThemeManager(MainWindow* mainWindow); ThemeManager(MainWindow* mainWindow);
QList<ITheme*> getValidApplicationThemes(); QList<ITheme*> getValidApplicationThemes();
void setIconTheme(const QString& name); void setIconTheme(const QString& name);
void applyCurrentlySelectedTheme(); void applyCurrentlySelectedTheme();
void setApplicationTheme(const QString& name); void setApplicationTheme(const QString& name);
/// <summary> /// <summary>
/// Returns the cat based on selected cat and with events (Birthday, XMas, etc.) /// Returns the cat based on selected cat and with events (Birthday, XMas, etc.)
/// </summary> /// </summary>
/// <param name="catName">Optional, if you need a specific cat.</param> /// <param name="catName">Optional, if you need a specific cat.</param>
/// <returns></returns> /// <returns></returns>
static QString getCatImage(QString catName = ""); static QString getCatImage(QString catName = "");
private: private:
std::map<QString, std::unique_ptr<ITheme>> m_themes; std::map<QString, std::unique_ptr<ITheme>> m_themes;
MainWindow* m_mainWindow; MainWindow* m_mainWindow;
void initializeThemes(); void initializeThemes();
QString addTheme(std::unique_ptr<ITheme> theme); QString addTheme(std::unique_ptr<ITheme> theme);
ITheme* getTheme(QString themeId); ITheme* getTheme(QString themeId);
}; };

View File

@ -1,148 +1,148 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "ThemeCustomizationWidget.h" #include "ThemeCustomizationWidget.h"
#include "ui_ThemeCustomizationWidget.h" #include "ui_ThemeCustomizationWidget.h"
#include "Application.h" #include "Application.h"
#include "ui/themes/ITheme.h" #include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h" #include "ui/themes/ThemeManager.h"
ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget) ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
loadSettings(); loadSettings();
connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme); connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyWidgetTheme); connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyWidgetTheme);
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme); connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
} }
ThemeCustomizationWidget::~ThemeCustomizationWidget() ThemeCustomizationWidget::~ThemeCustomizationWidget()
{ {
delete ui; delete ui;
} }
/// <summary> /// <summary>
/// The layout was not quite right, so currently this just disables the UI elements, which should be hidden instead /// The layout was not quite right, so currently this just disables the UI elements, which should be hidden instead
/// TODO FIXME /// TODO FIXME
/// ///
/// Original Method One: /// Original Method One:
/// ui->iconsComboBox->setVisible(features& ThemeFields::ICONS); /// ui->iconsComboBox->setVisible(features& ThemeFields::ICONS);
/// ui->iconsLabel->setVisible(features& ThemeFields::ICONS); /// ui->iconsLabel->setVisible(features& ThemeFields::ICONS);
/// ui->widgetStyleComboBox->setVisible(features& ThemeFields::WIDGETS); /// ui->widgetStyleComboBox->setVisible(features& ThemeFields::WIDGETS);
/// ui->widgetThemeLabel->setVisible(features& ThemeFields::WIDGETS); /// ui->widgetThemeLabel->setVisible(features& ThemeFields::WIDGETS);
/// ui->backgroundCatComboBox->setVisible(features& ThemeFields::CAT); /// ui->backgroundCatComboBox->setVisible(features& ThemeFields::CAT);
/// ui->backgroundCatLabel->setVisible(features& ThemeFields::CAT); /// ui->backgroundCatLabel->setVisible(features& ThemeFields::CAT);
/// ///
/// original Method Two: /// original Method Two:
/// if (!(features & ThemeFields::ICONS)) { /// if (!(features & ThemeFields::ICONS)) {
/// ui->formLayout->setRowVisible(0, false); /// ui->formLayout->setRowVisible(0, false);
/// } /// }
/// if (!(features & ThemeFields::WIDGETS)) { /// if (!(features & ThemeFields::WIDGETS)) {
/// ui->formLayout->setRowVisible(1, false); /// ui->formLayout->setRowVisible(1, false);
/// } /// }
/// if (!(features & ThemeFields::CAT)) { /// if (!(features & ThemeFields::CAT)) {
/// ui->formLayout->setRowVisible(2, false); /// ui->formLayout->setRowVisible(2, false);
/// } /// }
/// </summary> /// </summary>
/// <param name="features"></param> /// <param name="features"></param>
void ThemeCustomizationWidget::showFeatures(ThemeFields features) { void ThemeCustomizationWidget::showFeatures(ThemeFields features) {
ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS); ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS);
ui->iconsLabel->setEnabled(features & ThemeFields::ICONS); ui->iconsLabel->setEnabled(features & ThemeFields::ICONS);
ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS); ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS);
ui->widgetThemeLabel->setEnabled(features & ThemeFields::WIDGETS); ui->widgetThemeLabel->setEnabled(features & ThemeFields::WIDGETS);
ui->backgroundCatComboBox->setEnabled(features & ThemeFields::CAT); ui->backgroundCatComboBox->setEnabled(features & ThemeFields::CAT);
ui->backgroundCatLabel->setEnabled(features & ThemeFields::CAT); ui->backgroundCatLabel->setEnabled(features & ThemeFields::CAT);
} }
void ThemeCustomizationWidget::applyIconTheme(int index) { void ThemeCustomizationWidget::applyIconTheme(int index) {
auto settings = APPLICATION->settings(); auto settings = APPLICATION->settings();
auto original = settings->get("IconTheme").toString(); auto original = settings->get("IconTheme").toString();
settings->set("IconTheme", m_iconThemeOptions[index].first); settings->set("IconTheme", m_iconThemeOptions[index].first);
if (original != settings->get("IconTheme")) { if (original != settings->get("IconTheme")) {
APPLICATION->applyCurrentlySelectedTheme(); APPLICATION->applyCurrentlySelectedTheme();
} }
emit currentIconThemeChanged(index); emit currentIconThemeChanged(index);
} }
void ThemeCustomizationWidget::applyWidgetTheme(int index) { void ThemeCustomizationWidget::applyWidgetTheme(int index) {
auto settings = APPLICATION->settings(); auto settings = APPLICATION->settings();
auto originalAppTheme = settings->get("ApplicationTheme").toString(); auto originalAppTheme = settings->get("ApplicationTheme").toString();
auto newAppTheme = ui->widgetStyleComboBox->currentData().toString(); auto newAppTheme = ui->widgetStyleComboBox->currentData().toString();
if (originalAppTheme != newAppTheme) { if (originalAppTheme != newAppTheme) {
settings->set("ApplicationTheme", newAppTheme); settings->set("ApplicationTheme", newAppTheme);
APPLICATION->applyCurrentlySelectedTheme(); APPLICATION->applyCurrentlySelectedTheme();
} }
emit currentWidgetThemeChanged(index); emit currentWidgetThemeChanged(index);
} }
void ThemeCustomizationWidget::applyCatTheme(int index) { void ThemeCustomizationWidget::applyCatTheme(int index) {
auto settings = APPLICATION->settings(); auto settings = APPLICATION->settings();
settings->set("BackgroundCat", m_catOptions[index].first); settings->set("BackgroundCat", m_catOptions[index].first);
emit currentCatChanged(index); emit currentCatChanged(index);
} }
void ThemeCustomizationWidget::applySettings() void ThemeCustomizationWidget::applySettings()
{ {
applyIconTheme(ui->iconsComboBox->currentIndex()); applyIconTheme(ui->iconsComboBox->currentIndex());
applyWidgetTheme(ui->widgetStyleComboBox->currentIndex()); applyWidgetTheme(ui->widgetStyleComboBox->currentIndex());
applyCatTheme(ui->backgroundCatComboBox->currentIndex()); applyCatTheme(ui->backgroundCatComboBox->currentIndex());
} }
void ThemeCustomizationWidget::loadSettings() void ThemeCustomizationWidget::loadSettings()
{ {
auto settings = APPLICATION->settings(); auto settings = APPLICATION->settings();
auto iconTheme = settings->get("IconTheme").toString(); auto iconTheme = settings->get("IconTheme").toString();
for (auto& iconThemeFromList : m_iconThemeOptions) { for (auto& iconThemeFromList : m_iconThemeOptions) {
ui->iconsComboBox->addItem(QIcon(QString(":/icons/%1/scalable/settings").arg(iconThemeFromList.first)), iconThemeFromList.second); ui->iconsComboBox->addItem(QIcon(QString(":/icons/%1/scalable/settings").arg(iconThemeFromList.first)), iconThemeFromList.second);
if (iconTheme == iconThemeFromList.first) { if (iconTheme == iconThemeFromList.first) {
ui->iconsComboBox->setCurrentIndex(ui->iconsComboBox->count() - 1); ui->iconsComboBox->setCurrentIndex(ui->iconsComboBox->count() - 1);
} }
} }
{ {
auto currentTheme = settings->get("ApplicationTheme").toString(); auto currentTheme = settings->get("ApplicationTheme").toString();
auto themes = APPLICATION->getValidApplicationThemes(); auto themes = APPLICATION->getValidApplicationThemes();
int idx = 0; int idx = 0;
for (auto& theme : themes) { for (auto& theme : themes) {
ui->widgetStyleComboBox->addItem(theme->name(), theme->id()); ui->widgetStyleComboBox->addItem(theme->name(), theme->id());
if (currentTheme == theme->id()) { if (currentTheme == theme->id()) {
ui->widgetStyleComboBox->setCurrentIndex(idx); ui->widgetStyleComboBox->setCurrentIndex(idx);
} }
idx++; idx++;
} }
} }
auto cat = settings->get("BackgroundCat").toString(); auto cat = settings->get("BackgroundCat").toString();
for (auto& catFromList : m_catOptions) { for (auto& catFromList : m_catOptions) {
ui->backgroundCatComboBox->addItem(QIcon(QString(":/backgrounds/%1").arg(ThemeManager::getCatImage(catFromList.first))), ui->backgroundCatComboBox->addItem(QIcon(QString(":/backgrounds/%1").arg(ThemeManager::getCatImage(catFromList.first))),
catFromList.second); catFromList.second);
if (cat == catFromList.first) { if (cat == catFromList.first) {
ui->backgroundCatComboBox->setCurrentIndex(ui->backgroundCatComboBox->count() - 1); ui->backgroundCatComboBox->setCurrentIndex(ui->backgroundCatComboBox->count() - 1);
} }
} }
} }
void ThemeCustomizationWidget::retranslate() void ThemeCustomizationWidget::retranslate()
{ {
ui->retranslateUi(this); ui->retranslateUi(this);
} }

View File

@ -1,77 +1,77 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* Prism Launcher - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Tayou <tayou@gmx.net> * Copyright (C) 2022 Tayou <tayou@gmx.net>
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3. * the Free Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <QWidget> #include <QWidget>
#include "translations/TranslationsModel.h" #include "translations/TranslationsModel.h"
enum ThemeFields { NONE = 0b0000, ICONS = 0b0001, WIDGETS = 0b0010, CAT = 0b0100 }; enum ThemeFields { NONE = 0b0000, ICONS = 0b0001, WIDGETS = 0b0010, CAT = 0b0100 };
namespace Ui { namespace Ui {
class ThemeCustomizationWidget; class ThemeCustomizationWidget;
} }
class ThemeCustomizationWidget : public QWidget { class ThemeCustomizationWidget : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit ThemeCustomizationWidget(QWidget* parent = nullptr); explicit ThemeCustomizationWidget(QWidget* parent = nullptr);
~ThemeCustomizationWidget(); ~ThemeCustomizationWidget();
void showFeatures(ThemeFields features); void showFeatures(ThemeFields features);
void applySettings(); void applySettings();
void loadSettings(); void loadSettings();
void retranslate(); void retranslate();
private slots: private slots:
void applyIconTheme(int index); void applyIconTheme(int index);
void applyWidgetTheme(int index); void applyWidgetTheme(int index);
void applyCatTheme(int index); void applyCatTheme(int index);
signals: signals:
int currentIconThemeChanged(int index); int currentIconThemeChanged(int index);
int currentWidgetThemeChanged(int index); int currentWidgetThemeChanged(int index);
int currentCatChanged(int index); int currentCatChanged(int index);
private: private:
Ui::ThemeCustomizationWidget* ui; Ui::ThemeCustomizationWidget* ui;
//TODO finish implementing //TODO finish implementing
QList<std::pair<QString, QString>> m_iconThemeOptions{ QList<std::pair<QString, QString>> m_iconThemeOptions{
{ "pe_colored", QObject::tr("Simple (Colored Icons)") }, { "pe_colored", QObject::tr("Simple (Colored Icons)") },
{ "pe_light", QObject::tr("Simple (Light Icons)") }, { "pe_light", QObject::tr("Simple (Light Icons)") },
{ "pe_dark", QObject::tr("Simple (Dark Icons)") }, { "pe_dark", QObject::tr("Simple (Dark Icons)") },
{ "pe_blue", QObject::tr("Simple (Blue Icons)") }, { "pe_blue", QObject::tr("Simple (Blue Icons)") },
{ "breeze_light", QObject::tr("Breeze Light") }, { "breeze_light", QObject::tr("Breeze Light") },
{ "breeze_dark", QObject::tr("Breeze Dark") }, { "breeze_dark", QObject::tr("Breeze Dark") },
{ "OSX", QObject::tr("OSX") }, { "OSX", QObject::tr("OSX") },
{ "iOS", QObject::tr("iOS") }, { "iOS", QObject::tr("iOS") },
{ "flat", QObject::tr("Flat") }, { "flat", QObject::tr("Flat") },
{ "flat_white", QObject::tr("Flat (White)") }, { "flat_white", QObject::tr("Flat (White)") },
{ "multimc", QObject::tr("Legacy") }, { "multimc", QObject::tr("Legacy") },
{ "custom", QObject::tr("Custom") } { "custom", QObject::tr("Custom") }
}; };
QList<std::pair<QString, QString>> m_catOptions{ QList<std::pair<QString, QString>> m_catOptions{
{ "kitteh", QObject::tr("Background Cat (from MultiMC)") }, { "kitteh", QObject::tr("Background Cat (from MultiMC)") },
{ "rory", QObject::tr("Rory ID 11 (drawn by Ashtaka)") }, { "rory", QObject::tr("Rory ID 11 (drawn by Ashtaka)") },
{ "rory-flat", QObject::tr("Rory ID 11 (flat edition, drawn by Ashtaka)") }, { "rory-flat", QObject::tr("Rory ID 11 (flat edition, drawn by Ashtaka)") },
{ "teawie", QObject::tr("Teawie (drawn by SympathyTea)") } { "teawie", QObject::tr("Teawie (drawn by SympathyTea)") }
}; };
}; };

View File

@ -1,105 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ThemeCustomizationWidget</class> <class>ThemeCustomizationWidget</class>
<widget class="QWidget" name="ThemeCustomizationWidget"> <widget class="QWidget" name="ThemeCustomizationWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>311</height> <height>311</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string notr="true">Form</string> <string notr="true">Form</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetMinimumSize</enum>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="iconsLabel"> <widget class="QLabel" name="iconsLabel">
<property name="text"> <property name="text">
<string>&amp;Icons</string> <string>&amp;Icons</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>iconsComboBox</cstring> <cstring>iconsComboBox</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="iconsComboBox"> <widget class="QComboBox" name="iconsComboBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::StrongFocus</enum> <enum>Qt::StrongFocus</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="widgetThemeLabel"> <widget class="QLabel" name="widgetThemeLabel">
<property name="text"> <property name="text">
<string>&amp;Colors</string> <string>&amp;Colors</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>widgetStyleComboBox</cstring> <cstring>widgetStyleComboBox</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="widgetStyleComboBox"> <widget class="QComboBox" name="widgetStyleComboBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::StrongFocus</enum> <enum>Qt::StrongFocus</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="backgroundCatLabel"> <widget class="QLabel" name="backgroundCatLabel">
<property name="text"> <property name="text">
<string>C&amp;at</string> <string>C&amp;at</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>backgroundCatComboBox</cstring> <cstring>backgroundCatComboBox</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QComboBox" name="backgroundCatComboBox"> <widget class="QComboBox" name="backgroundCatComboBox">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::StrongFocus</enum> <enum>Qt::StrongFocus</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>