From 1dbd1505dc38542e2bca0a2cf99023c8540b11e3 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 1 Jan 2024 22:30:55 -0500 Subject: [PATCH] shell: Move wallpaper selector to homescreens directly --- .../qml/homescreen}/WallpaperSelector.qml | 18 +-- .../folio/package/contents/ui/HomeScreen.qml | 2 - .../ui/settings/SettingsComponent.qml | 29 +++- .../package/contents/ui/HomeScreen.qml | 25 +++- .../package/contents/ui/SettingsScreen.qml | 132 ++++++++++++++++++ .../halcyon/package/contents/ui/main.qml | 11 ++ .../ContainmentConfiguration.qml | 85 +---------- 7 files changed, 202 insertions(+), 100 deletions(-) rename {shell/contents/configuration => components/mobileshell/qml/homescreen}/WallpaperSelector.qml (86%) create mode 100644 containments/homescreens/halcyon/package/contents/ui/SettingsScreen.qml diff --git a/shell/contents/configuration/WallpaperSelector.qml b/components/mobileshell/qml/homescreen/WallpaperSelector.qml similarity index 86% rename from shell/contents/configuration/WallpaperSelector.qml rename to components/mobileshell/qml/homescreen/WallpaperSelector.qml index e6cd0874..3e5e983d 100644 --- a/shell/contents/configuration/WallpaperSelector.qml +++ b/components/mobileshell/qml/homescreen/WallpaperSelector.qml @@ -1,18 +1,16 @@ // SPDX-FileCopyrightText: 2013 Marco Martin -// SPDX-FileCopyrightText: 2022 Devin Lin +// SPDX-FileCopyrightText: 2022-2024 Devin Lin // SPDX-License-Identifier: GPL-2.0-or-later import QtQuick import QtQuick.Layouts import QtQuick.Window -import QtQuick.Controls 2.3 as Controls -import org.kde.plasma.core as PlasmaCore -import org.kde.plasma.configuration 2.0 +import QtQuick.Controls as Controls import org.kde.kirigami 2.20 as Kirigami import org.kde.plasma.wallpapers.image 2.0 as Wallpaper import org.kde.kquickcontrolsaddons 2.0 as Addons -import org.kde.kcmutils as KCM +import org.kde.plasma.private.mobileshell.wallpaperimageplugin as WallpaperImagePlugin Controls.Drawer { id: imageWallpaperDrawer @@ -23,6 +21,7 @@ Controls.Drawer { onOpened: { wallpapersView.forceActiveFocus() } + implicitWidth: Kirigami.Units.gridUnit * 10 implicitHeight: Kirigami.Units.gridUnit * 8 width: imageWallpaperDrawer.horizontal ? implicitWidth : parent.width @@ -37,6 +36,9 @@ Controls.Drawer { ListView { id: wallpapersView anchors.fill: parent + anchors.leftMargin: imageWallpaperDrawer.leftMargin + anchors.rightMargin: imageWallpaperDrawer.rightMargin + anchors.bottomMargin: imageWallpaperDrawer.bottomMargin orientation: imageWallpaperDrawer.horizontal ? ListView.Vertical : ListView.Horizontal keyNavigationEnabled: true highlightFollowsCurrentItem: true @@ -60,7 +62,7 @@ Controls.Drawer { } } - property bool isCurrent: configDialog.wallpaperConfiguration["Image"] == model.path + property bool isCurrent: WallpaperImagePlugin.WallpaperPlugin.homescreenWallpaperPath == model.path onIsCurrentChanged: { if (isCurrent) { wallpapersView.currentIndex = index; @@ -87,9 +89,7 @@ Controls.Drawer { } } onClicked: { - configDialog.currentWallpaper = "org.kde.image"; - configDialog.wallpaperConfiguration["Image"] = model.path; - configDialog.applyWallpaper() + WallpaperImagePlugin.WallpaperPlugin.setHomescreenWallpaper(model.path); } Keys.onReturnPressed: { clicked(); diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml index 87dfbece..1535837d 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreen.qml @@ -138,8 +138,6 @@ Item { settingsModeHomeScreenScale: root.settingsModeHomeScreenScale homeScreen: root - - onRequestLeaveSettingsMode: root.leaveSettingsMode(); } Item { diff --git a/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml b/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml index e6d218ad..2f7a2981 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/SettingsComponent.qml @@ -22,8 +22,6 @@ Item { readonly property bool homeScreenInteractive: !appletListViewer.open - signal requestLeaveSettingsMode() - MouseArea { id: closeSettings @@ -56,7 +54,6 @@ Item { PC3.ToolButton { opacity: 0.9 - enabled: false implicitHeight: Kirigami.Units.gridUnit * 4 implicitWidth: Kirigami.Units.gridUnit * 5 @@ -76,6 +73,11 @@ Item { font.bold: true } } + + onClicked: { + wallpaperSelectorLoader.active = true; + Folio.HomeScreenState.closeSettingsView(); + } } PC3.ToolButton { @@ -166,4 +168,25 @@ Item { homeScreen.openConfigure() } } + + Loader { + id: wallpaperSelectorLoader + asynchronous: true + active: false + + onLoaded: { + wallpaperSelectorLoader.item.open(); + } + + sourceComponent: MobileShell.WallpaperSelector { + horizontal: root.width > root.height + edge: horizontal ? Qt.LeftEdge : Qt.BottomEdge + bottomMargin: root.homeScreen.bottomMargin + leftMargin: root.homeScreen.leftMargin + rightMargin: root.homeScreen.rightMargin + onClosed: { + wallpaperSelectorLoader.active = false; + } + } + } } diff --git a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml index 0ddeea89..262b10fe 100644 --- a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml @@ -26,7 +26,14 @@ Item { required property var searchWidget property alias page: swipeView.currentIndex - + + property bool settingsOpen: false + property real settingsOpenFactor: settingsOpen ? 1 : 0 + + Behavior on settingsOpenFactor { + NumberAnimation { duration: 200 } + } + function triggerHomescreen() { swipeView.setCurrentIndex(0); swipeView.focusChild(); @@ -36,6 +43,10 @@ Item { } function openConfigure() { + settingsOpen = true; + } + + function openContainmentSettings() { Plasmoid.internalAction("configure").trigger(); Plasmoid.editMode = false; } @@ -50,9 +61,19 @@ Item { } } + SettingsScreen { + id: settings + bottomMargin: root.bottomMargin + anchors.fill: parent + opacity: root.settingsOpenFactor + visible: opacity > 0 + homeScreen: root + z: 1 + } + QQC2.SwipeView { id: swipeView - opacity: 1 - searchWidget.openFactor + opacity: Math.min(1 - root.settingsOpenFactor, 1 - searchWidget.openFactor) interactive: root.interactive anchors.fill: parent diff --git a/containments/homescreens/halcyon/package/contents/ui/SettingsScreen.qml b/containments/homescreens/halcyon/package/contents/ui/SettingsScreen.qml new file mode 100644 index 00000000..40de57df --- /dev/null +++ b/containments/homescreens/halcyon/package/contents/ui/SettingsScreen.qml @@ -0,0 +1,132 @@ +// SPDX-FileCopyrightText: 2023 Devin Lin +// SPDX-License-Identifier: LGPL-2.0-or-later + +import QtQuick +import QtQuick.Window +import QtQuick.Layouts +import QtQuick.Controls as QQC2 + +import org.kde.kirigami 2.20 as Kirigami + +import org.kde.plasma.components 3.0 as PC3 +import org.kde.plasma.private.mobileshell as MobileShell + +Item { + id: root + + property real leftMargin + property real rightMargin + property real bottomMargin + property var homeScreen + + MouseArea { + id: closeSettings + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: settingsBar.top + + onClicked: { + root.homeScreen.settingsOpen = false; + } + } + + Item { + id: settingsBar + height: settingsOptions.implicitHeight + + Kirigami.Theme.inherit: false + Kirigami.Theme.colorSet: Kirigami.Theme.Complementary + + anchors.left: parent.left + anchors.leftMargin: root.leftMargin + anchors.right: parent.right + anchors.rightMargin: parent.rightMargin + anchors.bottom: parent.bottom + anchors.bottomMargin: Kirigami.Units.largeSpacing + root.bottomMargin + + RowLayout { + id: settingsOptions + anchors.horizontalCenter: parent.horizontalCenter + spacing: Kirigami.Units.largeSpacing + + PC3.ToolButton { + opacity: 0.9 + implicitHeight: Kirigami.Units.gridUnit * 4 + implicitWidth: Kirigami.Units.gridUnit * 5 + + contentItem: ColumnLayout { + spacing: Kirigami.Units.largeSpacing + + Kirigami.Icon { + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + implicitWidth: Kirigami.Units.iconSizes.smallMedium + implicitHeight: Kirigami.Units.iconSizes.smallMedium + source: 'edit-image' + } + + QQC2.Label { + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + text: i18n('Wallpapers') + font.bold: true + } + } + + onClicked: { + root.homeScreen.settingsOpen = false; + wallpaperSelectorLoader.active = true; + } + } + + PC3.ToolButton { + opacity: 0.9 + implicitHeight: Kirigami.Units.gridUnit * 4 + implicitWidth: Kirigami.Units.gridUnit * 5 + + contentItem: ColumnLayout { + spacing: Kirigami.Units.largeSpacing + + Kirigami.Icon { + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + implicitWidth: Kirigami.Units.iconSizes.smallMedium + implicitHeight: Kirigami.Units.iconSizes.smallMedium + source: 'settings-configure' + } + + QQC2.Label { + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + text: i18n('Settings') + font.bold: true + } + } + + onClicked: { + root.homeScreen.settingsOpen = false; + root.homeScreen.openContainmentSettings(); + } + } + } + } + + Loader { + id: wallpaperSelectorLoader + asynchronous: true + active: false + + onLoaded: { + wallpaperSelectorLoader.item.open(); + } + + sourceComponent: MobileShell.WallpaperSelector { + horizontal: root.width > root.height + edge: horizontal ? Qt.LeftEdge : Qt.BottomEdge + bottomMargin: root.bottomMargin + leftMargin: root.leftMargin + rightMargin: root.rightMargin + onClosed: { + wallpaperSelectorLoader.active = false; + } + } + } +} diff --git a/containments/homescreens/halcyon/package/contents/ui/main.qml b/containments/homescreens/halcyon/package/contents/ui/main.qml index 58ff451d..4bc1103a 100644 --- a/containments/homescreens/halcyon/package/contents/ui/main.qml +++ b/containments/homescreens/halcyon/package/contents/ui/main.qml @@ -61,6 +61,17 @@ ContainmentItem { } } + Rectangle { + id: darkenSettingsBackground + color: Qt.rgba(0, 0, 0, 0.7) + opacity: halcyonHomeScreen.settingsOpenFactor + anchors.fill: parent + z: -1 + Behavior on color { + ColorAnimation { duration: Kirigami.Units.longDuration } + } + } + MobileShell.HomeScreen { id: homeScreen anchors.fill: parent diff --git a/shell/contents/configuration/ContainmentConfiguration.qml b/shell/contents/configuration/ContainmentConfiguration.qml index f74ee14d..bc757a85 100644 --- a/shell/contents/configuration/ContainmentConfiguration.qml +++ b/shell/contents/configuration/ContainmentConfiguration.qml @@ -16,7 +16,7 @@ import org.kde.ksvg 1.0 as KSvg AppletConfiguration { id: root isContainment: true - loadApp: false + loadApp: true readonly property bool horizontal: root.width > root.height @@ -37,87 +37,4 @@ AppletConfiguration { } } //END model - - // the wallpaper selector is quite heavy, so only load it when needed - Loader { - id: wallpaperSelectorLoader - asynchronous: true - active: false - - onLoaded: { - wallpaperSelectorLoader.item.open(); - } - - sourceComponent: WallpaperSelector { - visible: false - horizontal: root.horizontal - edge: root.horizontal ? Qt.LeftEdge : Qt.BottomEdge - onClosed: configDialog.close() - } - } - - MouseArea { - z: -1 - anchors.fill: parent - onClicked: configDialog.close() - - Controls.Control { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottomMargin: Kirigami.Units.gridUnit - - leftPadding: Kirigami.Units.gridUnit - rightPadding: Kirigami.Units.gridUnit - topPadding: Kirigami.Units.gridUnit - bottomPadding: Kirigami.Units.gridUnit - - NumberAnimation on opacity { - id: opacityAnim - running: true - from: 0 - to: 1 - duration: Kirigami.Units.longDuration - } - - background: KSvg.FrameSvgItem { - enabledBorders: KSvg.FrameSvgItem.AllBorders - imagePath: "widgets/background" - } - - contentItem: RowLayout { - PlasmaComponents3.Button { - Layout.alignment: Qt.AlignRight - Layout.preferredHeight: Kirigami.Units.gridUnit * 4 - Layout.preferredWidth: Kirigami.Units.gridUnit * 8 - - display: PlasmaComponents3.ToolButton.TextUnderIcon - icon.name: "viewimage" - icon.width: Kirigami.Units.iconSizes.medium - icon.height: Kirigami.Units.iconSizes.medium - text: i18n("Change Wallpaper") - onClicked: { - opacityAnim.from = 1; - opacityAnim.to = 0; - opacityAnim.restart(); - wallpaperSelectorLoader.active = true; - } - } - - PlasmaComponents3.Button { - Layout.alignment: Qt.AlignLeft - Layout.preferredHeight: Kirigami.Units.gridUnit * 4 - Layout.preferredWidth: Kirigami.Units.gridUnit * 8 - - display: PlasmaComponents3.ToolButton.TextUnderIcon - icon.name: "configure" - icon.width: Kirigami.Units.iconSizes.medium - icon.height: Kirigami.Units.iconSizes.medium - text: i18n("Configure") - onClicked: { - root.loadApp = true; - } - } - } - } - } }