From db9cb549a8724ca64479d4fbca5004f2d7dbe417 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Sun, 21 Mar 2021 15:50:44 +0800 Subject: [PATCH] Desktop background extension --- settings-daemon/theme/org.cutefish.Theme.xml | 12 ++++++++ settings-daemon/theme/thememanager.cpp | 30 ++++++++++++++++++++ settings-daemon/theme/thememanager.h | 13 +++++++++ 3 files changed, 55 insertions(+) diff --git a/settings-daemon/theme/org.cutefish.Theme.xml b/settings-daemon/theme/org.cutefish.Theme.xml index 1c7f8fd..ef5b89d 100644 --- a/settings-daemon/theme/org.cutefish.Theme.xml +++ b/settings-daemon/theme/org.cutefish.Theme.xml @@ -25,6 +25,12 @@ + + + + + + @@ -34,6 +40,8 @@ + + @@ -46,5 +54,9 @@ + + + + diff --git a/settings-daemon/theme/thememanager.cpp b/settings-daemon/theme/thememanager.cpp index cc2ad2e..300ac62 100644 --- a/settings-daemon/theme/thememanager.cpp +++ b/settings-daemon/theme/thememanager.cpp @@ -59,6 +59,8 @@ ThemeManager::ThemeManager(QObject *parent) m_darkModeDimsWallpaer = m_settings->value("DarkModeDimsWallpaer", false).toBool(); m_wallpaperPath = m_settings->value("Wallpaper", "/usr/share/wallpapers/cutefishos/unsplash-0.jpg").toString(); m_accentColor = m_settings->value("AccentColor", 0).toInt(); + m_backgroundType = m_settings->value("BackgroundType", 0).toInt(); + m_backgroundColor = m_settings->value("BackgroundColor", "#2B8ADA").toString(); // Start the DE and need to update the settings again. initGtkConfig(); @@ -170,6 +172,34 @@ void ThemeManager::setWallpaper(const QString &path) } } +int ThemeManager::backgroundType() +{ + return m_backgroundType; +} + +void ThemeManager::setBackgroundType(int type) +{ + if (m_backgroundType != type) { + m_backgroundType = type; + m_settings->setValue("BackgroundType", m_backgroundType); + emit backgroundTypeChanged(); + } +} + +QString ThemeManager::backgroundColor() +{ + return m_backgroundColor; +} + +void ThemeManager::setBackgroundColor(QString color) +{ + if (m_backgroundColor != color) { + m_backgroundColor = color; + m_settings->setValue("BackgroundColor", m_backgroundColor); + emit backgroundColorChanged(); + } +} + void ThemeManager::initGtkConfig() { QSettings settings(gtk3SettingsIniPath(), QSettings::IniFormat); diff --git a/settings-daemon/theme/thememanager.h b/settings-daemon/theme/thememanager.h index 5acb89f..0b6e473 100644 --- a/settings-daemon/theme/thememanager.h +++ b/settings-daemon/theme/thememanager.h @@ -34,6 +34,8 @@ class ThemeManager : public QObject Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio) Q_PROPERTY(QString wallpaper READ wallpaper WRITE setWallpaper NOTIFY wallpaperChanged) Q_PROPERTY(int accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged) + Q_PROPERTY(int backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged) + Q_PROPERTY(QString backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) public: ThemeManager(QObject *parent = nullptr); @@ -59,6 +61,12 @@ public: QString wallpaper(); void setWallpaper(const QString &path); + int backgroundType(); + void setBackgroundType(int type); + + QString backgroundColor(); + void setBackgroundColor(QString color); + int accentColor(); void setAccentColor(int accentColor); @@ -69,15 +77,20 @@ signals: void wallpaperChanged(QString path); void darkModeDimsWallpaerChanged(); void accentColorChanged(int accentColor); + void backgroundTypeChanged(); + void backgroundColorChanged(); private: void updateGtkFont(); void updateGtkDarkTheme(); QSettings *m_settings; + bool m_isDarkMode; bool m_darkModeDimsWallpaer; QString m_wallpaperPath; + int m_backgroundType; + QString m_backgroundColor; int m_accentColor; };