Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Add shortcuts for side stage #404

Open
wants to merge 2 commits into
base: xenial
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions qml/Components/KeyboardShortcutsOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -328,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
Expand Down
61 changes: 51 additions & 10 deletions qml/Stage/Stage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -223,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 {
Expand Down Expand Up @@ -330,6 +367,15 @@ FocusScope {
}
}

function toggleSideStage() {
if (sideStage.shown) {
sideStage.hide();
} else {
sideStage.show();
updateMainAndSideStageIndexes()
}
}

function updateMainAndSideStageIndexes() {
if (root.mode != "stagedWithSideStage") {
priv.sideStageDelegate = null;
Expand Down Expand Up @@ -2189,12 +2235,7 @@ FocusScope {
}

onClicked: {
if (sideStage.shown) {
sideStage.hide();
} else {
sideStage.show();
priv.updateMainAndSideStageIndexes()
}
priv.toggleSideStage()
}

onDragStarted: {
Expand Down