mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-02 15:55:39 +00:00
Partially working keyboard navigation support
This commit is contained in:
parent
f2e40889b2
commit
2e3de32810
@ -11,6 +11,8 @@ GridView {
|
|||||||
property AppModel appModel : createModel()
|
property AppModel appModel : createModel()
|
||||||
|
|
||||||
id: appGrid
|
id: appGrid
|
||||||
|
focus: true
|
||||||
|
activeFocusOnTab: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
@ -47,8 +49,9 @@ GridView {
|
|||||||
|
|
||||||
model: appModel
|
model: appModel
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
delegate: NavigableItemDelegate {
|
||||||
width: 200; height: 335;
|
width: 200; height: 335;
|
||||||
|
grid: pcGrid
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: appIcon
|
id: appIcon
|
||||||
|
24
app/gui/NavigableItemDelegate.qml
Normal file
24
app/gui/NavigableItemDelegate.qml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
property GridView grid
|
||||||
|
|
||||||
|
Keys.onLeftPressed: {
|
||||||
|
grid.moveCurrentIndexLeft()
|
||||||
|
}
|
||||||
|
Keys.onRightPressed: {
|
||||||
|
grid.moveCurrentIndexRight()
|
||||||
|
}
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
grid.moveCurrentIndexDown()
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onUpPressed: {
|
||||||
|
grid.moveCurrentIndexUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
clicked()
|
||||||
|
}
|
||||||
|
}
|
18
app/gui/NavigableToolButton.qml
Normal file
18
app/gui/NavigableToolButton.qml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
activeFocusOnTab: true
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
clicked()
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onRightPressed: {
|
||||||
|
nextItemInFocusChain(true).forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onLeftPressed: {
|
||||||
|
nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,8 @@ GridView {
|
|||||||
property ComputerModel computerModel : createModel()
|
property ComputerModel computerModel : createModel()
|
||||||
|
|
||||||
id: pcGrid
|
id: pcGrid
|
||||||
|
focus: true
|
||||||
|
activeFocusOnTab: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
@ -75,8 +77,9 @@ GridView {
|
|||||||
|
|
||||||
model: computerModel
|
model: computerModel
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
delegate: NavigableItemDelegate {
|
||||||
width: 300; height: 300;
|
width: 300; height: 300;
|
||||||
|
grid: pcGrid
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: pcIcon
|
id: pcIcon
|
||||||
|
@ -23,6 +23,20 @@ ApplicationWindow {
|
|||||||
id: stackView
|
id: stackView
|
||||||
initialItem: "PcView.qml"
|
initialItem: "PcView.qml"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
focus: true
|
||||||
|
|
||||||
|
onCurrentItemChanged: {
|
||||||
|
// Ensure focus travels to the next view
|
||||||
|
if (currentItem) {
|
||||||
|
currentItem.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onEscapePressed: {
|
||||||
|
if (depth > 1) {
|
||||||
|
stackView.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibilityChanged: {
|
onVisibilityChanged: {
|
||||||
@ -68,7 +82,7 @@ ApplicationWindow {
|
|||||||
spacing: 20
|
spacing: 20
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
ToolButton {
|
NavigableToolButton {
|
||||||
// Only make the button visible if the user has navigated somewhere.
|
// Only make the button visible if the user has navigated somewhere.
|
||||||
visible: stackView.depth > 1
|
visible: stackView.depth > 1
|
||||||
|
|
||||||
@ -85,6 +99,10 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClicked: stackView.pop()
|
onClicked: stackView.pop()
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@ -97,7 +115,7 @@ ApplicationWindow {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
NavigableToolButton {
|
||||||
property string browserUrl: ""
|
property string browserUrl: ""
|
||||||
|
|
||||||
id: updateButton
|
id: updateButton
|
||||||
@ -122,7 +140,6 @@ ApplicationWindow {
|
|||||||
|
|
||||||
onClicked: Qt.openUrlExternally(browserUrl);
|
onClicked: Qt.openUrlExternally(browserUrl);
|
||||||
|
|
||||||
|
|
||||||
function updateAvailable(url)
|
function updateAvailable(url)
|
||||||
{
|
{
|
||||||
updateButton.browserUrl = url
|
updateButton.browserUrl = url
|
||||||
@ -133,9 +150,13 @@ ApplicationWindow {
|
|||||||
AutoUpdateChecker.onUpdateAvailable.connect(updateAvailable)
|
AutoUpdateChecker.onUpdateAvailable.connect(updateAvailable)
|
||||||
AutoUpdateChecker.start()
|
AutoUpdateChecker.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
NavigableToolButton {
|
||||||
Image {
|
Image {
|
||||||
source: "qrc:/res/question_mark.svg"
|
source: "qrc:/res/question_mark.svg"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@ -152,9 +173,13 @@ ApplicationWindow {
|
|||||||
|
|
||||||
// TODO need to make sure browser is brought to foreground.
|
// TODO need to make sure browser is brought to foreground.
|
||||||
onClicked: Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide");
|
onClicked: Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide");
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
NavigableToolButton {
|
||||||
// TODO: Implement gamepad mapping then unhide this button
|
// TODO: Implement gamepad mapping then unhide this button
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
@ -173,9 +198,13 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
|
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton {
|
NavigableToolButton {
|
||||||
Image {
|
Image {
|
||||||
source: "qrc:/res/settings.svg"
|
source: "qrc:/res/settings.svg"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@ -187,6 +216,10 @@ ApplicationWindow {
|
|||||||
|
|
||||||
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
|
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
|
|
||||||
ToolTip.delay: 1000
|
ToolTip.delay: 1000
|
||||||
ToolTip.timeout: 3000
|
ToolTip.timeout: 3000
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
|
@ -7,5 +7,7 @@
|
|||||||
<file>gui/StreamSegue.qml</file>
|
<file>gui/StreamSegue.qml</file>
|
||||||
<file>gui/GamepadMapper.qml</file>
|
<file>gui/GamepadMapper.qml</file>
|
||||||
<file>gui/QuitSegue.qml</file>
|
<file>gui/QuitSegue.qml</file>
|
||||||
|
<file>gui/NavigableToolButton.qml</file>
|
||||||
|
<file>gui/NavigableItemDelegate.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user