Rework session initialization to return to the Qt event loop while connecting
We also display multiple launch warnings at the same time
This commit is contained in:
parent
6313129603
commit
54283ce0a1
3 changed files with 84 additions and 143 deletions
|
|
@ -48,18 +48,6 @@ Item {
|
|||
console.error(text)
|
||||
}
|
||||
|
||||
function displayLaunchWarning(text)
|
||||
{
|
||||
// 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.2; ToolTip {}', parent, '')
|
||||
toast.text = text
|
||||
toast.timeout = 3000
|
||||
toast.visible = true
|
||||
console.warn(text)
|
||||
}
|
||||
|
||||
function quitStarting()
|
||||
{
|
||||
// Avoid the push transition animation
|
||||
|
|
@ -132,7 +120,6 @@ Item {
|
|||
session.stageFailed.connect(stageFailed)
|
||||
session.connectionStarted.connect(connectionStarted)
|
||||
session.displayLaunchError.connect(displayLaunchError)
|
||||
session.displayLaunchWarning.connect(displayLaunchWarning)
|
||||
session.quitStarting.connect(quitStarting)
|
||||
session.sessionFinished.connect(sessionFinished)
|
||||
session.readyForDeletion.connect(sessionReadyForDeletion)
|
||||
|
|
@ -154,6 +141,19 @@ Item {
|
|||
onTriggered: stageSpinner.visible = true
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: startSessionTimer
|
||||
onTriggered: {
|
||||
// Garbage collect QML stuff before we start streaming,
|
||||
// since we'll probably be streaming for a while and we
|
||||
// won't be able to GC during the stream.
|
||||
gc()
|
||||
|
||||
// Run the streaming session to completion
|
||||
session.start()
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: streamLoader
|
||||
active: false
|
||||
|
|
@ -170,13 +170,41 @@ Item {
|
|||
// Stop GUI gamepad usage now
|
||||
SdlGamepadKeyNavigation.disable()
|
||||
|
||||
// Garbage collect QML stuff before we start streaming,
|
||||
// since we'll probably be streaming for a while and we
|
||||
// won't be able to GC during the stream.
|
||||
gc()
|
||||
// Initialize the session and probe for host/client capabilities
|
||||
if (!session.initialize(window)) {
|
||||
sessionFinished(0);
|
||||
sessionReadyForDeletion();
|
||||
return;
|
||||
}
|
||||
|
||||
// Run the streaming session to completion
|
||||
session.exec(window)
|
||||
// Don't wait unless we have toasts to display
|
||||
startSessionTimer.interval = 0
|
||||
|
||||
// Display the toasts together in a vertical centered arrangement
|
||||
var yOffset = 0
|
||||
for (var i = 0; i < session.launchWarnings.length; i++) {
|
||||
var text = session.launchWarnings[i]
|
||||
console.warn(text)
|
||||
|
||||
// Show the tooltip
|
||||
var toast = Qt.createQmlObject('import QtQuick.Controls 2.2; ToolTip {}', parent, '')
|
||||
toast.text = text
|
||||
toast.y += yOffset
|
||||
toast.visible = true
|
||||
|
||||
// Hide the tooltip when the connection starts or fails
|
||||
session.connectionStarted.connect(toast.hide)
|
||||
session.sessionFinished.connect(toast.hide)
|
||||
|
||||
// Offset the next toast below the previous one
|
||||
yOffset = toast.y + toast.padding + toast.height
|
||||
|
||||
// Allow the user 3.5 seconds to read the tooltip(s)
|
||||
startSessionTimer.interval = 3500;
|
||||
}
|
||||
|
||||
// Start the timer to wait for toasts (or start the session immediately)
|
||||
startSessionTimer.start()
|
||||
}
|
||||
|
||||
sourceComponent: Item {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue