From e376b781c1f5bbe75970980a325d8f4a7ab9eaf3 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 8 Feb 2016 14:12:18 -0800 Subject: [PATCH] Keyboard navigation in running scripts list --- .../qml/hifi/dialogs/RunningScripts.qml | 102 +++++++++--------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/RunningScripts.qml b/interface/resources/qml/hifi/dialogs/RunningScripts.qml index f61bf3f96d..8834c1d8bc 100644 --- a/interface/resources/qml/hifi/dialogs/RunningScripts.qml +++ b/interface/resources/qml/hifi/dialogs/RunningScripts.qml @@ -90,6 +90,7 @@ Window { } ScrollView { + onActiveFocusChanged: if (activeFocus && listView.currentItem) { listView.currentItem.forceActiveFocus(); } anchors { top: allButtons.bottom; left: parent.left; @@ -103,54 +104,57 @@ Window { id: listView clip: true anchors { fill: parent; margins: 0 } - model: runningScriptsModel - - delegate: Rectangle { - id: rectangle - clip: true - radius: 3 + delegate: FocusScope { + id: scope anchors { left: parent.left; right: parent.right } - height: scriptName.height + 12 + (ListView.isCurrentItem ? scriptName.height + 6 : 0) - color: ListView.isCurrentItem ? "#39f" : - index % 2 ? "#ddd" : "#eee" - - Text { - 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 { + Keys.onDownPressed: listView.incrementCurrentIndex() + Keys.onUpPressed: listView.decrementCurrentIndex() + Rectangle { + id: rectangle anchors.fill: parent - onClicked: listView.currentIndex = index - } + clip: true + radius: 3 + color: scope.ListView.isCurrentItem ? "#79f" : + index % 2 ? "#ddd" : "#eee" - 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) - } + Text { + id: scriptName + anchors { left: parent.left; leftMargin: 4; top: parent.top; topMargin:6 } + text: name } - HifiControls.FontAwesome { - size: scriptName.height; text: "\uf00d" - MouseArea { - anchors { fill: parent; margins: -2; } - onClicked: stopScript(model.url) + + 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 + 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.bottomMargin: 8 placeholderText: "filter" + focus: true onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i") Component.onCompleted: scriptsModel.filterRegExp = new RegExp("^.*$", "i") } @@ -232,7 +237,6 @@ Window { anchors.left: parent.left anchors.right: parent.right headerVisible: false - focus: true // FIXME doesn't work? onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index) // FIXME not triggered by double click? @@ -258,14 +262,14 @@ Window { console.log("Desktop size " + Qt.size(desktop.width, desktop.height)); } - TableViewColumn { + TableViewColumn { title: "Name"; role: "display"; -// delegate: Text { -// text: styleData.value -// renderType: Text.QtRendering -// elite: styleData.elideMode -// } + // delegate: Text { + // text: styleData.value + // renderType: Text.QtRendering + // elite: styleData.elideMode + // } } }