From 76177166cfb927ea6740671b09331d6948987346 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Wed, 22 Nov 2023 20:48:22 -0800 Subject: [PATCH] navigationpanel: Have it on the bottom if the screen height is large enough --- .../mobileshell/qml/components/Constants.qml | 4 ++++ .../qml/navigationpanel/NavigationPanel.qml | 10 ++++++---- .../taskpanel/package/contents/ui/main.qml | 15 ++++++--------- kwin/mobiletaskswitcher/qml/TaskSwitcher.qml | 6 ++++-- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/components/mobileshell/qml/components/Constants.qml b/components/mobileshell/qml/components/Constants.qml index a36d4920..fdd7e76f 100644 --- a/components/mobileshell/qml/components/Constants.qml +++ b/components/mobileshell/qml/components/Constants.qml @@ -14,4 +14,8 @@ pragma Singleton QtObject { readonly property real topPanelHeight: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing readonly property real bottomPanelHeight: ShellSettings.Settings.navigationPanelEnabled ? Kirigami.Units.gridUnit * 2 : 0 + + function navigationPanelOnSide(screenWidth: real, screenHeight: real): bool { + return screenWidth > screenHeight && screenHeight < 500; + } } diff --git a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml index 6cf5f7f4..2b68931c 100644 --- a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml @@ -29,6 +29,8 @@ Item { property NavigationPanelAction leftCornerAction property NavigationPanelAction rightCornerAction + property bool isVertical: false + // drop shadow for icons MultiEffect { anchors.fill: root @@ -117,8 +119,8 @@ Item { states: [ State { - name: "landscape" - when: root.width < root.height + name: "vertical" + when: root.isVertical PropertyChanges { target: icons buttonLength: Math.min(Kirigami.Units.gridUnit * 10, icons.height * 0.7 / 3) @@ -165,8 +167,8 @@ Item { width: icons.width } }, State { - name: "portrait" - when: root.width >= root.height + name: "horizontal" + when: !root.isVertical PropertyChanges { target: icons buttonLength: Math.min(Kirigami.Units.gridUnit * 8, icons.width * 0.7 / 3) diff --git a/containments/taskpanel/package/contents/ui/main.qml b/containments/taskpanel/package/contents/ui/main.qml index 0b00f4af..fd27207a 100644 --- a/containments/taskpanel/package/contents/ui/main.qml +++ b/containments/taskpanel/package/contents/ui/main.qml @@ -36,7 +36,7 @@ ContainmentItem { } } - readonly property bool inLandscape: Screen.width > Screen.height; + readonly property bool inLandscape: MobileShell.Constants.navigationPanelOnSide(Screen.width, Screen.height) readonly property real navigationPanelHeight: Kirigami.Units.gridUnit * 2 @@ -46,7 +46,9 @@ ContainmentItem { readonly property int intendedWindowLocation: inLandscape ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen - onIntendedWindowLocationChanged: locationChangeTimer.restart() + onIntendedWindowLocationChanged: { + root.panel.location = intendedWindowLocation; + } onIntendedWindowOffsetChanged: { if (root.panel) { root.panel.offset = intendedWindowOffset; @@ -66,13 +68,6 @@ ContainmentItem { } } - // use a timer so that rotation events are faster (offload the panel movement to later, after everything is figured out) - Timer { - id: locationChangeTimer - running: false - interval: 100 - onTriggered: root.panel.location = intendedWindowLocation - } function setWindowProperties() { if (root.panel) { @@ -117,8 +112,10 @@ ContainmentItem { // load appropriate system navigation component NavigationPanelComponent { + id: navigationPanel anchors.fill: parent opaqueBar: root.opaqueBar + isVertical: root.inLandscape } } } diff --git a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml index 1b07eed7..310e5e6e 100644 --- a/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml +++ b/kwin/mobiletaskswitcher/qml/TaskSwitcher.qml @@ -164,6 +164,8 @@ FocusScope { foregroundColorGroup: Kirigami.Theme.Complementary shadow: false + isVertical: MobileShell.Constants.navigationPanelOnSide(root.width, root.height) + leftAction: MobileShell.NavigationPanelAction { enabled: true iconSource: "mobile-task-switcher" @@ -206,7 +208,7 @@ FocusScope { states: [ State { name: "landscape" - when: root.width > root.height + when: MobileShell.Constants.navigationPanelOnSide(root.width, root.height) AnchorChanges { target: navigationPanel anchors { @@ -223,7 +225,7 @@ FocusScope { }, State { name: "portrait" - when: root.width <= root.height + when: !MobileShell.Constants.navigationPanelOnSide(root.width, root.height) AnchorChanges { target: navigationPanel anchors {