From 54d393632d5c964f0c30ca9bc816853b92552c9c Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 19 Jul 2023 16:29:52 +0100 Subject: Automatically create theme folders, and add an action to open them Signed-off-by: TheKodeToad --- launcher/ui/MainWindow.cpp | 23 ++++++++++++------ launcher/ui/MainWindow.h | 8 ++++--- launcher/ui/MainWindow.ui | 48 ++++++++++++++++++++++++++++++------- launcher/ui/themes/ThemeManager.cpp | 18 +++++++++----- 4 files changed, 72 insertions(+), 25 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index da572fc3..600d245d 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1134,26 +1134,35 @@ 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::refreshInstances() +void MainWindow::on_actionViewIconThemeFolder_triggered() { - APPLICATION->instances()->loadList(); + DesktopServices::openDirectory("iconthemes"); } -void MainWindow::on_actionViewCentralModsFolder_triggered() +void MainWindow::on_actionViewWidgetThemeFolder_triggered() { - DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true); + DesktopServices::openDirectory("themes"); +} + +void MainWindow::refreshInstances() +{ + APPLICATION->instances()->loadList(); } void MainWindow::checkForUpdates() diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 27c2756f..8756c078 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -111,16 +111,18 @@ private slots: void on_actionChangeInstIcon_triggered(); + void on_actionViewLauncherRootFolder_triggered(); + void on_actionViewInstanceFolder_triggered(); + void on_actionViewCentralModsFolder_triggered(); - void on_actionViewLauncherRootFolder_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 e4421d40..1bc62027 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 8c9a6a58..525201be 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")); -- cgit