diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c59a2a..1abd89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,6 @@ add_library(cutefish-filemanager-core STATIC widgets/rubberband.cpp widgets/itemviewadapter.cpp - desktop/desktopsettings.cpp desktop/dockdbusinterface.cpp helper/datehelper.cpp diff --git a/desktop/desktopsettings.cpp b/desktop/desktopsettings.cpp deleted file mode 100644 index 59e27d1..0000000 --- a/desktop/desktopsettings.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2021 CutefishOS Team. - * - * 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 "desktopsettings.h" - -#include -#include - -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(); - } -} diff --git a/desktop/desktopsettings.h b/desktop/desktopsettings.h deleted file mode 100644 index 7859515..0000000 --- a/desktop/desktopsettings.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2021 CutefishOS Team. - * - * 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 SETTINGS_H -#define SETTINGS_H - -#include -#include - -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 diff --git a/desktopplugin/desktopview.cpp b/desktopplugin/desktopview.cpp index 163a00d..352dd24 100644 --- a/desktopplugin/desktopview.cpp +++ b/desktopplugin/desktopview.cpp @@ -26,14 +26,13 @@ #include #include -static const char *kDesktopRootQml = "qrc:/qml/Desktop/Root.qml"; +static const char *kDesktopRootQml = "qrc:/qml/Desktop/Main.qml"; DesktopView::DesktopView(QQuickItem *parent) : QQuickItem(parent) , m_component(nullptr) , m_context(nullptr) , m_content(nullptr) - , m_primary(false) { setFlag(ItemHasContents, false); CutefishFM::initResources(); @@ -65,20 +64,6 @@ void DesktopView::setScreen(QScreen *screen) 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 { return m_screen ? m_screen->name() : QString(); diff --git a/desktopplugin/desktopview.h b/desktopplugin/desktopview.h index 5be6708..1f7fe0d 100644 --- a/desktopplugin/desktopview.h +++ b/desktopplugin/desktopview.h @@ -29,17 +29,17 @@ class QScreen; /** * The whole Cutefish desktop as a single QML item. * - * Everything the desktop does -- wallpaper, icons, layout, selection, drag and - * drop, context menus and file operations -- lives behind this item and reuses - * the file manager core. A host only has to place the item in a window and tell - * it which screen it is on: + * Everything the desktop does -- icons, layout, selection, drag and drop, + * context menus and file operations -- lives behind this item and reuses the + * file manager core. The background is not part of it: the shell draws that + * 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 * * DesktopView { * anchors.fill: parent * screen: Qt.application.screens[0] - * primary: true * } * * The item owns no window state (flags, type hints, stacking); that is the @@ -49,7 +49,6 @@ class DesktopView : public QQuickItem { Q_OBJECT 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(QRect screenRect READ screenRect NOTIFY screenRectChanged) @@ -60,20 +59,11 @@ public: QScreen *screen() const; 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; QRect screenRect() const; signals: void screenChanged(); - void primaryChanged(); void screenRectChanged(); protected: @@ -90,7 +80,6 @@ private: QQuickItem *m_content; QPointer m_screen; QRect m_screenRect; - bool m_primary; }; #endif // CUTEFISH_DESKTOPVIEW_H diff --git a/qml.qrc b/qml.qrc index 95f358f..29d2971 100644 --- a/qml.qrc +++ b/qml.qrc @@ -18,7 +18,6 @@ images/light/grid.svg images/light/list.svg qml/PathBar.qml - qml/Desktop/Root.qml qml/Desktop/Main.qml qml/FolderGridView.qml qml/GlobalSettings.qml @@ -61,7 +60,6 @@ images/light/drive-optical.svg qml/Dialogs/OpenWithDialog.qml qml/Dialogs/DeleteDialog.qml - qml/Desktop/Wallpaper.qml images/folder-document.svg images/folder-desktop.svg images/folder-download.svg diff --git a/qml/Desktop/Main.qml b/qml/Desktop/Main.qml index 30f9457..0f823f7 100644 --- a/qml/Desktop/Main.qml +++ b/qml/Desktop/Main.qml @@ -21,7 +21,6 @@ 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 @@ -37,10 +36,6 @@ Item { id: globalSettings } - Wallpaper { - anchors.fill: parent - } - FM.FolderModel { id: dirModel url: desktopPath() diff --git a/qml/Desktop/Root.qml b/qml/Desktop/Root.qml deleted file mode 100644 index 547c6e8..0000000 --- a/qml/Desktop/Root.qml +++ /dev/null @@ -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 . - */ - -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 }) - } -} diff --git a/qml/Desktop/Wallpaper.qml b/qml/Desktop/Wallpaper.qml deleted file mode 100644 index 4f3077a..0000000 --- a/qml/Desktop/Wallpaper.qml +++ /dev/null @@ -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 - } - } - - } - } - } -} diff --git a/qmltypes.cpp b/qmltypes.cpp index a27dc50..5f8dd66 100644 --- a/qmltypes.cpp +++ b/qmltypes.cpp @@ -23,7 +23,6 @@ #include "model/positioner.h" #include "widgets/rubberband.h" #include "widgets/itemviewadapter.h" -#include "desktop/desktopsettings.h" #include "helper/datehelper.h" #include "helper/fm.h" #include "helper/shortcut.h" @@ -63,7 +62,6 @@ void registerQmlTypes() qmlRegisterType(uri, 1, 0, "Positioner"); qmlRegisterType(uri, 1, 0, "RubberBand"); qmlRegisterType(uri, 1, 0, "ItemViewAdapter"); - qmlRegisterType(uri, 1, 0, "DesktopSettings"); qmlRegisterType(uri, 1, 0, "Fm"); qmlRegisterType(uri, 1, 0, "ShortCut");