Keyboard navigation in running scripts list

This commit is contained in:
Brad Davis 2016-02-08 14:12:18 -08:00
parent 63afa8c1ed
commit e376b781c1

View file

@ -90,6 +90,7 @@ Window {
} }
ScrollView { ScrollView {
onActiveFocusChanged: if (activeFocus && listView.currentItem) { listView.currentItem.forceActiveFocus(); }
anchors { anchors {
top: allButtons.bottom; top: allButtons.bottom;
left: parent.left; left: parent.left;
@ -103,17 +104,19 @@ Window {
id: listView id: listView
clip: true clip: true
anchors { fill: parent; margins: 0 } anchors { fill: parent; margins: 0 }
model: runningScriptsModel model: runningScriptsModel
delegate: FocusScope {
delegate: Rectangle { id: scope
anchors { left: parent.left; right: parent.right }
height: scriptName.height + 12 + (ListView.isCurrentItem ? scriptName.height + 6 : 0)
Keys.onDownPressed: listView.incrementCurrentIndex()
Keys.onUpPressed: listView.decrementCurrentIndex()
Rectangle {
id: rectangle id: rectangle
anchors.fill: parent
clip: true clip: true
radius: 3 radius: 3
anchors { left: parent.left; right: parent.right } color: scope.ListView.isCurrentItem ? "#79f" :
height: scriptName.height + 12 + (ListView.isCurrentItem ? scriptName.height + 6 : 0)
color: ListView.isCurrentItem ? "#39f" :
index % 2 ? "#ddd" : "#eee" index % 2 ? "#ddd" : "#eee"
Text { Text {
@ -131,7 +134,7 @@ Window {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: listView.currentIndex = index onClicked: { listView.currentIndex = index; scope.forceActiveFocus(); }
} }
Row { Row {
@ -157,6 +160,7 @@ Window {
} }
} }
} }
}
Text { Text {
id: loadLabel id: loadLabel
@ -220,6 +224,7 @@ Window {
anchors.bottom: treeView.top anchors.bottom: treeView.top
anchors.bottomMargin: 8 anchors.bottomMargin: 8
placeholderText: "filter" placeholderText: "filter"
focus: true
onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i") onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i")
Component.onCompleted: scriptsModel.filterRegExp = new RegExp("^.*$", "i") Component.onCompleted: scriptsModel.filterRegExp = new RegExp("^.*$", "i")
} }
@ -232,7 +237,6 @@ Window {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
headerVisible: false headerVisible: false
focus: true
// FIXME doesn't work? // FIXME doesn't work?
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index) onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
// FIXME not triggered by double click? // FIXME not triggered by double click?
@ -261,11 +265,11 @@ Window {
TableViewColumn { TableViewColumn {
title: "Name"; title: "Name";
role: "display"; role: "display";
// delegate: Text { // delegate: Text {
// text: styleData.value // text: styleData.value
// renderType: Text.QtRendering // renderType: Text.QtRendering
// elite: styleData.elideMode // elite: styleData.elideMode
// } // }
} }
} }