@@ -39,8 +39,6 @@ MouseArea {
39 readonly property int windowHeight: root.height - resizeHandleWidth * 2
39 readonly property int windowHeight: root.height - resizeHandleWidth * 2
41 property var startPoint
41 property var startPoint
42− property int startWidth
43− property int startHeight
45 property bool resizeTop: false
43 property bool resizeTop: false
46 property bool resizeBottom: false
44 property bool resizeBottom: false
@@ -60,9 +58,7 @@ MouseArea {
62 onPressed: {
60 onPressed: {
63− priv.startPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
61+ priv.startPoint = Qt.point(mouse.x, mouse.y);
64− priv.startWidth = root.width;
65− priv.startHeight = root.height;
66 priv.resizeTop = mouseY < root.resizeHandleWidth;
62 priv.resizeTop = mouseY < root.resizeHandleWidth;
67 priv.resizeBottom = mouseY > (root.height - root.resizeHandleWidth);
63 priv.resizeBottom = mouseY > (root.height - root.resizeHandleWidth);
68 priv.resizeLeft = mouseX < root.resizeHandleWidth;
64 priv.resizeLeft = mouseX < root.resizeHandleWidth;
@@ -70,32 +66,28 @@ MouseArea {
72 onPositionChanged: {
68 onPositionChanged: {
73− var currentPoint = mapToItem(null, Qt.point(mouse.x, mouse.y)).x;
69+ var currentPoint = Qt.point(mouse.x, mouse.y);
74 var mouseDiff = Qt.point(currentPoint.x - priv.startPoint.x, currentPoint.y - priv.startPoint.y);
70 var mouseDiff = Qt.point(currentPoint.x - priv.startPoint.x, currentPoint.y - priv.startPoint.y);
75 var moveDiff = Qt.point(0, 0);
71 var moveDiff = Qt.point(0, 0);
76 var sizeDiff = Qt.point(0, 0);
72 var sizeDiff = Qt.point(0, 0);
73+ var maxSizeDiff = Qt.point(root.minWidth - root.target.width, root.minHeight - root.target.height)
77 if (priv.resizeTop || priv.resizeBottom || priv.resizeLeft || priv.resizeRight) {
75 if (priv.resizeTop || priv.resizeBottom || priv.resizeLeft || priv.resizeRight) {
78 if (priv.resizeTop) {
76 if (priv.resizeTop) {
79− moveDiff.y += mouseDiff.y;
77+ sizeDiff.y = Math.max(maxSizeDiff.y, -currentPoint.y + priv.startPoint.y)
80− sizeDiff.y += -mouseDiff.y;
78+ moveDiff.y = -sizeDiff.y
81− } else if (priv.resizeBottom) {
82− sizeDiff.y += mouse.y - priv.startPoint.y;
83− priv.startPoint.y = mouse.y
85− if (priv.resizeLeft) {
80+ if (priv.resizeBottom) {
86− moveDiff.x += mouseDiff.x;
81+ sizeDiff.y = Math.max(maxSizeDiff.y, currentPoint.y - priv.startPoint.y)
87− sizeDiff.x += -mouseDiff.x;
82+ priv.startPoint.y += sizeDiff.y
88− } else if (priv.resizeRight) {
89− sizeDiff.x += mouse.x - priv.startPoint.x;
90− priv.startPoint.x = mouse.x
92− if (priv.windowWidth + sizeDiff.x < root.minWidth) {
84+ if (priv.resizeLeft) {
93− sizeDiff.x = root.minWidth - priv.windowWidth;
85+ sizeDiff.x = Math.max(maxSizeDiff.x, -currentPoint.x + priv.startPoint.x)
94− moveDiff.x = moveDiff.x == 0 ? 0 : -sizeDiff.x;
86+ moveDiff.x = -sizeDiff.x
96− if (priv.windowHeight + sizeDiff.y < root.minHeight) {
88+ if (priv.resizeRight) {
97− sizeDiff.y = root.minHeight - priv.windowHeight;
89+ sizeDiff.x = Math.max(maxSizeDiff.x, currentPoint.x - priv.startPoint.x)
98− moveDiff.y = moveDiff.y == 0 ? 0 : -sizeDiff.y;
90+ priv.startPoint.x += sizeDiff.x
101 target.x += moveDiff.x;
93 target.x += moveDiff.x;
@@ -106,6 +98,7 @@ MouseArea {
106 target.x += mouseDiff.x;
98 target.x += mouseDiff.x;
107 target.y += mouseDiff.y;
99 target.y += mouseDiff.y;
111 Component.onDestruction: {
104 Component.onDestruction: {