Skip to content

Commit

Permalink
Allow enter to be used to confirm canvas/image size dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcurtis committed Jan 26, 2019
1 parent 102161a commit 7d3bdb7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 53 deletions.
32 changes: 17 additions & 15 deletions app/qml/ui/CanvasSizePopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import QtQuick.Controls 2.3
import App 1.0

Dialog {
id: popup
id: root
objectName: "canvasSizePopup"
title: qsTr("Choose a size for the canvas")
modal: true
Expand All @@ -45,6 +45,8 @@ Dialog {

onClosed: canvas.forceActiveFocus()

onAccepted: project.size = Qt.size(widthSpinBox.value, heightSpinBox.value)

contentItem: ColumnLayout {
Item {
Layout.preferredHeight: 4
Expand All @@ -65,10 +67,12 @@ Dialog {
editable: true
stepSize: 1

ToolTip.text: isTilesetProject ? tilesetText : imageText

readonly property string tilesetText: qsTr("Number of horizontal tiles")
readonly property string imageText: qsTr("Canvas width in pixels")

ToolTip.text: isTilesetProject ? tilesetText : imageText

Keys.onReturnPressed: root.accept()
}
Label {
text: qsTr("Canvas height")
Expand All @@ -82,10 +86,12 @@ Dialog {
editable: true
stepSize: 1

ToolTip.text: isTilesetProject ? tilesetText : imageText

readonly property string tilesetText: qsTr("Number of vertical tiles")
readonly property string imageText: qsTr("Canvas height in pixels")

ToolTip.text: isTilesetProject ? tilesetText : imageText

Keys.onReturnPressed: root.accept()
}

Item {
Expand All @@ -97,23 +103,19 @@ Dialog {

footer: DialogButtonBox {
Button {
id: okButton
objectName: "canvasSizePopupOkButton"
text: "OK"
text: qsTr("OK")

DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole

onClicked: {
project.size = Qt.size(widthSpinBox.value, heightSpinBox.value);
popup.visible = false;
}
}
Button {
objectName: "canvasSizePopupCancelButton"
text: "Cancel"

DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole
text: qsTr("Cancel")

onClicked: popup.visible = false
// https://bugreports.qt.io/browse/QTBUG-67168
// TODO: replace this with DestructiveRole when it works (closes dialog)
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}
}
}
58 changes: 20 additions & 38 deletions app/qml/ui/ImageSizePopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import QtQuick.Controls 2.3
import App 1.0

Dialog {
id: dialog
id: root
objectName: "imageSizePopup"
title: qsTr("Choose a size for the image")
modal: true
Expand All @@ -42,6 +42,8 @@ Dialog {
}
}

onAccepted: project.resize(widthSpinBox.value, heightSpinBox.value, smoothCheckBox.checked)

contentItem: ColumnLayout {
Item {
Layout.preferredHeight: 4
Expand Down Expand Up @@ -123,6 +125,8 @@ Dialog {

ToolTip.text: qsTr("Image width in pixels")

Keys.onReturnPressed: root.accept()

onValueModified: valueUpdated(value)

// https://bugreports.qt.io/browse/QTBUG-64151
Expand Down Expand Up @@ -158,6 +162,8 @@ Dialog {

ToolTip.text: qsTr("Image height in pixels")

Keys.onReturnPressed: root.accept()

onValueModified: valueUpdated(value)

// https://bugreports.qt.io/browse/QTBUG-64151
Expand Down Expand Up @@ -199,46 +205,22 @@ Dialog {
Layout.fillHeight: true
}
}
}

RowLayout {
Button {
objectName: "imageSizePopupOkButton"
text: qsTr("OK")
footer: DialogButtonBox {
Button {
objectName: "imageSizePopupOkButton"
text: qsTr("OK")

onClicked: {
project.resize(widthSpinBox.value, heightSpinBox.value, smoothCheckBox.checked);
dialog.visible = false;
}
}
Button {
objectName: "imageSizePopupCancelButton"
text: qsTr("Cancel")
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
Button {
objectName: "imageSizePopupCancelButton"
text: qsTr("Cancel")

onClicked: dialog.visible = false
}
// https://bugreports.qt.io/browse/QTBUG-67168
// TODO: replace this with DestructiveRole when it works (closes dialog)
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}
}

// https://bugreports.qt.io/browse/QTBUG-64174
// footer: DialogButtonBox {
// Button {
// objectName: "imageSizePopupOkButton"
// text: qsTr("OK")

// DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole

// onClicked: {
// project.resize(widthSpinBox.value, heightSpinBox.value, smoothCheckBox.checked);
// dialog.visible = false;
// }
// }
// Button {
// objectName: "imageSizePopupCancelButton"
// text: qsTr("Cancel")

// DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole

// onClicked: dialog.visible = false
// }
// }
}

0 comments on commit 7d3bdb7

Please sign in to comment.