diff options
author | Tayou <tayou@gmx.net> | 2023-01-09 16:58:27 +0100 |
---|---|---|
committer | Tayou <tayou@gmx.net> | 2023-01-10 16:06:42 +0100 |
commit | 6daa45783894fc7517917d6f6df0deaac1a41ba3 (patch) | |
tree | 6e4386f9cd76f3437d16d88e4ff2b6ac0a166802 /launcher/ui/themes | |
parent | 49d317b19aa61fed056e0f14c12eb1997f68982d (diff) | |
download | PrismLauncher-6daa45783894fc7517917d6f6df0deaac1a41ba3.tar.gz PrismLauncher-6daa45783894fc7517917d6f6df0deaac1a41ba3.tar.bz2 PrismLauncher-6daa45783894fc7517917d6f6df0deaac1a41ba3.zip |
Implement Suggestions from flow & Scrumplex
Signed-off-by: Tayou <tayou@gmx.net>
Diffstat (limited to 'launcher/ui/themes')
-rw-r--r-- | launcher/ui/themes/ThemeManager.cpp | 35 | ||||
-rw-r--r-- | launcher/ui/themes/ThemeManager.h | 9 |
2 files changed, 31 insertions, 13 deletions
diff --git a/launcher/ui/themes/ThemeManager.cpp b/launcher/ui/themes/ThemeManager.cpp index a6cebc6f..44c13f40 100644 --- a/launcher/ui/themes/ThemeManager.cpp +++ b/launcher/ui/themes/ThemeManager.cpp @@ -31,13 +31,13 @@ ThemeManager::ThemeManager(MainWindow* mainWindow)
{
m_mainWindow = mainWindow;
- InitializeThemes();
+ initializeThemes();
}
/// @brief Adds the Theme to the list of themes
/// @param theme The Theme to add
/// @return Theme ID
-QString ThemeManager::AddTheme(std::unique_ptr<ITheme> theme)
+QString ThemeManager::addTheme(std::unique_ptr<ITheme> theme)
{
QString id = theme->id();
m_themes.emplace(id, std::move(theme));
@@ -47,12 +47,12 @@ QString ThemeManager::AddTheme(std::unique_ptr<ITheme> theme) /// @brief Gets the Theme from the List via ID
/// @param themeId Theme ID of theme to fetch
/// @return Theme at themeId
-ITheme* ThemeManager::GetTheme(QString themeId)
+ITheme* ThemeManager::getTheme(QString themeId)
{
return m_themes[themeId].get();
}
-void ThemeManager::InitializeThemes()
+void ThemeManager::initializeThemes()
{
// Icon themes
{
@@ -67,10 +67,10 @@ void ThemeManager::InitializeThemes() // Initialize widget themes
{
themeDebugLog() << "<> Initializing Widget Themes";
- themeDebugLog() << "Loading Built-in Theme:" << AddTheme(std::make_unique<SystemTheme>());
- auto darkThemeId = AddTheme(std::make_unique<DarkTheme>());
+ themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<SystemTheme>());
+ auto darkThemeId = addTheme(std::make_unique<DarkTheme>());
themeDebugLog() << "Loading Built-in Theme:" << darkThemeId;
- themeDebugLog() << "Loading Built-in Theme:" << AddTheme(std::make_unique<BrightTheme>());
+ themeDebugLog() << "Loading Built-in Theme:" << addTheme(std::make_unique<BrightTheme>());
// TODO: need some way to differentiate same name themes in different subdirectories (maybe smaller grey text next to theme name in
// dropdown?)
@@ -84,7 +84,7 @@ void ThemeManager::InitializeThemes() if (themeJson.exists()) {
// Load "theme.json" based themes
themeDebugLog() << "Loading JSON Theme from:" << themeJson.absoluteFilePath();
- AddTheme(std::make_unique<CustomTheme>(GetTheme(darkThemeId), themeJson, true));
+ addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), themeJson, true));
} else {
// Load pure QSS Themes
QDirIterator stylesheetFileIterator(dir.absoluteFilePath(""), { "*.qss", "*.css" }, QDir::Files);
@@ -92,7 +92,7 @@ void ThemeManager::InitializeThemes() QFile customThemeFile(stylesheetFileIterator.next());
QFileInfo customThemeFileInfo(customThemeFile);
themeDebugLog() << "Loading QSS Theme from:" << customThemeFileInfo.absoluteFilePath();
- AddTheme(std::make_unique<CustomTheme>(GetTheme(darkThemeId), customThemeFileInfo, false));
+ addTheme(std::make_unique<CustomTheme>(getTheme(darkThemeId), customThemeFileInfo, false));
}
}
}
@@ -136,3 +136,20 @@ void ThemeManager::setApplicationTheme(const QString& name) themeWarningLog() << "Tried to set invalid theme:" << name;
}
}
+
+QString ThemeManager::getCatImage(QString catName)
+{
+ QDateTime now = QDateTime::currentDateTime();
+ QDateTime birthday(QDate(now.date().year(), 11, 30), QTime(0, 0));
+ QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
+ QDateTime halloween(QDate(now.date().year(), 10, 31), QTime(0, 0));
+ QString cat = catName == "" ? APPLICATION->settings()->get("BackgroundCat").toString() : catName;
+ if (std::abs(now.daysTo(xmas)) <= 4) {
+ cat += "-xmas";
+ } else if (std::abs(now.daysTo(halloween)) <= 4) {
+ cat += "-spooky";
+ } else if (std::abs(now.daysTo(birthday)) <= 12) {
+ cat += "-bday";
+ }
+ return cat;
+}
\ No newline at end of file diff --git a/launcher/ui/themes/ThemeManager.h b/launcher/ui/themes/ThemeManager.h index bb10cd48..4f36bffa 100644 --- a/launcher/ui/themes/ThemeManager.h +++ b/launcher/ui/themes/ThemeManager.h @@ -40,12 +40,13 @@ class ThemeManager { void applyCurrentlySelectedTheme();
void setApplicationTheme(const QString& name);
+ static QString getCatImage(QString catName = "");
+
private:
std::map<QString, std::unique_ptr<ITheme>> m_themes;
MainWindow* m_mainWindow;
- bool m_firstThemeInitialized;
- void InitializeThemes();
- QString AddTheme(std::unique_ptr<ITheme> theme);
- ITheme* GetTheme(QString themeId);
+ void initializeThemes();
+ QString addTheme(std::unique_ptr<ITheme> theme);
+ ITheme* getTheme(QString themeId);
};
|