Enable resizable dialogs

This commit is contained in:
Brad Davis 2015-04-17 17:43:54 -07:00
parent 16efa2a46f
commit 8d23bf874f

View file

@ -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
}
}
}
}