From 2aaf5fca98e131251e64082b2349488b6a0118a6 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 9 Sep 2022 22:32:04 -0400 Subject: [PATCH] navigationpanel: Add force keyboard toggle, and add setting --- .../mobileshell/mobileshellsettings.cpp | 14 ++++++ components/mobileshell/mobileshellsettings.h | 14 ++++++ .../qml/navigationpanel/NavigationPanel.qml | 49 ++++++++++++++++++- .../navigationpanel/NavigationPanelAction.qml | 1 + .../contents/ui/NavigationPanelComponent.qml | 16 ++++++ kcms/mobileshell/package/contents/ui/main.qml | 20 ++++++++ 6 files changed, 112 insertions(+), 2 deletions(-) diff --git a/components/mobileshell/mobileshellsettings.cpp b/components/mobileshell/mobileshellsettings.cpp index aa3f185f9..6d7584d92 100644 --- a/components/mobileshell/mobileshellsettings.cpp +++ b/components/mobileshell/mobileshellsettings.cpp @@ -31,6 +31,7 @@ MobileShellSettings::MobileShellSettings(QObject *parent) Q_EMIT vibrationDurationChanged(); Q_EMIT animationsEnabledChanged(); Q_EMIT navigationPanelEnabledChanged(); + Q_EMIT keyboardButtonEnabledChanged(); Q_EMIT taskSwitcherPreviewsEnabledChanged(); Q_EMIT actionDrawerTopLeftModeChanged(); Q_EMIT actionDrawerTopRightModeChanged(); @@ -106,6 +107,19 @@ void MobileShellSettings::setNavigationPanelEnabled(bool navigationPanelEnabled) m_config->sync(); } +bool MobileShellSettings::keyboardButtonEnabled() const +{ + auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; + return group.readEntry("keyboardButtonEnabled", false); +} + +void MobileShellSettings::setKeyboardButtonEnabled(bool keyboardButtonEnabled) +{ + auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; + group.writeEntry("keyboardButtonEnabled", keyboardButtonEnabled, KConfigGroup::Notify); + m_config->sync(); +} + bool MobileShellSettings::taskSwitcherPreviewsEnabled() const { auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP}; diff --git a/components/mobileshell/mobileshellsettings.h b/components/mobileshell/mobileshellsettings.h index fbe3ba2b5..81a6a36dc 100644 --- a/components/mobileshell/mobileshellsettings.h +++ b/components/mobileshell/mobileshellsettings.h @@ -28,6 +28,7 @@ class MobileShellSettings : public QObject // navigation panel Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged) + Q_PROPERTY(bool keyboardButtonEnabled READ keyboardButtonEnabled WRITE setKeyboardButtonEnabled NOTIFY keyboardButtonEnabledChanged) // task switcher Q_PROPERTY(bool taskSwitcherPreviewsEnabled READ taskSwitcherPreviewsEnabled WRITE setTaskSwitcherPreviewsEnabled NOTIFY taskSwitcherPreviewsEnabledChanged) @@ -115,6 +116,18 @@ public: */ void setNavigationPanelEnabled(bool navigationPanelEnabled); + /** + * Whether the keyboard toggle button on the navigation panel is enabled. + */ + bool keyboardButtonEnabled() const; + + /** + * Set whether the keyboard toggle button on the navigation panel is enabled. + * + * @param keyboardButtonEnabled Whether the keyboard button on the navigation panel should be enabled. + */ + void setKeyboardButtonEnabled(bool keyboardButtonEnabled); + /** * Whether task switcher application previews are enabled. */ @@ -180,6 +193,7 @@ Q_SIGNALS: void vibrationIntensityChanged(); void vibrationDurationChanged(); void navigationPanelEnabledChanged(); + void keyboardButtonEnabledChanged(); void animationsEnabledChanged(); void taskSwitcherPreviewsEnabledChanged(); void actionDrawerTopLeftModeChanged(); diff --git a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml index dd80695e8..6a0950cd1 100644 --- a/components/mobileshell/qml/navigationpanel/NavigationPanel.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanel.qml @@ -31,6 +31,9 @@ Item { property NavigationPanelAction middleAction property NavigationPanelAction rightAction + property NavigationPanelAction leftCornerAction + property NavigationPanelAction rightCornerAction + DropShadow { anchors.fill: mouseArea visible: shadow @@ -124,6 +127,7 @@ Item { // button row (anchors provided by state) NavigationPanelButton { id: leftButton + visible: root.leftAction.visible mouseArea: mouseArea colorGroup: root.foregroundColorGroup enabled: root.leftAction.enabled @@ -139,6 +143,7 @@ Item { NavigationPanelButton { id: middleButton anchors.centerIn: parent + visible: root.middleAction.visible mouseArea: mouseArea colorGroup: root.foregroundColorGroup enabled: root.middleAction.enabled @@ -153,6 +158,7 @@ Item { NavigationPanelButton { id: rightButton + visible: root.rightAction.visible mouseArea: mouseArea colorGroup: root.foregroundColorGroup enabled: root.rightAction.enabled @@ -164,6 +170,21 @@ Item { } } } + + NavigationPanelButton { + id: rightCornerButton + visible: root.rightCornerAction.visible + mouseArea: mouseArea + colorGroup: root.foregroundColorGroup + enabled: root.rightCornerButton.enabled + iconSizeFactor: root.rightCornerAction.iconSizeFactor + iconSource: root.rightCornerAction.iconSource + onClicked: { + if (enabled) { + root.rightCornerAction.triggered(); + } + } + } } } @@ -173,7 +194,7 @@ Item { when: root.width < root.height PropertyChanges { target: icons - buttonLength: Math.min(PlasmaCore.Units.gridUnit * 10, icons.height * 0.8 / 3) + buttonLength: Math.min(PlasmaCore.Units.gridUnit * 10, icons.height * 0.7 / 3) } AnchorChanges { target: leftButton @@ -204,12 +225,24 @@ Item { height: icons.buttonLength width: icons.width } + AnchorChanges { + target: rightCornerButton + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + } + } + PropertyChanges { + target: rightCornerButton + height: PlasmaCore.Units.gridUnit * 2 + width: icons.width + } }, State { name: "portrait" when: root.width >= root.height PropertyChanges { target: icons - buttonLength: Math.min(PlasmaCore.Units.gridUnit * 8, icons.width * 0.8 / 3) + buttonLength: Math.min(PlasmaCore.Units.gridUnit * 8, icons.width * 0.7 / 3) } AnchorChanges { target: leftButton @@ -240,6 +273,18 @@ Item { height: parent.height width: icons.buttonLength } + AnchorChanges { + target: rightCornerButton + anchors { + verticalCenter: parent.verticalCenter + right: parent.right + } + } + PropertyChanges { + target: rightCornerButton + height: parent.height + width: PlasmaCore.Units.gridUnit * 2 + } } ] } diff --git a/components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml b/components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml index cfa5cc231..6c4159834 100644 --- a/components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml +++ b/components/mobileshell/qml/navigationpanel/NavigationPanelAction.qml @@ -8,6 +8,7 @@ import QtQuick 2.15 QtObject { property bool enabled + property bool visible: true property string iconSource property real iconSizeFactor diff --git a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml index db3772d2f..5d6deb5ef 100644 --- a/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml +++ b/containments/taskpanel/package/contents/ui/NavigationPanelComponent.qml @@ -104,4 +104,20 @@ MobileShell.NavigationPanel { } } } + + rightCornerAction: MobileShell.NavigationPanelAction { + id: keyboardToggleAction + visible: MobileShell.MobileShellSettings.keyboardButtonEnabled + enabled: Keyboards.KWinVirtualKeyboard.available + iconSource: "input-keyboard-virtual-symbolic" + iconSizeFactor: 0.75 + + onTriggered: { + if (Keyboards.KWinVirtualKeyboard.visible) { + Keyboards.KWinVirtualKeyboard.active = false; + } else { + Keyboards.KWinVirtualKeyboard.forceActivate(); + } + } + } } diff --git a/kcms/mobileshell/package/contents/ui/main.qml b/kcms/mobileshell/package/contents/ui/main.qml index 9edde815b..9c11aca7a 100644 --- a/kcms/mobileshell/package/contents/ui/main.qml +++ b/kcms/mobileshell/package/contents/ui/main.qml @@ -70,6 +70,7 @@ KCM.SimpleKCM { } MobileForm.FormSwitchDelegate { + id: gestureDelegate text: i18n("Gesture-only Mode") description: i18n("Whether to hide the navigation panel.") checked: !MobileShell.MobileShellSettings.navigationPanelEnabled @@ -79,6 +80,25 @@ KCM.SimpleKCM { } } } + + MobileForm.FormDelegateSeparator { + visible: MobileShell.MobileShellSettings.navigationPanelEnabled + above: gestureDelegate + below: keyboardButtonDelegate + } + + MobileForm.FormSwitchDelegate { + id: keyboardButtonDelegate + visible: MobileShell.MobileShellSettings.navigationPanelEnabled + text: i18n("Keyboard Toggle") + description: i18n("Whether to show a keyboard button on the navigation panel.") + checked: MobileShell.MobileShellSettings.keyboardButtonEnabled + onCheckedChanged: { + if (checked != MobileShell.MobileShellSettings.keyboardButtonEnabled) { + MobileShell.MobileShellSettings.keyboardButtonEnabled = checked; + } + } + } } } -- GitLab