refactor(desktop): drop wallpaper rendering, keep file features only
parent
9235d2403f
commit
f97f9f81aa
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 CutefishOS Team.
|
|
||||||
*
|
|
||||||
* 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 "desktopsettings.h"
|
|
||||||
|
|
||||||
#include <QDBusServiceWatcher>
|
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
DesktopSettings::DesktopSettings(QObject *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
, m_interface("com.cutefish.Settings",
|
|
||||||
"/Theme", "com.cutefish.Theme",
|
|
||||||
QDBusConnection::sessionBus(), this)
|
|
||||||
{
|
|
||||||
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(this);
|
|
||||||
watcher->setConnection(QDBusConnection::sessionBus());
|
|
||||||
watcher->addWatchedService("com.cutefish.Settings");
|
|
||||||
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &DesktopSettings::init);
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DesktopSettings::wallpaper() const
|
|
||||||
{
|
|
||||||
return m_wallpaper;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DesktopSettings::backgroundVisible() const
|
|
||||||
{
|
|
||||||
return m_interface.property("backgroundVisible").toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
process.setProgram(command);
|
|
||||||
process.setArguments(args);
|
|
||||||
process.startDetached();
|
|
||||||
}
|
|
||||||
|
|
||||||
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()));
|
|
||||||
connect(&m_interface, SIGNAL(backgroundVisibleChanged()), this, SIGNAL(backgroundVisibleChanged()));
|
|
||||||
m_wallpaper = m_interface.property("wallpaper").toString();
|
|
||||||
emit wallpaperChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopSettings::onWallpaperChanged(QString path)
|
|
||||||
{
|
|
||||||
if (path != m_wallpaper) {
|
|
||||||
m_wallpaper = path;
|
|
||||||
emit wallpaperChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 CutefishOS Team.
|
|
||||||
*
|
|
||||||
* 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 SETTINGS_H
|
|
||||||
#define SETTINGS_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QDBusInterface>
|
|
||||||
|
|
||||||
class DesktopSettings : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString wallpaper READ wallpaper NOTIFY wallpaperChanged)
|
|
||||||
Q_PROPERTY(bool dimsWallpaper READ dimsWallpaper NOTIFY dimsWallpaperChanged)
|
|
||||||
Q_PROPERTY(bool backgroundVisible READ backgroundVisible NOTIFY backgroundVisibleChanged)
|
|
||||||
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;
|
|
||||||
bool backgroundVisible() 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();
|
|
||||||
void backgroundVisibleChanged();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void init();
|
|
||||||
void onWallpaperChanged(QString);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QDBusInterface m_interface;
|
|
||||||
QString m_wallpaper;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 CutefishOS Team.
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.12
|
|
||||||
|
|
||||||
// Entry point of the desktop, loaded by the DesktopView item. The primary
|
|
||||||
// screen gets the full desktop (wallpaper + icons); the others get the
|
|
||||||
// wallpaper on its own.
|
|
||||||
Loader {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
asynchronous: false
|
|
||||||
source: desktopView.primary ? "Main.qml" : "Wallpaper.qml"
|
|
||||||
|
|
||||||
onLoaded: {
|
|
||||||
item.width = Qt.binding(function() { return root.width })
|
|
||||||
item.height = Qt.binding(function() { return root.height })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
import QtQuick 2.12
|
|
||||||
import QtQuick.Controls 2.12
|
|
||||||
import QtQuick.Layouts 1.12
|
|
||||||
import QtQuick.Window 2.12
|
|
||||||
import Qt5Compat.GraphicalEffects
|
|
||||||
|
|
||||||
import Cutefish.FileManager 1.0 as FM
|
|
||||||
import FishUI 1.0 as FishUI
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: control
|
|
||||||
|
|
||||||
FM.DesktopSettings {
|
|
||||||
id: settings
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: backgroundLoader
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 0
|
|
||||||
sourceComponent: settings.backgroundType === 0 ? wallpaper : background
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: background
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: settings.backgroundVisible
|
|
||||||
color: settings.backgroundColor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: wallpaper
|
|
||||||
|
|
||||||
Image {
|
|
||||||
anchors.fill: parent
|
|
||||||
source: "file://" + settings.wallpaper
|
|
||||||
sourceSize: Qt.size(width * Screen.devicePixelRatio,
|
|
||||||
height * Screen.devicePixelRatio)
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
clip: true
|
|
||||||
visible: settings.backgroundVisible
|
|
||||||
cache: false
|
|
||||||
|
|
||||||
// Clear cache. On secondary screens the wallpaper is the whole
|
|
||||||
// desktop, so there is no folder model to clear.
|
|
||||||
onSourceChanged: {
|
|
||||||
if (typeof dirModel !== "undefined")
|
|
||||||
dirModel.clearPixmapCache()
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorOverlay {
|
|
||||||
id: dimsWallpaper
|
|
||||||
anchors.fill: parent
|
|
||||||
source: parent
|
|
||||||
color: "#000000"
|
|
||||||
opacity: FishUI.Theme.darkMode && settings.dimsWallpaper ? 0.4 : 0.0
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue