Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Mobile
Commits
fc300d1a
Commit
fc300d1a
authored
May 03, 2022
by
Yari Polla
Browse files
taskswitcher: implement left/right swipe gesture
parent
26aaa808
Pipeline
#170999
passed with stage
in 1 minute and 7 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
components/mobileshell/qml/navigationpanel/NavigationGestureArea.qml
View file @
fc300d1a
...
...
@@ -21,11 +21,10 @@ Item {
id
:
root
property
var
taskSwitcher
MouseArea
{
id
:
mouseArea
anchors.fill
:
parent
drag.filterChildren
:
true
// drag gesture
property
int
oldMouseY
:
0
...
...
@@ -33,37 +32,36 @@ Item {
property
int
oldMouseX
:
0
property
int
startMouseX
:
0
property
bool
opening
:
false
enabled
:
!
taskSwitcher
.
visible
onPressed
:
{
startMouseX
=
oldMouseX
=
mouse
.
y
;
startMouseX
=
oldMouseX
=
mouse
.
x
;
startMouseY
=
oldMouseY
=
mouse
.
y
;
}
onPositionChanged
:
{
if
(
!
opening
&&
Math
.
abs
(
startMouseY
-
oldMouseY
)
<
root
.
height
)
{
oldMouseY
=
mouse
.
y
;
return
;
}
else
if
(
mouseArea
.
pressed
)
{
opening
=
true
;
}
if
(
root
.
taskSwitcher
.
visible
)
{
onPositionChanged
:
{
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
-
=
offsetX
;
taskSwitcher
.
taskSwitcherState
.
xPosition
=
taskSwitcher
.
taskSwitcherState
.
xPosition
-
offsetX
;
}
if
(
!
root
.
taskSwitcher
.
visible
&&
Math
.
abs
(
startMouseY
-
mouse
.
y
)
>
PlasmaCore
.
Units
.
gridUnit
&&
taskSwitcher
.
tasksCount
)
{
// start task switcher gesture
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
();
...
...
components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml
View file @
fc300d1a
...
...
@@ -62,6 +62,9 @@ QtObject {
// whether we are in a swipe up gesture to open the task switcher
property
bool
currentlyBeingOpened
:
false
// whether we are in a swipe left/right gesture to walk through tasks
property
bool
scrollingTasks
:
false
readonly
property
int
currentTaskIndex
:
{
let
candidateIndex
=
Math
.
round
(
-
xPosition
/
(
taskSpacing
+
taskWidth
));
return
Math
.
max
(
0
,
Math
.
min
(
taskSwitcher
.
tasksCount
-
1
,
candidateIndex
));
...
...
@@ -107,10 +110,10 @@ QtObject {
let
finalScale
=
Math
.
max
(
0
,
Math
.
min
(
maxScale
,
maxScale
-
subtract
));
// animate scale only if we are *not* opening from the homescreen
if
(
wasInActiveTask
||
!
currentlyBeingOpened
)
{
if
(
(
wasInActiveTask
||
!
currentlyBeingOpened
)
&&
!
scrollingTasks
)
{
return
finalScale
;
}
return
1
;
return
scrollingTasks
?
maxScale
:
1
;
}
// ~~ signals and functions ~~
...
...
@@ -159,7 +162,7 @@ QtObject {
cancelAnimations
();
// update vertical state
if
(
movingUp
||
root
.
yPosition
>=
openedYPosition
)
{
if
(
(
movingUp
||
root
.
yPosition
>=
openedYPosition
)
&&
!
scrollingTasks
)
{
// open task switcher and stay
openAnim
.
restart
();
}
else
{
...
...
@@ -197,20 +200,20 @@ QtObject {
easing.type
:
Easing
.
OutBack
}
property
var
openAnim
:
NumberAnimation
{
property
var
openAnim
:
NumberAnimation
{
target
:
root
property
:
"
yPosition
"
to
:
openedYPosition
to
:
openedYPosition
duration
:
MobileShell
.
MobileShellSettings
.
animationsEnabled
?
300
:
0
easing.type
:
Easing
.
OutBack
easing.type
:
Easing
.
OutBack
onFinished
:
{
root
.
currentlyBeingOpened
=
false
;
}
}
property
var
closeAnim
:
NumberAnimation
{
target
:
root
target
:
root
property
:
"
yPosition
"
to
:
0
duration
:
MobileShell
.
MobileShellSettings
.
animationsEnabled
?
PlasmaCore
.
Units
.
longDuration
:
0
...
...
@@ -218,8 +221,9 @@ QtObject {
onFinished
:
{
root
.
currentlyBeingOpened
=
false
;
scrollingTasks
=
false
;
taskSwitcher
.
instantHide
();
if
(
root
.
wasInActiveTask
)
{
taskSwitcher
.
setSingleActiveWindow
(
root
.
currentTaskIndex
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment