mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-23 16:39:02 +00:00
Use StackView activation callbacks to perform init and cleanup since visibility callbacks aren't guaranteed to run in any order
This commit is contained in:
@@ -20,35 +20,27 @@ GridView {
|
||||
anchors.bottomMargin: 5
|
||||
cellWidth: 225; cellHeight: 385;
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
function computerLost()
|
||||
{
|
||||
// Go back to the PC view on PC loss
|
||||
stackView.pop()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Don't show any highlighted item until interacting with them
|
||||
currentIndex = -1
|
||||
}
|
||||
|
||||
SdlGamepadKeyNavigation {
|
||||
id: gamepadKeyNav
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
appModel.computerLost.connect(computerLost)
|
||||
gamepadKeyNav.enable()
|
||||
}
|
||||
else {
|
||||
appModel.computerLost.disconnect(computerLost)
|
||||
gamepadKeyNav.disable()
|
||||
}
|
||||
StackView.onActivated: {
|
||||
appModel.computerLost.connect(computerLost)
|
||||
gamepadKeyNav.enable()
|
||||
|
||||
// Don't show any highlighted item until interacting with them
|
||||
currentIndex = -1
|
||||
}
|
||||
|
||||
StackView.onDeactivating: {
|
||||
appModel.computerLost.disconnect(computerLost)
|
||||
gamepadKeyNav.disable()
|
||||
}
|
||||
|
||||
function createModel()
|
||||
|
||||
Reference in New Issue
Block a user