Wallpaper: Use system interface

pull/6/head
reionwong 4 years ago
parent b707b0d579
commit e405a22ceb

@ -23,7 +23,6 @@ set(SRCS
src/main.cpp
src/pagemodel.cpp
src/ucunits.cpp
src/wallpaper.cpp
src/listmodelmanager.cpp
src/iconitem.cpp
)

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

@ -25,7 +25,6 @@
#include "launcheritem.h"
#include "launchermodel.h"
#include "pagemodel.h"
#include "wallpaper.h"
#include "iconitem.h"
#include <QDebug>
@ -45,7 +44,6 @@ int main(int argc, char *argv[])
qmlRegisterUncreatableType<LauncherItem>(uri, 1, 0, "LauncherItem", "cannot init application");
qmlRegisterType<LauncherModel>(uri, 1, 0, "LauncherModel");
qmlRegisterType<PageModel>(uri, 1, 0, "PageModel");
qmlRegisterType<Wallpaper>(uri, 1, 0, "Wallpaper");
qmlRegisterType<IconItem>(uri, 1, 0, "IconItem");
QApplication app(argc, argv);

@ -1,53 +0,0 @@
/*
* Copyright (C) 2021 CutefishOS.
*
* Author: revenmartin <revenmartin@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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();
}
}

@ -1,51 +0,0 @@
/*
* Copyright (C) 2021 CutefishOS.
*
* Author: revenmartin <revenmartin@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef WALLPAPER_H
#define WALLPAPER_H
#include <QObject>
#include <QDBusInterface>
#include <QProcess>
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
Loading…
Cancel
Save