mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
Rewrite dialog code to use Quick Controls 2
This commit is contained in:
+1
-5
@@ -1,5 +1,4 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import AppModel 1.0
|
||||
@@ -221,7 +220,7 @@ GridView {
|
||||
property string nextAppName: ""
|
||||
property int nextAppIndex: 0
|
||||
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
|
||||
function quitApp() {
|
||||
var component = Qt.createComponent("QuitSegue.qml")
|
||||
@@ -243,9 +242,6 @@ GridView {
|
||||
appModel.quitRunningApp()
|
||||
}
|
||||
|
||||
onYes: quitApp()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: quitApp()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
import Session 1.0
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import QtQml 2.2
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
|
||||
@@ -76,9 +75,8 @@ Item {
|
||||
|
||||
NavigableMessageDialog {
|
||||
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
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
property string appName : ""
|
||||
|
||||
function quitApp() {
|
||||
@@ -89,9 +87,6 @@ Item {
|
||||
launcher.quitRunningApp()
|
||||
}
|
||||
|
||||
onYes: quitApp()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: quitApp()
|
||||
|
||||
// Exit process if app quit is rejected (reacts also to closing of the
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import SystemProperties 1.0
|
||||
|
||||
NavigableMessageDialog {
|
||||
property string helpText
|
||||
property string helpUrl : "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting"
|
||||
|
||||
informativeText: SystemProperties.hasBrowser ? helpText : ""
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok |
|
||||
(SystemProperties.hasBrowser ? StandardButton.Help : 0)
|
||||
|
||||
onHelp: {
|
||||
Qt.openUrlExternally(helpUrl)
|
||||
}
|
||||
standardButtons: Dialog.Ok | (SystemProperties.hasBrowser ? Dialog.Help : 0)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Dialog {
|
||||
property Item originalFocusItem
|
||||
|
||||
x: Math.round((window.width - width) / 2)
|
||||
y: Math.round((window.height - height) / 2)
|
||||
|
||||
onAboutToShow: {
|
||||
originalFocusItem = window.activeFocusItem
|
||||
}
|
||||
|
||||
onOpened: {
|
||||
// Force focus on the dialog to ensure keyboard navigation works
|
||||
forceActiveFocus()
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
// We must force focus back to the last item for platforms without
|
||||
// support for more than one active window like Steam Link. If
|
||||
// we don't, gamepad and keyboard navigation will break after a
|
||||
// dialog appears.
|
||||
originalFocusItem.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,53 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
MessageDialog {
|
||||
property Item originalFocusItem
|
||||
import SystemProperties 1.0
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!isWindow) {
|
||||
if (visible) {
|
||||
originalFocusItem = window.activeFocusItem
|
||||
NavigableDialog {
|
||||
id: dialog
|
||||
|
||||
property alias text: dialogTextControl.dialogText
|
||||
|
||||
property string helpText
|
||||
property string helpUrl : "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting"
|
||||
|
||||
Row {
|
||||
spacing: 10
|
||||
|
||||
Image {
|
||||
source: (standardButtons & Dialog.Yes) ?
|
||||
"qrc:/res/baseline-help_outline-24px.svg" :
|
||||
"qrc:/res/baseline-error_outline-24px.svg"
|
||||
sourceSize {
|
||||
// The icon should be square so use the height as the width too
|
||||
width: 50
|
||||
height: 50
|
||||
}
|
||||
else {
|
||||
// We must force focus back to the last item for platforms without
|
||||
// support for more than one active window like Steam Link. If
|
||||
// we don't, gamepad and keyboard navigation will break after a
|
||||
// dialog appears.
|
||||
originalFocusItem.forceActiveFocus()
|
||||
}
|
||||
|
||||
Label {
|
||||
property string dialogText
|
||||
|
||||
id: dialogTextControl
|
||||
text: dialogText + (SystemProperties.hasBrowser ? (" " + helpText) : "")
|
||||
wrapMode: Text.WordWrap
|
||||
focus: true
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer: DialogButtonBox {
|
||||
id: dialogButtonBox
|
||||
standardButtons: dialog.standardButtons
|
||||
|
||||
onHelpRequested: {
|
||||
Qt.openUrlExternally(helpUrl)
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-8
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
@@ -240,10 +239,9 @@ GridView {
|
||||
NavigableMessageDialog {
|
||||
id: pairDialog
|
||||
// don't allow edits to the rest of the window while open
|
||||
modality:Qt.WindowModal
|
||||
property string pin : "0000"
|
||||
text:"Please enter " + pin + " on your GameStream PC. This dialog will close when pairing is completed."
|
||||
standardButtons: StandardButton.Cancel
|
||||
standardButtons: Dialog.Cancel
|
||||
onRejected: {
|
||||
// FIXME: We should interrupt pairing here
|
||||
}
|
||||
@@ -252,19 +250,15 @@ GridView {
|
||||
NavigableMessageDialog {
|
||||
id: deletePcDialog
|
||||
// don't allow edits to the rest of the window while open
|
||||
modality:Qt.WindowModal
|
||||
property int pcIndex : -1;
|
||||
text:"Are you sure you want to remove this PC?"
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
|
||||
function deletePc() {
|
||||
console.log("deleting PC pairing for PC at index: " + pcIndex)
|
||||
computerModel.deleteComputer(pcIndex);
|
||||
}
|
||||
|
||||
onYes: deletePc()
|
||||
|
||||
// For keyboard/gamepad activation
|
||||
onAccepted: deletePc()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
import Session 1.0
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
|
||||
+10
-21
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
@@ -379,7 +378,6 @@ ApplicationWindow {
|
||||
|
||||
ErrorMessageDialog {
|
||||
id: noHwDecoderDialog
|
||||
icon: StandardIcon.Warning
|
||||
text: "No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " +
|
||||
"Your streaming performance may be severely degraded in this configuration."
|
||||
helpText: "Click the Help button for more information on solving this problem."
|
||||
@@ -388,7 +386,6 @@ ApplicationWindow {
|
||||
|
||||
ErrorMessageDialog {
|
||||
id: waylandDialog
|
||||
icon: StandardIcon.Warning
|
||||
text: "Moonlight does not support hardware acceleration on Wayland. Continuing on Wayland may result in poor streaming performance. " +
|
||||
"Please switch to an X session for optimal performance."
|
||||
helpText: "Click the Help button for more information."
|
||||
@@ -397,8 +394,7 @@ ApplicationWindow {
|
||||
|
||||
NavigableMessageDialog {
|
||||
id: wow64Dialog
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
text: "This PC is running a 64-bit version of Windows. Please download the x64 version of Moonlight for the best streaming performance."
|
||||
onAccepted: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-qt/releases");
|
||||
@@ -408,7 +404,6 @@ ApplicationWindow {
|
||||
ErrorMessageDialog {
|
||||
id: unmappedGamepadDialog
|
||||
property string unmappedGamepads : ""
|
||||
icon: StandardIcon.Warning
|
||||
text: "Moonlight detected gamepads without a mapping:\n" + unmappedGamepads
|
||||
helpText: "Click the Help button for information on how to map your gamepads."
|
||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping"
|
||||
@@ -417,21 +412,17 @@ ApplicationWindow {
|
||||
// This dialog appears when quitting via keyboard or gamepad button
|
||||
NavigableMessageDialog {
|
||||
id: quitConfirmationDialog
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
text: "Are you sure you want to quit?"
|
||||
|
||||
onYes: Qt.quit()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: Qt.quit()
|
||||
}
|
||||
|
||||
Dialog {
|
||||
NavigableDialog {
|
||||
id: addPcDialog
|
||||
property string label: "Enter the IP address of your GameStream PC:"
|
||||
|
||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
|
||||
onAccepted: {
|
||||
if (editText.text) {
|
||||
@@ -439,22 +430,20 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
editText.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Text {
|
||||
Label {
|
||||
text: addPcDialog.label
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: editText
|
||||
color: "black"
|
||||
Layout.fillWidth: true
|
||||
focus: true
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
addPcDialog.accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user