refactor(desktop): drop wallpaper rendering, keep file features only

main
reionwong 3 weeks ago
parent 9235d2403f
commit f97f9f81aa

@ -73,7 +73,6 @@ add_library(cutefish-filemanager-core STATIC
widgets/rubberband.cpp widgets/rubberband.cpp
widgets/itemviewadapter.cpp widgets/itemviewadapter.cpp
desktop/desktopsettings.cpp
desktop/dockdbusinterface.cpp desktop/dockdbusinterface.cpp
helper/datehelper.cpp helper/datehelper.cpp

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

@ -26,14 +26,13 @@
#include <QScreen> #include <QScreen>
#include <QDebug> #include <QDebug>
static const char *kDesktopRootQml = "qrc:/qml/Desktop/Root.qml"; static const char *kDesktopRootQml = "qrc:/qml/Desktop/Main.qml";
DesktopView::DesktopView(QQuickItem *parent) DesktopView::DesktopView(QQuickItem *parent)
: QQuickItem(parent) : QQuickItem(parent)
, m_component(nullptr) , m_component(nullptr)
, m_context(nullptr) , m_context(nullptr)
, m_content(nullptr) , m_content(nullptr)
, m_primary(false)
{ {
setFlag(ItemHasContents, false); setFlag(ItemHasContents, false);
CutefishFM::initResources(); CutefishFM::initResources();
@ -65,20 +64,6 @@ void DesktopView::setScreen(QScreen *screen)
updateScreenRect(); updateScreenRect();
} }
bool DesktopView::isPrimary() const
{
return m_primary;
}
void DesktopView::setPrimary(bool primary)
{
if (m_primary == primary)
return;
m_primary = primary;
emit primaryChanged();
}
QString DesktopView::screenName() const QString DesktopView::screenName() const
{ {
return m_screen ? m_screen->name() : QString(); return m_screen ? m_screen->name() : QString();

@ -29,17 +29,17 @@ class QScreen;
/** /**
* The whole Cutefish desktop as a single QML item. * The whole Cutefish desktop as a single QML item.
* *
* Everything the desktop does -- wallpaper, icons, layout, selection, drag and * Everything the desktop does -- icons, layout, selection, drag and drop,
* drop, context menus and file operations -- lives behind this item and reuses * context menus and file operations -- lives behind this item and reuses the
* the file manager core. A host only has to place the item in a window and tell * file manager core. The background is not part of it: the shell draws that
* it which screen it is on: * under the item. A host only has to place the item in a window and tell it
* which screen it is on:
* *
* import org.cutefish.filemanager.desktop 1.0 * import org.cutefish.filemanager.desktop 1.0
* *
* DesktopView { * DesktopView {
* anchors.fill: parent * anchors.fill: parent
* screen: Qt.application.screens[0] * screen: Qt.application.screens[0]
* primary: true
* } * }
* *
* The item owns no window state (flags, type hints, stacking); that is the * The item owns no window state (flags, type hints, stacking); that is the
@ -49,7 +49,6 @@ class DesktopView : public QQuickItem
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged) Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(bool primary READ isPrimary WRITE setPrimary NOTIFY primaryChanged)
Q_PROPERTY(QString screenName READ screenName NOTIFY screenChanged) Q_PROPERTY(QString screenName READ screenName NOTIFY screenChanged)
Q_PROPERTY(QRect screenRect READ screenRect NOTIFY screenRectChanged) Q_PROPERTY(QRect screenRect READ screenRect NOTIFY screenRectChanged)
@ -60,20 +59,11 @@ public:
QScreen *screen() const; QScreen *screen() const;
void setScreen(QScreen *screen); void setScreen(QScreen *screen);
/**
* Only the primary screen shows icons; the others show the wallpaper alone,
* which is what the standalone desktop process used to do by swapping its
* QML source.
*/
bool isPrimary() const;
void setPrimary(bool primary);
QString screenName() const; QString screenName() const;
QRect screenRect() const; QRect screenRect() const;
signals: signals:
void screenChanged(); void screenChanged();
void primaryChanged();
void screenRectChanged(); void screenRectChanged();
protected: protected:
@ -90,7 +80,6 @@ private:
QQuickItem *m_content; QQuickItem *m_content;
QPointer<QScreen> m_screen; QPointer<QScreen> m_screen;
QRect m_screenRect; QRect m_screenRect;
bool m_primary;
}; };
#endif // CUTEFISH_DESKTOPVIEW_H #endif // CUTEFISH_DESKTOPVIEW_H

@ -18,7 +18,6 @@
<file>images/light/grid.svg</file> <file>images/light/grid.svg</file>
<file>images/light/list.svg</file> <file>images/light/list.svg</file>
<file>qml/PathBar.qml</file> <file>qml/PathBar.qml</file>
<file>qml/Desktop/Root.qml</file>
<file>qml/Desktop/Main.qml</file> <file>qml/Desktop/Main.qml</file>
<file>qml/FolderGridView.qml</file> <file>qml/FolderGridView.qml</file>
<file>qml/GlobalSettings.qml</file> <file>qml/GlobalSettings.qml</file>
@ -61,7 +60,6 @@
<file>images/light/drive-optical.svg</file> <file>images/light/drive-optical.svg</file>
<file>qml/Dialogs/OpenWithDialog.qml</file> <file>qml/Dialogs/OpenWithDialog.qml</file>
<file>qml/Dialogs/DeleteDialog.qml</file> <file>qml/Dialogs/DeleteDialog.qml</file>
<file>qml/Desktop/Wallpaper.qml</file>
<file>images/folder-document.svg</file> <file>images/folder-document.svg</file>
<file>images/folder-desktop.svg</file> <file>images/folder-desktop.svg</file>
<file>images/folder-download.svg</file> <file>images/folder-download.svg</file>

@ -21,7 +21,6 @@ import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Window 2.12 import QtQuick.Window 2.12
import Qt5Compat.GraphicalEffects
import Cutefish.FileManager 1.0 as FM import Cutefish.FileManager 1.0 as FM
import FishUI 1.0 as FishUI import FishUI 1.0 as FishUI
@ -37,10 +36,6 @@ Item {
id: globalSettings id: globalSettings
} }
Wallpaper {
anchors.fill: parent
}
FM.FolderModel { FM.FolderModel {
id: dirModel id: dirModel
url: desktopPath() url: desktopPath()

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

@ -23,7 +23,6 @@
#include "model/positioner.h" #include "model/positioner.h"
#include "widgets/rubberband.h" #include "widgets/rubberband.h"
#include "widgets/itemviewadapter.h" #include "widgets/itemviewadapter.h"
#include "desktop/desktopsettings.h"
#include "helper/datehelper.h" #include "helper/datehelper.h"
#include "helper/fm.h" #include "helper/fm.h"
#include "helper/shortcut.h" #include "helper/shortcut.h"
@ -63,7 +62,6 @@ void registerQmlTypes()
qmlRegisterType<Positioner>(uri, 1, 0, "Positioner"); qmlRegisterType<Positioner>(uri, 1, 0, "Positioner");
qmlRegisterType<RubberBand>(uri, 1, 0, "RubberBand"); qmlRegisterType<RubberBand>(uri, 1, 0, "RubberBand");
qmlRegisterType<ItemViewAdapter>(uri, 1, 0, "ItemViewAdapter"); qmlRegisterType<ItemViewAdapter>(uri, 1, 0, "ItemViewAdapter");
qmlRegisterType<DesktopSettings>(uri, 1, 0, "DesktopSettings");
qmlRegisterType<Fm>(uri, 1, 0, "Fm"); qmlRegisterType<Fm>(uri, 1, 0, "Fm");
qmlRegisterType<ShortCut>(uri, 1, 0, "ShortCut"); qmlRegisterType<ShortCut>(uri, 1, 0, "ShortCut");

Loading…
Cancel
Save