mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 08:15:37 +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:
parent
754a14941b
commit
8037fb76fc
@ -20,36 +20,28 @@ GridView {
|
|||||||
anchors.bottomMargin: 5
|
anchors.bottomMargin: 5
|
||||||
cellWidth: 225; cellHeight: 385;
|
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()
|
function computerLost()
|
||||||
{
|
{
|
||||||
// Go back to the PC view on PC loss
|
// Go back to the PC view on PC loss
|
||||||
stackView.pop()
|
stackView.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
// Don't show any highlighted item until interacting with them
|
|
||||||
currentIndex = -1
|
|
||||||
}
|
|
||||||
|
|
||||||
SdlGamepadKeyNavigation {
|
SdlGamepadKeyNavigation {
|
||||||
id: gamepadKeyNav
|
id: gamepadKeyNav
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible) {
|
|
||||||
appModel.computerLost.connect(computerLost)
|
appModel.computerLost.connect(computerLost)
|
||||||
gamepadKeyNav.enable()
|
gamepadKeyNav.enable()
|
||||||
|
|
||||||
|
// Don't show any highlighted item until interacting with them
|
||||||
|
currentIndex = -1
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
StackView.onDeactivating: {
|
||||||
appModel.computerLost.disconnect(computerLost)
|
appModel.computerLost.disconnect(computerLost)
|
||||||
gamepadKeyNav.disable()
|
gamepadKeyNav.disable()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function createModel()
|
function createModel()
|
||||||
{
|
{
|
||||||
|
@ -21,13 +21,8 @@ Item {
|
|||||||
errorDialog.open()
|
errorDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
// The StackView will trigger a visibility change when
|
StackView.onActivated: {
|
||||||
// we're pushed onto it, causing our onVisibleChanged
|
if (!launcher.isExecuted()) {
|
||||||
// routine to run, but only if we start as invisible
|
|
||||||
visible: false
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
if (visible && !launcher.isExecuted()) {
|
|
||||||
toolBar.visible = false
|
toolBar.visible = false
|
||||||
launcher.searchingComputer.connect(onSearchingComputer)
|
launcher.searchingComputer.connect(onSearchingComputer)
|
||||||
launcher.quittingApp.connect(onQuittingApp)
|
launcher.quittingApp.connect(onQuittingApp)
|
||||||
|
@ -6,8 +6,6 @@ import QtQuick.Dialogs 1.2
|
|||||||
import ComputerManager 1.0
|
import ComputerManager 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
visible: false
|
|
||||||
|
|
||||||
function onSearchingComputer() {
|
function onSearchingComputer() {
|
||||||
stageLabel.text = "Establishing connection to PC..."
|
stageLabel.text = "Establishing connection to PC..."
|
||||||
}
|
}
|
||||||
@ -36,8 +34,8 @@ Item {
|
|||||||
quitAppDialog.open()
|
quitAppDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible && !launcher.isExecuted()) {
|
if (!launcher.isExecuted()) {
|
||||||
toolBar.visible = false
|
toolBar.visible = false
|
||||||
launcher.searchingComputer.connect(onSearchingComputer)
|
launcher.searchingComputer.connect(onSearchingComputer)
|
||||||
launcher.searchingApp.connect(onSearchingApp)
|
launcher.searchingApp.connect(onSearchingApp)
|
||||||
|
@ -24,11 +24,6 @@ GridView {
|
|||||||
cellWidth: 350; cellHeight: 350;
|
cellWidth: 350; cellHeight: 350;
|
||||||
objectName: "Computers"
|
objectName: "Computers"
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
StreamingPreferences {
|
StreamingPreferences {
|
||||||
id: prefs
|
id: prefs
|
||||||
}
|
}
|
||||||
@ -37,16 +32,9 @@ GridView {
|
|||||||
id: gamepadKeyNav
|
id: gamepadKeyNav
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible) {
|
|
||||||
gamepadKeyNav.enable()
|
gamepadKeyNav.enable()
|
||||||
}
|
|
||||||
else {
|
|
||||||
gamepadKeyNav.disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
// Setup signals on CM
|
// Setup signals on CM
|
||||||
ComputerManager.computerAddCompleted.connect(addComplete)
|
ComputerManager.computerAddCompleted.connect(addComplete)
|
||||||
|
|
||||||
@ -54,6 +42,11 @@ GridView {
|
|||||||
currentIndex = -1
|
currentIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StackView.onDeactivating: {
|
||||||
|
gamepadKeyNav.disable()
|
||||||
|
ComputerManager.computerAddCompleted.disconnect(addComplete)
|
||||||
|
}
|
||||||
|
|
||||||
function pairingComplete(error)
|
function pairingComplete(error)
|
||||||
{
|
{
|
||||||
// Close the PIN dialog
|
// Close the PIN dialog
|
||||||
|
@ -14,11 +14,6 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
// 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 quitAppCompleted(error)
|
function quitAppCompleted(error)
|
||||||
{
|
{
|
||||||
// Display a failed dialog if we got an error
|
// Display a failed dialog if we got an error
|
||||||
@ -42,19 +37,18 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible) {
|
|
||||||
// Hide the toolbar before we start loading
|
// Hide the toolbar before we start loading
|
||||||
toolBar.visible = false
|
toolBar.visible = false
|
||||||
|
|
||||||
// Connect the quit completion signal
|
// Connect the quit completion signal
|
||||||
ComputerManager.quitAppCompleted.connect(quitAppCompleted)
|
ComputerManager.quitAppCompleted.connect(quitAppCompleted)
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
StackView.onDeactivating: {
|
||||||
// Disconnect the signal
|
// Disconnect the signal
|
||||||
ComputerManager.quitAppCompleted.disconnect(quitAppCompleted)
|
ComputerManager.quitAppCompleted.disconnect(quitAppCompleted)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -28,26 +28,17 @@ Flickable {
|
|||||||
id: prefs
|
id: prefs
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
SdlGamepadKeyNavigation {
|
SdlGamepadKeyNavigation {
|
||||||
id: gamepadKeyNav
|
id: gamepadKeyNav
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible) {
|
|
||||||
gamepadKeyNav.setSettingsMode(true)
|
gamepadKeyNav.setSettingsMode(true)
|
||||||
gamepadKeyNav.enable()
|
gamepadKeyNav.enable()
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
gamepadKeyNav.disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onDestruction: {
|
StackView.onDeactivating: {
|
||||||
|
gamepadKeyNav.disable()
|
||||||
prefs.save()
|
prefs.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,6 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
// 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 stageStarting(stage)
|
function stageStarting(stage)
|
||||||
{
|
{
|
||||||
// Update the spinner text
|
// Update the spinner text
|
||||||
@ -105,8 +100,7 @@ Item {
|
|||||||
id: gamepadKeyNav
|
id: gamepadKeyNav
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
StackView.onActivated: {
|
||||||
if (visible) {
|
|
||||||
// Hide the toolbar before we start loading
|
// Hide the toolbar before we start loading
|
||||||
toolBar.visible = false
|
toolBar.visible = false
|
||||||
|
|
||||||
@ -130,11 +124,11 @@ Item {
|
|||||||
// Run the streaming session to completion
|
// Run the streaming session to completion
|
||||||
session.exec(Screen.virtualX, Screen.virtualY)
|
session.exec(Screen.virtualX, Screen.virtualY)
|
||||||
}
|
}
|
||||||
else if (!quitAfter) {
|
|
||||||
// Show the toolbar again when we become hidden
|
StackView.onDeactivating: {
|
||||||
|
// Show the toolbar again
|
||||||
toolBar.visible = true
|
toolBar.visible = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user