Add a segue to the streaming window

This commit is contained in:
Cameron Gutman 2018-07-08 22:06:52 -07:00
parent 5a04a256e0
commit 83ca211d75
3 changed files with 105 additions and 9 deletions

View file

@ -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)
}
}
}

99
app/gui/StreamSegue.qml Normal file
View file

@ -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
}
}

View file

@ -7,5 +7,6 @@
<file>gui/ic_add_to_queue_white_48px.svg</file>
<file>gui/AppView.qml</file>
<file>gui/SettingsView.qml</file>
<file>gui/StreamSegue.qml</file>
</qresource>
</RCC>