mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +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");
|
||||
|
||||
// /navigationpanel
|
||||
qmlRegisterType(resolvePath("navigationpanel/NavigationGestureArea.qml"), uri, 1, 0, "NavigationGestureArea");
|
||||
qmlRegisterType(resolvePath("navigationpanel/NavigationPanel.qml"), uri, 1, 0, "NavigationPanel");
|
||||
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 var foregroundColorGroup
|
||||
|
||||
property bool dragGestureEnabled: false
|
||||
property var taskSwitcher
|
||||
|
||||
property NavigationPanelAction leftAction
|
||||
property NavigationPanelAction middleAction
|
||||
property NavigationPanelAction rightAction
|
||||
|
|
@ -36,7 +33,7 @@ Item {
|
|||
property NavigationPanelAction rightCornerAction
|
||||
|
||||
DropShadow {
|
||||
anchors.fill: mouseArea
|
||||
anchors.fill: root
|
||||
visible: shadow
|
||||
cached: true
|
||||
horizontalOffset: 0
|
||||
|
|
@ -46,148 +43,73 @@ Item {
|
|||
color: Qt.rgba(0,0,0,0.8)
|
||||
source: icons
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
Item {
|
||||
id: icons
|
||||
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;
|
||||
}
|
||||
property real buttonLength: 0
|
||||
|
||||
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 {
|
||||
id: icons
|
||||
// background colour
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.backgroundColor
|
||||
}
|
||||
|
||||
property real buttonLength: 0
|
||||
|
||||
// background colour
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.backgroundColor
|
||||
}
|
||||
|
||||
// button row (anchors provided by state)
|
||||
NavigationPanelButton {
|
||||
id: leftButton
|
||||
visible: root.leftAction.visible
|
||||
mouseArea: mouseArea
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.leftAction.enabled
|
||||
iconSizeFactor: root.leftAction.iconSizeFactor
|
||||
iconSource: root.leftAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.leftAction.triggered();
|
||||
}
|
||||
// button row (anchors provided by state)
|
||||
NavigationPanelButton {
|
||||
id: leftButton
|
||||
visible: root.leftAction.visible
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.leftAction.enabled
|
||||
iconSizeFactor: root.leftAction.iconSizeFactor
|
||||
iconSource: root.leftAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.leftAction.triggered();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NavigationPanelButton {
|
||||
id: middleButton
|
||||
anchors.centerIn: parent
|
||||
visible: root.middleAction.visible
|
||||
mouseArea: mouseArea
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.middleAction.enabled
|
||||
iconSizeFactor: root.middleAction.iconSizeFactor
|
||||
iconSource: root.middleAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.middleAction.triggered();
|
||||
}
|
||||
NavigationPanelButton {
|
||||
id: middleButton
|
||||
anchors.centerIn: parent
|
||||
visible: root.middleAction.visible
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.middleAction.enabled
|
||||
iconSizeFactor: root.middleAction.iconSizeFactor
|
||||
iconSource: root.middleAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.middleAction.triggered();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NavigationPanelButton {
|
||||
id: rightButton
|
||||
visible: root.rightAction.visible
|
||||
mouseArea: mouseArea
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.rightAction.enabled
|
||||
iconSizeFactor: root.rightAction.iconSizeFactor
|
||||
iconSource: root.rightAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.rightAction.triggered();
|
||||
}
|
||||
NavigationPanelButton {
|
||||
id: rightButton
|
||||
visible: root.rightAction.visible
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.rightAction.enabled
|
||||
iconSizeFactor: root.rightAction.iconSizeFactor
|
||||
iconSource: root.rightAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.rightAction.triggered();
|
||||
}
|
||||
}
|
||||
|
||||
NavigationPanelButton {
|
||||
id: rightCornerButton
|
||||
visible: root.rightCornerAction.visible
|
||||
mouseArea: mouseArea
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.rightCornerAction.enabled
|
||||
iconSizeFactor: root.rightCornerAction.iconSizeFactor
|
||||
iconSource: root.rightCornerAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.rightCornerAction.triggered();
|
||||
}
|
||||
}
|
||||
|
||||
NavigationPanelButton {
|
||||
id: rightCornerButton
|
||||
visible: root.rightCornerAction.visible
|
||||
colorGroup: root.foregroundColorGroup
|
||||
enabled: root.rightCornerAction.enabled
|
||||
iconSizeFactor: root.rightCornerAction.iconSizeFactor
|
||||
iconSource: root.rightCornerAction.iconSource
|
||||
onClicked: {
|
||||
if (enabled) {
|
||||
root.rightCornerAction.triggered();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,25 +5,22 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls as Controls
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.kquickcontrolsaddons 2.0
|
||||
|
||||
Item {
|
||||
Controls.AbstractButton {
|
||||
id: button
|
||||
width: Math.min(parent.width, parent.height)
|
||||
height: width
|
||||
|
||||
property MouseArea mouseArea
|
||||
readonly property bool pressed: mouseArea.pressed && mouseArea.activeButton == button
|
||||
property double iconSizeFactor: 1
|
||||
property alias iconSource: icon.source
|
||||
property alias colorGroup: icon.colorGroup
|
||||
|
||||
signal clicked()
|
||||
|
||||
Rectangle {
|
||||
id: rect
|
||||
radius: height/2
|
||||
|
|
@ -64,6 +61,7 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
id: icon
|
||||
readonly property real side: Math.min(button.width, button.height)
|
||||
|
|
@ -72,6 +70,5 @@ Item {
|
|||
margins: Math.round((side - side * iconSizeFactor * 0.6) / 2)
|
||||
}
|
||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||
//enabled: button.enabled && button.clickable
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
<file>qml/homescreen/HomeScreen.qml</file>
|
||||
|
||||
<file>qml/navigationpanel/NavigationGestureArea.qml</file>
|
||||
<file>qml/navigationpanel/NavigationPanel.qml</file>
|
||||
<file>qml/navigationpanel/NavigationPanelAction.qml</file>
|
||||
<file>qml/navigationpanel/NavigationPanelButton.qml</file>
|
||||
|
|
|
|||
|
|
@ -26,10 +26,6 @@ MobileShell.NavigationPanel {
|
|||
foregroundColorGroup: opaqueBar ? PlasmaCore.Theme.NormalColorGroup : PlasmaCore.Theme.ComplementaryColorGroup
|
||||
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 {
|
||||
id: virtualDesktopInfo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ PlasmaCore.ColorScope {
|
|||
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component
|
||||
property: "visibilityMode"
|
||||
// 0 - VisibilityMode.NormalPanel
|
||||
// 3 - VisibilityMode.WindowsGoBelow
|
||||
value: MobileShell.MobileShellSettings.navigationPanelEnabled ? 0 : 3
|
||||
// 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 : 2
|
||||
}
|
||||
|
||||
// we have the following scenarios:
|
||||
|
|
@ -43,14 +43,12 @@ PlasmaCore.ColorScope {
|
|||
readonly property bool isInLandscapeNavPanelMode: inLandscape && MobileShell.MobileShellSettings.navigationPanelEnabled
|
||||
|
||||
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 intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShellState.TopPanelControls.panelHeight : 0; // offset for top panel
|
||||
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
|
||||
onIntendedWindowOffsetChanged: plasmoid.Window.window.offset = intendedWindowOffset
|
||||
onIntendedWindowLocationChanged: locationChangeTimer.restart()
|
||||
|
|
@ -78,10 +76,12 @@ PlasmaCore.ColorScope {
|
|||
|
||||
function setWindowProperties() {
|
||||
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component
|
||||
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
||||
plasmoid.Window.window.offset = intendedWindowOffset;
|
||||
plasmoid.Window.window.thickness = intendedWindowThickness;
|
||||
plasmoid.Window.window.location = intendedWindowLocation;
|
||||
if (plasmoid) {
|
||||
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
||||
plasmoid.Window.window.offset = intendedWindowOffset;
|
||||
plasmoid.Window.window.thickness = navigationPanelHeight;
|
||||
plasmoid.Window.window.location = intendedWindowLocation;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
@ -138,24 +138,13 @@ PlasmaCore.ColorScope {
|
|||
// contrasting colour
|
||||
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
|
||||
Loader {
|
||||
id: navigationLoader
|
||||
active: MobileShell.MobileShellSettings.navigationPanelEnabled
|
||||
anchors.fill: parent
|
||||
sourceComponent: MobileShell.MobileShellSettings.navigationPanelEnabled ? navigationPanel : navigationGesture
|
||||
sourceComponent: NavigationPanelComponent {
|
||||
opaqueBar: root.opaqueBar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue