forked from qt-creator/qt-creator
Replace TextField with RealSpinBox for custom width and height
Change-Id: I07f993033a4a0fa5168abd0636fc883bd3ccd7fe Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -202,8 +202,8 @@ Item {
|
|||||||
dialogBox.setScreenSizeIndex(index);
|
dialogBox.setScreenSizeIndex(index);
|
||||||
|
|
||||||
var r = screenSizeModel.screenSizes(index);
|
var r = screenSizeModel.screenSizes(index);
|
||||||
widthTextField.text = r.width;
|
widthField.realValue = r.width;
|
||||||
heightTextField.text = r.height;
|
heightField.realValue = r.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -252,19 +252,20 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// content items
|
// content items
|
||||||
SC.TextField {
|
SC.RealSpinBox {
|
||||||
id: widthTextField
|
id: widthField
|
||||||
actionIndicatorVisible: false
|
actionIndicatorVisible: false
|
||||||
translationIndicatorVisible: false
|
implicitWidth: 70
|
||||||
implicitWidth: 50
|
labelColor: DialogValues.textColor
|
||||||
color: DialogValues.textColor
|
realFrom: 100
|
||||||
selectByMouse: true
|
realTo: 100000
|
||||||
validator: IntValidator { bottom: 1; top: 100000; }
|
realValue: 100
|
||||||
|
realStepSize: 10
|
||||||
font.pixelSize: DialogValues.defaultPixelSize
|
font.pixelSize: DialogValues.defaultPixelSize
|
||||||
|
|
||||||
onTextChanged: {
|
onRealValueChanged: {
|
||||||
var height = heightTextField.text ? parseInt(heightTextField.text) : 0
|
var height = heightField.realValue
|
||||||
var width = text ? parseInt(text) : 0
|
var width = realValue
|
||||||
|
|
||||||
if (width >= height)
|
if (width >= height)
|
||||||
orientationButton.setHorizontal()
|
orientationButton.setHorizontal()
|
||||||
@@ -276,22 +277,23 @@ Item {
|
|||||||
Binding {
|
Binding {
|
||||||
target: dialogBox
|
target: dialogBox
|
||||||
property: "customWidth"
|
property: "customWidth"
|
||||||
value: widthTextField.text
|
value: widthField.realValue
|
||||||
}
|
}
|
||||||
|
|
||||||
SC.TextField {
|
SC.RealSpinBox {
|
||||||
id: heightTextField
|
id: heightField
|
||||||
actionIndicatorVisible: false
|
actionIndicatorVisible: false
|
||||||
translationIndicatorVisible: false
|
implicitWidth: 70
|
||||||
implicitWidth: 50
|
labelColor: DialogValues.textColor
|
||||||
color: DialogValues.textColor
|
realFrom: 100
|
||||||
selectByMouse: true
|
realTo: 100000
|
||||||
validator: IntValidator { bottom: 1; top: 100000; }
|
realValue: 100
|
||||||
|
realStepSize: 10
|
||||||
font.pixelSize: DialogValues.defaultPixelSize
|
font.pixelSize: DialogValues.defaultPixelSize
|
||||||
|
|
||||||
onTextChanged: {
|
onRealValueChanged: {
|
||||||
var height = text ? parseInt(text) : 0
|
var height = realValue
|
||||||
var width = widthTextField.text ? parseInt(widthTextField.text) : 0
|
var width = widthField.realValue
|
||||||
|
|
||||||
if (width >= height)
|
if (width >= height)
|
||||||
orientationButton.setHorizontal()
|
orientationButton.setHorizontal()
|
||||||
@@ -303,7 +305,7 @@ Item {
|
|||||||
Binding {
|
Binding {
|
||||||
target: dialogBox
|
target: dialogBox
|
||||||
property: "customHeight"
|
property: "customHeight"
|
||||||
value: heightTextField.text
|
value: heightField.realValue
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
@@ -348,9 +350,8 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (widthTextField.text && heightTextField.text) {
|
if (widthField.realValue && heightField.realValue) {
|
||||||
[widthTextField.text, heightTextField.text] = [heightTextField.text, widthTextField.text];
|
[widthField.realValue, heightField.realValue] = [heightField.realValue, widthField.realValue];
|
||||||
|
|
||||||
checked = !checked
|
checked = !checked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user