diff options
author | Leonard Lee <leonard.lee@digia.com> | 2014-04-03 14:33:17 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-08 16:06:42 +0200 |
commit | 619ae7b9d35187c5debbf8560c63f5e9b42d0eb2 (patch) | |
tree | 80e85651c775775ee75bd6d3e5fa6fd36b7d98d0 /src/dialogs/DefaultFontDialog.qml | |
parent | 1ac885f99c15c2bf9859df483048bfa6b68b15f3 (diff) | |
download | qtquickcontrols-619ae7b9d35187c5debbf8560c63f5e9b42d0eb2.tar.gz |
Implement input for entering non-standard font size.
User should be able to enter non-standard font size which is not
available in the list of standard font sizes. The selected value
in the list of standard font sizes should synchronize with the
input field for the non-standard point size value, and vice versa
if there is a match.
Change-Id: I63b855054b2feb4dad339fe8ec06be5179bb2a37
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/dialogs/DefaultFontDialog.qml')
-rw-r--r-- | src/dialogs/DefaultFontDialog.qml | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/src/dialogs/DefaultFontDialog.qml b/src/dialogs/DefaultFontDialog.qml index c8eccf3f..20377dc1 100644 --- a/src/dialogs/DefaultFontDialog.qml +++ b/src/dialogs/DefaultFontDialog.qml @@ -91,8 +91,7 @@ AbstractFontDialog { switch (event.key) { case Qt.Key_Return: case Qt.Key_Select: - root.font = content.font - root.accept() + updateUponAccepted() break case Qt.Key_Escape: case Qt.Key_Back: @@ -105,6 +104,11 @@ AbstractFontDialog { } } + function updateUponAccepted() { + root.font = content.font + root.accept() + } + ColumnLayout { id: mainLayout anchors { fill: parent; margins: content.outerSpacing } @@ -235,19 +239,52 @@ AbstractFontDialog { positionViewAtRow(row, ListView.Contain) } } - TableView { - id: pointSizesListView - Layout.fillHeight: true - headerVisible: false - implicitWidth: (Component.status == Component.Ready) ? (psColumn.width + content.outerSpacing) : (80) - Component.onCompleted: resizeColumnsToContents(); - TableViewColumn{ id: psColumn; role: ""; title: qsTr("Size") } - model: content.pointSizes - onClicked: { - if (row == -1) - return - content.font.pointSize = content.pointSizes[row] - positionViewAtRow(row, ListView.Contain) + ColumnLayout { + SpinBox { + id: pointSizeSpinBox; + implicitWidth: (Component.status == Component.Ready) ? (psColumn.width + content.outerSpacing) : (80) + value: content.font.pointSize + decimals: 0 + minimumValue: 1 + maximumValue: 512 + onValueChanged: { + content.font.pointSize = Number(value); + updatePointSizesIndex(); + } + function updatePointSizesIndex() { + pointSizesListView.selection.clear() + if (content.pointSizes.length <= 0 || pointSizesListView.rowCount <= 0) + return + var currentRow = -1 + for (var i = 0; i < content.pointSizes.length; ++i) { + if (content.font.pointSize == content.pointSizes[i]) { + currentRow = i + break + } + } + if (currentRow < 0) + return + content.font.pointSize = content.pointSizes[currentRow] + pointSizesListView.selection.select(currentRow) + pointSizesListView.positionViewAtRow(currentRow, ListView.Contain) + pointSizesListView.clicked(currentRow) + } + } + TableView { + id: pointSizesListView + Layout.fillHeight: true + headerVisible: false + implicitWidth: (Component.status == Component.Ready) ? (psColumn.width + content.outerSpacing) : (80) + Component.onCompleted: resizeColumnsToContents(); + TableViewColumn{ id: psColumn; role: ""; title: qsTr("Size") } + model: content.pointSizes + onClicked: { + if (row == -1) + return + content.font.pointSize = content.pointSizes[row] + pointSizeSpinBox.value = content.pointSizes[row] + positionViewAtRow(row, ListView.Contain) + } } } } @@ -350,8 +387,7 @@ AbstractFontDialog { Button { text: qsTr("OK") onClicked: { - root.font = content.font - root.accept() + content.updateUponAccepted() } } } |