From e405a22ceb2bee4c74b53996caca3e2e69d91143 Mon Sep 17 00:00:00 2001 From: reionwong Date: Wed, 28 Jul 2021 04:22:57 +0800 Subject: [PATCH] Wallpaper: Use system interface --- CMakeLists.txt | 1 - qml/main.qml | 7 ++++--- src/main.cpp | 2 -- src/wallpaper.cpp | 53 ----------------------------------------------- src/wallpaper.h | 51 --------------------------------------------- 5 files changed, 4 insertions(+), 110 deletions(-) delete mode 100644 src/wallpaper.cpp delete mode 100644 src/wallpaper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a491ed9..709391a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ set(SRCS src/main.cpp src/pagemodel.cpp src/ucunits.cpp - src/wallpaper.cpp src/listmodelmanager.cpp src/iconitem.cpp ) diff --git a/qml/main.qml b/qml/main.qml index a5fc937..1605948 100755 --- a/qml/main.qml +++ b/qml/main.qml @@ -24,6 +24,7 @@ import QtQuick.Layouts 1.12 import QtGraphicalEffects 1.0 import Cutefish.Launcher 1.0 +import Cutefish.System 1.0 as System import FishUI 1.0 as FishUI Item { @@ -89,14 +90,14 @@ Item { duration: 250 } - Wallpaper { + System.Wallpaper { id: backend } Image { id: wallpaper anchors.fill: parent - source: "file://" + backend.wallpaper + source: "file://" + backend.path sourceSize: Qt.size(launcher.screenRect.width, launcher.screenRect.height) fillMode: Image.PreserveAspectCrop @@ -119,7 +120,7 @@ Item { anchors.fill: parent source: wallpaperBlur color: "#000000" - opacity: 0.4 + opacity: backend.dimsWallpaper ? 0.5 : 0.4 visible: true } diff --git a/src/main.cpp b/src/main.cpp index fa6e6e8..88220db 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,6 @@ #include "launcheritem.h" #include "launchermodel.h" #include "pagemodel.h" -#include "wallpaper.h" #include "iconitem.h" #include @@ -45,7 +44,6 @@ int main(int argc, char *argv[]) qmlRegisterUncreatableType(uri, 1, 0, "LauncherItem", "cannot init application"); qmlRegisterType(uri, 1, 0, "LauncherModel"); qmlRegisterType(uri, 1, 0, "PageModel"); - qmlRegisterType(uri, 1, 0, "Wallpaper"); qmlRegisterType(uri, 1, 0, "IconItem"); QApplication app(argc, argv); diff --git a/src/wallpaper.cpp b/src/wallpaper.cpp deleted file mode 100644 index 9d35558..0000000 --- a/src/wallpaper.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2021 CutefishOS. - * - * Author: revenmartin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "wallpaper.h" - -Wallpaper::Wallpaper(QObject *parent) - : QObject(parent) - , m_interface("org.cutefish.Settings", - "/Theme", "org.cutefish.Theme", - QDBusConnection::sessionBus(), this) -{ - if (m_interface.isValid()) { - connect(&m_interface, SIGNAL(wallpaperChanged(QString)), this, SLOT(onWallpaperChanged(QString))); - connect(&m_interface, SIGNAL(darkModeDimsWallpaerChanged()), this, SIGNAL(dimsWallpaperChanged())); - - m_wallpaper = m_interface.property("wallpaper").toString(); - emit wallpaperChanged(); - } -} - -QString Wallpaper::wallpaper() const -{ - return m_wallpaper; -} - -bool Wallpaper::dimsWallpaper() const -{ - return m_interface.property("darkModeDimsWallpaer").toBool(); -} - -void Wallpaper::onWallpaperChanged(QString path) -{ - if (path != m_wallpaper) { - m_wallpaper = path; - emit wallpaperChanged(); - } -} diff --git a/src/wallpaper.h b/src/wallpaper.h deleted file mode 100644 index de96227..0000000 --- a/src/wallpaper.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2021 CutefishOS. - * - * Author: revenmartin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef WALLPAPER_H -#define WALLPAPER_H - -#include -#include -#include - -class Wallpaper : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged) - Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged) - -public: - explicit Wallpaper(QObject *parent = nullptr); - - QString wallpaper() const; - bool dimsWallpaper() const; - -signals: - void wallpaperChanged(); - void dimsWallpaperChanged(); - -private slots: - void onWallpaperChanged(QString); - -private: - QDBusInterface m_interface; - QString m_wallpaper; -}; - -#endif // WALLPAPER_H