aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/themes/ThemeManager.cpp
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2023-07-20 11:51:44 +0100
committerTheKodeToad <TheKodeToad@proton.me>2023-07-20 11:54:15 +0100
commit842f08dcfc29d24cae13c25264e67375dd069e27 (patch)
tree6ddab902a2a2a994b2518744074726c220f695d2 /launcher/ui/themes/ThemeManager.cpp
parent960093700a9daa4e2115d4663ab486a5dd1a4757 (diff)
downloadPrismLauncher-842f08dcfc29d24cae13c25264e67375dd069e27.tar.gz
PrismLauncher-842f08dcfc29d24cae13c25264e67375dd069e27.tar.bz2
PrismLauncher-842f08dcfc29d24cae13c25264e67375dd069e27.zip
(UX) Add open folder button next to combo boxes
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/ui/themes/ThemeManager.cpp')
-rw-r--r--launcher/ui/themes/ThemeManager.cpp44
1 files changed, 26 insertions, 18 deletions
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<IconTheme*> ThemeManager::getValidIconThemes()
+{
+ QList<IconTheme*> ret;
+ ret.reserve(m_icons.size());
+ for (auto&& [id, theme] : m_icons) {
+ ret.append(&theme);
+ }
+ return ret;
+}
+
QList<ITheme*> ThemeManager::getValidApplicationThemes()
{
QList<ITheme*> ret;
@@ -158,14 +166,9 @@ QList<ITheme*> ThemeManager::getValidApplicationThemes()
return ret;
}
-QList<IconTheme*> ThemeManager::getValidIconThemes()
+bool ThemeManager::isValidIconTheme(const QString& id)
{
- QList<IconTheme*> 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)