2018-07-09 05:06:52 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.2
|
2018-08-30 04:00:05 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2018-09-05 22:15:53 +00:00
|
|
|
import QtQuick.Window 2.2
|
2018-07-09 05:06:52 +00:00
|
|
|
|
|
|
|
import Session 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property Session session
|
2018-08-02 05:32:21 +00:00
|
|
|
property string appName
|
|
|
|
property string stageText : "Starting " + appName + "..."
|
2018-07-09 05:06:52 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2018-08-04 23:05:37 +00:00
|
|
|
// This toast appears for 3 seconds, just shorter than how long
|
|
|
|
// Session will wait for it to be displayed. This gives it time
|
|
|
|
// to transition to invisible before continuing.
|
|
|
|
var toast = Qt.createQmlObject('import QtQuick.Controls 2.3; ToolTip {}', parent, '')
|
|
|
|
toast.text = text
|
|
|
|
toast.timeout = 3000
|
|
|
|
toast.visible = true
|
2018-07-09 05:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
2018-07-09 07:12:27 +00:00
|
|
|
// Hide the toolbar before we start loading
|
|
|
|
toolBar.visible = false
|
|
|
|
|
2018-07-09 05:06:52 +00:00
|
|
|
// Hook up our signals
|
|
|
|
session.stageStarting.connect(stageStarting)
|
|
|
|
session.stageFailed.connect(stageFailed)
|
|
|
|
session.connectionStarted.connect(connectionStarted)
|
|
|
|
session.displayLaunchError.connect(displayLaunchError)
|
|
|
|
session.displayLaunchWarning.connect(displayLaunchWarning)
|
|
|
|
|
2018-09-13 21:38:56 +00:00
|
|
|
// Run the streaming session to completion
|
|
|
|
session.exec(Screen.virtualX, Screen.virtualY)
|
|
|
|
|
|
|
|
// Show the Qt window again after streaming
|
|
|
|
window.visible = true
|
|
|
|
|
|
|
|
// Exit this view
|
|
|
|
stackView.pop()
|
2018-07-09 05:06:52 +00:00
|
|
|
}
|
2018-07-09 07:12:27 +00:00
|
|
|
else {
|
|
|
|
// Show the toolbar again when we become hidden
|
|
|
|
toolBar.visible = true
|
|
|
|
}
|
2018-07-09 05:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-15 02:11:06 +00:00
|
|
|
Label {
|
|
|
|
text: "Tip: Press Ctrl+Alt+Shift+Q to disconnect your session"
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 50
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
font.pointSize: 18
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
color: "white"
|
|
|
|
}
|
|
|
|
|
2018-07-09 05:06:52 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: errorDialog
|
|
|
|
modality:Qt.WindowModal
|
|
|
|
icon: StandardIcon.Critical
|
2018-09-09 18:49:34 +00:00
|
|
|
standardButtons: StandardButton.Ok | StandardButton.Help
|
|
|
|
onHelp: {
|
|
|
|
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting");
|
|
|
|
}
|
2018-07-09 05:06:52 +00:00
|
|
|
}
|
|
|
|
}
|