mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 08:15:37 +00:00
Finish keyboard navigation for GridViews and MenuItems
This commit is contained in:
parent
2e3de32810
commit
8fb37ae229
@ -31,6 +31,11 @@ GridView {
|
|||||||
stackView.pop()
|
stackView.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// Don't show any highlighted item until interacting with them
|
||||||
|
currentIndex = -1
|
||||||
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
appModel.computerLost.connect(computerLost)
|
appModel.computerLost.connect(computerLost)
|
||||||
@ -51,7 +56,7 @@ GridView {
|
|||||||
|
|
||||||
delegate: NavigableItemDelegate {
|
delegate: NavigableItemDelegate {
|
||||||
width: 200; height: 335;
|
width: 200; height: 335;
|
||||||
grid: pcGrid
|
grid: appGrid
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: appIcon
|
id: appIcon
|
||||||
@ -129,7 +134,7 @@ GridView {
|
|||||||
}
|
}
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
}
|
}
|
||||||
MenuItem {
|
NavigableMenuItem {
|
||||||
text: "Quit Game"
|
text: "Quit Game"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
quitAppDialog.appName = appModel.getRunningAppName()
|
quitAppDialog.appName = appModel.getRunningAppName()
|
||||||
|
@ -4,6 +4,8 @@ import QtQuick.Controls 2.2
|
|||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
property GridView grid
|
property GridView grid
|
||||||
|
|
||||||
|
highlighted: grid.activeFocus && grid.currentItem === this
|
||||||
|
|
||||||
Keys.onLeftPressed: {
|
Keys.onLeftPressed: {
|
||||||
grid.moveCurrentIndexLeft()
|
grid.moveCurrentIndexLeft()
|
||||||
}
|
}
|
||||||
@ -13,11 +15,9 @@ ItemDelegate {
|
|||||||
Keys.onDownPressed: {
|
Keys.onDownPressed: {
|
||||||
grid.moveCurrentIndexDown()
|
grid.moveCurrentIndexDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onUpPressed: {
|
Keys.onUpPressed: {
|
||||||
grid.moveCurrentIndexUp()
|
grid.moveCurrentIndexUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
clicked()
|
clicked()
|
||||||
}
|
}
|
||||||
|
8
app/gui/NavigableMenuItem.qml
Normal file
8
app/gui/NavigableMenuItem.qml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
triggered()
|
||||||
|
}
|
||||||
|
}
|
@ -45,6 +45,9 @@ GridView {
|
|||||||
else if (!prefs.hasAnyHardwareAcceleration()) {
|
else if (!prefs.hasAnyHardwareAcceleration()) {
|
||||||
noHwDecoderDialog.open()
|
noHwDecoderDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't show any highlighted item until interacting with them
|
||||||
|
currentIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
function pairingComplete(error)
|
function pairingComplete(error)
|
||||||
@ -131,13 +134,13 @@ GridView {
|
|||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: pcContextMenu
|
id: pcContextMenu
|
||||||
MenuItem {
|
NavigableMenuItem {
|
||||||
text: "Wake PC"
|
text: "Wake PC"
|
||||||
onTriggered: computerModel.wakeComputer(index)
|
onTriggered: computerModel.wakeComputer(index)
|
||||||
visible: !model.addPc && !model.online && model.wakeable
|
visible: !model.addPc && !model.online && model.wakeable
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
}
|
}
|
||||||
MenuItem {
|
NavigableMenuItem {
|
||||||
text: "Delete PC"
|
text: "Delete PC"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
deletePcDialog.pcIndex = index
|
deletePcDialog.pcIndex = index
|
||||||
|
@ -26,7 +26,7 @@ ApplicationWindow {
|
|||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
onCurrentItemChanged: {
|
onCurrentItemChanged: {
|
||||||
// Ensure focus travels to the next view
|
// Ensure focus travels to the next view when going back
|
||||||
if (currentItem) {
|
if (currentItem) {
|
||||||
currentItem.forceActiveFocus()
|
currentItem.forceActiveFocus()
|
||||||
}
|
}
|
||||||
@ -37,6 +37,12 @@ ApplicationWindow {
|
|||||||
stackView.pop()
|
stackView.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onBackPressed: {
|
||||||
|
if (depth > 1) {
|
||||||
|
stackView.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibilityChanged: {
|
onVisibilityChanged: {
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
<file>gui/QuitSegue.qml</file>
|
<file>gui/QuitSegue.qml</file>
|
||||||
<file>gui/NavigableToolButton.qml</file>
|
<file>gui/NavigableToolButton.qml</file>
|
||||||
<file>gui/NavigableItemDelegate.qml</file>
|
<file>gui/NavigableItemDelegate.qml</file>
|
||||||
|
<file>gui/NavigableMenuItem.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user