mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-15 21:22:40 +00:00
* Add quit cli command and app quit option after stream session. Fixes #92 * Code review fixes.
This commit is contained in:
committed by
Cameron Gutman
parent
ad47990a87
commit
0ab07303c9
@@ -1,3 +1,4 @@
|
||||
import QtQml 2.2
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
@@ -30,13 +31,19 @@ Item {
|
||||
errorDialog.open()
|
||||
}
|
||||
|
||||
function onAppQuitRequired(appName) {
|
||||
quitAppDialog.appName = appName
|
||||
quitAppDialog.open()
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
if (visible && !launcher.isExecuted()) {
|
||||
toolBar.visible = false
|
||||
launcher.searchingComputer.connect(onSearchingComputer)
|
||||
launcher.searchingApp.connect(onSearchingApp)
|
||||
launcher.sessionCreated.connect(onSessionCreated)
|
||||
launcher.failed.connect(onLaunchFailed)
|
||||
launcher.appQuitRequired.connect(onAppQuitRequired)
|
||||
launcher.execute(ComputerManager)
|
||||
}
|
||||
}
|
||||
@@ -74,4 +81,44 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: quitAppDialog
|
||||
modality:Qt.WindowModal
|
||||
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
property string appName : ""
|
||||
|
||||
function quitApp() {
|
||||
var component = Qt.createComponent("QuitSegue.qml")
|
||||
var params = {"appName": appName}
|
||||
stackView.push(component.createObject(stackView, params))
|
||||
// Trigger the quit after pushing the quit segue on screen
|
||||
launcher.quitRunningApp()
|
||||
}
|
||||
|
||||
onYes: quitApp()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: quitApp()
|
||||
|
||||
// Exit process if app quit is rejected (reacts also to closing of the
|
||||
// dialog from title bar's close button).
|
||||
// Note: this depends on undocumented behavior of visibleChanged()
|
||||
// signal being emitted before yes() or accepted() has been emitted.
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
quitTimer.start()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
yes.connect(quitTimer.stop)
|
||||
accepted.connect(quitTimer.stop)
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: quitTimer
|
||||
interval: 100
|
||||
onTriggered: Qt.quit()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user