|
|
|
@ -19,6 +19,7 @@
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
|
|
|
|
|
import org.kde.latte 0.2 as Latte
|
|
|
|
@ -27,11 +28,57 @@ Item {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: relevantItem
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
|
|
Item{
|
|
|
|
|
id: clickedCenter
|
|
|
|
|
|
|
|
|
|
readonly property int center: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.width/2 : parent.height/2
|
|
|
|
|
|
|
|
|
|
states:[
|
|
|
|
|
State {
|
|
|
|
|
name: "bottom"
|
|
|
|
|
when: (plasmoid.location === PlasmaCore.Types.BottomEdge)
|
|
|
|
|
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: clickedCenter
|
|
|
|
|
anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined;
|
|
|
|
|
horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "left"
|
|
|
|
|
when: (plasmoid.location === PlasmaCore.Types.LeftEdge)
|
|
|
|
|
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: clickedCenter
|
|
|
|
|
anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined;
|
|
|
|
|
horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "right"
|
|
|
|
|
when: (plasmoid.location === PlasmaCore.Types.RightEdge)
|
|
|
|
|
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: clickedCenter
|
|
|
|
|
anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right;
|
|
|
|
|
horizontalCenter:undefined; verticalCenter:parent.verticalCenter}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "top"
|
|
|
|
|
when: (plasmoid.location === PlasmaCore.Types.TopEdge)
|
|
|
|
|
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: clickedCenter
|
|
|
|
|
anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined;
|
|
|
|
|
horizontalCenter:parent.horizontalCenter; verticalCenter:undefined}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
@ -51,6 +98,12 @@ Item {
|
|
|
|
|
script: {
|
|
|
|
|
clickedRectangle.width = 0;
|
|
|
|
|
clickedRectangle.opacity = 0.85;
|
|
|
|
|
clickedRectangle.anchors.rightMargin = 0;
|
|
|
|
|
clickedRectangle.anchors.leftMargin = 0;
|
|
|
|
|
clickedRectangle.anchors.topMargin = 0;
|
|
|
|
|
clickedRectangle.anchors.bottomMargin = 0;
|
|
|
|
|
clickedRectangle.anchors.horizontalCenterOffset = 0;
|
|
|
|
|
clickedRectangle.anchors.verticalCenterOffset = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -75,8 +128,54 @@ Item {
|
|
|
|
|
Connections {
|
|
|
|
|
target: level
|
|
|
|
|
onMousePressed: {
|
|
|
|
|
clickedCenter.x = x;
|
|
|
|
|
clickedCenter.y = y;
|
|
|
|
|
var fixedX = 0;
|
|
|
|
|
var fixedY = 0;
|
|
|
|
|
|
|
|
|
|
if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
|
|
|
|
|
fixedX = x - clickedCenter.center;
|
|
|
|
|
} else {
|
|
|
|
|
if (plasmoid.location === PlasmaCore.Types.RightEdge) {
|
|
|
|
|
fixedX = relevantItem.width - x;
|
|
|
|
|
} else {
|
|
|
|
|
fixedX = x;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
|
|
|
|
|
fixedY = y - clickedCenter.center;
|
|
|
|
|
} else {
|
|
|
|
|
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
|
|
|
|
|
fixedY = relevantItem.height - y;
|
|
|
|
|
} else {
|
|
|
|
|
fixedY = y;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) {
|
|
|
|
|
clickedCenter.anchors.horizontalCenterOffset = fixedX;
|
|
|
|
|
} else {
|
|
|
|
|
if (plasmoid.location === PlasmaCore.Types.LeftEdge) {
|
|
|
|
|
clickedCenter.anchors.leftMargin = fixedX;
|
|
|
|
|
} else if (plasmoid.location === PlasmaCore.Types.RightEdge) {
|
|
|
|
|
clickedCenter.anchors.rightMargin = fixedX;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {
|
|
|
|
|
clickedCenter.anchors.verticalCenterOffset = fixedY;
|
|
|
|
|
} else {
|
|
|
|
|
if (plasmoid.location === PlasmaCore.Types.BottomEdge) {
|
|
|
|
|
clickedCenter.anchors.bottomMargin = fixedY;
|
|
|
|
|
} else if (plasmoid.location === PlasmaCore.Types.TopEdge) {
|
|
|
|
|
clickedCenter.anchors.topMargin = fixedY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clickedCenter.anchors.verticalCenterOffset = fixedY;
|
|
|
|
|
|
|
|
|
|
clickedAnimation.start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|