mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-27 22:33:08 +00:00
enable autoscroll for applets
This commit is contained in:
parent
7eb7fb1f32
commit
d4e675ec27
3 changed files with 77 additions and 32 deletions
|
|
@ -61,10 +61,9 @@ MouseEventListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = mapToItem(headerItem, mouse.x, mouse.y);
|
|
||||||
draggingApplet.y = mouse.y - draggingApplet.height/2;
|
draggingApplet.y = mouse.y - draggingApplet.height/2;
|
||||||
|
|
||||||
pos = mapToItem(appletsLayout, mouse.x, mouse.y);
|
var pos = mapToItem(appletsLayout, mouse.x, mouse.y);
|
||||||
var itemUnderMouse = appletsSpace.layout.childAt(pos.x, pos.y);
|
var itemUnderMouse = appletsSpace.layout.childAt(pos.x, pos.y);
|
||||||
|
|
||||||
if (itemUnderMouse && itemUnderMouse != dndSpacer) {
|
if (itemUnderMouse && itemUnderMouse != dndSpacer) {
|
||||||
|
|
@ -75,6 +74,18 @@ MouseEventListener {
|
||||||
LayoutManager.insertAfter(itemUnderMouse, dndSpacer);
|
LayoutManager.insertAfter(itemUnderMouse, dndSpacer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pos = mapToItem(root, mouse.x, mouse.y);
|
||||||
|
//SCROLL UP
|
||||||
|
if (applicationsView.contentY > -applicationsView.headerItem.height + root.height && pos.y < root.height/4) {
|
||||||
|
root.scrollUp();
|
||||||
|
//SCROLL DOWN
|
||||||
|
} else if (applicationsView.contentY < 0 && pos.y > 3 * (root.height / 4)) {
|
||||||
|
root.scrollDown();
|
||||||
|
//DON't SCROLL
|
||||||
|
} else {
|
||||||
|
root.stopScroll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
if (!draggingApplet) {
|
if (!draggingApplet) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transform: Translate {
|
transform: Translate {
|
||||||
y: root.locked ? -background.height : 0
|
y: root.locked || editOverlay.visible ? -background.height : 0
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: units.longDuration
|
duration: units.longDuration
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,15 @@ Item {
|
||||||
width: 480
|
width: 480
|
||||||
height: 640
|
height: 640
|
||||||
|
|
||||||
|
//BEGIN properties
|
||||||
property Item toolBox
|
property Item toolBox
|
||||||
property alias appletsSpace: applicationsView.headerItem
|
property alias appletsSpace: applicationsView.headerItem
|
||||||
property int buttonHeight: width/4
|
property int buttonHeight: width/4
|
||||||
property bool reorderingApps: false
|
property bool reorderingApps: false
|
||||||
property bool locked: applicationsView.contentY <= -applicationsView.headerItem.height + root.height
|
property bool locked: applicationsView.contentY <= -applicationsView.headerItem.height + root.height
|
||||||
|
//END properties
|
||||||
|
|
||||||
Containment.onAppletAdded: {
|
//BEGIN functions
|
||||||
addApplet(applet, x, y);
|
|
||||||
LayoutManager.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addApplet(applet, x, y) {
|
function addApplet(applet, x, y) {
|
||||||
var container = appletContainerComponent.createObject(appletsSpace.layout)
|
var container = appletContainerComponent.createObject(appletsSpace.layout)
|
||||||
container.visible = true
|
container.visible = true
|
||||||
|
|
@ -81,6 +79,29 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Autoscroll related functions
|
||||||
|
function scrollUp() {
|
||||||
|
autoScrollTimer.scrollDown = false;
|
||||||
|
autoScrollTimer.running = true;
|
||||||
|
scrollUpIndicator.opacity = 1;
|
||||||
|
scrollDownIndicator.opacity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollDown() {
|
||||||
|
autoScrollTimer.scrollDown = true;
|
||||||
|
autoScrollTimer.running = true;
|
||||||
|
scrollUpIndicator.opacity = 0;
|
||||||
|
scrollDownIndicator.opacity = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopScroll() {
|
||||||
|
autoScrollTimer.running = false;
|
||||||
|
scrollUpIndicator.opacity = 0;
|
||||||
|
scrollDownIndicator.opacity = 0;
|
||||||
|
}
|
||||||
|
//END functions
|
||||||
|
|
||||||
|
//BEGIN slots
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
LayoutManager.plasmoid = plasmoid;
|
LayoutManager.plasmoid = plasmoid;
|
||||||
LayoutManager.root = root;
|
LayoutManager.root = root;
|
||||||
|
|
@ -93,12 +114,18 @@ Item {
|
||||||
plasmoid.nativeInterface.applicationListModel.loadApplications();
|
plasmoid.nativeInterface.applicationListModel.loadApplications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Containment.onAppletAdded: {
|
||||||
|
addApplet(applet, x, y);
|
||||||
|
LayoutManager.save();
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: plasmoid.nativeInterface.applicationListModel
|
target: plasmoid.nativeInterface.applicationListModel
|
||||||
onAppOrderChanged: {
|
onAppOrderChanged: {
|
||||||
plasmoid.configuration.AppOrder = plasmoid.nativeInterface.applicationListModel.appOrder;
|
plasmoid.configuration.AppOrder = plasmoid.nativeInterface.applicationListModel.appOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//END slots
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: autoScrollTimer
|
id: autoScrollTimer
|
||||||
|
|
@ -106,9 +133,22 @@ Item {
|
||||||
repeat: true
|
repeat: true
|
||||||
interval: 1500
|
interval: 1500
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
//reordering launcher icons
|
||||||
|
if (root.reorderingApps) {
|
||||||
scrollAnim.to = scrollDown ?
|
scrollAnim.to = scrollDown ?
|
||||||
|
//Scroll down
|
||||||
Math.min(applicationsView.contentItem.height - applicationsView.headerItem.height - root.height, applicationsView.contentY + root.height/2) :
|
Math.min(applicationsView.contentItem.height - applicationsView.headerItem.height - root.height, applicationsView.contentY + root.height/2) :
|
||||||
|
//Scroll up
|
||||||
Math.max(0, applicationsView.contentY - root.height/2);
|
Math.max(0, applicationsView.contentY - root.height/2);
|
||||||
|
|
||||||
|
//reordering applets
|
||||||
|
} else {
|
||||||
|
scrollAnim.to = scrollDown ?
|
||||||
|
//Scroll down
|
||||||
|
Math.min(-root.height, applicationsView.contentY + root.height/2) :
|
||||||
|
//Scroll up
|
||||||
|
Math.max(-applicationsView.headerItem.height + root.height, applicationsView.contentY - root.height/2);
|
||||||
|
}
|
||||||
scrollAnim.running = true;
|
scrollAnim.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,13 +224,12 @@ Item {
|
||||||
topMargin: plasmoid.availableScreenRect.y
|
topMargin: plasmoid.availableScreenRect.y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EditOverlay {
|
|
||||||
id: editOverlay
|
|
||||||
z: 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseEventListener {
|
MouseEventListener {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
//Events handling: those events are about clicking and reordering of app icons
|
||||||
|
//applet related events are in AppeltsArea.qml
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
||||||
//in favorites area?
|
//in favorites area?
|
||||||
|
|
@ -245,26 +284,16 @@ Item {
|
||||||
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
var pos = mapToItem(applicationsView.headerItem.favoritesStrip, mouse.x, mouse.y);
|
||||||
//FAVORITES
|
//FAVORITES
|
||||||
if (applicationsView.headerItem.favoritesStrip.contains(pos)) {
|
if (applicationsView.headerItem.favoritesStrip.contains(pos)) {
|
||||||
autoScrollTimer.running = false;
|
root.stopScroll();
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
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;
|
root.scrollUp();
|
||||||
autoScrollTimer.running = true;
|
|
||||||
scrollUpIndicator.opacity = 1;
|
|
||||||
scrollDownIndicator.opacity = 0;
|
|
||||||
//SCROLL DOWN
|
//SCROLL DOWN
|
||||||
} else if (!applicationsView.atYEnd && mouse.y > 3 * (root.height / 4)) {
|
} else if (!applicationsView.atYEnd && mouse.y > 3 * (root.height / 4)) {
|
||||||
autoScrollTimer.scrollDown = true;
|
root.scrollDown();
|
||||||
autoScrollTimer.running = true;
|
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
scrollDownIndicator.opacity = 1;
|
|
||||||
//DON't SCROLL
|
//DON't SCROLL
|
||||||
} else {
|
} else {
|
||||||
autoScrollTimer.running = false;
|
root.stopScroll();
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
scrollDownIndicator.opacity = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -283,9 +312,7 @@ Item {
|
||||||
applicationsView.dragData = null;
|
applicationsView.dragData = null;
|
||||||
root.reorderingApps = false;
|
root.reorderingApps = false;
|
||||||
applicationsView.forceLayout();
|
applicationsView.forceLayout();
|
||||||
autoScrollTimer.running = false;
|
root.stopScroll();
|
||||||
scrollUpIndicator.opacity = 0;
|
|
||||||
scrollDownIndicator.opacity = 0;
|
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (krunner.showingResults) {
|
if (krunner.showingResults) {
|
||||||
|
|
@ -323,6 +350,10 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditOverlay {
|
||||||
|
id: editOverlay
|
||||||
|
z: 2
|
||||||
|
}
|
||||||
PlasmaCore.Svg {
|
PlasmaCore.Svg {
|
||||||
id: arrowsSvg
|
id: arrowsSvg
|
||||||
imagePath: "widgets/arrows"
|
imagePath: "widgets/arrows"
|
||||||
|
|
@ -353,6 +384,7 @@ Item {
|
||||||
anchors {
|
anchors {
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
bottomMargin: units.gridUnit * 2
|
||||||
}
|
}
|
||||||
z: 2
|
z: 2
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
@ -368,6 +400,8 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This HomeLauncher is the placeholder for the "drag"
|
||||||
|
//delegate (that is not actual drag and drop
|
||||||
HomeLauncher {
|
HomeLauncher {
|
||||||
id: dragDelegate
|
id: dragDelegate
|
||||||
z: 999
|
z: 999
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue