mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
different way to switch activities
limit usage of MouseEventListener to make things less glitchy
This commit is contained in:
parent
b79bb13450
commit
a198e597a3
2 changed files with 95 additions and 18 deletions
87
shell/contents/views/ActivityHandle.qml
Normal file
87
shell/contents/views/ActivityHandle.qml
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2014 Aaron Seigo <aseigo@kde.org>
|
||||
* Copyright 2017 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.6
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
MouseArea {
|
||||
id: handle
|
||||
z: 999
|
||||
|
||||
property bool mirrored: false
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
right: handle.mirrored ? parent.right : undefined
|
||||
left: handle.mirrored ? undefined : parent.left
|
||||
}
|
||||
width: units.gridUnit
|
||||
drag.target: nextActivityLabel
|
||||
drag.axis: Drag.XAxis
|
||||
property real position: (mirrored ? -1 : 1) * (nextActivityLabel.x + nextActivityLabel.width/2) / (parent.width/2)
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: nextActivityLabel
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: handle.mirrored ? handle.width : -width
|
||||
opacity: parent.position
|
||||
imagePath: "widgets/background"
|
||||
width: childrenRect.width + units.gridUnit*2
|
||||
height: childrenRect.height + units.gridUnit*2
|
||||
PlasmaComponents.Label {
|
||||
anchors.centerIn: parent
|
||||
text: handle.mirrored ? i18n("Go To Next Activity") : i18n("Go To Previous Activity")
|
||||
}
|
||||
}
|
||||
onPressed: {
|
||||
nextActivityLabel.x = handle.mirrored ? handle.width : -nextActivityLabel.width
|
||||
}
|
||||
onReleased: {
|
||||
if (position > 0.5) {
|
||||
if (handle.mirrored) {
|
||||
root.containmentsEnterFromRight = true;
|
||||
activitiesRepresentation.incrementCurrentIndex();
|
||||
} else {
|
||||
root.containmentsEnterFromRight = false;
|
||||
activitiesRepresentation.decrementCurrentIndex();
|
||||
}
|
||||
acceptAnim.running = true;
|
||||
} else {
|
||||
dismissAnim.running = true;
|
||||
}
|
||||
}
|
||||
OpacityAnimator {
|
||||
id: acceptAnim
|
||||
target: nextActivityLabel
|
||||
from: nextActivityLabel.opacity
|
||||
to: 0
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
XAnimator {
|
||||
id: dismissAnim
|
||||
target: nextActivityLabel
|
||||
from: nextActivityLabel.x
|
||||
to: handle.mirrored ? 0 : -nextActivityLabel.width
|
||||
duration: units.longDuration
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick 2.6
|
||||
import QtGraphicalEffects 1.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.shell 2.0 as Shell
|
||||
|
|
@ -28,7 +28,7 @@ import org.kde.kquickcontrolsaddons 2.0
|
|||
import org.kde.activities 0.1 as Activities
|
||||
import "../components"
|
||||
|
||||
MouseEventListener {
|
||||
Item {
|
||||
id: root
|
||||
width: 1080
|
||||
height: 1920
|
||||
|
|
@ -59,24 +59,14 @@ MouseEventListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
property int mouseDownX
|
||||
property int mouseDownY
|
||||
onPressed: {
|
||||
mouseDownX = mouse.x
|
||||
mouseDownY = mouse.y
|
||||
|
||||
ActivityHandle {
|
||||
mirrored: true
|
||||
}
|
||||
onReleased: {
|
||||
if (Math.abs(mouse.x - mouseDownX) < Math.abs(mouse.y - mouseDownY)) {
|
||||
return;
|
||||
}
|
||||
if (mouse.x - mouseDownX > root.width/6) {
|
||||
root.containmentsEnterFromRight = false;
|
||||
activitiesRepresentation.decrementCurrentIndex();
|
||||
} else if (mouse.x - mouseDownX < -root.width/6) {
|
||||
root.containmentsEnterFromRight = true;
|
||||
activitiesRepresentation.incrementCurrentIndex();
|
||||
}
|
||||
ActivityHandle {
|
||||
mirrored: false
|
||||
}
|
||||
|
||||
function toggleWidgetExplorer(containment) {
|
||||
console.log("Widget Explorer toggled");
|
||||
if (widgetExplorerStack.source != "") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue