From 97662f5c8ecdf32403939e427c74310f9175fb9e Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 18 Jul 2023 22:50:43 +0100 Subject: Multiple icon themes! Signed-off-by: TheKodeToad --- launcher/ui/widgets/ThemeCustomizationWidget.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'launcher/ui/widgets/ThemeCustomizationWidget.cpp') diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp index 3bfcd821..455cbb7b 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++; } } -- cgit From 842f08dcfc29d24cae13c25264e67375dd069e27 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 20 Jul 2023 11:51:44 +0100 Subject: (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 | 44 ++++++----- launcher/ui/themes/ThemeManager.h | 8 +- launcher/ui/widgets/ThemeCustomizationWidget.cpp | 35 +++++---- launcher/ui/widgets/ThemeCustomizationWidget.ui | 94 ++++++++++++++++++------ 8 files changed, 132 insertions(+), 98 deletions(-) (limited to 'launcher/ui/widgets/ThemeCustomizationWidget.cpp') diff --git a/launcher/Application.cpp b/launcher/Application.cpp index ea706d6f..40d506e3 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 0b953f0a..b8996022 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 2984a1b4..4939161f 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 600d245d..00bb296f 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 a9fae589..32585618 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,6 +146,16 @@ void ThemeManager::initializeWidgets() themeDebugLog() << "<> Widget themes initialized."; } +QList ThemeManager::getValidIconThemes() +{ + QList ret; + ret.reserve(m_icons.size()); + for (auto&& [id, theme] : m_icons) { + ret.append(&theme); + } + return ret; +} + QList ThemeManager::getValidApplicationThemes() { QList ret; @@ -158,14 +166,9 @@ QList ThemeManager::getValidApplicationThemes() return ret; } -QList ThemeManager::getValidIconThemes() +bool ThemeManager::isValidIconTheme(const QString& id) { - QList ret; - ret.reserve(m_icons.size()); - for (auto&& [id, theme] : m_icons) { - ret.append(&theme); - } - return ret; + return !id.isEmpty() && m_icons.find(id) != m_icons.end(); } bool ThemeManager::isValidApplicationTheme(const QString& id) @@ -173,9 +176,14 @@ bool ThemeManager::isValidApplicationTheme(const QString& id) return !id.isEmpty() && m_themes.find(id) != m_themes.end(); } -bool ThemeManager::isValidIconTheme(const QString& id) +QDir ThemeManager::getIconThemesFolder() { - return !id.isEmpty() && m_icons.find(id) != m_icons.end(); + return m_iconThemeFolder; +} + +QDir ThemeManager::getApplicationThemesFolder() +{ + return m_applicationThemeFolder; } void ThemeManager::setIconTheme(const QString& name) diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index 627fdc75..5634a81a 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 455cbb7b..106a9ca3 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 6b2c87f9..700c530c 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 + -- cgit From 1a7c5693cc9d21cf974ad56e55a3ca07a22c8477 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 21 Jul 2023 13:01:01 +0100 Subject: 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(-) (limited to 'launcher/ui/widgets/ThemeCustomizationWidget.cpp') diff --git a/launcher/Application.cpp b/launcher/Application.cpp index e6a8562c..acac2da2 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 203fd16e..1c221cec 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 05f0004d..155550e1 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 1c336921..fe11ed9a 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 8ccb5dcc..b9294908 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()) { -- cgit From 816acc9c769eee50a4b738761d0b07995dc1eef6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 26 Jul 2023 17:17:02 +0100 Subject: 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 ++ launcher/ui/widgets/ThemeCustomizationWidget.cpp | 1 + launcher/ui/widgets/ThemeCustomizationWidget.ui | 12 +++++++----- 7 files changed, 40 insertions(+), 13 deletions(-) (limited to 'launcher/ui/widgets/ThemeCustomizationWidget.cpp') diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 00bb296f..e4a699da 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 8756c078..ffc7154a 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 a3f6dff7..ad0a0808 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 46fe0b25..bce13b45 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 1eb83ce1..b5c66677 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 b9294908..c999ac92 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 266b1dd6..4503181c 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. - + .. -- cgit From e079cbb055556fdd6bd379e8f8fc426915fa25c0 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 7 Aug 2023 12:10:21 +0100 Subject: 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(-) (limited to 'launcher/ui/widgets/ThemeCustomizationWidget.cpp') diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 840bd9a3..03ce2f29 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 be9c4994..dd35d5d0 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 4569c42e..7afa03d4 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 c999ac92..0de97441 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() -- cgit