Desktop background extension

pull/2/head
cutefishd 6 years ago
parent 909a7f50d5
commit db9cb549a8

@ -25,6 +25,12 @@
<method name="setAccentColor">
<arg name="accentColor" type="i" direction="in"/>
</method>
<method name="setBackgroundColor">
<arg name="color" type="s" direction="in"/>
</method>
<method name="setBackgroundType">
<arg name="type" type="i" direction="in"/>
</method>
<property name="isDarkMode" type="b" access="read"/>
<property name="darkModeDimsWallpaer" type="b" access="read"/>
@ -34,6 +40,8 @@
<property name="devicePixelRatio" type="d" access="read"/>
<property name="wallpaper" type="s" access="read"/>
<property name="accentColor" type="i" access="read"/>
<property name="backgroundType" type="i" access="read"/>
<property name="backgroundColor" type="s" access="read"/>
<signal name="darkModeChanged">
<arg type="b"/>
@ -46,5 +54,9 @@
<signal name="accentColorChanged">
<arg type="i"/>
</signal>
<signal name="backgroundTypeChanged">
</signal>
<signal name="backgroundColorChanged">
</signal>
</interface>
</node>

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

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

Loading…
Cancel
Save