diff --git a/qml/Desktop/Desktop.qml b/qml/Desktop/Desktop.qml index ff29d65..a79d028 100644 --- a/qml/Desktop/Desktop.qml +++ b/qml/Desktop/Desktop.qml @@ -56,28 +56,45 @@ FolderViewDropArea { id: settings } - Image { - id: wallpaper + Loader { + id: backgroundLoader anchors.fill: parent - source: "file://" + settings.wallpaper - sourceSize: Qt.size(width, height) - fillMode: Image.PreserveAspectCrop - clip: true - cache: false + sourceComponent: settings.backgroundType === 0 ? wallpaper : background + } - ColorOverlay { - id: dimsWallpaper - anchors.fill: wallpaper - source: wallpaper - color: "#000000" - opacity: Meui.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0 + Component { + id: wallpaper - Behavior on opacity { - NumberAnimation { - duration: 200 + Image { + source: "file://" + settings.wallpaper + sourceSize: Qt.size(width, height) + fillMode: Image.PreserveAspectCrop + clip: true + cache: false + + ColorOverlay { + id: dimsWallpaper + anchors.fill: parent + source: parent + color: "#000000" + opacity: Meui.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0 + + Behavior on opacity { + NumberAnimation { + duration: 200 + } } - } + } + } + } + + Component { + id: background + + Rectangle { + anchors.fill: parent + color: settings.backgroundColor } } diff --git a/src/desktop/desktopsettings.cpp b/src/desktop/desktopsettings.cpp index 3cd5231..293eb45 100644 --- a/src/desktop/desktopsettings.cpp +++ b/src/desktop/desktopsettings.cpp @@ -27,6 +27,16 @@ bool DesktopSettings::dimsWallpaper() const return m_interface.property("darkModeDimsWallpaer").toBool(); } +int DesktopSettings::backgroundType() const +{ + return m_interface.property("backgroundType").toInt(); +} + +QString DesktopSettings::backgroundColor() const +{ + return m_interface.property("backgroundColor").toString(); +} + void DesktopSettings::launch(const QString &command, const QStringList &args) { QProcess process; @@ -40,6 +50,8 @@ void DesktopSettings::init() if (m_interface.isValid()) { connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString))); connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged())); + connect(&m_interface, SIGNAL(backgroundTypeChanged()), this, SIGNAL(backgroundTypeChanged())); + connect(&m_interface, SIGNAL(backgroundColorChanged()), this, SIGNAL(backgroundColorChanged())); m_wallpaper = m_interface.property("wallpaper").toString(); emit wallpaperChanged(); diff --git a/src/desktop/desktopsettings.h b/src/desktop/desktopsettings.h index 463dbe3..259d750 100644 --- a/src/desktop/desktopsettings.h +++ b/src/desktop/desktopsettings.h @@ -10,17 +10,25 @@ class DesktopSettings : public QObject Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged) Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged) + Q_PROPERTY(int backgroundType READ backgroundType NOTIFY backgroundTypeChanged) + Q_PROPERTY(QString backgroundColor READ backgroundColor NOTIFY backgroundColorChanged) + public: explicit DesktopSettings(QObject *parent = nullptr); QString wallpaper() const; bool dimsWallpaper() const; + int backgroundType() const; + QString backgroundColor() const; + Q_INVOKABLE void launch(const QString &command, const QStringList &args); signals: void wallpaperChanged(); void dimsWallpaperChanged(); + void backgroundColorChanged(); + void backgroundTypeChanged(); private slots: void init();