summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2014-08-08 12:50:54 +0200
committerLiang Qi <liang.qi@digia.com>2014-08-19 13:56:40 +0200
commitc4eafa613e1985dc47646365b27c07f509e14b1c (patch)
tree463e3cf6e8a47419b5ac4ae66c8177b602d6c5a0
parent0efe37f9304b54912aff52bbe98083702d5b1f22 (diff)
QtQuick.Dialogs FontDialog: support keyboard navigation
[ChangeLog][QtQuick.Dialogs] FontDialog: support keyboard navigation Task-number: QTBUG-39365 Change-Id: Ic4cdbe6643be2fc66dbb23873e780a1f1f88a410 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
-rw-r--r--src/dialogs/DefaultFontDialog.qml36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/dialogs/DefaultFontDialog.qml b/src/dialogs/DefaultFontDialog.qml
index 6c308caf4..041be8444 100644
--- a/src/dialogs/DefaultFontDialog.qml
+++ b/src/dialogs/DefaultFontDialog.qml
@@ -123,6 +123,7 @@ AbstractFontDialog {
Label { id: sizeLabel; text: qsTr("Size"); font.bold: true }
TableView {
id: fontListView
+ focus: true
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: fontColumn.width
@@ -165,26 +166,30 @@ AbstractFontDialog {
if (content.pointSizes.length <= 0 || pointSizesListView.rowCount <= 0)
return
- var currentRow = 0
+ var currentRow = -1
for (var i = 0; i < content.pointSizes.length; ++i) {
if (content.font.pointSize == content.pointSizes[i]) {
currentRow = i
break
}
}
- content.font.pointSize = content.pointSizes[currentRow]
- pointSizesListView.selection.select(currentRow)
- pointSizesListView.positionViewAtRow(currentRow, ListView.Contain)
- pointSizesListView.clicked(currentRow)
+ if (currentRow != -1) {
+ content.font.pointSize = content.pointSizes[currentRow]
+ pointSizesListView.selection.select(currentRow)
+ pointSizesListView.positionViewAtRow(currentRow, ListView.Contain)
+ pointSizesListView.clicked(currentRow)
+ }
}
}
- onClicked: {
+ function select(row) {
if (row == -1)
return
+ currentRow = row
content.font.family = fontModel.get(row).family
positionViewAtRow(row, ListView.Contain)
}
-
+ onClicked: select(row)
+ onCurrentRowChanged: select(currentRow)
}
TableView {
id: weightListView
@@ -233,12 +238,15 @@ AbstractFontDialog {
weightListView.clicked(currentRow)
}
}
- onClicked: {
+ function select(row) {
if (row == -1)
return
+ currentRow = row
content.font.weight = weightModel.get(row).weight
positionViewAtRow(row, ListView.Contain)
}
+ onClicked: select(row)
+ onCurrentRowChanged: select(currentRow)
}
ColumnLayout {
SpinBox {
@@ -279,13 +287,21 @@ AbstractFontDialog {
Component.onCompleted: resizeColumnsToContents();
TableViewColumn{ id: psColumn; role: ""; title: qsTr("Size") }
model: content.pointSizes
- onClicked: {
- if (row == -1)
+ property bool guard: false
+ function select(row) {
+ if (row == -1 || !guard)
return
+ currentRow = row
content.font.pointSize = content.pointSizes[row]
pointSizeSpinBox.value = content.pointSizes[row]
positionViewAtRow(row, ListView.Contain)
}
+ onClicked: select(row)
+ onCurrentRowChanged: {
+ select(currentRow)
+ if (!guard)
+ guard = true
+ }
}
}
}