From 81ad1a18fa7db429b339ac1dfbbd8695bfcad452 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 31 Mar 2019 13:57:57 -0700 Subject: [PATCH] Fix error dialog focus issues after dismissal on Steam Link --- app/gui/AppView.qml | 2 +- app/gui/CliStartStreamSegue.qml | 2 +- app/gui/ErrorMessageDialog.qml | 2 +- app/gui/NavigableMessageDialog.qml | 21 +++++++++++++++++++++ app/gui/PcView.qml | 4 ++-- app/gui/main.qml | 12 +++++++++--- app/qml.qrc | 1 + 7 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 app/gui/NavigableMessageDialog.qml diff --git a/app/gui/AppView.qml b/app/gui/AppView.qml index 5f7028ef..d585a752 100644 --- a/app/gui/AppView.qml +++ b/app/gui/AppView.qml @@ -214,7 +214,7 @@ GridView { } } - MessageDialog { + NavigableMessageDialog { id: quitAppDialog modality:Qt.WindowModal property string appName : "" diff --git a/app/gui/CliStartStreamSegue.qml b/app/gui/CliStartStreamSegue.qml index 75f150ee..06edfcc9 100644 --- a/app/gui/CliStartStreamSegue.qml +++ b/app/gui/CliStartStreamSegue.qml @@ -78,7 +78,7 @@ Item { } } - MessageDialog { + NavigableMessageDialog { id: quitAppDialog modality:Qt.WindowModal text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost." diff --git a/app/gui/ErrorMessageDialog.qml b/app/gui/ErrorMessageDialog.qml index 4e1289e0..1b7a5a7e 100644 --- a/app/gui/ErrorMessageDialog.qml +++ b/app/gui/ErrorMessageDialog.qml @@ -3,7 +3,7 @@ import QtQuick.Dialogs 1.2 import SystemProperties 1.0 -MessageDialog { +NavigableMessageDialog { property string helpText informativeText: SystemProperties.hasBrowser ? helpText : "" diff --git a/app/gui/NavigableMessageDialog.qml b/app/gui/NavigableMessageDialog.qml new file mode 100644 index 00000000..a4677556 --- /dev/null +++ b/app/gui/NavigableMessageDialog.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import QtQuick.Dialogs 1.2 + +MessageDialog { + property Item originalFocusItem + + onVisibleChanged: { + if (!isWindow) { + if (visible) { + originalFocusItem = window.activeFocusItem + } + 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() + } + } + } +} diff --git a/app/gui/PcView.qml b/app/gui/PcView.qml index 14ace787..a63e1938 100644 --- a/app/gui/PcView.qml +++ b/app/gui/PcView.qml @@ -238,7 +238,7 @@ GridView { } } - MessageDialog { + NavigableMessageDialog { id: pairDialog // don't allow edits to the rest of the window while open modality:Qt.WindowModal @@ -250,7 +250,7 @@ GridView { } } - MessageDialog { + NavigableMessageDialog { id: deletePcDialog // don't allow edits to the rest of the window while open modality:Qt.WindowModal diff --git a/app/gui/main.qml b/app/gui/main.qml index 013a6862..29e09ae9 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -230,7 +230,13 @@ ApplicationWindow { ToolTip.delay: 1000 ToolTip.timeout: 3000 ToolTip.visible: hovered - ToolTip.text: "Add a new PC manually" + ToolTip.text: "Add PC manually" + (newPcShortcut.nativeText ? (" ("+newPcShortcut.nativeText+")") : "") + + Shortcut { + id: newPcShortcut + sequence: StandardKey.New + onActivated: addPcButton.clicked() + } onClicked: { addPcDialog.open() @@ -393,7 +399,7 @@ ApplicationWindow { } } - MessageDialog { + NavigableMessageDialog { id: wow64Dialog icon: StandardIcon.Warning standardButtons: StandardButton.Ok | StandardButton.Cancel @@ -415,7 +421,7 @@ ApplicationWindow { } // This dialog appears when quitting via keyboard or gamepad button - MessageDialog { + NavigableMessageDialog { id: quitConfirmationDialog icon: StandardIcon.Warning standardButtons: StandardButton.Yes | StandardButton.No diff --git a/app/qml.qrc b/app/qml.qrc index af31c758..e9f03992 100644 --- a/app/qml.qrc +++ b/app/qml.qrc @@ -15,5 +15,6 @@ gui/AutoResizingComboBox.qml gui/NavigableMenu.qml gui/ErrorMessageDialog.qml + gui/NavigableMessageDialog.qml