From b14a0fa2ce459b89c297e7a2ab6da469c143938e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 30 Sep 2018 22:39:51 -0700 Subject: [PATCH] Ensure initial warning dialogs always appear on top of the Moonlight window --- app/gui/PcView.qml | 66 ------------------------------------ app/gui/main.qml | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/app/gui/PcView.qml b/app/gui/PcView.qml index b7296269..ed614b82 100644 --- a/app/gui/PcView.qml +++ b/app/gui/PcView.qml @@ -50,22 +50,6 @@ GridView { // Setup signals on CM ComputerManager.computerAddCompleted.connect(addComplete) - if (prefs.isRunningWayland()) { - waylandDialog.open() - } - else if (prefs.isWow64()) { - wow64Dialog.open() - } - else if (!prefs.hasAnyHardwareAcceleration()) { - noHwDecoderDialog.open() - } - - var unmappedGamepads = prefs.getUnmappedGamepads() - if (unmappedGamepads) { - unmappedGamepadDialog.unmappedGamepads = unmappedGamepads - unmappedGamepadDialog.open() - } - // Don't show any highlighted item until interacting with them currentIndex = -1 } @@ -236,56 +220,6 @@ GridView { } } - MessageDialog { - id: noHwDecoderDialog - modality:Qt.WindowModal - icon: StandardIcon.Warning - standardButtons: StandardButton.Ok | StandardButton.Help - text: "No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " + - "Your streaming performance may be severely degraded in this configuration. " + - "Click the Help button for more information on solving this problem." - onHelp: { - Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"); - } - } - - MessageDialog { - id: waylandDialog - modality:Qt.WindowModal - icon: StandardIcon.Warning - standardButtons: StandardButton.Ok | StandardButton.Help - 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." - onHelp: { - Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"); - } - } - - MessageDialog { - id: wow64Dialog - modality:Qt.WindowModal - icon: StandardIcon.Warning - standardButtons: StandardButton.Ok | StandardButton.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"); - } - } - - MessageDialog { - id: unmappedGamepadDialog - property string unmappedGamepads : "" - modality:Qt.WindowModal - icon: StandardIcon.Warning - standardButtons: StandardButton.Ok | StandardButton.Help - text: "Moonlight detected gamepads without a proper mapping. " + - "The following gamepads will not function until this is resolved: " + unmappedGamepads + "\n\n" + - "Click the Help button for information on how to map your gamepads." - onHelp: { - Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping"); - } - } - MessageDialog { id: pairDialog // don't allow edits to the rest of the window while open diff --git a/app/gui/main.qml b/app/gui/main.qml index 98845249..54c18ca8 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -1,5 +1,6 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 +import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 @@ -7,6 +8,7 @@ import QtQuick.Controls.Material 2.1 import ComputerManager 1.0 import AutoUpdateChecker 1.0 +import StreamingPreferences 1.0 ApplicationWindow { property bool pollingActive: false @@ -19,6 +21,10 @@ ApplicationWindow { Material.theme: Material.Dark Material.accent: Material.Purple + StreamingPreferences { + id: prefs + } + StackView { id: stackView initialItem: initialView @@ -74,6 +80,34 @@ ApplicationWindow { } } + property bool initialized: false + + onAfterSynchronizing: { + // We use this callback to trigger dialog display because + // it only happens once the window is fully constructed. + // Doing it earlier can lead to the dialog appearing behind + // the window or otherwise without input focus. + if (!initialized) { + if (prefs.isRunningWayland()) { + waylandDialog.open() + } + else if (prefs.isWow64()) { + wow64Dialog.open() + } + else if (!prefs.hasAnyHardwareAcceleration()) { + noHwDecoderDialog.open() + } + + var unmappedGamepads = prefs.getUnmappedGamepads() + if (unmappedGamepads) { + unmappedGamepadDialog.unmappedGamepads = unmappedGamepads + unmappedGamepadDialog.open() + } + + initialized = true; + } + } + function navigateTo(url, objectName) { var existingItem = stackView.find(function(item, index) { @@ -260,4 +294,54 @@ ApplicationWindow { } } } + + MessageDialog { + id: noHwDecoderDialog + modality:Qt.WindowModal + icon: StandardIcon.Warning + standardButtons: StandardButton.Ok | StandardButton.Help + text: "No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " + + "Your streaming performance may be severely degraded in this configuration. " + + "Click the Help button for more information on solving this problem." + onHelp: { + Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"); + } + } + + MessageDialog { + id: waylandDialog + modality:Qt.WindowModal + icon: StandardIcon.Warning + standardButtons: StandardButton.Ok | StandardButton.Help + 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." + onHelp: { + Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"); + } + } + + MessageDialog { + id: wow64Dialog + modality:Qt.WindowModal + icon: StandardIcon.Warning + standardButtons: StandardButton.Ok | StandardButton.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"); + } + } + + MessageDialog { + id: unmappedGamepadDialog + property string unmappedGamepads : "" + modality:Qt.WindowModal + icon: StandardIcon.Warning + standardButtons: StandardButton.Ok | StandardButton.Help + text: "Moonlight detected gamepads without a proper mapping. " + + "The following gamepads will not function until this is resolved: " + unmappedGamepads + "\n\n" + + "Click the Help button for information on how to map your gamepads." + onHelp: { + Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping"); + } + } }