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/ui/themes/ThemeManager.cpp | 44 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'launcher/ui/themes/ThemeManager.cpp') 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) -- cgit