From 8d441119e23fb5e6e8ec7d93bdc2fd5cc3f2d77c Mon Sep 17 00:00:00 2001 From: kugiigi Date: Wed, 14 Jul 2021 22:21:07 +0800 Subject: [PATCH 1/2] Added shortcut to toggle side stage --- qml/Components/KeyboardShortcutsOverlay.qml | 13 +++++++++++ qml/Stage/Stage.qml | 25 ++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/qml/Components/KeyboardShortcutsOverlay.qml b/qml/Components/KeyboardShortcutsOverlay.qml index 65eca6554b..4fe7af9b14 100644 --- a/qml/Components/KeyboardShortcutsOverlay.qml +++ b/qml/Components/KeyboardShortcutsOverlay.qml @@ -240,6 +240,19 @@ Rectangle { Layout.maximumWidth: maxTextSize } + Label { + text: i18n.tr("Super + S") + fontSize: "small" + font.weight: Font.Medium + } + Label { + text: i18n.tr("Shows or hides the side stage.") + fontSize: "small" + font.weight: Font.Light + wrapMode: Text.Wrap + Layout.maximumWidth: maxTextSize + } + Label { text: i18n.tr("Cursor Left or Right") fontSize: "small" diff --git a/qml/Stage/Stage.qml b/qml/Stage/Stage.qml index 8c97bc4497..f8f87e1501 100644 --- a/qml/Stage/Stage.qml +++ b/qml/Stage/Stage.qml @@ -206,6 +206,15 @@ FocusScope { onTriggered: priv.goneToSpread = true } + GlobalShortcut { + id: toggleSideStageShortcut + shortcut: Qt.MetaModifier|Qt.Key_S + active: priv.sideStageEnabled + onTriggered: { + priv.toggleSideStage() + } + } + GlobalShortcut { id: minimizeAllShortcut shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_D @@ -330,6 +339,15 @@ FocusScope { } } + function toggleSideStage() { + if (sideStage.shown) { + sideStage.hide(); + } else { + sideStage.show(); + updateMainAndSideStageIndexes() + } + } + function updateMainAndSideStageIndexes() { if (root.mode != "stagedWithSideStage") { priv.sideStageDelegate = null; @@ -2189,12 +2207,7 @@ FocusScope { } onClicked: { - if (sideStage.shown) { - sideStage.hide(); - } else { - sideStage.show(); - priv.updateMainAndSideStageIndexes() - } + priv.toggleSideStage() } onDragStarted: { From 2b7268433357c02cfbcfd4a7b478c6d331231a83 Mon Sep 17 00:00:00 2001 From: kugiigi Date: Thu, 15 Jul 2021 00:47:23 +0800 Subject: [PATCH 2/2] Add shortcut for moving apps between stages --- qml/Components/KeyboardShortcutsOverlay.qml | 49 +++++++++++++++------ qml/Stage/Stage.qml | 36 +++++++++++++-- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/qml/Components/KeyboardShortcutsOverlay.qml b/qml/Components/KeyboardShortcutsOverlay.qml index 4fe7af9b14..0db7934ce6 100644 --- a/qml/Components/KeyboardShortcutsOverlay.qml +++ b/qml/Components/KeyboardShortcutsOverlay.qml @@ -240,19 +240,6 @@ Rectangle { Layout.maximumWidth: maxTextSize } - Label { - text: i18n.tr("Super + S") - fontSize: "small" - font.weight: Font.Medium - } - Label { - text: i18n.tr("Shows or hides the side stage.") - fontSize: "small" - font.weight: Font.Light - wrapMode: Text.Wrap - Layout.maximumWidth: maxTextSize - } - Label { text: i18n.tr("Cursor Left or Right") fontSize: "small" @@ -341,6 +328,42 @@ Rectangle { wrapMode: Text.Wrap Layout.maximumWidth: maxTextSize } + + // Stages section + Item { Layout.columnSpan: 2; height: units.gu(2) } + Label { + Layout.columnSpan: 2 + text: i18n.tr("Stages") + font.weight: Font.Light + color: theme.palette.normal.baseText + lineHeight: 1.3 + } + + Label { + text: i18n.tr("Super + S") + fontSize: "small" + font.weight: Font.Medium + } + Label { + text: i18n.tr("Shows or hides the side stage.") + fontSize: "small" + font.weight: Font.Light + wrapMode: Text.Wrap + Layout.maximumWidth: maxTextSize + } + + Label { + text: i18n.tr("Ctrl + Super + Left or Right") + fontSize: "small" + font.weight: Font.Medium + } + Label { + text: i18n.tr("Moves app between main stage and side stage.") + fontSize: "small" + font.weight: Font.Light + wrapMode: Text.Wrap + Layout.maximumWidth: maxTextSize + } } Item { Layout.fillHeight: true; Layout.columnSpan: 2 } // spacer diff --git a/qml/Stage/Stage.qml b/qml/Stage/Stage.qml index f8f87e1501..fa7b8d8591 100644 --- a/qml/Stage/Stage.qml +++ b/qml/Stage/Stage.qml @@ -232,15 +232,43 @@ FocusScope { GlobalShortcut { id: maximizeWindowLeftShortcut shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Left - onTriggered: priv.focusedAppDelegate.requestMaximizeLeft() - active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight + onTriggered: { + switch (root.mode) { + case "stagedWithSideStage": + if (priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage) { + priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.MainStage); + priv.focusedAppDelegate.focus = true; + } + break; + case "windowed": + priv.focusedAppDelegate.requestMaximizeLeft() + break; + } + } + active: (root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight) + || (root.state == "stagedWithSideStage" && priv.focusedAppDelegate.stage == ApplicationInfoInterface.SideStage) } GlobalShortcut { id: maximizeWindowRightShortcut shortcut: Qt.MetaModifier|Qt.ControlModifier|Qt.Key_Right - onTriggered: priv.focusedAppDelegate.requestMaximizeRight() - active: root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight + onTriggered: { + switch (root.mode) { + case "stagedWithSideStage": + if (priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage) { + priv.focusedAppDelegate.saveStage(ApplicationInfoInterface.SideStage); + priv.focusedAppDelegate.focus = true; + sideStage.show(); + priv.updateMainAndSideStageIndexes() + } + break; + case "windowed": + priv.focusedAppDelegate.requestMaximizeRight() + break; + } + } + active: (root.state == "windowed" && priv.focusedAppDelegate && priv.focusedAppDelegate.canBeMaximizedLeftRight) + || (root.state == "stagedWithSideStage" && priv.focusedAppDelegate.stage == ApplicationInfoInterface.MainStage) } GlobalShortcut {