2018-07-04 21:16:25 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
2018-10-01 05:39:51 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2018-07-08 05:15:02 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
2018-08-14 02:47:42 +00:00
|
|
|
import QtQuick.Window 2.2
|
2018-07-04 21:16:25 +00:00
|
|
|
|
2018-07-09 06:24:26 +00:00
|
|
|
import QtQuick.Controls.Material 2.1
|
|
|
|
|
2018-08-14 02:47:42 +00:00
|
|
|
import ComputerManager 1.0
|
2018-08-10 05:51:27 +00:00
|
|
|
import AutoUpdateChecker 1.0
|
2018-10-01 05:39:51 +00:00
|
|
|
import StreamingPreferences 1.0
|
2018-08-10 05:51:27 +00:00
|
|
|
|
2018-07-04 21:16:25 +00:00
|
|
|
ApplicationWindow {
|
2018-08-14 02:47:42 +00:00
|
|
|
property bool pollingActive: false
|
|
|
|
|
2018-07-04 21:16:25 +00:00
|
|
|
id: window
|
|
|
|
visible: true
|
2018-07-06 05:08:55 +00:00
|
|
|
width: 1280
|
2018-09-09 20:21:11 +00:00
|
|
|
height: 600
|
2018-07-09 06:24:26 +00:00
|
|
|
|
2018-10-06 20:14:32 +00:00
|
|
|
// Maximize the window by default when the stream is configured
|
|
|
|
// for full-screen or borderless windowed. This is ideal for TV
|
|
|
|
// setups where the user doesn't want a tiny window in the middle
|
|
|
|
// of their screen when starting Moonlight.
|
|
|
|
visibility: prefs.windowMode != StreamingPreferences.WM_WINDOWED ? "Maximized" : "Windowed"
|
|
|
|
|
2018-07-09 06:24:26 +00:00
|
|
|
Material.theme: Material.Dark
|
|
|
|
Material.accent: Material.Purple
|
2018-07-04 21:16:25 +00:00
|
|
|
|
2018-10-01 05:39:51 +00:00
|
|
|
StreamingPreferences {
|
|
|
|
id: prefs
|
|
|
|
}
|
|
|
|
|
2018-07-06 03:37:51 +00:00
|
|
|
StackView {
|
|
|
|
id: stackView
|
2018-09-29 21:06:55 +00:00
|
|
|
initialItem: initialView
|
2018-07-06 03:37:51 +00:00
|
|
|
anchors.fill: parent
|
2018-09-23 22:16:27 +00:00
|
|
|
focus: true
|
|
|
|
|
|
|
|
onCurrentItemChanged: {
|
2018-09-24 02:06:26 +00:00
|
|
|
// Ensure focus travels to the next view when going back
|
2018-09-23 22:16:27 +00:00
|
|
|
if (currentItem) {
|
|
|
|
currentItem.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Keys.onEscapePressed: {
|
|
|
|
if (depth > 1) {
|
|
|
|
stackView.pop()
|
|
|
|
}
|
|
|
|
}
|
2018-09-24 02:06:26 +00:00
|
|
|
|
|
|
|
Keys.onBackPressed: {
|
|
|
|
if (depth > 1) {
|
|
|
|
stackView.pop()
|
|
|
|
}
|
|
|
|
}
|
2018-09-30 20:41:32 +00:00
|
|
|
|
|
|
|
Keys.onMenuPressed: {
|
|
|
|
settingsButton.clicked()
|
|
|
|
}
|
2018-09-30 20:52:38 +00:00
|
|
|
|
|
|
|
// This is a keypress we've reserved for letting the
|
|
|
|
// SdlGamepadKeyNavigation object tell us to show settings
|
|
|
|
// when Menu is consumed by a focused control.
|
|
|
|
Keys.onHangupPressed: {
|
|
|
|
settingsButton.clicked()
|
|
|
|
}
|
2018-07-04 21:16:25 +00:00
|
|
|
}
|
2018-07-08 05:15:02 +00:00
|
|
|
|
2018-08-14 02:47:42 +00:00
|
|
|
onVisibilityChanged: {
|
|
|
|
// We don't want to just use 'active' here because that will stop polling if
|
|
|
|
// we lose focus, which might be overzealous for users with multiple screens
|
|
|
|
// where we may be clearly visible on the other display. Ideally we'll poll
|
|
|
|
// only if the window is visible to the user (not if obscured by other windows),
|
|
|
|
// but it seems difficult to do this portably.
|
|
|
|
var shouldPoll = visibility !== Window.Minimized && visibility !== Window.Hidden
|
|
|
|
|
|
|
|
if (shouldPoll && !pollingActive) {
|
|
|
|
ComputerManager.startPolling()
|
|
|
|
pollingActive = true
|
|
|
|
}
|
|
|
|
else if (!shouldPoll && pollingActive) {
|
|
|
|
ComputerManager.stopPollingAsync()
|
|
|
|
pollingActive = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-01 05:39:51 +00:00
|
|
|
property bool initialized: false
|
|
|
|
|
2018-10-06 02:54:13 +00:00
|
|
|
// BUG: Using onAfterSynchronizing: here causes very strange
|
|
|
|
// failures on Linux. Many shaders fail to compile and we
|
|
|
|
// eventually segfault deep inside the Qt OpenGL code.
|
|
|
|
onAfterRendering: {
|
2018-10-01 05:39:51 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 05:37:29 +00:00
|
|
|
function navigateTo(url, objectName)
|
|
|
|
{
|
|
|
|
var existingItem = stackView.find(function(item, index) {
|
|
|
|
return item.objectName === objectName
|
|
|
|
})
|
|
|
|
|
|
|
|
if (existingItem !== null) {
|
|
|
|
// Pop to the existing item
|
|
|
|
stackView.pop(existingItem)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Create a new item
|
|
|
|
stackView.push(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 05:15:02 +00:00
|
|
|
header: ToolBar {
|
2018-07-09 07:12:27 +00:00
|
|
|
id: toolBar
|
2018-08-31 06:28:26 +00:00
|
|
|
anchors.topMargin: 5
|
|
|
|
anchors.bottomMargin: 5
|
2018-07-08 05:15:02 +00:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 20
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
NavigableToolButton {
|
2018-07-08 05:15:02 +00:00
|
|
|
// Only make the button visible if the user has navigated somewhere.
|
|
|
|
visible: stackView.depth > 1
|
|
|
|
|
2018-08-31 06:28:26 +00:00
|
|
|
// FIXME: We're using an Image here rather than icon.source because
|
|
|
|
// icons don't work on Qt 5.9 LTS.
|
|
|
|
Image {
|
|
|
|
source: "qrc:/res/arrow_left.svg"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
sourceSize {
|
|
|
|
// The icon should be square so use the height as the width too
|
|
|
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 05:15:02 +00:00
|
|
|
onClicked: stackView.pop()
|
2018-09-23 22:16:27 +00:00
|
|
|
|
|
|
|
Keys.onDownPressed: {
|
|
|
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
|
|
|
}
|
2018-07-08 05:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
|
|
|
text: stackView.currentItem.objectName
|
|
|
|
font.pointSize: 15
|
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
NavigableToolButton {
|
2018-08-10 05:51:27 +00:00
|
|
|
property string browserUrl: ""
|
|
|
|
|
|
|
|
id: updateButton
|
2018-08-31 06:28:26 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
source: "qrc:/res/update.svg"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
sourceSize {
|
|
|
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
2018-08-10 05:51:27 +00:00
|
|
|
|
2018-08-10 06:20:20 +00:00
|
|
|
ToolTip.delay: 1000
|
|
|
|
ToolTip.timeout: 3000
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: "Update available for Moonlight"
|
|
|
|
|
2018-08-10 05:51:27 +00:00
|
|
|
// Invisible until we get a callback notifying us that
|
|
|
|
// an update is available
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
onClicked: Qt.openUrlExternally(browserUrl);
|
|
|
|
|
|
|
|
function updateAvailable(url)
|
|
|
|
{
|
|
|
|
updateButton.browserUrl = url
|
|
|
|
updateButton.visible = true
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
AutoUpdateChecker.onUpdateAvailable.connect(updateAvailable)
|
|
|
|
AutoUpdateChecker.start()
|
|
|
|
}
|
2018-09-23 22:16:27 +00:00
|
|
|
|
|
|
|
Keys.onDownPressed: {
|
|
|
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
|
|
|
}
|
2018-08-10 05:51:27 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
NavigableToolButton {
|
2018-09-24 02:24:47 +00:00
|
|
|
id: helpButton
|
|
|
|
|
2018-08-31 06:28:26 +00:00
|
|
|
Image {
|
|
|
|
source: "qrc:/res/question_mark.svg"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
sourceSize {
|
|
|
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
2018-07-09 05:37:29 +00:00
|
|
|
|
2018-08-10 06:20:20 +00:00
|
|
|
ToolTip.delay: 1000
|
|
|
|
ToolTip.timeout: 3000
|
|
|
|
ToolTip.visible: hovered
|
2018-09-24 02:24:47 +00:00
|
|
|
ToolTip.text: "Help" + (helpShortcut.nativeText ? (" ("+helpShortcut.nativeText+")") : "")
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
id: helpShortcut
|
|
|
|
sequence: StandardKey.HelpContents
|
|
|
|
onActivated: helpButton.clicked()
|
|
|
|
}
|
2018-08-10 06:20:20 +00:00
|
|
|
|
2018-07-09 05:37:29 +00:00
|
|
|
// TODO need to make sure browser is brought to foreground.
|
|
|
|
onClicked: Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide");
|
2018-09-23 22:16:27 +00:00
|
|
|
|
|
|
|
Keys.onDownPressed: {
|
|
|
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
|
|
|
}
|
2018-07-08 05:15:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
NavigableToolButton {
|
2018-07-28 08:27:42 +00:00
|
|
|
// TODO: Implement gamepad mapping then unhide this button
|
|
|
|
visible: false
|
|
|
|
|
2018-08-10 06:20:20 +00:00
|
|
|
ToolTip.delay: 1000
|
|
|
|
ToolTip.timeout: 3000
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: "Gamepad Mapper"
|
|
|
|
|
2018-08-31 06:28:26 +00:00
|
|
|
Image {
|
|
|
|
source: "qrc:/res/ic_videogame_asset_white_48px.svg"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
sourceSize {
|
|
|
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 05:37:29 +00:00
|
|
|
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
|
2018-09-23 22:16:27 +00:00
|
|
|
|
|
|
|
Keys.onDownPressed: {
|
|
|
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
|
|
|
}
|
2018-07-09 05:37:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
NavigableToolButton {
|
2018-09-24 02:24:47 +00:00
|
|
|
id: settingsButton
|
|
|
|
|
2018-08-31 06:28:26 +00:00
|
|
|
Image {
|
|
|
|
source: "qrc:/res/settings.svg"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
sourceSize {
|
|
|
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 05:37:29 +00:00
|
|
|
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
|
2018-07-08 05:15:02 +00:00
|
|
|
|
2018-09-23 22:16:27 +00:00
|
|
|
Keys.onDownPressed: {
|
|
|
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
|
|
|
}
|
|
|
|
|
2018-09-24 02:24:47 +00:00
|
|
|
Shortcut {
|
|
|
|
id: settingsShortcut
|
|
|
|
sequence: StandardKey.Preferences
|
|
|
|
onActivated: settingsButton.clicked()
|
|
|
|
}
|
|
|
|
|
2018-08-10 06:20:20 +00:00
|
|
|
ToolTip.delay: 1000
|
|
|
|
ToolTip.timeout: 3000
|
|
|
|
ToolTip.visible: hovered
|
2018-09-24 02:24:47 +00:00
|
|
|
ToolTip.text: "Settings" + (settingsShortcut.nativeText ? (" ("+settingsShortcut.nativeText+")") : "")
|
2018-07-08 05:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-01 05:39:51 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
2018-07-04 21:16:25 +00:00
|
|
|
}
|