croll up homescreen when there are no tasks

This commit is contained in:
Marco Martin 2020-07-23 17:09:37 +02:00
parent daebf5ae60
commit ece092bf98
4 changed files with 29 additions and 9 deletions

View file

@ -25,6 +25,9 @@ QtObject {
id: delegate
signal resetHomeScreenPosition()
signal snapHomeScreenPosition()
signal requestHomeScreenPosition(real y)
property real homeScreenPosition: 0
property Item homeScreen
property QtObject homeScreenWindow
property bool homeScreenVisible: true

View file

@ -103,6 +103,12 @@ Item {
scrollAnim.to = 0;
scrollAnim.restart();
}
function onSnapHomeScreenPosition() {
mainFlickable.flick(0, 1);
}
function onRequestHomeScreenPosition(y) {
mainFlickable.contentY = y;
}
}
Timer {
@ -158,6 +164,8 @@ Item {
onFlickStarted: cancelEditModeForItemsRequested()
onFlickEnded: cancelEditModeForItemsRequested()
onContentYChanged: MobileShell.HomeScreenControls.homeScreenPosition = contentY
PlasmaComponents.ScrollBar.vertical: PlasmaComponents.ScrollBar {
id: scrollabr
opacity: mainFlickable.moving
@ -355,7 +363,7 @@ Item {
oldMouseY = mouse.y;
}
onReleased: {
mainFlickable.flick(0, 1)
mainFlickable.flick(0, 1);
}
}
Launcher.FavoriteStrip {

View file

@ -32,10 +32,11 @@ MouseArea {
property alias iconSource: icon.source
property bool checked
property bool checkable
property bool clickable
Rectangle {
radius: height/2
anchors.fill: parent
opacity: button.pressed ? 0.1 : 0
opacity: button.pressed && button.containsMouse && button.clickable ? 0.1 : 0
color: PlasmaCore.ColorScope.textColor
Behavior on opacity {
OpacityAnimator {
@ -48,7 +49,7 @@ MouseArea {
id: icon
anchors.fill: parent
colorGroup: PlasmaCore.ColorScope.colorGroup
enabled: button.enabled
enabled: button.enabled && button.clickable
}
onClicked: {
if (checkable) {

View file

@ -124,10 +124,14 @@ PlasmaCore.ColorScope {
taskSwitcher.offset = taskSwitcher.offset - (mouse.y - oldMouseY);
opening = oldMouseY > mouse.y;
oldMouseY = mouse.y;
if (taskSwitcher.visibility == Window.Hidden && taskSwitcher.offset > -taskSwitcher.height + units.gridUnit && taskSwitcher.tasksCount) {
taskSwitcher.showFullScreen();
//no tasks, let's scroll up the homescreen instead
} else if (taskSwitcher.tasksCount === 0) {
MobileShell.HomeScreenControls.requestHomeScreenPosition(MobileShell.HomeScreenControls.homeScreenPosition - (mouse.y - oldMouseY));
}
oldMouseY = mouse.y;
}
onReleased: {
if (!isDragging) {
@ -135,6 +139,9 @@ PlasmaCore.ColorScope {
}
if (taskSwitcher.visibility == Window.Hidden) {
if (taskSwitcher.tasksCount === 0) {
MobileShell.HomeScreenControls.snapHomeScreenPosition();
}
return;
}
if (opening) {
@ -195,9 +202,10 @@ PlasmaCore.ColorScope {
height: parent.height
width: parent.width/3
enabled: root.hasTasks
clickable: root.hasTasks && !taskSwitcher.visible
iconSource: "box"
onClicked: {
if (taskSwitcher.visible) {
if (!clickable) {
return;
}
plasmoid.nativeInterface.showDesktop = false;
@ -214,10 +222,10 @@ PlasmaCore.ColorScope {
width: parent.width/3
anchors.horizontalCenter: parent.horizontalCenter
iconSource: "start-here-kde"
enabled: taskSwitcher && taskSwitcher.tasksCount > 0
clickable: !taskSwitcher.visible && (root.showingApp || MobileShell.HomeScreenControls.homeScreenPosition != 0)
//checkable: true
onClicked: {
if (taskSwitcher.visible) {
if (!clickable) {
return;
}
root.minimizeAll();
@ -244,9 +252,9 @@ PlasmaCore.ColorScope {
anchors.right: parent.right
iconSource: "paint-none"
//FIXME:Qt.UserRole+9 is IsWindow Qt.UserRole+15 is IsClosable. We can't reach that enum from QML
opacity: plasmoid.nativeInterface.hasCloseableActiveWindow ? 1 : 0.4
clickable: plasmoid.nativeInterface.hasCloseableActiveWindow && !taskSwitcher.visible
onClicked: {
if (taskSwitcher.visible) {
if (!clickable) {
return;
}
if (!plasmoid.nativeInterface.hasCloseableActiveWindow) {