SettingsDaemon: Add icon theme interface

pull/15/head
reionwong 4 years ago
parent 18924fef4a
commit d5b02178fd

@ -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");
}
}

@ -37,6 +37,9 @@
<method name="setCursorSize">
<arg name="type" type="i" direction="in"/>
</method>
<method name="setIconTheme">
<arg name="type" type="s" direction="in"/>
</method>
<method name="applyXResources"></method>
@ -52,6 +55,7 @@
<property name="backgroundColor" type="s" access="read"/>
<property name="cursorTheme" type="s" access="read"/>
<property name="cursorSize" type="i" access="read"/>
<property name="iconTheme" type="s" access="read"/>
<signal name="darkModeChanged">
<arg type="b"/>
@ -68,5 +72,6 @@
<signal name="backgroundColorChanged"></signal>
<signal name="cursorThemeChanged"></signal>
<signal name="cursorSizeChanged"></signal>
<signal name="iconThemeChanged"></signal>
</interface>
</node>

@ -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();
}

@ -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

Loading…
Cancel
Save