Commit e6f47721 authored by Marco Martin's avatar Marco Martin
Browse files

don't move the handle on resize

also fix handle sizing, and don't hide when the mouse is over an handle button
BUG:332245
BUG:332695
parent a2f561ca
......@@ -32,7 +32,7 @@ Item {
anchors.rightMargin: -handleWidth*controlsOpacity
property int handleWidth: iconSize + 8 // 4 pixels margins inside handle
property int handleWidth: iconSize
property int minimumHandleHeight: 6 * (root.iconSize + 6) + margins.top + margins.bottom
property int handleHeight: (height < minimumHandleHeight) ? minimumHandleHeight : height
property string category
......@@ -100,11 +100,8 @@ Item {
id: mouseListener
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
fill: parent
}
height: handleHeight
width: parent.width+handleWidth;
z: 10
hoverEnabled: true
......@@ -120,14 +117,11 @@ Item {
animationsEnabled = true;
//print("Mouse is " + containsMouse);
if (!plasmoid.immutable && containsMouse) {
if (!plasmoid.immutable) {
if (!root.pressAndHoldHandle) {
hoverTracker.interval = root.handleDelay;
hoverTracker.restart();
}
} else {
hoverTracker.stop();
showAppletHandle = false;
}
}
......@@ -135,7 +129,13 @@ Item {
id: hoverTracker
repeat: false
interval: handleDelay
onTriggered: showAppletHandle = true;
onTriggered: {
if (mouseListener.containsMouse || (appletHandle.item && appletHandle.item.containsMouse)) {
showAppletHandle = true;
} else {
showAppletHandle = false;
}
}
}
Rectangle { color: Qt.rgba(0,0,0,0); border.width: 3; border.color: "red"; opacity: 0.5; visible: debug; anchors.fill: parent; }
......@@ -309,8 +309,7 @@ Item {
id: appletHandle
z: appletContainer.z + 1
anchors {
top: parent.top
bottom: parent.bottom
verticalCenter: parent.verticalCenter
right: plasmoidBackground.right
rightMargin: appletItem.margins.right
}
......
......@@ -22,20 +22,27 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
import "plasmapackage:/code/LayoutManager.js" as LayoutManager
Item {
KQuickControlsAddons.MouseEventListener {
id: appletHandle
opacity: appletItem.controlsOpacity
visible: opacity > 0
width: appletItem.handleWidth
height: Math.max(appletItem.height - appletItem.margins.top - appletItem.margins.bottom, buttonColumn.implicitHeight)
hoverEnabled: true
onContainsMouseChanged: {
if (!containsMouse) {
hoverTracker.restart()
}
}
//z: dragMouseArea.z + 1
property int buttonMargin: 6
property int minimumHeight: 6 * (root.iconSize + buttonMargin)
property Item buttonsParent: appletItem.handleMerged ? appletHandle : noBackgroundHandle
signal removeApplet
......@@ -48,9 +55,9 @@ Item {
visible: controlsOpacity > 0
z: plasmoidBackground.z - 10
height: (backgroundHints != "NoBackground") ? appletItem.handleHeight : appletItem.handleHeight + noBackgroundHandle.margins.top + noBackgroundHandle.margins.bottom
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
......@@ -68,14 +75,11 @@ Item {
ColumnLayout {
id: buttonColumn
width: handleWidth
parent: buttonsParent
anchors {
top: parent.top
topMargin: (!appletItem.hasBackground || !handleMerged) ? noBackgroundHandle.margins.top : appletItem.margins.top
bottom: parent.bottom
bottomMargin: (!appletItem.hasBackground && !handleMerged) ? noBackgroundHandle.margins.bottom : appletItem.margins.bottom
right: parent.right
rightMargin: appletItem.handleMerged ? -buttonMargin : noBackgroundHandle.margins.right - buttonMargin
}
spacing: buttonMargin*2
ActionButton {
......@@ -108,9 +112,11 @@ Item {
LayoutManager.setSpaceAvailable(appletItem.x, appletItem.y, appletItem.width, appletItem.height, true)
}
onPositionChanged: {
appletItem.width = Math.max(appletItem.minimumWidth, appletItem.width + mouse.x-startX)
appletItem.y = appletItem.y + (mouse.y-startY);
appletItem.width = Math.max(appletItem.minimumWidth, appletItem.width + mouse.x-startX);
var oldBottom = appletItem.y + appletItem.height;
appletItem.height = Math.max(appletItem.minimumHeight, appletItem.height + startY-mouse.y)
appletItem.y = oldBottom - appletItem.height;
}
onReleased: {
animationsEnabled = true
......@@ -228,9 +234,52 @@ Item {
}
//spacer
Item {
MouseArea {
id: dragMouseArea
implicitHeight: root.iconSize * 2
Layout.fillWidth: true
Layout.fillHeight: true
height: 0
property int lastX
property int lastY
property int zoffset: 1000
onPressed: {
appletItem.z = appletItem.z + zoffset;
animationsEnabled = false
mouse.accepted = true
var x = Math.round(appletItem.x/LayoutManager.cellSize.width)*LayoutManager.cellSize.width
var y = Math.round(appletItem.y/LayoutManager.cellSize.height)*LayoutManager.cellSize.height
LayoutManager.setSpaceAvailable(x, y, appletItem.width, appletItem.height, true)
var globalMousePos = mapToItem(root, mouse.x, mouse.y)
lastX = globalMousePos.x
lastY = globalMousePos.y
placeHolder.syncWithItem(appletItem)
placeHolderPaint.opacity = root.haloOpacity;
}
onPositionChanged: {
placeHolder.syncWithItem(appletItem)
var globalPos = mapToItem(root, x, y)
var globalMousePos = mapToItem(root, mouse.x, mouse.y)
appletItem.x += (globalMousePos.x - lastX)
appletItem.y += (globalMousePos.y - lastY)
lastX = globalMousePos.x
lastY = globalMousePos.y
}
onReleased: {
appletItem.z = appletItem.z - zoffset;
repositionTimer.running = false
placeHolderPaint.opacity = 0
animationsEnabled = true
LayoutManager.positionItem(appletItem)
LayoutManager.save()
}
}
ActionButton {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment