mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-21 23:50:26 +00:00
Rewrite dialog code to use Quick Controls 2
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user