mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 22:33:08 +00:00
better autoscroll behavior
This commit is contained in:
parent
f9b30c1f95
commit
1efb009b5e
1 changed files with 77 additions and 26 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.1
|
import QtQuick 2.4
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
import org.kde.plasma.plasmoid 2.0
|
import org.kde.plasma.plasmoid 2.0
|
||||||
|
|
@ -115,12 +115,12 @@ MouseEventListener {
|
||||||
id: autoScrollTimer
|
id: autoScrollTimer
|
||||||
property bool scrollDown: true
|
property bool scrollDown: true
|
||||||
repeat: true
|
repeat: true
|
||||||
interval: 10
|
interval: 1500
|
||||||
onTriggered: {return;
|
onTriggered: {
|
||||||
applicationsView.contentY += scrollDown ? 8 : -8;
|
scrollAnim.to = scrollDown ?
|
||||||
if (applicationsView.dragData) {
|
Math.min(applicationsView.contentItem.height - applicationsView.headerItem.height - root.height, applicationsView.contentY + root.height/2) :
|
||||||
dragDelegate.updateRow();
|
Math.max(0, applicationsView.contentY - root.height/2);
|
||||||
}
|
scrollAnim.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,27 +186,31 @@ MouseEventListener {
|
||||||
|
|
||||||
dragDelegate.updateRow();
|
dragDelegate.updateRow();
|
||||||
|
|
||||||
if (!autoScrollTimer.running) {
|
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
||||||
|
//FAVORITES
|
||||||
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
if (applicationsView.headerItem.favoritesStrip.contains(pos)) {
|
||||||
//FAVORITES
|
autoScrollTimer.running = false;
|
||||||
if (applicationsView.headerItem.favoritesStrip.contains(pos)) {
|
scrollUpIndicator.opacity = 0;
|
||||||
autoScrollTimer.running = false;
|
scrollDownIndicator.opacity = 0;
|
||||||
//SCROLL UP
|
//SCROLL UP
|
||||||
} else if (applicationsView.contentY > 0 && mouse.y < root.buttonHeight + root.height / 4) {
|
} else if (applicationsView.contentY > 0 && mouse.y < root.buttonHeight + root.height / 4) {
|
||||||
autoScrollTimer.scrollDown = false;
|
autoScrollTimer.scrollDown = false;
|
||||||
autoScrollTimer.running = true;
|
autoScrollTimer.running = true;
|
||||||
//SCROLL DOWN
|
scrollUpIndicator.opacity = 1;
|
||||||
} else if (!applicationsView.atYEnd && mouse.y > 3 * (root.height / 4)) {
|
scrollDownIndicator.opacity = 0;
|
||||||
autoScrollTimer.scrollDown = true;
|
//SCROLL DOWN
|
||||||
autoScrollTimer.running = true;
|
} else if (!applicationsView.atYEnd && mouse.y > 3 * (root.height / 4)) {
|
||||||
//DON't SCROLL
|
autoScrollTimer.scrollDown = true;
|
||||||
} else {
|
autoScrollTimer.running = true;
|
||||||
autoScrollTimer.running = false;
|
scrollUpIndicator.opacity = 0;
|
||||||
}
|
scrollDownIndicator.opacity = 1;
|
||||||
|
//DON't SCROLL
|
||||||
} else {
|
} else {
|
||||||
autoScrollTimer.running = false;
|
autoScrollTimer.running = false;
|
||||||
|
scrollUpIndicator.opacity = 0;
|
||||||
|
scrollDownIndicator.opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
applicationsView.interactive = true;
|
applicationsView.interactive = true;
|
||||||
|
|
@ -215,6 +219,8 @@ MouseEventListener {
|
||||||
root.reorderingApps = false;
|
root.reorderingApps = false;
|
||||||
applicationsView.forceLayout();
|
applicationsView.forceLayout();
|
||||||
autoScrollTimer.running = false;
|
autoScrollTimer.running = false;
|
||||||
|
scrollUpIndicator.opacity = 0;
|
||||||
|
scrollDownIndicator.opacity = 0;
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var pos = mapToItem(applicationsView.contentItem, mouse.x, mouse.y);
|
var pos = mapToItem(applicationsView.contentItem, mouse.x, mouse.y);
|
||||||
|
|
@ -234,6 +240,51 @@ MouseEventListener {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaCore.Svg {
|
||||||
|
id: arrowsSvg
|
||||||
|
imagePath: "widgets/arrows"
|
||||||
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
}
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
id: scrollUpIndicator
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 200
|
||||||
|
}
|
||||||
|
z: 2
|
||||||
|
opacity: 0
|
||||||
|
svg: arrowsSvg
|
||||||
|
elementId: "up-arrow"
|
||||||
|
width: units.iconSizes.large
|
||||||
|
height: width
|
||||||
|
Behavior on opacity {
|
||||||
|
OpacityAnimator {
|
||||||
|
duration: 1000
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
id: scrollDownIndicator
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
z: 2
|
||||||
|
opacity: 0
|
||||||
|
svg: arrowsSvg
|
||||||
|
elementId: "down-arrow"
|
||||||
|
width: units.iconSizes.large
|
||||||
|
height: width
|
||||||
|
Behavior on opacity {
|
||||||
|
OpacityAnimator {
|
||||||
|
duration: 1000
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HomeLauncher {
|
HomeLauncher {
|
||||||
id: dragDelegate
|
id: dragDelegate
|
||||||
z: 999
|
z: 999
|
||||||
|
|
@ -425,7 +476,7 @@ MouseEventListener {
|
||||||
radius: width
|
radius: width
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
y: applicationsView.height * applicationsView.visibleArea.yPosition
|
y: applicationsView.height * applicationsView.visibleArea.yPosition
|
||||||
opacity: scrollbarMouse.pressed || applicationsView.flicking ? 0.8 : 0
|
opacity: scrollbarMouse.pressed || applicationsView.flicking || scrollDownIndicator.opacity > 0 || scrollUpIndicator.opacity > 0 ? 0.8 : 0
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: units.longDuration
|
duration: units.longDuration
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue