From 372626b786b10d4f8a4255a86b0c648d30e53394 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 31 Mar 2023 22:10:02 -0700 Subject: [PATCH] taskswitcher: Restore status bar and navigation panel --- .../mobileshell/qml/statusbar/StatusBar.qml | 1 - envmanager/settings.cpp | 2 +- kwin/mobiletaskswitcher/qml/TaskList.qml | 4 + kwin/mobiletaskswitcher/qml/TaskSwitcher.qml | 107 +++++++++++++++++- 4 files changed, 110 insertions(+), 4 deletions(-) diff --git a/components/mobileshell/qml/statusbar/StatusBar.qml b/components/mobileshell/qml/statusbar/StatusBar.qml index 6477b056..7b7666df 100644 --- a/components/mobileshell/qml/statusbar/StatusBar.qml +++ b/components/mobileshell/qml/statusbar/StatusBar.qml @@ -15,7 +15,6 @@ import Qt5Compat.GraphicalEffects import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasma5support 2.0 as P5Support import org.kde.plasma.components 3.0 as PlasmaComponents -import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState import "indicators" as Indicators import "../dataproviders" as DataProviders diff --git a/envmanager/settings.cpp b/envmanager/settings.cpp index 5ef47e26..507c4788 100644 --- a/envmanager/settings.cpp +++ b/envmanager/settings.cpp @@ -141,7 +141,7 @@ void Settings::saveConfigSetting(const QString &fileName, const QString &group, auto keyGroup = KConfigGroup{&fileGroup, group}; if (!keyGroup.hasKey(key)) { - qCDebug(LOGGING_CATEGORY) << "In" << fileName << "set" << key << "to" << value; + qCDebug(LOGGING_CATEGORY) << "In" << fileName << "saved" << key << "to" << value; keyGroup.writeEntry(key, value); } } diff --git a/kwin/mobiletaskswitcher/qml/TaskList.qml b/kwin/mobiletaskswitcher/qml/TaskList.qml index d535eb94..b7855d8f 100644 --- a/kwin/mobiletaskswitcher/qml/TaskList.qml +++ b/kwin/mobiletaskswitcher/qml/TaskList.qml @@ -32,6 +32,10 @@ MouseArea { return baseY + diff / 2 - shellTopMargin; } + function getTaskAt(index) { + return repeater.itemAt(index); + } + function closeAll() { for (var i = 0; i < repeater.count; i++) { repeater.itemAt(i).closeApp(); diff --git a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml index 2aab2c31..589e502e 100644 --- a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml +++ b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml @@ -11,6 +11,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.extras as PlasmaExtras import org.kde.plasma.private.mobileshell as MobileShell import org.kde.plasma.private.mobileshell.state as MobileShellState +import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings import org.kde.kwin 3.0 as KWinComponents import org.kde.kwin.private.effects 1.0 @@ -25,10 +26,13 @@ FocusScope { readonly property QtObject effect: KWinComponents.SceneView.effect readonly property QtObject targetScreen: KWinComponents.SceneView.screen + readonly property bool inLandscape: width > height; + readonly property bool isInLandscapeNavPanelMode: inLandscape && ShellSettings.Settings.navigationPanelEnabled + readonly property real topMargin: MobileShell.Constants.topPanelHeight - readonly property real bottomMargin: MobileShell.Constants.bottomPanelHeight + readonly property real bottomMargin: isInLandscapeNavPanelMode ? 0 : MobileShell.Constants.bottomPanelHeight readonly property real leftMargin: 0 - readonly property real rightMargin: 0 + readonly property real rightMargin: isInLandscapeNavPanelMode ? MobileShell.Constants.bottomPanelHeight : 0 property var taskSwitcherState: TaskSwitcherState { taskSwitcher: root @@ -114,6 +118,7 @@ FocusScope { } } + // view of the desktop background KWinComponents.DesktopBackground { id: backgroundItem activity: KWinComponents.Workspace.currentActivity @@ -137,6 +142,104 @@ FocusScope { } } + // status bar + MobileShell.StatusBar { + id: statusBar + z: 1 + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + backgroundColor: "transparent" + + height: root.topMargin + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + } + + // navigation panel + MobileShell.NavigationPanel { + id: navigationPanel + z: 1 + visible: ShellSettings.Settings.navigationPanelEnabled + backgroundColor: Qt.rgba(0, 0, 0, 0.1) + foregroundColorGroup: PlasmaCore.Theme.ComplementaryColorGroup + shadow: false + + leftAction: MobileShell.NavigationPanelAction { + enabled: true + iconSource: "mobile-task-switcher" + iconSizeFactor: 0.75 + + onTriggered: { + if (taskList.count === 0) { + root.hide(); + } else { + const currentIndex = taskSwitcherState.currentTaskIndex; + taskSwitcherState.openApp(taskSwitcherState.currentTaskIndex, taskList.getTaskAt(currentIndex).window); + } + } + } + + // home button + middleAction: MobileShell.NavigationPanelAction { + enabled: true + iconSource: "start-here-kde" + iconSizeFactor: 1 + onTriggered: root.hide() + } + + // close app/keyboard button + rightAction: MobileShell.NavigationPanelAction { + enabled: true + iconSource: "mobile-close-app" + iconSizeFactor: 0.75 + + onTriggered: { + taskList.getTaskAt(taskSwitcherState.currentTaskIndex).closeApp(); + } + } + + rightCornerAction: MobileShell.NavigationPanelAction { + visible: false + } + } + + states: [ + State { + name: "landscape" + when: root.width > root.height + AnchorChanges { + target: navigationPanel + anchors { + right: root.right + top: root.top + bottom: root.bottom + } + } + PropertyChanges { + target: navigationPanel + width: root.rightMargin + anchors.topMargin: root.topMargin + } + }, + State { + name: "portrait" + when: root.width <= root.height + AnchorChanges { + target: navigationPanel + anchors { + right: root.right + left: root.left + bottom: root.bottom + } + } + PropertyChanges { + target: navigationPanel + height: root.bottomMargin + } + } + ] + + // task list Item { id: container