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,54 +104,57 @@ 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
id: rectangle
clip: true
radius: 3
anchors { left: parent.left; right: parent.right } anchors { left: parent.left; right: parent.right }
height: scriptName.height + 12 + (ListView.isCurrentItem ? scriptName.height + 6 : 0) height: scriptName.height + 12 + (ListView.isCurrentItem ? scriptName.height + 6 : 0)
color: ListView.isCurrentItem ? "#39f" : Keys.onDownPressed: listView.incrementCurrentIndex()
index % 2 ? "#ddd" : "#eee" Keys.onUpPressed: listView.decrementCurrentIndex()
Rectangle {
Text { id: rectangle
id: scriptName
anchors { left: parent.left; leftMargin: 4; top: parent.top; topMargin:6 }
text: name
}
Text {
id: scriptUrl
anchors { left: scriptName.left; right: parent.right; rightMargin: 4; top: scriptName.bottom; topMargin: 6 }
text: url
elide: Text.ElideMiddle
}
MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: listView.currentIndex = index clip: true
} radius: 3
color: scope.ListView.isCurrentItem ? "#79f" :
index % 2 ? "#ddd" : "#eee"
Row { Text {
anchors.verticalCenter: scriptName.verticalCenter id: scriptName
anchors.right: parent.right anchors { left: parent.left; leftMargin: 4; top: parent.top; topMargin:6 }
anchors.rightMargin: 4 text: name
spacing: 4
HifiControls.FontAwesome {
text: "\uf021"; size: scriptName.height;
MouseArea {
anchors { fill: parent; margins: -2; }
onClicked: reloadScript(model.url)
}
} }
HifiControls.FontAwesome {
size: scriptName.height; text: "\uf00d" Text {
MouseArea { id: scriptUrl
anchors { fill: parent; margins: -2; } anchors { left: scriptName.left; right: parent.right; rightMargin: 4; top: scriptName.bottom; topMargin: 6 }
onClicked: stopScript(model.url) text: url
elide: Text.ElideMiddle
}
MouseArea {
anchors.fill: parent
onClicked: { listView.currentIndex = index; scope.forceActiveFocus(); }
}
Row {
anchors.verticalCenter: scriptName.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 4
spacing: 4
HifiControls.FontAwesome {
text: "\uf021"; size: scriptName.height;
MouseArea {
anchors { fill: parent; margins: -2; }
onClicked: reloadScript(model.url)
}
}
HifiControls.FontAwesome {
size: scriptName.height; text: "\uf00d"
MouseArea {
anchors { fill: parent; margins: -2; }
onClicked: stopScript(model.url)
}
} }
} }
} }
@ -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
// } // }
} }
} }