mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-03 18:24:46 +00:00
taskpanel: Refactor and cleanup
This commit is contained in:
parent
cb30fd1a06
commit
57175abcf4
1 changed files with 68 additions and 57 deletions
|
|
@ -87,6 +87,71 @@ PlasmaCore.ColorScope {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// navigation panel actions
|
||||||
|
MobileShell.NavigationPanelAction {
|
||||||
|
id: taskSwitcherAction
|
||||||
|
|
||||||
|
enabled: hasTasks || taskSwitcher.visible
|
||||||
|
iconSource: "mobile-task-switcher"
|
||||||
|
iconSizeFactor: 0.75
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
plasmoid.nativeInterface.showDesktop = false;
|
||||||
|
|
||||||
|
if (!taskSwitcher.visible) {
|
||||||
|
taskSwitcher.show(true);
|
||||||
|
} else {
|
||||||
|
// when task switcher is open
|
||||||
|
if (taskSwitcher.wasInActiveTask) {
|
||||||
|
// restore active window
|
||||||
|
taskSwitcher.activateWindow(root.currentTaskIndex);
|
||||||
|
} else {
|
||||||
|
taskSwitcher.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileShell.NavigationPanelAction {
|
||||||
|
id: homeAction
|
||||||
|
|
||||||
|
enabled: true
|
||||||
|
iconSource: "start-here-kde"
|
||||||
|
iconSizeFactor: 1
|
||||||
|
onTriggered: {
|
||||||
|
MobileShell.HomeScreenControls.openHomeScreen();
|
||||||
|
plasmoid.nativeInterface.allMinimizedChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MobileShell.NavigationPanelAction {
|
||||||
|
id: closeAppAction
|
||||||
|
|
||||||
|
enabled: MobileShell.KWinVirtualKeyboard.visible || taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow
|
||||||
|
// mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons
|
||||||
|
iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75
|
||||||
|
iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
|
||||||
|
|
||||||
|
onTriggered: {
|
||||||
|
if (MobileShell.KWinVirtualKeyboard.active) {
|
||||||
|
// close keyboard if it is open
|
||||||
|
MobileShell.KWinVirtualKeyboard.active = false;
|
||||||
|
} else if (taskSwitcher.visible) {
|
||||||
|
|
||||||
|
// if task switcher is open, close the current window shown
|
||||||
|
taskSwitcher.model.requestClose(taskSwitcher.model.index(taskSwitcher.currentTaskIndex, 0));
|
||||||
|
|
||||||
|
} else if (plasmoid.nativeInterface.hasCloseableActiveWindow) {
|
||||||
|
|
||||||
|
// if task switcher is closed, but there is an active window
|
||||||
|
var index = taskSwitcher.model.activeTask;
|
||||||
|
if (index) {
|
||||||
|
taskSwitcher.model.requestClose(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// bottom navigation panel
|
// bottom navigation panel
|
||||||
MobileShell.NavigationPanel {
|
MobileShell.NavigationPanel {
|
||||||
id: panel
|
id: panel
|
||||||
|
|
@ -106,63 +171,9 @@ PlasmaCore.ColorScope {
|
||||||
// also don't disable drag gesture mid-drag
|
// also don't disable drag gesture mid-drag
|
||||||
dragGestureEnabled: !taskSwitcher.visible || taskSwitcher.currentlyDragging
|
dragGestureEnabled: !taskSwitcher.visible || taskSwitcher.currentlyDragging
|
||||||
|
|
||||||
leftAction: MobileShell.NavigationPanelAction {
|
leftAction: taskSwitcherAction
|
||||||
enabled: hasTasks || taskSwitcher.visible
|
middleAction: homeAction
|
||||||
iconSource: "mobile-task-switcher"
|
rightAction: closeAppAction
|
||||||
iconSizeFactor: 0.75
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
plasmoid.nativeInterface.showDesktop = false;
|
|
||||||
|
|
||||||
if (!taskSwitcher.visible) {
|
|
||||||
taskSwitcher.show(true);
|
|
||||||
} else {
|
|
||||||
// when task switcher is open
|
|
||||||
if (taskSwitcher.wasInActiveTask) {
|
|
||||||
// restore active window
|
|
||||||
taskSwitcher.activateWindow(root.currentTaskIndex);
|
|
||||||
} else {
|
|
||||||
taskSwitcher.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
middleAction: MobileShell.NavigationPanelAction {
|
|
||||||
enabled: true
|
|
||||||
iconSource: "start-here-kde"
|
|
||||||
iconSizeFactor: 1
|
|
||||||
onTriggered: {
|
|
||||||
MobileShell.HomeScreenControls.openHomeScreen();
|
|
||||||
plasmoid.nativeInterface.allMinimizedChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rightAction: MobileShell.NavigationPanelAction {
|
|
||||||
enabled: MobileShell.KWinVirtualKeyboard.visible || taskSwitcher.visible || plasmoid.nativeInterface.hasCloseableActiveWindow
|
|
||||||
// mobile-close-app (from plasma-frameworks) seems to have less margins than icons from breeze-icons
|
|
||||||
iconSizeFactor: MobileShell.KWinVirtualKeyboard.visible ? 1 : 0.75
|
|
||||||
iconSource: MobileShell.KWinVirtualKeyboard.visible ? "go-down-symbolic" : "mobile-close-app"
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
if (MobileShell.KWinVirtualKeyboard.active) {
|
|
||||||
// close keyboard if it is open
|
|
||||||
MobileShell.KWinVirtualKeyboard.active = false;
|
|
||||||
} else if (taskSwitcher.visible) {
|
|
||||||
|
|
||||||
// if task switcher is open, close the current window shown
|
|
||||||
taskSwitcher.model.requestClose(taskSwitcher.model.index(taskSwitcher.currentTaskIndex, 0));
|
|
||||||
|
|
||||||
} else if (plasmoid.nativeInterface.hasCloseableActiveWindow) {
|
|
||||||
|
|
||||||
// if task switcher is closed, but there is an active window
|
|
||||||
var index = taskSwitcher.model.activeTask;
|
|
||||||
if (index) {
|
|
||||||
taskSwitcher.model.requestClose(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue