mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-23 00:19:40 +00:00
Focus on first item when a gamepad is connected
This commit is contained in:
@@ -5,6 +5,7 @@ import ComputerModel 1.0
|
||||
|
||||
import ComputerManager 1.0
|
||||
import StreamingPreferences 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
|
||||
CenteredGridView {
|
||||
property ComputerModel computerModel : createModel()
|
||||
@@ -27,6 +28,16 @@ CenteredGridView {
|
||||
StackView.onActivated: {
|
||||
// Setup signals on CM
|
||||
ComputerManager.computerAddCompleted.connect(addComplete)
|
||||
|
||||
// This is a bit of a hack to do this here as opposed to main.qml, but
|
||||
// we need it enabled before calling getConnectedGamepads() and PcView
|
||||
// is never destroyed, so it should be okay.
|
||||
SdlGamepadKeyNavigation.enable()
|
||||
|
||||
// Highlight the first item if a gamepad is connected
|
||||
if (currentIndex == -1 && SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
|
||||
currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
StackView.onDeactivating: {
|
||||
|
||||
Reference in New Issue
Block a user