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() && if (QFile("/usr/bin/cutefish-welcome").exists() &&
!QFile("/run/live/medium/live/filesystem.squashfs").exists()) { !QFile("/run/live/medium/live/filesystem.squashfs").exists()) {
QSettings settings("cutefishos", "login"); QSettings settings("cutefishos", "login");
if (!settings.value("Finished", false).toBool()) { if (!settings.value("Finished", false).toBool()) {
list << qMakePair(QString("/usr/bin/cutefish-welcome"), QStringList()); 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"> <method name="setCursorSize">
<arg name="type" type="i" direction="in"/> <arg name="type" type="i" direction="in"/>
</method> </method>
<method name="setIconTheme">
<arg name="type" type="s" direction="in"/>
</method>
<method name="applyXResources"></method> <method name="applyXResources"></method>
@ -52,6 +55,7 @@
<property name="backgroundColor" type="s" access="read"/> <property name="backgroundColor" type="s" access="read"/>
<property name="cursorTheme" type="s" access="read"/> <property name="cursorTheme" type="s" access="read"/>
<property name="cursorSize" type="i" access="read"/> <property name="cursorSize" type="i" access="read"/>
<property name="iconTheme" type="s" access="read"/>
<signal name="darkModeChanged"> <signal name="darkModeChanged">
<arg type="b"/> <arg type="b"/>
@ -68,5 +72,6 @@
<signal name="backgroundColorChanged"></signal> <signal name="backgroundColorChanged"></signal>
<signal name="cursorThemeChanged"></signal> <signal name="cursorThemeChanged"></signal>
<signal name="cursorSizeChanged"></signal> <signal name="cursorSizeChanged"></signal>
<signal name="iconThemeChanged"></signal>
</interface> </interface>
</node> </node>

@ -66,6 +66,7 @@ ThemeManager::ThemeManager(QObject *parent)
m_backgroundColor = m_settings->value("BackgroundColor", "#2B8ADA").toString(); m_backgroundColor = m_settings->value("BackgroundColor", "#2B8ADA").toString();
m_cursorTheme = m_settings->value("CursorTheme", "default").toString(); m_cursorTheme = m_settings->value("CursorTheme", "default").toString();
m_cursorSize = m_settings->value("CursorSize", 24).toInt(); 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. // Start the DE and need to update the settings again.
initGtkConfig(); initGtkConfig();
@ -264,12 +265,13 @@ void ThemeManager::initGtkConfig()
settings.clear(); settings.clear();
settings.setIniCodec("UTF-8"); settings.setIniCodec("UTF-8");
settings.beginGroup("Settings"); settings.beginGroup("Settings");
// font // font
settings.setValue("gtk-font-name", QString("%1 %2").arg(systemFont()).arg(systemFontPointSize())); settings.setValue("gtk-font-name", QString("%1 %2").arg(systemFont()).arg(systemFontPointSize()));
// dark mode // dark mode
settings.setValue("gtk-application-prefer-dark-theme", isDarkMode()); settings.setValue("gtk-application-prefer-dark-theme", isDarkMode());
// icon theme // icon theme
settings.setValue("gtk-icon-theme-name", "Crule"); settings.setValue("gtk-icon-theme-name", m_iconTheme);
// other // other
settings.setValue("gtk-enable-animations", true); settings.setValue("gtk-enable-animations", true);
settings.sync(); settings.sync();
@ -310,7 +312,9 @@ void ThemeManager::applyCursor()
p.start("cupdatecursor", QStringList() << cursorTheme() << QString::number(cursorSize() * devicePixelRatio())); p.start("cupdatecursor", QStringList() << cursorTheme() << QString::number(cursorSize() * devicePixelRatio()));
p.waitForFinished(-1); p.waitForFinished(-1);
QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings",
"org.kde.KGlobalSettings",
"notifyChange");
// ChangeCursor // ChangeCursor
message << 5; message << 5;
message << 0; message << 0;
@ -327,6 +331,15 @@ void ThemeManager::updateGtkFont()
} }
void ThemeManager::updateGtkDarkTheme() 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); QSettings settings(gtk3SettingsIniPath(), QSettings::IniFormat);
settings.setIniCodec("UTF-8"); settings.setIniCodec("UTF-8");
@ -334,3 +347,19 @@ void ThemeManager::updateGtkDarkTheme()
settings.setValue("gtk-application-prefer-dark-theme", isDarkMode()); settings.setValue("gtk-application-prefer-dark-theme", isDarkMode());
settings.sync(); 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 backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
Q_PROPERTY(QString cursorTheme READ cursorTheme WRITE setCursorTheme NOTIFY cursorThemeChanged) Q_PROPERTY(QString cursorTheme READ cursorTheme WRITE setCursorTheme NOTIFY cursorThemeChanged)
Q_PROPERTY(int cursorSize READ cursorSize WRITE setCursorSize NOTIFY cursorSizeChanged) Q_PROPERTY(int cursorSize READ cursorSize WRITE setCursorSize NOTIFY cursorSizeChanged)
Q_PROPERTY(QString iconTheme READ iconTheme WRITE setIconTheme NOTIFY iconThemeChanged)
public: public:
ThemeManager(QObject *parent = nullptr); ThemeManager(QObject *parent = nullptr);
@ -82,6 +83,9 @@ public:
void applyXResources(); void applyXResources();
void applyCursor(); void applyCursor();
QString iconTheme() const;
void setIconTheme(const QString &iconTheme);
signals: signals:
void darkModeChanged(bool darkMode); void darkModeChanged(bool darkMode);
void wallpaperChanged(QString path); void wallpaperChanged(QString path);
@ -91,10 +95,12 @@ signals:
void backgroundColorChanged(); void backgroundColorChanged();
void cursorThemeChanged(); void cursorThemeChanged();
void cursorSizeChanged(); void cursorSizeChanged();
void iconThemeChanged();
private: private:
void updateGtkFont(); void updateGtkFont();
void updateGtkDarkTheme(); void updateGtkDarkTheme();
void updateGtkIconTheme();
QSettings *m_settings; QSettings *m_settings;
@ -107,6 +113,8 @@ private:
QString m_cursorTheme; QString m_cursorTheme;
int m_cursorSize; int m_cursorSize;
QString m_iconTheme;
}; };
#endif #endif

Loading…
Cancel
Save