drag applets from the place they are, not the cursor

fix applet transparency when they are dragged out of
the screen to delete them
This commit is contained in:
Marco Martin 2015-09-15 19:12:39 +02:00
parent d4d7c4e7bc
commit baae0fb1ce
3 changed files with 14 additions and 14 deletions

View file

@ -36,6 +36,8 @@ MouseEventListener {
property Item draggingApplet
property int startMouseX
property int startMouseY
property int oldMouseX
property int oldMouseY
SequentialAnimation {
id: removeAnim
@ -56,6 +58,8 @@ MouseEventListener {
onPressed: {
startMouseX = mouse.screenX;
startMouseY = mouse.screenY;
oldMouseX = mouse.screenX;
oldMouseY = mouse.screenY;
}
onPressAndHold: {
print(favoritesView.contains(mapToItem(favoritesView, mouse.x, mouse.y)))
@ -82,13 +86,16 @@ MouseEventListener {
return;
}
applicationsView.interactive = false;
if (Math.abs(mouse.screenX - startMouseX) > units.gridUnit ||
Math.abs(mouse.screenY - startMouseY) > units.gridUnit) {
editOverlay.opacity = 0;
}
draggingApplet.y = mouse.y - draggingApplet.height/2;
draggingApplet.x = mouse.x - draggingApplet.width/2;
draggingApplet.x -= oldMouseX - mouse.screenX;
draggingApplet.y -= oldMouseY - mouse.screenY;
oldMouseX = mouse.screenX;
oldMouseY = mouse.screenY;
var pos = mapToItem(appletsLayout, mouse.x, mouse.y);
var itemUnderMouse = appletsSpace.layout.childAt(pos.x, pos.y);
@ -119,10 +126,9 @@ MouseEventListener {
return;
}
if (draggingApplet.x > -draggingApplet.width/4 && draggingApplet.x < draggingApplet.width/4) {
if (draggingApplet.x > -draggingApplet.width/3 && draggingApplet.x < draggingApplet.width/3) {
draggingApplet.x = 0;
root.layoutManager.insertBefore( dndSpacer, draggingApplet);
draggingApplet.animationsEnabled = true;
} else {
removeAnim.target = draggingApplet;
removeAnim.to = (draggingApplet.x > 0) ? root.width : -root.width
@ -184,13 +190,6 @@ MouseEventListener {
easing.type: Easing.InOutQuad
}
}
add: Transition {
NumberAnimation {
properties: "x,y"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
Item {
id: dndSpacer

View file

@ -81,7 +81,7 @@ Rectangle {
top: parent.top
topMargin: parent.margins.top
}
PlasmaComponents.Button {
PlasmaComponents.ToolButton {
Layout.fillWidth: true
Layout.fillHeight:true
text: i18n("Wallpaper...")
@ -90,7 +90,7 @@ Rectangle {
editOverlay.opacity = 0;
}
}
PlasmaComponents.Button {
PlasmaComponents.ToolButton {
Layout.fillWidth: true
Layout.fillHeight:true
text: i18n("Add Widgets...")

View file

@ -170,7 +170,7 @@ Item {
property bool animationsEnabled: true
property Item applet
z: applet && applet.compactRepresentationItem && applet.expanded ? 99 : 0
opacity: 1/Math.abs(x/(width/2))
opacity: 1 - Math.abs(x/(width/2))
Layout.fillWidth: true
Layout.fillHeight: applet && applet.Layout.fillHeight
@ -257,6 +257,7 @@ Item {
z: 999
}
MouseEventListener {
id: mainListener
anchors.fill: parent
//Events handling: those events are about clicking and reordering of app icons