From 8d23bf874f325cdcd375e5fe6e86d62a26f36858 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 17 Apr 2015 17:43:54 -0700 Subject: [PATCH] Enable resizable dialogs --- interface/resources/qml/CustomDialog.qml | 34 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/CustomDialog.qml b/interface/resources/qml/CustomDialog.qml index dd051566e3..1e0351af4f 100644 --- a/interface/resources/qml/CustomDialog.qml +++ b/interface/resources/qml/CustomDialog.qml @@ -15,6 +15,10 @@ Item { property int animationDuration: 400 property bool destroyOnInvisible: false property bool destroyOnCloseButton: true + property bool resizable: false + property int minX: 256 + property int minY: 256 + clip: true onEnabledChanged: { scale = enabled ? 1.0 : 0.0 @@ -37,6 +41,11 @@ Item { } enabled = false; } + + function deltaSize(dx, dy) { + width = Math.max(width + dx, minX) + height = Math.max(height + dy, minY) + } Behavior on scale { NumberAnimation { @@ -82,8 +91,6 @@ Item { MouseArea { id: titleDrag - property int startX - property int startY anchors.right: closeButton.left anchors.bottom: parent.bottom anchors.left: parent.left @@ -127,6 +134,29 @@ Item { anchors.rightMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 + clip: true } // client border } // window border + + MouseArea { + id: sizeDrag + property int startX + property int startY + anchors.right: parent.right + anchors.bottom: parent.bottom + width: 16 + height: 16 + hoverEnabled: true + onPressed: { + startX = mouseX + startY = mouseY + } + onPositionChanged: { + if (pressed && dialog.resizable) { + dialog.deltaSize((mouseX - startX), (mouseY - startY)) + startX = mouseX + startY = mouseY + } + } + } }