diff --git a/app/gui/AppView.qml b/app/gui/AppView.qml index 8d75e065..1f4a80ff 100644 --- a/app/gui/AppView.qml +++ b/app/gui/AppView.qml @@ -72,16 +72,12 @@ GridView { anchors.fill: parent onClicked: { // TODO: Check if a different game is running - var session = appModel.createSessionForApp(index) - // Don't poll while the stream is running - ComputerManager.stopPollingAsync() - - // Run the streaming session to completion - session.exec() - - // Start polling again - ComputerManager.startPolling() + var component = Qt.createComponent("StreamSegue.qml") + var segue = component.createObject(stackView) + segue.appname = model.name + segue.session = appModel.createSessionForApp(index) + stackView.push(segue) } } } diff --git a/app/gui/StreamSegue.qml b/app/gui/StreamSegue.qml new file mode 100644 index 00000000..e5c51c0a --- /dev/null +++ b/app/gui/StreamSegue.qml @@ -0,0 +1,99 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import QtQuick.Dialogs 1.3 + +import Session 1.0 + +Item { + property Session session + property string appname + property string stageText : "Starting " + appname + "..." + + 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 + stageText = "Starting " + stage + "..." + } + + function stageFailed(stage, errorCode) + { + errorDialog.text = "Starting " + stage + " failed: Error " + errorCode + errorDialog.open() + } + + function connectionStarted() + { + // Hide the UI contents so the user doesn't + // see them briefly when we pop off the StackView + stageSpinner.visible = false + stageLabel.visible = false + + // Hide the window now that streaming has begun + window.visible = false + } + + function displayLaunchError(text) + { + errorDialog.text = text + errorDialog.open() + } + + function displayLaunchWarning(text) + { + // TODO: toast + } + + onVisibleChanged: { + if (visible) { + // Hook up our signals + session.stageStarting.connect(stageStarting) + session.stageFailed.connect(stageFailed) + session.connectionStarted.connect(connectionStarted) + session.displayLaunchError.connect(displayLaunchError) + session.displayLaunchWarning.connect(displayLaunchWarning) + + // Run the streaming session to completion + session.exec() + + // Show the Qt window again after streaming + window.visible = true + + // Exit this view + stackView.pop() + } + } + + Row { + anchors.centerIn: parent + spacing: 5 + + BusyIndicator { + id: stageSpinner + } + + Label { + id: stageLabel + height: stageSpinner.height + text: stageText + font.pointSize: 20 + verticalAlignment: Text.AlignVCenter + + wrapMode: Text.Wrap + color: "white" + } + } + + MessageDialog { + id: errorDialog + modality:Qt.WindowModal + icon: StandardIcon.Critical + standardButtons: StandardButton.Ok + } +} diff --git a/app/qml.qrc b/app/qml.qrc index 83a8c65a..73a252e8 100644 --- a/app/qml.qrc +++ b/app/qml.qrc @@ -7,5 +7,6 @@ gui/ic_add_to_queue_white_48px.svg gui/AppView.qml gui/SettingsView.qml + gui/StreamSegue.qml