From 97662f5c8ecdf32403939e427c74310f9175fb9e Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 18 Jul 2023 22:50:43 +0100 Subject: [PATCH 01/17] Multiple icon themes! Signed-off-by: TheKodeToad --- launcher/Application.cpp | 5 + launcher/Application.h | 3 + launcher/CMakeLists.txt | 2 + launcher/resources/multimc/index.theme | 2 +- launcher/resources/pe_blue/index.theme | 2 +- launcher/resources/pe_colored/index.theme | 2 +- launcher/resources/pe_dark/index.theme | 2 +- launcher/resources/pe_light/index.theme | 2 +- launcher/ui/themes/IconTheme.cpp | 35 ++++++ launcher/ui/themes/IconTheme.h | 18 +++ launcher/ui/themes/ThemeManager.cpp | 117 ++++++++++++------ launcher/ui/themes/ThemeManager.h | 8 ++ .../ui/widgets/ThemeCustomizationWidget.cpp | 22 ++-- .../ui/widgets/ThemeCustomizationWidget.h | 19 +-- 14 files changed, 171 insertions(+), 68 deletions(-) create mode 100644 launcher/ui/themes/IconTheme.cpp create mode 100644 launcher/ui/themes/IconTheme.h diff --git a/launcher/Application.cpp b/launcher/Application.cpp index d6c135de7..df8a23636 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1163,6 +1163,11 @@ QList Application::getValidApplicationThemes() return m_themeManager->getValidApplicationThemes(); } +QList Application::getValidIconThemes() +{ + return m_themeManager->getValidIconThemes(); +} + void Application::applyCurrentlySelectedTheme(bool initial) { m_themeManager->applyCurrentlySelectedTheme(initial); diff --git a/launcher/Application.h b/launcher/Application.h index 527c536b3..0b953f0a5 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -70,6 +70,7 @@ class TranslationsModel; class ITheme; class MCEditTool; class ThemeManager; +class IconTheme; namespace Meta { class Index; @@ -124,6 +125,8 @@ public: QList getValidApplicationThemes(); + QList getValidIconThemes(); + void setApplicationTheme(const QString& name); shared_qobject_ptr updater() { diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 7cba97b4f..89fc901b0 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -759,6 +759,8 @@ SET(LAUNCHER_SOURCES ui/themes/ITheme.h ui/themes/SystemTheme.cpp ui/themes/SystemTheme.h + ui/themes/IconTheme.cpp + ui/themes/IconTheme.h ui/themes/ThemeManager.cpp ui/themes/ThemeManager.h diff --git a/launcher/resources/multimc/index.theme b/launcher/resources/multimc/index.theme index 070e23f10..4da8072d9 100644 --- a/launcher/resources/multimc/index.theme +++ b/launcher/resources/multimc/index.theme @@ -1,5 +1,5 @@ [Icon Theme] -Name=multimc +Name=Legacy Comment=Default Icons Inherits=default Directories=8x8,16x16,22x22,24x24,32x32,32x32/instances,48x48,50x50/instances,64x64,128x128/instances,256x256,scalable,scalable/instances diff --git a/launcher/resources/pe_blue/index.theme b/launcher/resources/pe_blue/index.theme index c9e0d93ad..6d842b5d2 100644 --- a/launcher/resources/pe_blue/index.theme +++ b/launcher/resources/pe_blue/index.theme @@ -1,5 +1,5 @@ [Icon Theme] -Name=pe_blue +Name=Simple (Blue) Comment=Icons by pexner (blue) Inherits=multimc Directories=scalable diff --git a/launcher/resources/pe_colored/index.theme b/launcher/resources/pe_colored/index.theme index b757bbd79..bca5494f1 100644 --- a/launcher/resources/pe_colored/index.theme +++ b/launcher/resources/pe_colored/index.theme @@ -1,5 +1,5 @@ [Icon Theme] -Name=pe_colored +Name=Simple (Colored) Comment=Icons by pexner (colored) Inherits=multimc Directories=scalable diff --git a/launcher/resources/pe_dark/index.theme b/launcher/resources/pe_dark/index.theme index b7d1ad011..4cfbf09c4 100644 --- a/launcher/resources/pe_dark/index.theme +++ b/launcher/resources/pe_dark/index.theme @@ -1,5 +1,5 @@ [Icon Theme] -Name=pe_dark +Name=Simple (Dark) Comment=Icons by pexner (dark) Inherits=multimc Directories=scalable diff --git a/launcher/resources/pe_light/index.theme b/launcher/resources/pe_light/index.theme index c106acc8b..87b76d139 100644 --- a/launcher/resources/pe_light/index.theme +++ b/launcher/resources/pe_light/index.theme @@ -1,5 +1,5 @@ [Icon Theme] -Name=pe_light +Name=Simple (Light) Comment=Icons by pexner (light) Inherits=multimc Directories=scalable diff --git a/launcher/ui/themes/IconTheme.cpp b/launcher/ui/themes/IconTheme.cpp new file mode 100644 index 000000000..ef2455051 --- /dev/null +++ b/launcher/ui/themes/IconTheme.cpp @@ -0,0 +1,35 @@ +#include "IconTheme.h" + +#include +#include + +IconTheme::IconTheme(const QString& id, const QString& path) : m_id(id), m_path(path) {} + +bool IconTheme::load() +{ + QString path = m_path + "/index.theme"; + + if (!QFile::exists(path)) + return false; + + QSettings settings(path, QSettings::IniFormat); + settings.beginGroup("Icon Theme"); + m_name = settings.value("Name").toString(); + settings.endGroup(); + return !m_name.isNull(); +} + +QString IconTheme::id() +{ + return m_id; +} + +QString IconTheme::path() +{ + return m_path; +} + +QString IconTheme::name() +{ + return m_name; +} \ No newline at end of file diff --git a/launcher/ui/themes/IconTheme.h b/launcher/ui/themes/IconTheme.h new file mode 100644 index 000000000..cb05d8c73 --- /dev/null +++ b/launcher/ui/themes/IconTheme.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +class IconTheme { + public: + IconTheme(const QString& id, const QString& path); + + bool load(); + QString id(); + QString path(); + QString name(); + + private: + QString m_id; + QString m_path; + QString m_name; +}; \ No newline at end of file diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index b50c6157f..3453a2463 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -55,50 +55,84 @@ ITheme* ThemeManager::getTheme(QString themeId) void ThemeManager::initializeThemes() { // Icon themes - { - // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! - // set icon theme search path! - auto searchPaths = QIcon::themeSearchPaths(); - searchPaths.append("iconthemes"); - QIcon::setThemeSearchPaths(searchPaths); - themeDebugLog() << "<> Icon themes initialized."; - } + initializeIcons(); // Initialize widget themes - { - themeDebugLog() << "<> Initializing Widget Themes"; - themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique()); - auto darkThemeId = addTheme(std::make_unique()); - themeDebugLog() << "Loading Built-in Theme:" << darkThemeId; - themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique()); + initializeWidgets(); +} - // TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in - // dropdown?) - QString themeFolder = QDir("./themes/").absoluteFilePath(""); - themeDebugLog() << "Theme Folder Path: " << themeFolder; +void ThemeManager::initializeIcons() +{ + // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! + // set icon theme search path! - QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); - while (directoryIterator.hasNext()) { - QDir dir(directoryIterator.next()); - QFileInfo themeJson(dir.absoluteFilePath("theme.json")); - if (themeJson.exists()) { - // Load "theme.json" based themes - themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath(); - addTheme(std::make_unique(getTheme(darkThemeId), themeJson, true)); - } else { - // Load pure QSS Themes - QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files); - while (stylesheetFileIterator.hasNext()) { - QFile customThemeFile(stylesheetFileIterator.next()); - QFileInfo customThemeFileInfo(customThemeFile); - themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath(); - addTheme(std::make_unique(getTheme(darkThemeId), customThemeFileInfo, false)); - } - } + QString themeFolder = "iconthemes"; + + auto searchPaths = QIcon::themeSearchPaths(); + searchPaths.append(themeFolder); + QIcon::setThemeSearchPaths(searchPaths); + + themeDebugLog() << "<> Initializing Icon Themes"; + + for (const QString& id : builtinIcons) { + IconTheme theme(id, QString(":/icons/%1").arg(id)); + if (!theme.load()) { + themeWarningLog() << "Couldn't load built-in icon theme" << id; + continue; } - themeDebugLog() << "<> Widget themes initialized."; + m_icons.append(theme); + themeDebugLog() << "Loaded Built-In Icon Theme" << id; } + + QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + while (directoryIterator.hasNext()) { + QDir dir(directoryIterator.next()); + IconTheme theme(dir.dirName(), dir.path()); + if (!theme.load()) + continue; + + m_icons.append(theme); + themeDebugLog() << "Loaded Custom Icon Theme from" << dir.path(); + } + + themeDebugLog() << "<> Icon themes initialized."; +} + +void ThemeManager::initializeWidgets() +{ + themeDebugLog() << "<> Initializing Widget Themes"; + themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique()); + auto darkThemeId = addTheme(std::make_unique()); + themeDebugLog() << "Loading Built-in Theme:" << darkThemeId; + themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique()); + + // TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in + // dropdown?) + QString themeFolder = QDir("./themes/").absoluteFilePath(""); + themeDebugLog() << "Theme Folder Path: " << themeFolder; + + QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + while (directoryIterator.hasNext()) { + QDir dir(directoryIterator.next()); + QFileInfo themeJson(dir.absoluteFilePath("theme.json")); + if (themeJson.exists()) { + // Load "theme.json" based themes + themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath(); + addTheme(std::make_unique(getTheme(darkThemeId), themeJson, true)); + } else { + // Load pure QSS Themes + QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files); + while (stylesheetFileIterator.hasNext()) { + QFile customThemeFile(stylesheetFileIterator.next()); + QFileInfo customThemeFileInfo(customThemeFile); + themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath(); + addTheme(std::make_unique(getTheme(darkThemeId), customThemeFileInfo, false)); + } + } + } + + themeDebugLog() << "<> Widget themes initialized."; } QList ThemeManager::getValidApplicationThemes() @@ -111,6 +145,15 @@ QList ThemeManager::getValidApplicationThemes() return ret; } +QList ThemeManager::getValidIconThemes() +{ + QList ret; + ret.reserve(m_icons.size()); + for (IconTheme& theme : m_icons) + ret.append(&theme); + return ret; +} + void ThemeManager::setIconTheme(const QString& name) { QIcon::setThemeName(name); diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index d2a6fb70a..7509377c4 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -19,6 +19,7 @@ #include +#include "IconTheme.h" #include "ui/MainWindow.h" #include "ui/themes/ITheme.h" @@ -36,6 +37,7 @@ class ThemeManager { ThemeManager(MainWindow* mainWindow); QList getValidApplicationThemes(); + QList getValidIconThemes(); void setIconTheme(const QString& name); void applyCurrentlySelectedTheme(bool initial = false); void setApplicationTheme(const QString& name, bool initial = false); @@ -49,9 +51,15 @@ class ThemeManager { private: std::map> m_themes; + QList m_icons; MainWindow* m_mainWindow; void initializeThemes(); QString addTheme(std::unique_ptr theme); ITheme* getTheme(QString themeId); + void initializeIcons(); + void initializeWidgets(); + + const QStringList builtinIcons{ "pe_colored", "pe_light", "pe_dark", "pe_blue", "breeze_light", "breeze_dark", + "OSX", "iOS", "flat", "flat_white", "multimc" }; }; diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index 3bfcd8213..455cbb7b6 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp +++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp @@ -73,10 +73,9 @@ void ThemeCustomizationWidget::showFeatures(ThemeFields features) { void ThemeCustomizationWidget::applyIconTheme(int index) { auto settings = APPLICATION->settings(); auto originalIconTheme = settings->get("IconTheme").toString(); - auto& newIconTheme = m_iconThemeOptions[index].first; - settings->set("IconTheme", newIconTheme); - + auto newIconTheme = ui->iconsComboBox->currentData().toString(); if (originalIconTheme != newIconTheme) { + settings->set("IconTheme", newIconTheme); APPLICATION->applyCurrentlySelectedTheme(); } @@ -112,12 +111,17 @@ void ThemeCustomizationWidget::loadSettings() { auto settings = APPLICATION->settings(); - auto iconTheme = settings->get("IconTheme").toString(); - for (auto& iconThemeFromList : m_iconThemeOptions) { - QIcon iconForComboBox = QIcon(QString(":/icons/%1/scalable/settings").arg(iconThemeFromList.first)); - ui->iconsComboBox->addItem(iconForComboBox, iconThemeFromList.second); - if (iconTheme == iconThemeFromList.first) { - ui->iconsComboBox->setCurrentIndex(ui->iconsComboBox->count() - 1); + { + auto currentIconTheme = settings->get("IconTheme").toString(); + auto iconThemes = APPLICATION->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++; } } diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.h b/launcher/ui/widgets/ThemeCustomizationWidget.h index 6c33c3c50..976ede435 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.h +++ b/launcher/ui/widgets/ThemeCustomizationWidget.h @@ -31,7 +31,7 @@ class ThemeCustomizationWidget : public QWidget { public: explicit ThemeCustomizationWidget(QWidget* parent = nullptr); - ~ThemeCustomizationWidget(); + ~ThemeCustomizationWidget() override; void showFeatures(ThemeFields features); @@ -53,22 +53,7 @@ class ThemeCustomizationWidget : public QWidget { private: Ui::ThemeCustomizationWidget* ui; - //TODO finish implementing - QList> m_iconThemeOptions{ - { "pe_colored", QObject::tr("Simple (Colored Icons)") }, - { "pe_light", QObject::tr("Simple (Light Icons)") }, - { "pe_dark", QObject::tr("Simple (Dark Icons)") }, - { "pe_blue", QObject::tr("Simple (Blue Icons)") }, - { "breeze_light", QObject::tr("Breeze Light") }, - { "breeze_dark", QObject::tr("Breeze Dark") }, - { "OSX", QObject::tr("OSX") }, - { "iOS", QObject::tr("iOS") }, - { "flat", QObject::tr("Flat") }, - { "flat_white", QObject::tr("Flat (White)") }, - { "multimc", QObject::tr("Legacy") }, - { "custom", QObject::tr("Custom") } - }; - QList> m_catOptions{ + QList> m_catOptions{ { "kitteh", QObject::tr("Background Cat (from MultiMC)") }, { "rory", QObject::tr("Rory ID 11 (drawn by Ashtaka)") }, { "rory-flat", QObject::tr("Rory ID 11 (flat edition, drawn by Ashtaka)") }, From 58c2059e10a52ff0cb4481fdb14f512b198de964 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 10:38:56 +0100 Subject: [PATCH 02/17] Remove recursion It will add icon packs which aren't available - as QIcon's search paths are not recursed! Signed-off-by: TheKodeToad --- launcher/ui/themes/ThemeManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 3453a2463..5e0fa580c 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -85,7 +85,7 @@ void ThemeManager::initializeIcons() themeDebugLog() << "Loaded Built-In Icon Theme" << id; } - QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); IconTheme theme(dir.dirName(), dir.path()); From 44ca7c7d22f89d28bc9026700c8e0f8efe89b668 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 12:29:51 +0100 Subject: [PATCH 03/17] Licenses Signed-off-by: TheKodeToad --- launcher/ui/themes/IconTheme.cpp | 18 ++++++++++++++++++ launcher/ui/themes/IconTheme.h | 18 ++++++++++++++++++ launcher/ui/themes/ThemeManager.cpp | 1 + launcher/ui/themes/ThemeManager.h | 1 + 4 files changed, 38 insertions(+) diff --git a/launcher/ui/themes/IconTheme.cpp b/launcher/ui/themes/IconTheme.cpp index ef2455051..cd1dfbaf5 100644 --- a/launcher/ui/themes/IconTheme.cpp +++ b/launcher/ui/themes/IconTheme.cpp @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + #include "IconTheme.h" #include diff --git a/launcher/ui/themes/IconTheme.h b/launcher/ui/themes/IconTheme.h index cb05d8c73..0282d7cbf 100644 --- a/launcher/ui/themes/IconTheme.h +++ b/launcher/ui/themes/IconTheme.h @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + #pragma once #include diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 5e0fa580c..84e11ccf3 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -2,6 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Tayou + * Copyright (C) 2023 TheKodeToad * * 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 diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 7509377c4..9b97f3723 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -2,6 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Tayou + * Copyright (C) 2023 TheKodeToad * * 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 From 96ebdfc9a88004056b6ec581f071678e08c0c989 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 14:12:39 +0100 Subject: [PATCH 04/17] Sorting and invalid reset Signed-off-by: TheKodeToad --- launcher/ui/themes/IconTheme.h | 1 + launcher/ui/themes/ThemeManager.cpp | 37 +++++++++++++++++++++++------ launcher/ui/themes/ThemeManager.h | 7 +++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/launcher/ui/themes/IconTheme.h b/launcher/ui/themes/IconTheme.h index 0282d7cbf..458ea12c1 100644 --- a/launcher/ui/themes/IconTheme.h +++ b/launcher/ui/themes/IconTheme.h @@ -23,6 +23,7 @@ class IconTheme { public: IconTheme(const QString& id, const QString& path); + IconTheme() = default; bool load(); QString id(); diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 84e11ccf3..8c9a6a585 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -53,6 +53,13 @@ ITheme* ThemeManager::getTheme(QString themeId) return m_themes[themeId].get(); } +QString ThemeManager::addIconTheme(IconTheme theme) +{ + QString id = theme.id(); + m_icons.emplace(id, std::move(theme)); + return id; +} + void ThemeManager::initializeThemes() { // Icon themes @@ -82,7 +89,7 @@ void ThemeManager::initializeIcons() continue; } - m_icons.append(theme); + addIconTheme(std::move(theme)); themeDebugLog() << "Loaded Built-In Icon Theme" << id; } @@ -93,7 +100,7 @@ void ThemeManager::initializeIcons() if (!theme.load()) continue; - m_icons.append(theme); + addIconTheme(std::move(theme)); themeDebugLog() << "Loaded Custom Icon Theme from" << dir.path(); } @@ -150,25 +157,39 @@ QList ThemeManager::getValidIconThemes() { QList ret; ret.reserve(m_icons.size()); - for (IconTheme& theme : m_icons) + for (auto&& [id, theme] : m_icons) { ret.append(&theme); + } return ret; } -void ThemeManager::setIconTheme(const QString& name) +bool ThemeManager::setIconTheme(const QString& name) { + if (m_icons.find(name) == m_icons.end()) { + themeWarningLog() << "Tried to set invalid icon theme:" << name; + return false; + } + QIcon::setThemeName(name); + return true; } void ThemeManager::applyCurrentlySelectedTheme(bool initial) { - setIconTheme(APPLICATION->settings()->get("IconTheme").toString()); + auto settings = APPLICATION->settings(); + if (!setIconTheme(settings->get("IconTheme").toString())) { + APPLICATION->settings()->reset("IconTheme"); + setIconTheme(settings->get("IconTheme").toString()); + } themeDebugLog() << "<> Icon theme set."; - setApplicationTheme(APPLICATION->settings()->get("ApplicationTheme").toString(), initial); + if (!setApplicationTheme(settings->get("ApplicationTheme").toString(), initial)) { + APPLICATION->settings()->reset("ApplicationTheme"); + setApplicationTheme(settings->get("ApplicationTheme").toString(), initial); + } themeDebugLog() << "<> Application theme set."; } -void ThemeManager::setApplicationTheme(const QString& name, bool initial) +bool ThemeManager::setApplicationTheme(const QString& name, bool initial) { auto systemPalette = qApp->palette(); auto themeIter = m_themes.find(name); @@ -176,8 +197,10 @@ void ThemeManager::setApplicationTheme(const QString& name, bool initial) auto& theme = themeIter->second; themeDebugLog() << "applying theme" << theme->name(); theme->apply(initial); + return true; } else { themeWarningLog() << "Tried to set invalid theme:" << name; + return false; } } diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 9b97f3723..2b6c57e97 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -39,9 +39,9 @@ class ThemeManager { QList getValidApplicationThemes(); QList getValidIconThemes(); - void setIconTheme(const QString& name); + bool setIconTheme(const QString& name); void applyCurrentlySelectedTheme(bool initial = false); - void setApplicationTheme(const QString& name, bool initial = false); + bool setApplicationTheme(const QString& name, bool initial = false); /// /// Returns the cat based on selected cat and with events (Birthday, XMas, etc.) @@ -52,12 +52,13 @@ class ThemeManager { private: std::map> m_themes; - QList m_icons; + std::map m_icons; MainWindow* m_mainWindow; void initializeThemes(); QString addTheme(std::unique_ptr theme); ITheme* getTheme(QString themeId); + QString addIconTheme(IconTheme theme); void initializeIcons(); void initializeWidgets(); From c633c6d083f7b2395cd98da2d26df361392cfa61 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 14:17:17 +0100 Subject: [PATCH 05/17] Colors->Widgets Signed-off-by: TheKodeToad --- launcher/ui/widgets/ThemeCustomizationWidget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.ui b/launcher/ui/widgets/ThemeCustomizationWidget.ui index f216a610e..6b2c87f97 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.ui +++ b/launcher/ui/widgets/ThemeCustomizationWidget.ui @@ -55,7 +55,7 @@ - &Colors + &Widgets widgetStyleComboBox From 54d393632d5c964f0c30ca9bc816853b92552c9c Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 16:29:52 +0100 Subject: [PATCH 06/17] Automatically create theme folders, and add an action to open them Signed-off-by: TheKodeToad --- launcher/ui/MainWindow.cpp | 25 ++++++++++----- launcher/ui/MainWindow.h | 10 +++--- launcher/ui/MainWindow.ui | 48 +++++++++++++++++++++++------ launcher/ui/themes/ThemeManager.cpp | 18 +++++++---- 4 files changed, 74 insertions(+), 27 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index da572fc34..600d245d9 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1134,16 +1134,30 @@ void MainWindow::undoTrashInstance() ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething()); } +void MainWindow::on_actionViewLauncherRootFolder_triggered() +{ + DesktopServices::openDirectory("."); +} + void MainWindow::on_actionViewInstanceFolder_triggered() { QString str = APPLICATION->settings()->get("InstanceDir").toString(); DesktopServices::openDirectory(str); } -void MainWindow::on_actionViewLauncherRootFolder_triggered() +void MainWindow::on_actionViewCentralModsFolder_triggered() { - const QString dataPath = QDir::currentPath(); - DesktopServices::openDirectory(dataPath); + DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true); +} + +void MainWindow::on_actionViewIconThemeFolder_triggered() +{ + DesktopServices::openDirectory("iconthemes"); +} + +void MainWindow::on_actionViewWidgetThemeFolder_triggered() +{ + DesktopServices::openDirectory("themes"); } void MainWindow::refreshInstances() @@ -1151,11 +1165,6 @@ void MainWindow::refreshInstances() APPLICATION->instances()->loadList(); } -void MainWindow::on_actionViewCentralModsFolder_triggered() -{ - DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true); -} - void MainWindow::checkForUpdates() { if (BuildConfig.UPDATER_ENABLED) { diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 27c2756f6..8756c0784 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -111,16 +111,18 @@ private slots: void on_actionChangeInstIcon_triggered(); - void on_actionViewInstanceFolder_triggered(); - void on_actionViewLauncherRootFolder_triggered(); + void on_actionViewInstanceFolder_triggered(); + void on_actionViewCentralModsFolder_triggered(); + + void on_actionViewIconThemeFolder_triggered(); + void on_actionViewWidgetThemeFolder_triggered(); + void on_actionViewSelectedInstFolder_triggered(); void refreshInstances(); - void on_actionViewCentralModsFolder_triggered(); - void checkForUpdates(); void on_actionSettings_triggered(); diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index e4421d400..1bc620277 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -131,7 +131,7 @@ 0 0 800 - 20 + 31 @@ -186,9 +186,13 @@ true - + + + + + @@ -465,7 +469,8 @@ - + + .. Prism Launcher (zip) @@ -473,7 +478,8 @@ - + + .. Modrinth (mrpack) @@ -481,15 +487,17 @@ - + + .. - CurseForge (zip) + CurseForge (zip) - + + .. Mod List @@ -552,7 +560,7 @@ .. - &View Instance Folder + View &Instance Folder Open the instance folder in a file browser. @@ -564,7 +572,7 @@ .. - &View Launcher Root Folder + View Launcher &Root Folder Open the launcher's root folder in a file browser. @@ -719,6 +727,28 @@ Open the %1 wiki + + + + + + View &Widget Themes Folder + + + View Widget Theme Folder + + + + + + + + View I&con Theme Folder + + + View Icon Theme Folder + + diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 8c9a6a585..525201be7 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -74,10 +74,13 @@ void ThemeManager::initializeIcons() // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! // set icon theme search path! - QString themeFolder = "iconthemes"; + QDir themeFolder("iconthemes"); + if (!themeFolder.mkpath(".")) + themeWarningLog() << "Couldn't create icon theme folder"; + themeDebugLog() << "Icon Theme Folder Path: " << themeFolder.absolutePath(); auto searchPaths = QIcon::themeSearchPaths(); - searchPaths.append(themeFolder); + searchPaths.append(themeFolder.path()); QIcon::setThemeSearchPaths(searchPaths); themeDebugLog() << "<> Initializing Icon Themes"; @@ -93,7 +96,7 @@ void ThemeManager::initializeIcons() themeDebugLog() << "Loaded Built-In Icon Theme" << id; } - QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot); + QDirIterator directoryIterator(themeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); IconTheme theme(dir.dirName(), dir.path()); @@ -117,10 +120,13 @@ void ThemeManager::initializeWidgets() // TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in // dropdown?) - QString themeFolder = QDir("./themes/").absoluteFilePath(""); - themeDebugLog() << "Theme Folder Path: " << themeFolder; - QDirIterator directoryIterator(themeFolder, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + QDir themeFolder("themes"); + if (!themeFolder.mkpath(".")) + themeWarningLog() << "Couldn't create theme folder"; + themeDebugLog() << "Theme Folder Path: " << themeFolder.absolutePath(); + + QDirIterator directoryIterator(themeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); QFileInfo themeJson(dir.absoluteFilePath("theme.json")); From 960093700a9daa4e2115d4663ab486a5dd1a4757 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 20:57:08 +0100 Subject: [PATCH 07/17] Better theme reset Signed-off-by: TheKodeToad --- launcher/Application.cpp | 21 +++++++++---- launcher/ui/themes/ThemeManager.cpp | 46 ++++++++++++++--------------- launcher/ui/themes/ThemeManager.h | 9 +++--- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index df8a23636..ea706d6f4 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -526,7 +526,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings.reset(new INISettingsObject({ BuildConfig.LAUNCHER_CONFIGFILE, "polymc.cfg", "multimc.cfg" }, this)); // Theming - m_settings->registerSetting("IconTheme", QString("pe_colored")); + m_settings->registerSetting("IconTheme", QString()); m_settings->registerSetting("ApplicationTheme", QString()); m_settings->registerSetting("BackgroundCat", QString("kitteh")); @@ -801,7 +801,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) } // Themes - m_themeManager = std::make_unique(m_mainWindow); + m_themeManager = std::make_unique(); // initialize and load all instances { @@ -893,8 +893,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) } }); - applyCurrentlySelectedTheme(true); - updateCapabilities(); if(createSetupWizard()) @@ -902,6 +900,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) return; } + applyCurrentlySelectedTheme(true); performMainStartupAction(); } @@ -930,11 +929,21 @@ bool Application::createSetupWizard() }(); bool languageRequired = settings()->get("Language").toString().isEmpty(); bool pasteInterventionRequired = settings()->get("PastebinURL") != ""; - bool themeInterventionRequired = settings()->get("ApplicationTheme") == ""; + bool validWidgets = m_themeManager->isValidApplicationTheme(settings()->get("ApplicationTheme").toString()); + bool validIcons = m_themeManager->isValidIconTheme(settings()->get("IconTheme").toString()); + bool themeInterventionRequired = !validWidgets || !validIcons; bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired; if(wizardRequired) { + // set default theme after going into theme wizard + if (!validIcons) + settings()->set("IconTheme", QString("pe_colored")); + if (!validWidgets) + settings()->set("ApplicationTheme", QString("system")); + + applyCurrentlySelectedTheme(true); + m_setupWizard = new SetupWizard(nullptr); if (languageRequired) { @@ -953,9 +962,9 @@ bool Application::createSetupWizard() if (themeInterventionRequired) { - settings()->set("ApplicationTheme", QString("system")); // set default theme after going into theme wizard m_setupWizard->addPage(new ThemeWizardPage(m_setupWizard)); } + connect(m_setupWizard, &QDialog::finished, this, &Application::setupWizardFinished); m_setupWizard->show(); return true; diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 525201be7..a9fae5896 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -29,9 +29,8 @@ #include "Application.h" -ThemeManager::ThemeManager(MainWindow* mainWindow) +ThemeManager::ThemeManager() { - m_mainWindow = mainWindow; initializeThemes(); } @@ -169,33 +168,27 @@ QList ThemeManager::getValidIconThemes() return ret; } -bool ThemeManager::setIconTheme(const QString& name) +bool ThemeManager::isValidApplicationTheme(const QString& id) +{ + return !id.isEmpty() && m_themes.find(id) != m_themes.end(); +} + +bool ThemeManager::isValidIconTheme(const QString& id) +{ + return !id.isEmpty() && m_icons.find(id) != m_icons.end(); +} + +void ThemeManager::setIconTheme(const QString& name) { if (m_icons.find(name) == m_icons.end()) { themeWarningLog() << "Tried to set invalid icon theme:" << name; - return false; + return; } QIcon::setThemeName(name); - return true; } -void ThemeManager::applyCurrentlySelectedTheme(bool initial) -{ - auto settings = APPLICATION->settings(); - if (!setIconTheme(settings->get("IconTheme").toString())) { - APPLICATION->settings()->reset("IconTheme"); - setIconTheme(settings->get("IconTheme").toString()); - } - themeDebugLog() << "<> Icon theme set."; - if (!setApplicationTheme(settings->get("ApplicationTheme").toString(), initial)) { - APPLICATION->settings()->reset("ApplicationTheme"); - setApplicationTheme(settings->get("ApplicationTheme").toString(), initial); - } - themeDebugLog() << "<> Application theme set."; -} - -bool ThemeManager::setApplicationTheme(const QString& name, bool initial) +void ThemeManager::setApplicationTheme(const QString& name, bool initial) { auto systemPalette = qApp->palette(); auto themeIter = m_themes.find(name); @@ -203,13 +196,20 @@ bool ThemeManager::setApplicationTheme(const QString& name, bool initial) auto& theme = themeIter->second; themeDebugLog() << "applying theme" << theme->name(); theme->apply(initial); - return true; } else { themeWarningLog() << "Tried to set invalid theme:" << name; - return false; } } +void ThemeManager::applyCurrentlySelectedTheme(bool initial) +{ + auto settings = APPLICATION->settings(); + setIconTheme(settings->get("IconTheme").toString()); + themeDebugLog() << "<> Icon theme set."; + setApplicationTheme(settings->get("ApplicationTheme").toString(), initial); + themeDebugLog() << "<> Application theme set."; +} + QString ThemeManager::getCatImage(QString catName) { QDateTime now = QDateTime::currentDateTime(); diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 2b6c57e97..627fdc75e 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -35,13 +35,15 @@ inline auto themeWarningLog() class ThemeManager { public: - ThemeManager(MainWindow* mainWindow); + ThemeManager(); QList getValidApplicationThemes(); QList getValidIconThemes(); - bool setIconTheme(const QString& name); + bool isValidApplicationTheme(const QString& id); + bool isValidIconTheme(const QString& id); void applyCurrentlySelectedTheme(bool initial = false); - bool setApplicationTheme(const QString& name, bool initial = false); + void setIconTheme(const QString& name); + void setApplicationTheme(const QString& name, bool initial = false); /// /// Returns the cat based on selected cat and with events (Birthday, XMas, etc.) @@ -53,7 +55,6 @@ class ThemeManager { private: std::map> m_themes; std::map m_icons; - MainWindow* m_mainWindow; void initializeThemes(); QString addTheme(std::unique_ptr theme); From 842f08dcfc29d24cae13c25264e67375dd069e27 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Jul 2023 11:51:44 +0100 Subject: [PATCH 08/17] (UX) Add open folder button next to combo boxes Signed-off-by: TheKodeToad --- launcher/Application.cpp | 29 +----- launcher/Application.h | 10 +- launcher/DesktopServices.cpp | 2 +- launcher/ui/MainWindow.cpp | 8 +- launcher/ui/themes/ThemeManager.cpp | 50 +++++----- launcher/ui/themes/ThemeManager.h | 8 +- .../ui/widgets/ThemeCustomizationWidget.cpp | 35 ++++--- .../ui/widgets/ThemeCustomizationWidget.ui | 94 ++++++++++++++----- 8 files changed, 135 insertions(+), 101 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index ea706d6f4..40d506e35 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -900,7 +900,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) return; } - applyCurrentlySelectedTheme(true); + m_themeManager->applyCurrentlySelectedTheme(true); performMainStartupAction(); } @@ -942,7 +942,7 @@ bool Application::createSetupWizard() if (!validWidgets) settings()->set("ApplicationTheme", QString("system")); - applyCurrentlySelectedTheme(true); + m_themeManager->applyCurrentlySelectedTheme(true); m_setupWizard = new SetupWizard(nullptr); if (languageRequired) @@ -1167,31 +1167,6 @@ std::shared_ptr Application::javalist() return m_javalist; } -QList Application::getValidApplicationThemes() -{ - return m_themeManager->getValidApplicationThemes(); -} - -QList Application::getValidIconThemes() -{ - return m_themeManager->getValidIconThemes(); -} - -void Application::applyCurrentlySelectedTheme(bool initial) -{ - m_themeManager->applyCurrentlySelectedTheme(initial); -} - -void Application::setApplicationTheme(const QString& name) -{ - m_themeManager->setApplicationTheme(name); -} - -void Application::setIconTheme(const QString& name) -{ - m_themeManager->setIconTheme(name); -} - QIcon Application::getThemedIcon(const QString& name) { if(name == "logo") { diff --git a/launcher/Application.h b/launcher/Application.h index 0b953f0a5..b89960229 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -119,15 +119,7 @@ public: QIcon getThemedIcon(const QString& name); - void setIconTheme(const QString& name); - - void applyCurrentlySelectedTheme(bool initial = false); - - QList getValidApplicationThemes(); - - QList getValidIconThemes(); - - void setApplicationTheme(const QString& name); + ThemeManager* themeManager() { return m_themeManager.get(); } shared_qobject_ptr updater() { return m_updater; diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp index 2984a1b4f..4939161f9 100644 --- a/launcher/DesktopServices.cpp +++ b/launcher/DesktopServices.cpp @@ -109,7 +109,7 @@ bool openDirectory(const QString &path, bool ensureExists) qDebug() << "Opening directory" << path; QDir parentPath; QDir dir(path); - if (!dir.exists()) + if (ensureExists && !dir.exists()) { parentPath.mkpath(dir.absolutePath()); } diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 600d245d9..00bb296fe 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -627,7 +627,7 @@ void MainWindow::updateThemeMenu() themeMenu = new QMenu(this); } - auto themes = APPLICATION->getValidApplicationThemes(); + auto themes = APPLICATION->themeManager()->getValidApplicationThemes(); QActionGroup* themesGroup = new QActionGroup(this); @@ -641,7 +641,7 @@ void MainWindow::updateThemeMenu() themeAction->setActionGroup(themesGroup); connect(themeAction, &QAction::triggered, [theme]() { - APPLICATION->setApplicationTheme(theme->id()); + APPLICATION->themeManager()->setApplicationTheme(theme->id()); APPLICATION->settings()->set("ApplicationTheme", theme->id()); }); } @@ -1152,12 +1152,12 @@ void MainWindow::on_actionViewCentralModsFolder_triggered() void MainWindow::on_actionViewIconThemeFolder_triggered() { - DesktopServices::openDirectory("iconthemes"); + DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); } void MainWindow::on_actionViewWidgetThemeFolder_triggered() { - DesktopServices::openDirectory("themes"); + DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); } void MainWindow::refreshInstances() diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index a9fae5896..32585618f 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -73,13 +73,12 @@ void ThemeManager::initializeIcons() // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! // set icon theme search path! - QDir themeFolder("iconthemes"); - if (!themeFolder.mkpath(".")) + if (!m_iconThemeFolder.mkpath(".")) themeWarningLog() << "Couldn't create icon theme folder"; - themeDebugLog() << "Icon Theme Folder Path: " << themeFolder.absolutePath(); + themeDebugLog() << "Icon Theme Folder Path: " << m_iconThemeFolder.absolutePath(); auto searchPaths = QIcon::themeSearchPaths(); - searchPaths.append(themeFolder.path()); + searchPaths.append(m_iconThemeFolder.path()); QIcon::setThemeSearchPaths(searchPaths); themeDebugLog() << "<> Initializing Icon Themes"; @@ -95,7 +94,7 @@ void ThemeManager::initializeIcons() themeDebugLog() << "Loaded Built-In Icon Theme" << id; } - QDirIterator directoryIterator(themeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); + QDirIterator directoryIterator(m_iconThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); IconTheme theme(dir.dirName(), dir.path()); @@ -120,12 +119,11 @@ void ThemeManager::initializeWidgets() // TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in // dropdown?) - QDir themeFolder("themes"); - if (!themeFolder.mkpath(".")) + if (!m_applicationThemeFolder.mkpath(".")) themeWarningLog() << "Couldn't create theme folder"; - themeDebugLog() << "Theme Folder Path: " << themeFolder.absolutePath(); + themeDebugLog() << "Theme Folder Path: " << m_applicationThemeFolder.absolutePath(); - QDirIterator directoryIterator(themeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + QDirIterator directoryIterator(m_applicationThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); QFileInfo themeJson(dir.absoluteFilePath("theme.json")); @@ -148,16 +146,6 @@ void ThemeManager::initializeWidgets() themeDebugLog() << "<> Widget themes initialized."; } -QList ThemeManager::getValidApplicationThemes() -{ - QList ret; - ret.reserve(m_themes.size()); - for (auto&& [id, theme] : m_themes) { - ret.append(theme.get()); - } - return ret; -} - QList ThemeManager::getValidIconThemes() { QList ret; @@ -168,9 +156,14 @@ QList ThemeManager::getValidIconThemes() return ret; } -bool ThemeManager::isValidApplicationTheme(const QString& id) +QList ThemeManager::getValidApplicationThemes() { - return !id.isEmpty() && m_themes.find(id) != m_themes.end(); + QList ret; + ret.reserve(m_themes.size()); + for (auto&& [id, theme] : m_themes) { + ret.append(theme.get()); + } + return ret; } bool ThemeManager::isValidIconTheme(const QString& id) @@ -178,6 +171,21 @@ bool ThemeManager::isValidIconTheme(const QString& id) return !id.isEmpty() && m_icons.find(id) != m_icons.end(); } +bool ThemeManager::isValidApplicationTheme(const QString& id) +{ + return !id.isEmpty() && m_themes.find(id) != m_themes.end(); +} + +QDir ThemeManager::getIconThemesFolder() +{ + return m_iconThemeFolder; +} + +QDir ThemeManager::getApplicationThemesFolder() +{ + return m_applicationThemeFolder; +} + void ThemeManager::setIconTheme(const QString& name) { if (m_icons.find(name) == m_icons.end()) { diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 627fdc75e..5634a81a3 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -37,10 +37,12 @@ class ThemeManager { public: ThemeManager(); - QList getValidApplicationThemes(); QList getValidIconThemes(); - bool isValidApplicationTheme(const QString& id); + QList getValidApplicationThemes(); bool isValidIconTheme(const QString& id); + bool isValidApplicationTheme(const QString& id); + QDir getIconThemesFolder(); + QDir getApplicationThemesFolder(); void applyCurrentlySelectedTheme(bool initial = false); void setIconTheme(const QString& name); void setApplicationTheme(const QString& name, bool initial = false); @@ -55,6 +57,8 @@ class ThemeManager { private: std::map> m_themes; std::map m_icons; + QDir m_iconThemeFolder{ "iconthemes" }; + QDir m_applicationThemeFolder{ "themes" }; void initializeThemes(); QString addTheme(std::unique_ptr theme); diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index 455cbb7b6..106a9ca36 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp +++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp @@ -19,17 +19,22 @@ #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) +ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget) { ui->setupUi(this); loadSettings(); connect(ui->iconsComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme); - connect(ui->widgetStyleComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyWidgetTheme); + connect(ui->widgetStyleComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, + &ThemeCustomizationWidget::applyWidgetTheme); connect(ui->backgroundCatComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme); + + connect(ui->iconsFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); }); + connect(ui->widgetStyleFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); }); } ThemeCustomizationWidget::~ThemeCustomizationWidget() @@ -40,7 +45,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget() /// /// The layout was not quite right, so currently this just disables the UI elements, which should be hidden instead /// TODO FIXME -/// +/// /// Original Method One: /// ui->iconsComboBox->setVisible(features& ThemeFields::ICONS); /// ui->iconsLabel->setVisible(features& ThemeFields::ICONS); @@ -48,7 +53,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget() /// ui->widgetThemeLabel->setVisible(features& ThemeFields::WIDGETS); /// ui->backgroundCatComboBox->setVisible(features& ThemeFields::CAT); /// ui->backgroundCatLabel->setVisible(features& ThemeFields::CAT); -/// +/// /// original Method Two: /// if (!(features & ThemeFields::ICONS)) { /// ui->formLayout->setRowVisible(0, false); @@ -61,40 +66,44 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget() /// } /// /// -void ThemeCustomizationWidget::showFeatures(ThemeFields features) { +void ThemeCustomizationWidget::showFeatures(ThemeFields features) +{ ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS); ui->iconsLabel->setEnabled(features & ThemeFields::ICONS); ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS); - ui->widgetThemeLabel->setEnabled(features & ThemeFields::WIDGETS); + ui->widgetStyleLabel->setEnabled(features & ThemeFields::WIDGETS); ui->backgroundCatComboBox->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 originalIconTheme = settings->get("IconTheme").toString(); auto newIconTheme = ui->iconsComboBox->currentData().toString(); if (originalIconTheme != newIconTheme) { settings->set("IconTheme", newIconTheme); - APPLICATION->applyCurrentlySelectedTheme(); + APPLICATION->themeManager()->applyCurrentlySelectedTheme(); } emit currentIconThemeChanged(index); } -void ThemeCustomizationWidget::applyWidgetTheme(int index) { +void ThemeCustomizationWidget::applyWidgetTheme(int index) +{ auto settings = APPLICATION->settings(); auto originalAppTheme = settings->get("ApplicationTheme").toString(); auto newAppTheme = ui->widgetStyleComboBox->currentData().toString(); if (originalAppTheme != newAppTheme) { settings->set("ApplicationTheme", newAppTheme); - APPLICATION->applyCurrentlySelectedTheme(); + APPLICATION->themeManager()->applyCurrentlySelectedTheme(); } emit currentWidgetThemeChanged(index); } -void ThemeCustomizationWidget::applyCatTheme(int index) { +void ThemeCustomizationWidget::applyCatTheme(int index) +{ auto settings = APPLICATION->settings(); settings->set("BackgroundCat", m_catOptions[index].first); @@ -113,7 +122,7 @@ void ThemeCustomizationWidget::loadSettings() { auto currentIconTheme = settings->get("IconTheme").toString(); - auto iconThemes = APPLICATION->getValidIconThemes(); + auto iconThemes = APPLICATION->themeManager()->getValidIconThemes(); int idx = 0; for (auto iconTheme : iconThemes) { QIcon iconForComboBox = QIcon(iconTheme->path() + "/scalable/settings"); @@ -127,7 +136,7 @@ void ThemeCustomizationWidget::loadSettings() { auto currentTheme = settings->get("ApplicationTheme").toString(); - auto themes = APPLICATION->getValidApplicationThemes(); + auto themes = APPLICATION->themeManager()->getValidApplicationThemes(); int idx = 0; for (auto& theme : themes) { ui->widgetStyleComboBox->addItem(theme->name(), theme->id()); diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.ui b/launcher/ui/widgets/ThemeCustomizationWidget.ui index 6b2c87f97..700c530c7 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.ui +++ b/launcher/ui/widgets/ThemeCustomizationWidget.ui @@ -40,20 +40,40 @@ - - - - 0 - 0 - - - - Qt::StrongFocus - - + + + + + + 0 + 0 + + + + Qt::StrongFocus + + + + + + + View icon themes folder. + + + + + + + + + true + + + + - + &Widgets @@ -63,17 +83,37 @@ - - - - 0 - 0 - - - - Qt::StrongFocus - - + + + + + + 0 + 0 + + + + Qt::StrongFocus + + + + + + + View widget themes folder. + + + + + + + + + true + + + + @@ -89,7 +129,7 @@ - + @@ -127,6 +167,12 @@ + + iconsComboBox + widgetStyleComboBox + backgroundCatComboBox + catInfoLabel + From 39f7bea53e8b8b30c1bb8c3e97eb4f856b361880 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Jul 2023 14:13:29 +0100 Subject: [PATCH 09/17] Revert accidental change in MainWindow Signed-off-by: TheKodeToad --- launcher/ui/MainWindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index 1bc620277..a3f6dff7c 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -131,7 +131,7 @@ 0 0 800 - 31 + 20 From 5088d33fd2aec8fed9725f9dedb64e9629226c11 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Jul 2023 14:16:44 +0100 Subject: [PATCH 10/17] Finish things :P Signed-off-by: TheKodeToad --- launcher/ui/themes/IconTheme.cpp | 4 ++-- launcher/ui/themes/IconTheme.h | 2 +- launcher/ui/themes/ThemeManager.cpp | 11 +++++------ launcher/ui/widgets/ThemeCustomizationWidget.ui | 6 ------ 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/launcher/ui/themes/IconTheme.cpp b/launcher/ui/themes/IconTheme.cpp index cd1dfbaf5..4bd889854 100644 --- a/launcher/ui/themes/IconTheme.cpp +++ b/launcher/ui/themes/IconTheme.cpp @@ -25,7 +25,7 @@ IconTheme::IconTheme(const QString& id, const QString& path) : m_id(id), m_path( bool IconTheme::load() { - QString path = m_path + "/index.theme"; + const QString path = m_path + "/index.theme"; if (!QFile::exists(path)) return false; @@ -50,4 +50,4 @@ QString IconTheme::path() QString IconTheme::name() { return m_name; -} \ No newline at end of file +} diff --git a/launcher/ui/themes/IconTheme.h b/launcher/ui/themes/IconTheme.h index 458ea12c1..4e466c6ae 100644 --- a/launcher/ui/themes/IconTheme.h +++ b/launcher/ui/themes/IconTheme.h @@ -34,4 +34,4 @@ class IconTheme { QString m_id; QString m_path; QString m_name; -}; \ No newline at end of file +}; diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 32585618f..c929549e3 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -72,17 +72,12 @@ void ThemeManager::initializeIcons() { // TODO: icon themes and instance icons do not mesh well together. Rearrange and fix discrepancies! // set icon theme search path! - - if (!m_iconThemeFolder.mkpath(".")) - themeWarningLog() << "Couldn't create icon theme folder"; - themeDebugLog() << "Icon Theme Folder Path: " << m_iconThemeFolder.absolutePath(); + themeDebugLog() << "<> Initializing Icon Themes"; auto searchPaths = QIcon::themeSearchPaths(); searchPaths.append(m_iconThemeFolder.path()); QIcon::setThemeSearchPaths(searchPaths); - themeDebugLog() << "<> Initializing Icon Themes"; - for (const QString& id : builtinIcons) { IconTheme theme(id, QString(":/icons/%1").arg(id)); if (!theme.load()) { @@ -94,6 +89,10 @@ void ThemeManager::initializeIcons() themeDebugLog() << "Loaded Built-In Icon Theme" << id; } + if (!m_iconThemeFolder.mkpath(".")) + themeWarningLog() << "Couldn't create icon theme folder"; + themeDebugLog() << "Icon Theme Folder Path: " << m_iconThemeFolder.absolutePath(); + QDirIterator directoryIterator(m_iconThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.ui b/launcher/ui/widgets/ThemeCustomizationWidget.ui index 700c530c7..266b1dd62 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.ui +++ b/launcher/ui/widgets/ThemeCustomizationWidget.ui @@ -167,12 +167,6 @@ - - iconsComboBox - widgetStyleComboBox - backgroundCatComboBox - catInfoLabel - From 1a7c5693cc9d21cf974ad56e55a3ca07a22c8477 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 21 Jul 2023 13:01:01 +0100 Subject: [PATCH 11/17] Remove redundant methods Signed-off-by: TheKodeToad --- launcher/Application.cpp | 10 ---------- launcher/Application.h | 4 ---- launcher/ui/instanceview/InstanceView.cpp | 4 ++-- launcher/ui/setupwizard/ThemeWizardPage.cpp | 2 +- launcher/ui/widgets/ThemeCustomizationWidget.cpp | 2 +- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index e6a8562c2..acac2da26 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -1175,16 +1175,6 @@ QIcon Application::getThemedIcon(const QString& name) return QIcon::fromTheme(name); } -QList Application::getValidCatPacks() -{ - return m_themeManager->getValidCatPacks(); -} - -QString Application::getCatPack(QString catName) -{ - return m_themeManager->getCatPack(catName); -} - bool Application::openJsonEditor(const QString& filename) { const QString file = QDir::current().absoluteFilePath(filename); diff --git a/launcher/Application.h b/launcher/Application.h index 203fd16ee..1c221cece 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -122,10 +122,6 @@ public: ThemeManager* themeManager() { return m_themeManager.get(); } - QList getValidCatPacks(); - - QString getCatPack(QString catName = ""); - shared_qobject_ptr updater() { return m_updater; } void triggerUpdateCheck(); diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 05f0004d1..155550e12 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -52,7 +52,7 @@ #include #include - +#include "ui/themes/ThemeManager.h" template bool listsIntersect(const QList &l1, const QList t2) { @@ -503,7 +503,7 @@ void InstanceView::setPaintCat(bool visible) { m_catVisible = visible; if (visible) - m_catPixmap.load(APPLICATION->getCatPack()); + m_catPixmap.load(APPLICATION->themeManager()->getCatPack()); else m_catPixmap = QPixmap(); } diff --git a/launcher/ui/setupwizard/ThemeWizardPage.cpp b/launcher/ui/setupwizard/ThemeWizardPage.cpp index 1c3369219..fe11ed9ae 100644 --- a/launcher/ui/setupwizard/ThemeWizardPage.cpp +++ b/launcher/ui/setupwizard/ThemeWizardPage.cpp @@ -61,7 +61,7 @@ void ThemeWizardPage::updateIcons() void ThemeWizardPage::updateCat() { qDebug() << "Setting Cat"; - ui->catImagePreviewButton->setIcon(QIcon(QString(R"(%1)").arg(APPLICATION->getCatPack()))); + ui->catImagePreviewButton->setIcon(QIcon(QString(R"(%1)").arg(APPLICATION->themeManager()->getCatPack()))); } void ThemeWizardPage::retranslate() diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index 8ccb5dcce..b9294908d 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp +++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp @@ -152,7 +152,7 @@ void ThemeCustomizationWidget::loadSettings() } auto cat = settings->get("BackgroundCat").toString(); - for (auto& catFromList : APPLICATION->getValidCatPacks()) { + 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()) { From 516ddb22ae2c05e35401b0a5a6d81d93fc3d5ea1 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 21 Jul 2023 17:58:48 +0100 Subject: [PATCH 12/17] More catpack changes :3 This is just embarrasing Signed-off-by: TheKodeToad --- launcher/ui/themes/ThemeManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index fc7c3649b..46fe0b25d 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -62,7 +62,10 @@ ITheme* ThemeManager::getTheme(QString themeId) QString ThemeManager::addIconTheme(IconTheme theme) { QString id = theme.id(); - m_icons.emplace(id, std::move(theme)); + if (m_icons.find(id) == m_icons.end()) + m_icons.emplace(id, std::move(theme)); + else + themeWarningLog() << "IconTheme(" << id << ") not added to prevent id duplication"; return id; } @@ -129,7 +132,7 @@ void ThemeManager::initializeWidgets() themeWarningLog() << "Couldn't create theme folder"; themeDebugLog() << "Theme Folder Path: " << m_applicationThemeFolder.absolutePath(); - QDirIterator directoryIterator(m_applicationThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + QDirIterator directoryIterator(m_applicationThemeFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); QFileInfo themeJson(dir.absoluteFilePath("theme.json")); From 816acc9c769eee50a4b738761d0b07995dc1eef6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 26 Jul 2023 17:17:02 +0100 Subject: [PATCH 13/17] Open catpak folder action Signed-off-by: TheKodeToad --- launcher/ui/MainWindow.cpp | 5 +++++ launcher/ui/MainWindow.h | 1 + launcher/ui/MainWindow.ui | 17 ++++++++++++++--- launcher/ui/themes/ThemeManager.cpp | 15 ++++++++++----- launcher/ui/themes/ThemeManager.h | 2 ++ .../ui/widgets/ThemeCustomizationWidget.cpp | 1 + launcher/ui/widgets/ThemeCustomizationWidget.ui | 12 +++++++----- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 00bb296fe..e4a699da6 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1160,6 +1160,11 @@ void MainWindow::on_actionViewWidgetThemeFolder_triggered() DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); } +void MainWindow::on_actionViewCatPackFolder_triggered() +{ + DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path()); +} + void MainWindow::refreshInstances() { APPLICATION->instances()->loadList(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 8756c0784..ffc7154a3 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -118,6 +118,7 @@ private slots: void on_actionViewIconThemeFolder_triggered(); void on_actionViewWidgetThemeFolder_triggered(); + void on_actionViewCatPackFolder_triggered(); void on_actionViewSelectedInstFolder_triggered(); diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index a3f6dff7c..ad0a0808a 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -131,7 +131,7 @@ 0 0 800 - 20 + 30 @@ -193,6 +193,7 @@ + @@ -729,7 +730,8 @@ - + + .. View &Widget Themes Folder @@ -740,7 +742,8 @@ - + + .. View I&con Theme Folder @@ -749,6 +752,14 @@ View Icon Theme Folder + + + + + + View Cat Packs Folder + + diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index 46fe0b25d..bce13b459 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -205,6 +205,11 @@ QDir ThemeManager::getApplicationThemesFolder() return m_applicationThemeFolder; } +QDir ThemeManager::getCatPacksFolder() +{ + return m_catPacksFolder; +} + void ThemeManager::setIconTheme(const QString& name) { if (m_icons.find(name) == m_icons.end()) { @@ -270,9 +275,9 @@ void ThemeManager::initializeCatPacks() for (auto [id, name] : defaultCats) { addCatPack(std::unique_ptr(new BasicCatPack(id, name))); } - QDir catpacksDir("catpacks"); - QString catpacksFolder = catpacksDir.absoluteFilePath(""); - themeDebugLog() << "CatPacks Folder Path:" << catpacksFolder; + if (!m_catPacksFolder.mkpath(".")) + themeWarningLog() << "Couldn't create theme folder"; + themeDebugLog() << "CatPacks Folder Path:" << m_catPacksFolder.absolutePath(); QStringList supportedImageFormats; for (auto format : QImageReader::supportedImageFormats()) { @@ -289,9 +294,9 @@ void ThemeManager::initializeCatPacks() } }; - loadFiles(catpacksDir); + loadFiles(m_catPacksFolder); - QDirIterator directoryIterator(catpacksFolder, QDir::Dirs | QDir::NoDotAndDotDot); + QDirIterator directoryIterator(m_catPacksFolder.path(), QDir::Dirs | QDir::NoDotAndDotDot); while (directoryIterator.hasNext()) { QDir dir(directoryIterator.next()); QFileInfo manifest(dir.absoluteFilePath("catpack.json")); diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 1eb83ce1e..b5c66677b 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -44,6 +44,7 @@ class ThemeManager { bool isValidApplicationTheme(const QString& id); QDir getIconThemesFolder(); QDir getApplicationThemesFolder(); + QDir getCatPacksFolder(); void applyCurrentlySelectedTheme(bool initial = false); void setIconTheme(const QString& name); void setApplicationTheme(const QString& name, bool initial = false); @@ -59,6 +60,7 @@ class ThemeManager { std::map m_icons; QDir m_iconThemeFolder{ "iconthemes" }; QDir m_applicationThemeFolder{ "themes" }; + QDir m_catPacksFolder{ "catpacks" }; std::map> m_catPacks; void initializeThemes(); diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index b9294908d..c999ac92c 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp +++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp @@ -35,6 +35,7 @@ ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(pa connect(ui->iconsFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); }); connect(ui->widgetStyleFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); }); + connect(ui->catPackFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path()); }); } ThemeCustomizationWidget::~ThemeCustomizationWidget() diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.ui b/launcher/ui/widgets/ThemeCustomizationWidget.ui index 266b1dd62..4503181c2 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.ui +++ b/launcher/ui/widgets/ThemeCustomizationWidget.ui @@ -63,7 +63,8 @@ - + + .. true @@ -106,7 +107,8 @@ - + + .. true @@ -147,15 +149,15 @@ - + - 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. + View cat packs folder. - + .. From 719d87de3bb6f65bc63ad518126074fd9f5f6283 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 26 Jul 2023 17:21:12 +0100 Subject: [PATCH 14/17] Update MainWindow.ui Signed-off-by: TheKodeToad --- launcher/ui/MainWindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index ad0a0808a..6ef32099f 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -131,7 +131,7 @@ 0 0 800 - 30 + 20 From e079cbb055556fdd6bd379e8f8fc426915fa25c0 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 7 Aug 2023 12:10:21 +0100 Subject: [PATCH 15/17] Fix actions Signed-off-by: TheKodeToad --- launcher/Application.cpp | 3 +-- launcher/ui/MainWindow.h | 5 +---- launcher/ui/instanceview/InstanceView.cpp | 2 +- launcher/ui/widgets/ThemeCustomizationWidget.cpp | 9 ++++++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 840bd9a36..03ce2f290 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -895,8 +895,7 @@ bool Application::createSetupWizard() bool themeInterventionRequired = !validWidgets || !validIcons; bool wizardRequired = javaRequired || languageRequired || pasteInterventionRequired || themeInterventionRequired; - if(wizardRequired) - { + if (wizardRequired) { // set default theme after going into theme wizard if (!validIcons) settings()->set("IconTheme", QString("pe_colored")); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index be9c4994b..dd35d5d00 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -155,10 +155,7 @@ class MainWindow : public QMainWindow { void deleteGroup(); void undoTrashInstance(); - inline void on_actionExportInstance_triggered() - { - on_actionExportInstanceZip_triggered(); - } + inline void on_actionExportInstance_triggered() { on_actionExportInstanceZip_triggered(); } void on_actionExportInstanceZip_triggered(); void on_actionExportInstanceMrPack_triggered(); void on_actionExportInstanceFlamePack_triggered(); diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 4569c42ea..7afa03d49 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -47,8 +47,8 @@ #include #include -#include #include "VisualGroup.h" +#include "ui/themes/ThemeManager.h" #include #include diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index c999ac92c..0de97441f 100644 --- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp +++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp @@ -33,9 +33,12 @@ ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(pa &ThemeCustomizationWidget::applyWidgetTheme); connect(ui->backgroundCatComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme); - connect(ui->iconsFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); }); - connect(ui->widgetStyleFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); }); - connect(ui->catPackFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path()); }); + connect(ui->iconsFolder, &QPushButton::clicked, this, + [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); }); + connect(ui->widgetStyleFolder, &QPushButton::clicked, this, + [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); }); + connect(ui->catPackFolder, &QPushButton::clicked, this, + [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getCatPacksFolder().path()); }); } ThemeCustomizationWidget::~ThemeCustomizationWidget() From 3c209ba502d946f8302192287c9e1c18bf5fdd7c Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 12 Aug 2023 19:04:34 +0100 Subject: [PATCH 16/17] `theme` -> `catpacks` Co-authored-by: Alexandru Ionut Tripon Signed-off-by: TheKodeToad --- launcher/ui/themes/ThemeManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index bce13b459..0bcac100c 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -276,7 +276,7 @@ void ThemeManager::initializeCatPacks() addCatPack(std::unique_ptr(new BasicCatPack(id, name))); } if (!m_catPacksFolder.mkpath(".")) - themeWarningLog() << "Couldn't create theme folder"; + themeWarningLog() << "Couldn't create catpacks folder"; themeDebugLog() << "CatPacks Folder Path:" << m_catPacksFolder.absolutePath(); QStringList supportedImageFormats; From 6ce7e426d2e3bbca74719da073eb46d05b001439 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 15 Aug 2023 10:38:04 +0200 Subject: [PATCH 17/17] chore: reformat Signed-off-by: Sefa Eyeoglu --- launcher/ui/MainWindow.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index dd35d5d00..be9c4994b 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -155,7 +155,10 @@ class MainWindow : public QMainWindow { void deleteGroup(); void undoTrashInstance(); - inline void on_actionExportInstance_triggered() { on_actionExportInstanceZip_triggered(); } + inline void on_actionExportInstance_triggered() + { + on_actionExportInstanceZip_triggered(); + } void on_actionExportInstanceZip_triggered(); void on_actionExportInstanceMrPack_triggered(); void on_actionExportInstanceFlamePack_triggered();