From d5b02178fd42304d015432755b72ac497e15f296 Mon Sep 17 00:00:00 2001 From: reionwong Date: Thu, 7 Oct 2021 05:29:45 +0800 Subject: [PATCH] SettingsDaemon: Add icon theme interface --- session/processmanager.cpp | 3 ++ settings-daemon/theme/com.cutefish.Theme.xml | 5 +++ settings-daemon/theme/thememanager.cpp | 33 ++++++++++++++++++-- settings-daemon/theme/thememanager.h | 8 +++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/session/processmanager.cpp b/session/processmanager.cpp index 3bf1b55..65b8db4 100644 --- a/session/processmanager.cpp +++ b/session/processmanager.cpp @@ -126,8 +126,11 @@ void ProcessManager::startDesktopProcess() if (QFile("/usr/bin/cutefish-welcome").exists() && !QFile("/run/live/medium/live/filesystem.squashfs").exists()) { QSettings settings("cutefishos", "login"); + if (!settings.value("Finished", false).toBool()) { list << qMakePair(QString("/usr/bin/cutefish-welcome"), QStringList()); + } else { + list << qMakePair(QString("/usr/bin/cutefish-welcome"), QStringList() << "-d"); } } diff --git a/settings-daemon/theme/com.cutefish.Theme.xml b/settings-daemon/theme/com.cutefish.Theme.xml index bc77c8c..8182da3 100644 --- a/settings-daemon/theme/com.cutefish.Theme.xml +++ b/settings-daemon/theme/com.cutefish.Theme.xml @@ -37,6 +37,9 @@ + + + @@ -52,6 +55,7 @@ + @@ -68,5 +72,6 @@ + diff --git a/settings-daemon/theme/thememanager.cpp b/settings-daemon/theme/thememanager.cpp index 786a667..a8a20d0 100644 --- a/settings-daemon/theme/thememanager.cpp +++ b/settings-daemon/theme/thememanager.cpp @@ -66,6 +66,7 @@ ThemeManager::ThemeManager(QObject *parent) m_backgroundColor = m_settings->value("BackgroundColor", "#2B8ADA").toString(); m_cursorTheme = m_settings->value("CursorTheme", "default").toString(); m_cursorSize = m_settings->value("CursorSize", 24).toInt(); + m_iconTheme = m_settings->value("IconTheme", "Crule").toString(); // Start the DE and need to update the settings again. initGtkConfig(); @@ -264,12 +265,13 @@ void ThemeManager::initGtkConfig() settings.clear(); settings.setIniCodec("UTF-8"); settings.beginGroup("Settings"); + // font settings.setValue("gtk-font-name", QString("%1 %2").arg(systemFont()).arg(systemFontPointSize())); // dark mode settings.setValue("gtk-application-prefer-dark-theme", isDarkMode()); // icon theme - settings.setValue("gtk-icon-theme-name", "Crule"); + settings.setValue("gtk-icon-theme-name", m_iconTheme); // other settings.setValue("gtk-enable-animations", true); settings.sync(); @@ -310,7 +312,9 @@ void ThemeManager::applyCursor() p.start("cupdatecursor", QStringList() << cursorTheme() << QString::number(cursorSize() * devicePixelRatio())); p.waitForFinished(-1); - QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); + QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", + "org.kde.KGlobalSettings", + "notifyChange"); // ChangeCursor message << 5; message << 0; @@ -327,6 +331,15 @@ void ThemeManager::updateGtkFont() } void ThemeManager::updateGtkDarkTheme() +{ + QSettings settings(gtk3SettingsIniPath(), QSettings::IniFormat); + settings.setIniCodec("UTF-8"); + settings.beginGroup("Settings"); + settings.setValue("gtk-icon-theme-name", m_iconTheme); + settings.sync(); +} + +void ThemeManager::updateGtkIconTheme() { QSettings settings(gtk3SettingsIniPath(), QSettings::IniFormat); settings.setIniCodec("UTF-8"); @@ -334,3 +347,19 @@ void ThemeManager::updateGtkDarkTheme() settings.setValue("gtk-application-prefer-dark-theme", isDarkMode()); settings.sync(); } + +QString ThemeManager::iconTheme() const +{ + return m_iconTheme; +} + +void ThemeManager::setIconTheme(const QString &iconTheme) +{ + if (m_iconTheme == iconTheme) + return; + + m_iconTheme = iconTheme; + m_settings->setValue("IconTheme", m_iconTheme); + updateGtkDarkTheme(); + emit iconThemeChanged(); +} diff --git a/settings-daemon/theme/thememanager.h b/settings-daemon/theme/thememanager.h index cd236bd..44549f2 100644 --- a/settings-daemon/theme/thememanager.h +++ b/settings-daemon/theme/thememanager.h @@ -38,6 +38,7 @@ class ThemeManager : public QObject Q_PROPERTY(QString backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) Q_PROPERTY(QString cursorTheme READ cursorTheme WRITE setCursorTheme NOTIFY cursorThemeChanged) Q_PROPERTY(int cursorSize READ cursorSize WRITE setCursorSize NOTIFY cursorSizeChanged) + Q_PROPERTY(QString iconTheme READ iconTheme WRITE setIconTheme NOTIFY iconThemeChanged) public: ThemeManager(QObject *parent = nullptr); @@ -82,6 +83,9 @@ public: void applyXResources(); void applyCursor(); + QString iconTheme() const; + void setIconTheme(const QString &iconTheme); + signals: void darkModeChanged(bool darkMode); void wallpaperChanged(QString path); @@ -91,10 +95,12 @@ signals: void backgroundColorChanged(); void cursorThemeChanged(); void cursorSizeChanged(); + void iconThemeChanged(); private: void updateGtkFont(); void updateGtkDarkTheme(); + void updateGtkIconTheme(); QSettings *m_settings; @@ -107,6 +113,8 @@ private: QString m_cursorTheme; int m_cursorSize; + + QString m_iconTheme; }; #endif