From 3f81d055af4a9392ef412befa20d6fade0bde918 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 9 Aug 2018 18:48:40 -0700 Subject: [PATCH] Return to the PC grid if the selected PC goes offline or becomes unpaired --- app/gui/AppView.qml | 10 ++++++++++ app/gui/appmodel.cpp | 8 ++++++++ app/gui/appmodel.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/app/gui/AppView.qml b/app/gui/AppView.qml index f661a92b..8da1d0f5 100644 --- a/app/gui/AppView.qml +++ b/app/gui/AppView.qml @@ -28,14 +28,24 @@ GridView { // 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() + } + onVisibleChanged: { if (visible) { // Start polling when this view is shown ComputerManager.startPolling() + + appModel.computerLost.connect(computerLost) } else { // Stop polling when this view is not on top ComputerManager.stopPollingAsync() + + appModel.computerLost.disconnect(computerLost) } } diff --git a/app/gui/appmodel.cpp b/app/gui/appmodel.cpp index ba951b74..2c23185c 100644 --- a/app/gui/appmodel.cpp +++ b/app/gui/appmodel.cpp @@ -108,6 +108,14 @@ void AppModel::handleComputerStateChanged(NvComputer* computer) return; } + // If the computer has gone offline or we've been unpaired, + // signal the UI so we can go back to the PC view. + if (m_Computer->state == NvComputer::CS_OFFLINE || + m_Computer->pairState == NvComputer::PS_NOT_PAIRED) { + emit computerLost(); + return; + } + // First, process additions/removals from the app list. This // is required because the new game may now be running, so // we can't check that first. diff --git a/app/gui/appmodel.h b/app/gui/appmodel.h index 07e94126..c00a5312 100644 --- a/app/gui/appmodel.h +++ b/app/gui/appmodel.h @@ -42,6 +42,9 @@ private slots: void handleBoxArtLoaded(NvComputer* computer, NvApp app, QUrl image); +signals: + void computerLost(); + private: NvComputer* m_Computer; BoxArtManager m_BoxArtManager;