diff --git a/app/gui/AppView.qml b/app/gui/AppView.qml index e7b240ea..f939dbfd 100644 --- a/app/gui/AppView.qml +++ b/app/gui/AppView.qml @@ -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() diff --git a/app/gui/CliQuitStreamSegue.qml b/app/gui/CliQuitStreamSegue.qml index 31e239ed..2afc4e61 100644 --- a/app/gui/CliQuitStreamSegue.qml +++ b/app/gui/CliQuitStreamSegue.qml @@ -21,13 +21,8 @@ Item { errorDialog.open() } - // 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 - - onVisibleChanged: { - if (visible && !launcher.isExecuted()) { + StackView.onActivated: { + if (!launcher.isExecuted()) { toolBar.visible = false launcher.searchingComputer.connect(onSearchingComputer) launcher.quittingApp.connect(onQuittingApp) diff --git a/app/gui/CliStartStreamSegue.qml b/app/gui/CliStartStreamSegue.qml index 739216a0..7571495e 100644 --- a/app/gui/CliStartStreamSegue.qml +++ b/app/gui/CliStartStreamSegue.qml @@ -6,8 +6,6 @@ import QtQuick.Dialogs 1.2 import ComputerManager 1.0 Item { - visible: false - function onSearchingComputer() { stageLabel.text = "Establishing connection to PC..." } @@ -36,8 +34,8 @@ Item { quitAppDialog.open() } - onVisibleChanged: { - if (visible && !launcher.isExecuted()) { + StackView.onActivated: { + if (!launcher.isExecuted()) { toolBar.visible = false launcher.searchingComputer.connect(onSearchingComputer) launcher.searchingApp.connect(onSearchingApp) diff --git a/app/gui/PcView.qml b/app/gui/PcView.qml index 81b6165c..61d1704d 100644 --- a/app/gui/PcView.qml +++ b/app/gui/PcView.qml @@ -24,11 +24,6 @@ GridView { cellWidth: 350; cellHeight: 350; 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 { id: prefs } @@ -37,16 +32,9 @@ GridView { id: gamepadKeyNav } - onVisibleChanged: { - if (visible) { - gamepadKeyNav.enable() - } - else { - gamepadKeyNav.disable() - } - } + StackView.onActivated: { + gamepadKeyNav.enable() - Component.onCompleted: { // Setup signals on CM ComputerManager.computerAddCompleted.connect(addComplete) @@ -54,6 +42,11 @@ GridView { currentIndex = -1 } + StackView.onDeactivating: { + gamepadKeyNav.disable() + ComputerManager.computerAddCompleted.disconnect(addComplete) + } + function pairingComplete(error) { // Close the PIN dialog diff --git a/app/gui/QuitSegue.qml b/app/gui/QuitSegue.qml index b876c2ea..5375e675 100644 --- a/app/gui/QuitSegue.qml +++ b/app/gui/QuitSegue.qml @@ -14,11 +14,6 @@ Item { 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) { // Display a failed dialog if we got an error @@ -42,18 +37,17 @@ Item { } } - onVisibleChanged: { - if (visible) { - // Hide the toolbar before we start loading - toolBar.visible = false + StackView.onActivated: { + // Hide the toolbar before we start loading + toolBar.visible = false - // Connect the quit completion signal - ComputerManager.quitAppCompleted.connect(quitAppCompleted) - } - else { - // Disconnect the signal - ComputerManager.quitAppCompleted.disconnect(quitAppCompleted) - } + // Connect the quit completion signal + ComputerManager.quitAppCompleted.connect(quitAppCompleted) + } + + StackView.onDeactivating: { + // Disconnect the signal + ComputerManager.quitAppCompleted.disconnect(quitAppCompleted) } Row { diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index 5c6a53df..2099e178 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -28,26 +28,17 @@ Flickable { 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 { id: gamepadKeyNav } - onVisibleChanged: { - if (visible) { - gamepadKeyNav.setSettingsMode(true) - gamepadKeyNav.enable() - } - else { - gamepadKeyNav.disable() - } + StackView.onActivated: { + gamepadKeyNav.setSettingsMode(true) + gamepadKeyNav.enable() } - Component.onDestruction: { + StackView.onDeactivating: { + gamepadKeyNav.disable() prefs.save() } diff --git a/app/gui/StreamSegue.qml b/app/gui/StreamSegue.qml index d3a4dec1..ccb3bc1e 100644 --- a/app/gui/StreamSegue.qml +++ b/app/gui/StreamSegue.qml @@ -15,11 +15,6 @@ Item { 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) { // Update the spinner text @@ -105,35 +100,34 @@ Item { id: gamepadKeyNav } - onVisibleChanged: { - if (visible) { - // Hide the toolbar before we start loading - toolBar.visible = false + StackView.onActivated: { + // Hide the toolbar before we start loading + toolBar.visible = false - // Set the hint text. We do this here rather than - // in the hintText control itself to synchronize - // with Session.exec() which requires no concurrent - // gamepad usage. - hintText.text = gamepadKeyNav.getConnectedGamepads() > 0 ? - "Tip: Press Start+Select+L1+R1 to disconnect your session" : - "Tip: Press Ctrl+Alt+Shift+Q to disconnect your session" + // Set the hint text. We do this here rather than + // in the hintText control itself to synchronize + // with Session.exec() which requires no concurrent + // gamepad usage. + hintText.text = gamepadKeyNav.getConnectedGamepads() > 0 ? + "Tip: Press Start+Select+L1+R1 to disconnect your session" : + "Tip: Press Ctrl+Alt+Shift+Q to disconnect your session" - // Hook up our signals - session.stageStarting.connect(stageStarting) - session.stageFailed.connect(stageFailed) - session.connectionStarted.connect(connectionStarted) - session.displayLaunchError.connect(displayLaunchError) - session.displayLaunchWarning.connect(displayLaunchWarning) - session.quitStarting.connect(quitStarting) - session.sessionFinished.connect(sessionFinished) + // Hook up our signals + session.stageStarting.connect(stageStarting) + session.stageFailed.connect(stageFailed) + session.connectionStarted.connect(connectionStarted) + session.displayLaunchError.connect(displayLaunchError) + session.displayLaunchWarning.connect(displayLaunchWarning) + session.quitStarting.connect(quitStarting) + session.sessionFinished.connect(sessionFinished) - // Run the streaming session to completion - session.exec(Screen.virtualX, Screen.virtualY) - } - else if (!quitAfter) { - // Show the toolbar again when we become hidden - toolBar.visible = true - } + // Run the streaming session to completion + session.exec(Screen.virtualX, Screen.virtualY) + } + + StackView.onDeactivating: { + // Show the toolbar again + toolBar.visible = true } Row {