shell: Move wallpaper selector to homescreens directly

This commit is contained in:
Devin Lin 2024-01-01 22:30:55 -05:00
parent 77e59801d0
commit 1dbd1505dc
7 changed files with 202 additions and 100 deletions

View file

@ -1,18 +1,16 @@
// SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-FileCopyrightText: 2022-2024 Devin Lin <devin@kde.org>
// 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();

View file

@ -138,8 +138,6 @@ Item {
settingsModeHomeScreenScale: root.settingsModeHomeScreenScale
homeScreen: root
onRequestLeaveSettingsMode: root.leaveSettingsMode();
}
Item {

View file

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

View file

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

View file

@ -0,0 +1,132 @@
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// 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;
}
}
}
}

View file

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

View file

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