From c330898aeb6027fdb69601f6292e341d74062263 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 5 Mar 2021 17:44:31 -0600 Subject: [PATCH] Add workaround for AppView breaking after changing language at runtime --- app/gui/SettingsView.qml | 5 +++++ app/gui/main.qml | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index 33cb0e51..5dace508 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -787,6 +787,11 @@ Flickable { if (!StreamingPreferences.retranslate()) { ToolTip.show(qsTr("You must restart Moonlight for this change to take effect"), 5000) } + else { + // Force the back operation to pop any AppView pages that exist. + // The AppView stops working after retranslate() for some reason. + window.clearOnBack = true + } } } } diff --git a/app/gui/main.qml b/app/gui/main.qml index 92c140bc..34b52f36 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -12,6 +12,11 @@ import SdlGamepadKeyNavigation 1.0 ApplicationWindow { property bool pollingActive: false + // Set by SettingsView to force the back operation to pop all + // pages except the initial view. This is required when doing + // a retranslate() because AppView breaks for some reason. + property bool clearOnBack: false + id: window visible: true width: 1280 @@ -31,6 +36,17 @@ ApplicationWindow { // it will never insert a line break and just extend on forever. ToolTip.toolTip.contentWidth: ToolTip.toolTip.implicitContentWidth < 400 ? ToolTip.toolTip.implicitContentWidth : 400 + function goBack() { + if (clearOnBack) { + // Pop all items except the first one + stackView.pop(null) + clearOnBack = false + } + else { + stackView.pop() + } + } + StackView { id: stackView initialItem: initialView @@ -46,7 +62,7 @@ ApplicationWindow { Keys.onEscapePressed: { if (depth > 1) { - stackView.pop() + goBack() } else { quitConfirmationDialog.open() @@ -55,7 +71,7 @@ ApplicationWindow { Keys.onBackPressed: { if (depth > 1) { - stackView.pop() + goBack() } else { quitConfirmationDialog.open() @@ -210,7 +226,7 @@ ApplicationWindow { iconSource: "qrc:/res/arrow_left.svg" - onClicked: stackView.pop() + onClicked: goBack() Keys.onDownPressed: { stackView.currentItem.forceActiveFocus(Qt.TabFocus)