@@ -39,8 +39,6 @@ MouseArea {
3939 readonly property int windowHeight: root.height - resizeHandleWidth * 2
4040
4141 property var startPoint
42− property int startWidth
43− property int startHeight
4442
4543 property bool resizeTop: false
4644 property bool resizeBottom: false
@@ -60,9 +58,7 @@ MouseArea {
6058 }
6159
6260 onPressed: {
63− priv.startPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
64− priv.startWidth = root.width;
65− priv.startHeight = root.height;
61+ priv.startPoint = Qt.point(mouse.x, mouse.y);
6662 priv.resizeTop = mouseY < root.resizeHandleWidth;
6763 priv.resizeBottom = mouseY > (root.height - root.resizeHandleWidth);
6864 priv.resizeLeft = mouseX < root.resizeHandleWidth;
@@ -70,32 +66,28 @@ MouseArea {
7066 }
7167
7268 onPositionChanged: {
73− var currentPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
69+ var currentPoint = Qt.point(mouse.x, mouse.y);
7470 var mouseDiff = Qt.point(currentPoint.x - priv.startPoint.x, currentPoint.y - priv.startPoint.y);
7571 var moveDiff = Qt.point(0, 0);
7672 var sizeDiff = Qt.point(0, 0);
73+ var maxSizeDiff = Qt.point(root.minWidth - root.target.width, root.minHeight - root.target.height)
74+
7775 if (priv.resizeTop || priv.resizeBottom || priv.resizeLeft || priv.resizeRight) {
7876 if (priv.resizeTop) {
79− moveDiff.y += mouseDiff.y;
80− sizeDiff.y += -mouseDiff.y;
81− } else if (priv.resizeBottom) {
82− sizeDiff.y += mouse.y - priv.startPoint.y;
83− priv.startPoint.y = mouse.y
77+ sizeDiff.y = Math.max(maxSizeDiff.y, -currentPoint.y + priv.startPoint.y)
78+ moveDiff.y = -sizeDiff.y
8479 }
85− if (priv.resizeLeft) {
86− moveDiff.x += mouseDiff.x;
87− sizeDiff.x += -mouseDiff.x;
88− } else if (priv.resizeRight) {
89− sizeDiff.x += mouse.x - priv.startPoint.x;
90− priv.startPoint.x = mouse.x
80+ if (priv.resizeBottom) {
81+ sizeDiff.y = Math.max(maxSizeDiff.y, currentPoint.y - priv.startPoint.y)
82+ priv.startPoint.y += sizeDiff.y
9183 }
92− if (priv.windowWidth + sizeDiff.x < root.minWidth) {
93− sizeDiff.x = root.minWidth - priv.windowWidth;
94− moveDiff.x = moveDiff.x == 0 ? 0 : -sizeDiff.x;
84+ if (priv.resizeLeft) {
85+ sizeDiff.x = Math.max(maxSizeDiff.x, -currentPoint.x + priv.startPoint.x)
86+ moveDiff.x = -sizeDiff.x
9587 }
96− if (priv.windowHeight + sizeDiff.y < root.minHeight) {
97− sizeDiff.y = root.minHeight - priv.windowHeight;
98− moveDiff.y = moveDiff.y == 0 ? 0 : -sizeDiff.y;
88+ if (priv.resizeRight) {
89+ sizeDiff.x = Math.max(maxSizeDiff.x, currentPoint.x - priv.startPoint.x)
90+ priv.startPoint.x += sizeDiff.x
9991 }
10092
10193 target.x += moveDiff.x;
@@ -106,6 +98,7 @@ MouseArea {
10698 target.x += mouseDiff.x;
10799 target.y += mouseDiff.y;
108100 }
101+
109102 }
110103
111104 Component.onDestruction: {