mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-01 09:18:07 +00:00
taskpanel: Cleanup remnants of old task switcher
This commit is contained in:
parent
c5434eae26
commit
9e8838834b
7 changed files with 73 additions and 240 deletions
|
|
@ -75,7 +75,6 @@ void MobileShellPlugin::registerTypes(const char *uri)
|
||||||
qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "HomeScreen");
|
qmlRegisterType(resolvePath("homescreen/HomeScreen.qml"), uri, 1, 0, "HomeScreen");
|
||||||
|
|
||||||
// /navigationpanel
|
// /navigationpanel
|
||||||
qmlRegisterType(resolvePath("navigationpanel/NavigationGestureArea.qml"), uri, 1, 0, "NavigationGestureArea");
|
|
||||||
qmlRegisterType(resolvePath("navigationpanel/NavigationPanel.qml"), uri, 1, 0, "NavigationPanel");
|
qmlRegisterType(resolvePath("navigationpanel/NavigationPanel.qml"), uri, 1, 0, "NavigationPanel");
|
||||||
qmlRegisterType(resolvePath("navigationpanel/NavigationPanelAction.qml"), uri, 1, 0, "NavigationPanelAction");
|
qmlRegisterType(resolvePath("navigationpanel/NavigationPanelAction.qml"), uri, 1, 0, "NavigationPanelAction");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
||||||
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.4
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
import QtQuick.Window 2.2
|
|
||||||
import Qt5Compat.GraphicalEffects
|
|
||||||
|
|
||||||
import org.kde.taskmanager 0.1 as TaskManager
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
import org.kde.kquickcontrolsaddons 2.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property var taskSwitcher
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
// drag gesture
|
|
||||||
property int oldMouseY: 0
|
|
||||||
property int startMouseY: 0
|
|
||||||
property int oldMouseX: 0
|
|
||||||
property int startMouseX: 0
|
|
||||||
property bool opening: false
|
|
||||||
|
|
||||||
enabled: !taskSwitcher.visible
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
|
||||||
startMouseX = oldMouseX = mouse.x;
|
|
||||||
startMouseY = oldMouseY = mouse.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
|
||||||
if (root.taskSwitcher.visible || taskSwitcher.taskSwitcherState.currentlyBeingOpened) {
|
|
||||||
// update task switcher drag
|
|
||||||
let offsetY = (mouse.y - oldMouseY) * 0.5; // we want to make the gesture take a longer swipe than it being pixel perfect
|
|
||||||
let offsetX = (mouse.x - oldMouseX) * 0.7; // we want to make the gesture not too hard to swipe, but not too easy
|
|
||||||
taskSwitcher.taskSwitcherState.yPosition = Math.max(0, taskSwitcher.taskSwitcherState.yPosition - offsetY);
|
|
||||||
taskSwitcher.taskSwitcherState.xPosition = taskSwitcher.taskSwitcherState.xPosition - offsetX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!root.taskSwitcher.visible && Math.abs(startMouseX - mouse.x) > PlasmaCore.Units.gridUnit && taskSwitcher.tasksCount && taskSwitcher.tasksModel.activeTask.row >= 0){
|
|
||||||
// start switch task gesture
|
|
||||||
taskSwitcher.taskSwitcherState.scrollingTasks = true;
|
|
||||||
root.taskSwitcher.show(false);
|
|
||||||
} else if (!root.taskSwitcher.visible && Math.abs(startMouseY - mouse.y) > PlasmaCore.Units.gridUnit && taskSwitcher.tasksCount) {
|
|
||||||
// start task switcher opening gesture
|
|
||||||
root.taskSwitcher.show(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
oldMouseY = mouse.y;
|
|
||||||
oldMouseX = mouse.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: {
|
|
||||||
if (taskSwitcher.taskSwitcherState.currentlyBeingOpened) {
|
|
||||||
taskSwitcher.taskSwitcherState.updateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -25,9 +25,6 @@ Item {
|
||||||
property color backgroundColor
|
property color backgroundColor
|
||||||
property var foregroundColorGroup
|
property var foregroundColorGroup
|
||||||
|
|
||||||
property bool dragGestureEnabled: false
|
|
||||||
property var taskSwitcher
|
|
||||||
|
|
||||||
property NavigationPanelAction leftAction
|
property NavigationPanelAction leftAction
|
||||||
property NavigationPanelAction middleAction
|
property NavigationPanelAction middleAction
|
||||||
property NavigationPanelAction rightAction
|
property NavigationPanelAction rightAction
|
||||||
|
|
@ -36,7 +33,7 @@ Item {
|
||||||
property NavigationPanelAction rightCornerAction
|
property NavigationPanelAction rightCornerAction
|
||||||
|
|
||||||
DropShadow {
|
DropShadow {
|
||||||
anchors.fill: mouseArea
|
anchors.fill: root
|
||||||
visible: shadow
|
visible: shadow
|
||||||
cached: true
|
cached: true
|
||||||
horizontalOffset: 0
|
horizontalOffset: 0
|
||||||
|
|
@ -47,76 +44,6 @@ Item {
|
||||||
source: icons
|
source: icons
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
drag.filterChildren: true
|
|
||||||
|
|
||||||
// drag gesture
|
|
||||||
property int oldMouseY: 0
|
|
||||||
property int startMouseY: 0
|
|
||||||
property int oldMouseX: 0
|
|
||||||
property int startMouseX: 0
|
|
||||||
property bool opening: false
|
|
||||||
|
|
||||||
property NavigationPanelButton activeButton
|
|
||||||
|
|
||||||
Components.HapticsEffectLoader {
|
|
||||||
id: haptics
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
|
||||||
startMouseX = oldMouseX = mouse.y;
|
|
||||||
startMouseY = oldMouseY = mouse.y;
|
|
||||||
activeButton = icons.childAt(mouse.x, mouse.y);
|
|
||||||
if (activeButton && activeButton.enabled) {
|
|
||||||
haptics.buttonVibrate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
|
||||||
let newButton = icons.childAt(mouse.x, mouse.y);
|
|
||||||
if (newButton != activeButton) {
|
|
||||||
activeButton = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.dragGestureEnabled) {
|
|
||||||
if (!opening && Math.abs(startMouseY - oldMouseY) < root.height) {
|
|
||||||
oldMouseY = mouse.y;
|
|
||||||
return;
|
|
||||||
} else if (mouseArea.pressed) {
|
|
||||||
opening = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.taskSwitcher.visible) {
|
|
||||||
// update task switcher drag
|
|
||||||
let offsetY = (mouse.y - oldMouseY) * 0.5; // we want to make the gesture take a longer swipe than it being pixel perfect
|
|
||||||
let offsetX = (mouse.x - oldMouseX) * 0.7; // we want to make the gesture not too hard to swipe, but not too easy
|
|
||||||
taskSwitcher.taskSwitcherState.yPosition = Math.max(0, taskSwitcher.taskSwitcherState.yPosition - offsetY);
|
|
||||||
taskSwitcher.taskSwitcherState.xPosition -= offsetX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!root.taskSwitcher.visible && Math.abs(startMouseY - mouse.y) > PlasmaCore.Units.gridUnit && taskSwitcher.tasksCount) {
|
|
||||||
// start task switcher gesture
|
|
||||||
activeButton = null;
|
|
||||||
root.taskSwitcher.show(false);
|
|
||||||
} else if (taskSwitcher.tasksCount === 0) { // no tasks, let's scroll up the homescreen instead
|
|
||||||
MobileShellState.HomeScreenControls.requestRelativeScroll(Qt.point(mouse.x - oldMouseX, mouse.y - oldMouseY));
|
|
||||||
}
|
|
||||||
|
|
||||||
oldMouseY = mouse.y;
|
|
||||||
oldMouseX = mouse.x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onReleased: {
|
|
||||||
if (activeButton) {
|
|
||||||
activeButton.clicked();
|
|
||||||
} else if (root.dragGestureEnabled && taskSwitcher.taskSwitcherState.currentlyBeingOpened) {
|
|
||||||
taskSwitcher.taskSwitcherState.updateState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: icons
|
id: icons
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -133,7 +60,6 @@ Item {
|
||||||
NavigationPanelButton {
|
NavigationPanelButton {
|
||||||
id: leftButton
|
id: leftButton
|
||||||
visible: root.leftAction.visible
|
visible: root.leftAction.visible
|
||||||
mouseArea: mouseArea
|
|
||||||
colorGroup: root.foregroundColorGroup
|
colorGroup: root.foregroundColorGroup
|
||||||
enabled: root.leftAction.enabled
|
enabled: root.leftAction.enabled
|
||||||
iconSizeFactor: root.leftAction.iconSizeFactor
|
iconSizeFactor: root.leftAction.iconSizeFactor
|
||||||
|
|
@ -149,7 +75,6 @@ Item {
|
||||||
id: middleButton
|
id: middleButton
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: root.middleAction.visible
|
visible: root.middleAction.visible
|
||||||
mouseArea: mouseArea
|
|
||||||
colorGroup: root.foregroundColorGroup
|
colorGroup: root.foregroundColorGroup
|
||||||
enabled: root.middleAction.enabled
|
enabled: root.middleAction.enabled
|
||||||
iconSizeFactor: root.middleAction.iconSizeFactor
|
iconSizeFactor: root.middleAction.iconSizeFactor
|
||||||
|
|
@ -164,7 +89,6 @@ Item {
|
||||||
NavigationPanelButton {
|
NavigationPanelButton {
|
||||||
id: rightButton
|
id: rightButton
|
||||||
visible: root.rightAction.visible
|
visible: root.rightAction.visible
|
||||||
mouseArea: mouseArea
|
|
||||||
colorGroup: root.foregroundColorGroup
|
colorGroup: root.foregroundColorGroup
|
||||||
enabled: root.rightAction.enabled
|
enabled: root.rightAction.enabled
|
||||||
iconSizeFactor: root.rightAction.iconSizeFactor
|
iconSizeFactor: root.rightAction.iconSizeFactor
|
||||||
|
|
@ -179,7 +103,6 @@ Item {
|
||||||
NavigationPanelButton {
|
NavigationPanelButton {
|
||||||
id: rightCornerButton
|
id: rightCornerButton
|
||||||
visible: root.rightCornerAction.visible
|
visible: root.rightCornerAction.visible
|
||||||
mouseArea: mouseArea
|
|
||||||
colorGroup: root.foregroundColorGroup
|
colorGroup: root.foregroundColorGroup
|
||||||
enabled: root.rightCornerAction.enabled
|
enabled: root.rightCornerAction.enabled
|
||||||
iconSizeFactor: root.rightCornerAction.iconSizeFactor
|
iconSizeFactor: root.rightCornerAction.iconSizeFactor
|
||||||
|
|
@ -191,7 +114,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,22 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls as Controls
|
||||||
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.kquickcontrolsaddons 2.0
|
import org.kde.kquickcontrolsaddons 2.0
|
||||||
|
|
||||||
Item {
|
Controls.AbstractButton {
|
||||||
id: button
|
id: button
|
||||||
width: Math.min(parent.width, parent.height)
|
width: Math.min(parent.width, parent.height)
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
property MouseArea mouseArea
|
|
||||||
readonly property bool pressed: mouseArea.pressed && mouseArea.activeButton == button
|
|
||||||
property double iconSizeFactor: 1
|
property double iconSizeFactor: 1
|
||||||
property alias iconSource: icon.source
|
property alias iconSource: icon.source
|
||||||
property alias colorGroup: icon.colorGroup
|
property alias colorGroup: icon.colorGroup
|
||||||
|
|
||||||
signal clicked()
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: rect
|
id: rect
|
||||||
radius: height/2
|
radius: height/2
|
||||||
|
|
@ -64,6 +61,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
id: icon
|
id: icon
|
||||||
readonly property real side: Math.min(button.width, button.height)
|
readonly property real side: Math.min(button.width, button.height)
|
||||||
|
|
@ -72,6 +70,5 @@ Item {
|
||||||
margins: Math.round((side - side * iconSizeFactor * 0.6) / 2)
|
margins: Math.round((side - side * iconSizeFactor * 0.6) / 2)
|
||||||
}
|
}
|
||||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||||
//enabled: button.enabled && button.clickable
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
<file>qml/homescreen/HomeScreen.qml</file>
|
<file>qml/homescreen/HomeScreen.qml</file>
|
||||||
|
|
||||||
<file>qml/navigationpanel/NavigationGestureArea.qml</file>
|
|
||||||
<file>qml/navigationpanel/NavigationPanel.qml</file>
|
<file>qml/navigationpanel/NavigationPanel.qml</file>
|
||||||
<file>qml/navigationpanel/NavigationPanelAction.qml</file>
|
<file>qml/navigationpanel/NavigationPanelAction.qml</file>
|
||||||
<file>qml/navigationpanel/NavigationPanelButton.qml</file>
|
<file>qml/navigationpanel/NavigationPanelButton.qml</file>
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,6 @@ MobileShell.NavigationPanel {
|
||||||
foregroundColorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
foregroundColorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
shadow: !opaqueBar
|
shadow: !opaqueBar
|
||||||
|
|
||||||
// do not enable drag gesture when task switcher is already open
|
|
||||||
// also don't disable drag gesture mid-drag
|
|
||||||
dragGestureEnabled: false // !root.taskSwitcher.visible || root.taskSwitcher.taskSwitcherState.currentlyBeingOpened
|
|
||||||
|
|
||||||
TaskManager.VirtualDesktopInfo {
|
TaskManager.VirtualDesktopInfo {
|
||||||
id: virtualDesktopInfo
|
id: virtualDesktopInfo
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ PlasmaCore.ColorScope {
|
||||||
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component
|
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component
|
||||||
property: "visibilityMode"
|
property: "visibilityMode"
|
||||||
// 0 - VisibilityMode.NormalPanel
|
// 0 - VisibilityMode.NormalPanel
|
||||||
// 3 - VisibilityMode.WindowsGoBelow
|
// 2 - VisibilityMode.LetWindowsCover HACK: TODO one day we make delete the panel component instead of making it invisible in gesture-only mode
|
||||||
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? 0 : 3
|
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? 0 : 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have the following scenarios:
|
// we have the following scenarios:
|
||||||
|
|
@ -43,14 +43,12 @@ PlasmaCore.ColorScope {
|
||||||
readonly property bool isInLandscapeNavPanelMode: inLandscape && MobileShell.MobileShellSettings.navigationPanelEnabled
|
readonly property bool isInLandscapeNavPanelMode: inLandscape && MobileShell.MobileShellSettings.navigationPanelEnabled
|
||||||
|
|
||||||
readonly property real navigationPanelHeight: PlasmaCore.Units.gridUnit * 2
|
readonly property real navigationPanelHeight: PlasmaCore.Units.gridUnit * 2
|
||||||
readonly property real gesturePanelHeight: 8
|
|
||||||
|
|
||||||
readonly property real intendedWindowThickness: MobileShell.MobileShellSettings.navigationPanelEnabled ? navigationPanelHeight : gesturePanelHeight
|
readonly property real intendedWindowThickness: navigationPanelHeight
|
||||||
readonly property real intendedWindowLength: isInLandscapeNavPanelMode ? Screen.height : Screen.width
|
readonly property real intendedWindowLength: isInLandscapeNavPanelMode ? Screen.height : Screen.width
|
||||||
readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShellState.TopPanelControls.panelHeight : 0; // offset for top panel
|
readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShellState.TopPanelControls.panelHeight : 0; // offset for top panel
|
||||||
readonly property int intendedWindowLocation: isInLandscapeNavPanelMode ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
|
readonly property int intendedWindowLocation: isInLandscapeNavPanelMode ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
|
||||||
|
|
||||||
onIntendedWindowThicknessChanged: plasmoid.Window.window.thickness = intendedWindowThickness
|
|
||||||
onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
|
onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
|
||||||
onIntendedWindowOffsetChanged: plasmoid.Window.window.offset = intendedWindowOffset
|
onIntendedWindowOffsetChanged: plasmoid.Window.window.offset = intendedWindowOffset
|
||||||
onIntendedWindowLocationChanged: locationChangeTimer.restart()
|
onIntendedWindowLocationChanged: locationChangeTimer.restart()
|
||||||
|
|
@ -78,11 +76,13 @@ PlasmaCore.ColorScope {
|
||||||
|
|
||||||
function setWindowProperties() {
|
function setWindowProperties() {
|
||||||
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component
|
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component
|
||||||
|
if (plasmoid) {
|
||||||
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
||||||
plasmoid.Window.window.offset = intendedWindowOffset;
|
plasmoid.Window.window.offset = intendedWindowOffset;
|
||||||
plasmoid.Window.window.thickness = intendedWindowThickness;
|
plasmoid.Window.window.thickness = navigationPanelHeight;
|
||||||
plasmoid.Window.window.location = intendedWindowLocation;
|
plasmoid.Window.window.location = intendedWindowLocation;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: plasmoid.Window.window
|
target: plasmoid.Window.window
|
||||||
|
|
@ -138,24 +138,13 @@ PlasmaCore.ColorScope {
|
||||||
// contrasting colour
|
// contrasting colour
|
||||||
colorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
colorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
|
||||||
// bottom navigation panel component
|
|
||||||
Component {
|
|
||||||
id: navigationPanel
|
|
||||||
NavigationPanelComponent {
|
|
||||||
opaqueBar: root.opaqueBar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// bottom navigation gesture area component
|
|
||||||
Component {
|
|
||||||
id: navigationGesture
|
|
||||||
MobileShell.NavigationGestureArea {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// load appropriate system navigation component
|
// load appropriate system navigation component
|
||||||
Loader {
|
Loader {
|
||||||
id: navigationLoader
|
id: navigationLoader
|
||||||
|
active: MobileShell.MobileShellSettings.navigationPanelEnabled
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: MobileShell.MobileShellSettings.navigationPanelEnabled ? navigationPanel : navigationGesture
|
sourceComponent: NavigationPanelComponent {
|
||||||
|
opaqueBar: root.opaqueBar
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue