mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Fix focus issues after dismissal of consecutive dialogs (like Add PC -> Add PC error)
This commit is contained in:
@@ -2,27 +2,16 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
property Item originalFocusItem
|
|
||||||
|
|
||||||
parent: overlay
|
parent: overlay
|
||||||
|
|
||||||
x: Math.round((parent.width - width) / 2)
|
x: Math.round((parent.width - width) / 2)
|
||||||
y: Math.round((parent.height - height) / 2)
|
y: Math.round((parent.height - height) / 2)
|
||||||
|
|
||||||
onAboutToShow: {
|
onAboutToHide: {
|
||||||
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
|
// We must force focus back to the last item for platforms without
|
||||||
// support for more than one active window like Steam Link. If
|
// support for more than one active window like Steam Link. If
|
||||||
// we don't, gamepad and keyboard navigation will break after a
|
// we don't, gamepad and keyboard navigation will break after a
|
||||||
// dialog appears.
|
// dialog appears.
|
||||||
originalFocusItem.forceActiveFocus()
|
stackView.forceActiveFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,16 @@ import SystemProperties 1.0
|
|||||||
NavigableDialog {
|
NavigableDialog {
|
||||||
id: dialog
|
id: dialog
|
||||||
|
|
||||||
property alias text: dialogTextControl.dialogText
|
property alias text: dialogLabel.dialogText
|
||||||
|
|
||||||
property string helpText
|
property string helpText
|
||||||
property string helpUrl : "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting"
|
property string helpUrl : "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting"
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
// Force keyboard focus on the label so keyboard navigation works
|
||||||
|
dialogLabel.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
@@ -29,10 +34,9 @@ NavigableDialog {
|
|||||||
Label {
|
Label {
|
||||||
property string dialogText
|
property string dialogText
|
||||||
|
|
||||||
id: dialogTextControl
|
id: dialogLabel
|
||||||
text: dialogText + (SystemProperties.hasBrowser ? (" " + helpText) : "")
|
text: dialogText + (SystemProperties.hasBrowser ? (" " + helpText) : "")
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
focus: true
|
|
||||||
|
|
||||||
// Cap the width so the dialog doesn't grow horizontally forever. This
|
// Cap the width so the dialog doesn't grow horizontally forever. This
|
||||||
// will cause word wrap to kick in.
|
// will cause word wrap to kick in.
|
||||||
|
|||||||
@@ -424,6 +424,11 @@ ApplicationWindow {
|
|||||||
|
|
||||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
// Force keyboard focus on the textbox so keyboard navigation works
|
||||||
|
editText.forceActiveFocus()
|
||||||
|
}
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (editText.text) {
|
if (editText.text) {
|
||||||
ComputerManager.addNewHost(editText.text, false)
|
ComputerManager.addNewHost(editText.text, false)
|
||||||
|
|||||||
Reference in New Issue
Block a user