-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathSettingsView.qml
More file actions
1809 lines (1580 loc) · 81.5 KB
/
SettingsView.qml
File metadata and controls
1809 lines (1580 loc) · 81.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
import QtQuick.Window 2.2
import StreamingPreferences 1.0
import ComputerManager 1.0
import SdlGamepadKeyNavigation 1.0
import SystemProperties 1.0
Flickable {
id: settingsPage
objectName: qsTr("Settings")
signal languageChanged()
boundsBehavior: Flickable.OvershootBounds
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
contentHeight: settingsColumn1.height > settingsColumn2.height ? settingsColumn1.height : settingsColumn2.height
ScrollBar.vertical: ScrollBar {
anchors {
left: parent.right
leftMargin: -10
}
}
function isChildOfFlickable(item) {
while (item) {
if (item.parent === contentItem) {
return true
}
item = item.parent
}
return false
}
NumberAnimation on contentY {
id: autoScrollAnimation
duration: 100
}
Window.onActiveFocusItemChanged: {
var item = Window.activeFocusItem
if (item) {
// Ignore non-child elements like the toolbar buttons
if (!isChildOfFlickable(item)) {
return
}
// Map the focus item's position into our content item's coordinate space
var pos = item.mapToItem(contentItem, 0, 0)
// Ensure some extra space is visible around the element we're scrolling to
var scrollMargin = height > 100 ? 50 : 0
if (pos.y - scrollMargin < contentY) {
autoScrollAnimation.from = contentY
autoScrollAnimation.to = Math.max(pos.y - scrollMargin, 0)
autoScrollAnimation.start()
}
else if (pos.y + item.height + scrollMargin > contentY + height) {
autoScrollAnimation.from = contentY
autoScrollAnimation.to = Math.min(pos.y + item.height + scrollMargin - height, contentHeight - height)
autoScrollAnimation.start()
}
}
}
StackView.onActivated: {
// This enables Tab and BackTab based navigation rather than arrow keys.
// It is required to shift focus between controls on the settings page.
SdlGamepadKeyNavigation.setUiNavMode(true)
// Highlight the first item if a gamepad is connected
if (SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
resolutionComboBox.forceActiveFocus(Qt.TabFocus)
}
}
StackView.onDeactivating: {
SdlGamepadKeyNavigation.setUiNavMode(false)
// Save the prefs so the Session can observe the changes
StreamingPreferences.save()
}
Component.onDestruction: {
// Also save preferences on destruction, since we won't get a
// deactivating callback if the user just closes Moonlight
StreamingPreferences.save()
}
Column {
padding: 10
id: settingsColumn1
width: settingsPage.width / 2
spacing: 15
GroupBox {
id: basicSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">" + qsTr("Basic Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
Label {
width: parent.width
id: resFPStitle
text: qsTr("Resolution and FPS")
font.pointSize: 12
wrapMode: Text.Wrap
}
Label {
width: parent.width
id: resFPSdesc
text: qsTr("Setting values too high for your PC or network connection may cause lag, stuttering, or errors.")
font.pointSize: 9
wrapMode: Text.Wrap
}
Row {
spacing: 5
width: parent.width
AutoResizingComboBox {
property int lastIndexValue
function addDetectedResolution(friendlyNamePrefix, rect) {
var indexToAdd = 0
for (var j = 0; j < resolutionComboBox.count; j++) {
var existing_width = parseInt(resolutionListModel.get(j).video_width);
var existing_height = parseInt(resolutionListModel.get(j).video_height);
if (rect.width === existing_width && rect.height === existing_height) {
// Duplicate entry, skip
indexToAdd = -1
break
}
else if (rect.width * rect.height > existing_width * existing_height) {
// Candidate entrypoint after this entry
indexToAdd = j + 1
}
}
// Insert this display's resolution if it's not a duplicate
if (indexToAdd >= 0) {
resolutionListModel.insert(indexToAdd,
{
"text": friendlyNamePrefix+" ("+rect.width+"x"+rect.height+")",
"video_width": ""+rect.width,
"video_height": ""+rect.height,
"is_custom": false
})
}
}
// ignore setting the index at first, and actually set it when the component is loaded
Component.onCompleted: {
// Refresh display data before using it to build the list
SystemProperties.refreshDisplays()
// Add native and safe area resolutions for all attached displays
var done = false
for (var displayIndex = 0; !done; displayIndex++) {
var screenRect = SystemProperties.getNativeResolution(displayIndex);
var safeAreaRect = SystemProperties.getSafeAreaResolution(displayIndex);
if (screenRect.width === 0) {
// Exceeded max count of displays
done = true
break
}
addDetectedResolution(qsTr("Native"), screenRect)
addDetectedResolution(qsTr("Native (Excluding Notch)"), safeAreaRect)
}
// Prune resolutions that are over the decoder's maximum
var max_pixels = SystemProperties.maximumResolution.width * SystemProperties.maximumResolution.height;
if (max_pixels > 0) {
for (var j = 0; j < resolutionComboBox.count; j++) {
var existing_width = parseInt(resolutionListModel.get(j).video_width);
var existing_height = parseInt(resolutionListModel.get(j).video_height);
if (existing_width * existing_height > max_pixels) {
resolutionListModel.remove(j)
j--
}
}
}
// load the saved width/height, and iterate through the ComboBox until a match is found
// and set it to that index.
var saved_width = StreamingPreferences.width
var saved_height = StreamingPreferences.height
var index_set = false
for (var i = 0; i < resolutionListModel.count; i++) {
var el_width = parseInt(resolutionListModel.get(i).video_width);
var el_height = parseInt(resolutionListModel.get(i).video_height);
if (saved_width === el_width && saved_height === el_height) {
currentIndex = i
index_set = true
break
}
}
if (!index_set) {
// We did not find a match. This must be a custom resolution.
resolutionListModel.append({
"text": qsTr("Custom")+" ("+StreamingPreferences.width+"x"+StreamingPreferences.height+")",
"video_width": ""+StreamingPreferences.width,
"video_height": ""+StreamingPreferences.height,
"is_custom": true
})
currentIndex = resolutionListModel.count - 1
}
else {
resolutionListModel.append({
"text": qsTr("Custom"),
"video_width": "",
"video_height": "",
"is_custom": true
})
}
// Since we don't call activate() here, we need to trigger
// width calculation manually
recalculateWidth()
lastIndexValue = currentIndex
}
id: resolutionComboBox
maximumWidth: parent.width / 2
textRole: "text"
model: ListModel {
id: resolutionListModel
// Other elements may be added at runtime
// based on attached display resolution
ListElement {
text: qsTr("720p")
video_width: "1280"
video_height: "720"
is_custom: false
}
ListElement {
text: qsTr("1080p")
video_width: "1920"
video_height: "1080"
is_custom: false
}
ListElement {
text: qsTr("1440p")
video_width: "2560"
video_height: "1440"
is_custom: false
}
ListElement {
text: qsTr("4K")
video_width: "3840"
video_height: "2160"
is_custom: false
}
}
function updateBitrateForSelection() {
var selectedWidth = parseInt(resolutionListModel.get(currentIndex).video_width)
var selectedHeight = parseInt(resolutionListModel.get(currentIndex).video_height)
// Only modify the bitrate if the values actually changed
if (StreamingPreferences.width !== selectedWidth || StreamingPreferences.height !== selectedHeight) {
StreamingPreferences.width = selectedWidth
StreamingPreferences.height = selectedHeight
if (StreamingPreferences.autoAdjustBitrate) {
StreamingPreferences.bitrateKbps = StreamingPreferences.getDefaultBitrate(StreamingPreferences.width,
StreamingPreferences.height,
StreamingPreferences.fps,
StreamingPreferences.enableYUV444);
slider.value = StreamingPreferences.bitrateKbps
}
}
lastIndexValue = currentIndex
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
if (resolutionListModel.get(currentIndex).is_custom) {
customResolutionDialog.open()
}
else {
updateBitrateForSelection()
}
}
NavigableDialog {
id: customResolutionDialog
standardButtons: Dialog.Ok | Dialog.Cancel
onOpened: {
// Force keyboard focus on the textbox so keyboard navigation works
widthField.forceActiveFocus()
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
onClosed: {
widthField.clear()
heightField.clear()
}
onRejected: {
resolutionComboBox.currentIndex = resolutionComboBox.lastIndexValue
}
function isInputValid() {
// If we have text in either textbox that isn't valid,
// reject the input.
if ((!widthField.acceptableInput && widthField.text) ||
(!heightField.acceptableInput && heightField.text)) {
return false
}
// The textboxes need to have text or placeholder text
if ((!widthField.text && !widthField.placeholderText) ||
(!heightField.text && !heightField.placeholderText)) {
return false
}
return true
}
onAccepted: {
// Reject if there's invalid input
if (!isInputValid()) {
reject()
return
}
var width = widthField.text ? widthField.text : widthField.placeholderText
var height = heightField.text ? heightField.text : heightField.placeholderText
// Find and update the custom entry
for (var i = 0; i < resolutionListModel.count; i++) {
if (resolutionListModel.get(i).is_custom) {
resolutionListModel.setProperty(i, "video_width", width)
resolutionListModel.setProperty(i, "video_height", height)
resolutionListModel.setProperty(i, "text", "Custom ("+width+"x"+height+")")
// Now update the bitrate using the custom resolution
resolutionComboBox.currentIndex = i
resolutionComboBox.updateBitrateForSelection()
// Update the combobox width too
resolutionComboBox.recalculateWidth()
break
}
}
}
ColumnLayout {
Label {
text: qsTr("Custom resolutions are not officially supported by GeForce Experience, so it will not set your host display resolution. You will need to set it manually while in game.") + "\n\n" +
qsTr("Resolutions that are not supported by your client or host PC may cause streaming errors.") + "\n"
wrapMode: Label.WordWrap
Layout.maximumWidth: 300
}
Label {
text: qsTr("Enter a custom resolution:")
font.bold: true
}
RowLayout {
TextField {
id: widthField
maximumLength: 5
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: resolutionListModel.get(resolutionComboBox.currentIndex).video_width
validator: IntValidator{bottom:256; top:8192}
focus: true
onTextChanged: {
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
Keys.onReturnPressed: {
customResolutionDialog.accept()
}
Keys.onEnterPressed: {
customResolutionDialog.accept()
}
}
Label {
text: "x"
font.bold: true
}
TextField {
id: heightField
maximumLength: 5
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: resolutionListModel.get(resolutionComboBox.currentIndex).video_height
validator: IntValidator{bottom:256; top:8192}
onTextChanged: {
// standardButton() was added in Qt 5.10, so we must check for it first
if (customResolutionDialog.standardButton) {
customResolutionDialog.standardButton(Dialog.Ok).enabled = customResolutionDialog.isInputValid()
}
}
Keys.onReturnPressed: {
customResolutionDialog.accept()
}
Keys.onEnterPressed: {
customResolutionDialog.accept()
}
}
}
}
}
}
AutoResizingComboBox {
property int lastIndexValue
function updateBitrateForSelection() {
// Only modify the bitrate if the values actually changed
var selectedFps = parseInt(model.get(fpsComboBox.currentIndex).video_fps)
if (StreamingPreferences.fps !== selectedFps) {
StreamingPreferences.fps = selectedFps
if (StreamingPreferences.autoAdjustBitrate) {
StreamingPreferences.bitrateKbps = StreamingPreferences.getDefaultBitrate(StreamingPreferences.width,
StreamingPreferences.height,
StreamingPreferences.fps,
StreamingPreferences.enableYUV444);
slider.value = StreamingPreferences.bitrateKbps
}
}
lastIndexValue = currentIndex
}
NavigableDialog {
function isInputValid() {
// If we have text that isn't valid, reject the input.
if (!fpsField.acceptableInput && fpsField.text) {
return false
}
// The textbox needs to have text or placeholder text
if (!fpsField.text && !fpsField.placeholderText) {
return false
}
return true
}
id: customFpsDialog
standardButtons: Dialog.Ok | Dialog.Cancel
onOpened: {
// Force keyboard focus on the textbox so keyboard navigation works
fpsField.forceActiveFocus()
// standardButton() was added in Qt 5.10, so we must check for it first
if (customFpsDialog.standardButton) {
customFpsDialog.standardButton(Dialog.Ok).enabled = customFpsDialog.isInputValid()
}
}
onClosed: {
fpsField.clear()
}
onRejected: {
fpsComboBox.currentIndex = fpsComboBox.lastIndexValue
}
onAccepted: {
// Reject if there's invalid input
if (!isInputValid()) {
reject()
return
}
var fps = fpsField.text ? fpsField.text : fpsField.placeholderText
// Find and update the custom entry
for (var i = 0; i < fpsListModel.count; i++) {
if (fpsListModel.get(i).is_custom) {
fpsListModel.setProperty(i, "video_fps", fps)
fpsListModel.setProperty(i, "text", qsTr("Custom (%1 FPS)").arg(fps))
// Now update the bitrate using the custom resolution
fpsComboBox.currentIndex = i
fpsComboBox.updateBitrateForSelection()
// Update the combobox width too
fpsComboBox.recalculateWidth()
break
}
}
}
ColumnLayout {
Label {
text: qsTr("Enter a custom frame rate:")
font.bold: true
}
RowLayout {
TextField {
id: fpsField
maximumLength: 4
inputMethodHints: Qt.ImhDigitsOnly
placeholderText: fpsListModel.get(fpsComboBox.currentIndex).video_fps
validator: IntValidator{bottom:10; top:9999}
focus: true
onTextChanged: {
// standardButton() was added in Qt 5.10, so we must check for it first
if (customFpsDialog.standardButton) {
customFpsDialog.standardButton(Dialog.Ok).enabled = customFpsDialog.isInputValid()
}
}
Keys.onReturnPressed: {
customFpsDialog.accept()
}
Keys.onEnterPressed: {
customFpsDialog.accept()
}
}
}
}
}
function addRefreshRateOrdered(fpsListModel, refreshRate, description, custom) {
var indexToAdd = 0
for (var j = 0; j < fpsListModel.count; j++) {
var existing_fps = parseInt(fpsListModel.get(j).video_fps);
if (refreshRate === existing_fps || (custom && fpsListModel.get(j).is_custom)) {
// Duplicate entry, skip
indexToAdd = -1
break
}
else if (refreshRate > existing_fps) {
// Candidate entrypoint after this entry
indexToAdd = j + 1
}
}
// Insert this frame rate if it's not a duplicate
if (indexToAdd >= 0) {
// Custom values always go at the end of the list
if (custom) {
indexToAdd = fpsListModel.count
}
fpsListModel.insert(indexToAdd,
{
"text": description,
"video_fps": ""+refreshRate,
"is_custom": custom
})
}
return indexToAdd
}
function reinitialize() {
// Add native refresh rate for all attached displays
var done = false
for (var displayIndex = 0; !done; displayIndex++) {
var refreshRate = SystemProperties.getRefreshRate(displayIndex);
if (refreshRate === 0) {
// Exceeded max count of displays
done = true
break
}
addRefreshRateOrdered(fpsListModel, refreshRate, qsTr("%1 FPS").arg(refreshRate), false)
}
var saved_fps = StreamingPreferences.fps
var found = false
for (var i = 0; i < model.count; i++) {
var el_fps = parseInt(model.get(i).video_fps);
// Look for a matching frame rate
if (saved_fps === el_fps) {
currentIndex = i
found = true
break
}
}
// If we didn't find one, add a custom frame rate for the current value
if (!found) {
currentIndex = addRefreshRateOrdered(model, saved_fps, qsTr("Custom (%1 FPS)").arg(saved_fps), true)
}
else {
addRefreshRateOrdered(model, "", qsTr("Custom"), true)
}
recalculateWidth()
lastIndexValue = currentIndex
}
// ignore setting the index at first, and actually set it when the component is loaded
Component.onCompleted: {
reinitialize()
languageChanged.connect(reinitialize)
}
model: ListModel {
id: fpsListModel
// Other elements may be added at runtime
ListElement {
text: qsTr("30 FPS")
video_fps: "30"
is_custom: false
}
ListElement {
text: qsTr("60 FPS")
video_fps: "60"
is_custom: false
}
}
id: fpsComboBox
maximumWidth: parent.width / 2
textRole: "text"
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
if (model.get(currentIndex).is_custom) {
customFpsDialog.open()
}
else {
updateBitrateForSelection()
}
}
}
}
Label {
width: parent.width
id: bitrateTitle
text: qsTr("Video bitrate:")
font.pointSize: 12
wrapMode: Text.Wrap
}
Label {
width: parent.width
id: bitrateDesc
text: qsTr("Lower the bitrate on slower connections. Raise the bitrate to increase image quality.")
font.pointSize: 9
wrapMode: Text.Wrap
}
Row {
width: parent.width
spacing: 5
Slider {
id: slider
value: StreamingPreferences.bitrateKbps
stepSize: 500
from : 500
to: StreamingPreferences.unlockBitrate ? 500000 : 150000
snapMode: "SnapOnRelease"
width: Math.min(bitrateDesc.implicitWidth, parent.width - (resetBitrateButton.visible ? resetBitrateButton.width + parent.spacing : 0))
onValueChanged: {
bitrateTitle.text = qsTr("Video bitrate: %1 Mbps").arg(value / 1000.0)
StreamingPreferences.bitrateKbps = value
}
onMoved: {
StreamingPreferences.autoAdjustBitrate = false
}
Component.onCompleted: {
// Refresh the text after translations change
languageChanged.connect(valueChanged)
}
}
Button {
id: resetBitrateButton
text: qsTr("Use Default (%1 Mbps)").arg(StreamingPreferences.getDefaultBitrate(StreamingPreferences.width, StreamingPreferences.height, StreamingPreferences.fps, StreamingPreferences.enableYUV444) / 1000.0)
visible: StreamingPreferences.bitrateKbps !== StreamingPreferences.getDefaultBitrate(StreamingPreferences.width, StreamingPreferences.height, StreamingPreferences.fps, StreamingPreferences.enableYUV444)
onClicked: {
var defaultBitrate = StreamingPreferences.getDefaultBitrate(StreamingPreferences.width, StreamingPreferences.height, StreamingPreferences.fps, StreamingPreferences.enableYUV444)
StreamingPreferences.bitrateKbps = defaultBitrate
StreamingPreferences.autoAdjustBitrate = true
slider.value = defaultBitrate
}
}
}
Label {
width: parent.width
id: windowModeTitle
text: qsTr("Display mode")
font.pointSize: 12
wrapMode: Text.Wrap
visible: SystemProperties.hasDesktopEnvironment
}
AutoResizingComboBox {
function createModel() {
var model = Qt.createQmlObject('import QtQuick 2.0; ListModel {}', parent, '')
model.append({
text: qsTr("Fullscreen"),
val: StreamingPreferences.WM_FULLSCREEN
})
model.append({
text: qsTr("Borderless windowed"),
val: StreamingPreferences.WM_FULLSCREEN_DESKTOP
})
model.append({
text: qsTr("Windowed"),
val: StreamingPreferences.WM_WINDOWED
})
// Set the recommended option based on the OS
for (var i = 0; i < model.count; i++) {
var thisWm = model.get(i).val;
if (thisWm === StreamingPreferences.recommendedFullScreenMode) {
model.get(i).text += " " + qsTr("(Recommended)")
model.move(i, 0, 1)
break
}
}
return model
}
// This is used on initialization and upon retranslation
function reinitialize() {
if (!visible) {
// Do nothing if the control won't even be visible
return
}
model = createModel()
currentIndex = 0
// Set the current value based on the saved preferences
var savedWm = StreamingPreferences.windowMode
for (var i = 0; i < model.count; i++) {
var thisWm = model.get(i).val;
if (savedWm === thisWm) {
currentIndex = i
break
}
}
activated(currentIndex)
}
Component.onCompleted: {
reinitialize()
languageChanged.connect(reinitialize)
}
id: windowModeComboBox
visible: SystemProperties.hasDesktopEnvironment
enabled: !SystemProperties.rendererAlwaysFullScreen
hoverEnabled: true
textRole: "text"
onActivated: {
StreamingPreferences.windowMode = model.get(currentIndex).val
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Fullscreen generally provides the best performance, but borderless windowed may work better with features like macOS Spaces, Alt+Tab, screenshot tools, on-screen overlays, etc.")
}
CheckBox {
id: vsyncCheck
width: parent.width
hoverEnabled: true
text: qsTr("V-Sync")
font.pointSize: 12
checked: StreamingPreferences.enableVsync
onCheckedChanged: {
StreamingPreferences.enableVsync = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Disabling V-Sync allows sub-frame rendering latency, but it can display visible tearing")
}
CheckBox {
id: framePacingCheck
width: parent.width
hoverEnabled: true
text: qsTr("Frame pacing")
font.pointSize: 12
enabled: StreamingPreferences.enableVsync
checked: StreamingPreferences.enableVsync && StreamingPreferences.framePacing
onCheckedChanged: {
StreamingPreferences.framePacing = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Frame pacing reduces micro-stutter by delaying frames that come in too early")
}
}
}
GroupBox {
id: audioSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">" + qsTr("Audio Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
Label {
width: parent.width
id: resAudioTitle
text: qsTr("Audio configuration")
font.pointSize: 12
wrapMode: Text.Wrap
}
AutoResizingComboBox {
// ignore setting the index at first, and actually set it when the component is loaded
Component.onCompleted: {
var saved_audio = StreamingPreferences.audioConfig
currentIndex = 0
for (var i = 0; i < audioListModel.count; i++) {
var el_audio = audioListModel.get(i).val;
if (saved_audio === el_audio) {
currentIndex = i
break
}
}
activated(currentIndex)
}
id: audioComboBox
textRole: "text"
model: ListModel {
id: audioListModel
ListElement {
text: qsTr("Stereo")
val: StreamingPreferences.AC_STEREO
}
ListElement {
text: qsTr("5.1 surround sound")
val: StreamingPreferences.AC_51_SURROUND
}
ListElement {
text: qsTr("7.1 surround sound")
val: StreamingPreferences.AC_71_SURROUND
}
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
StreamingPreferences.audioConfig = audioListModel.get(currentIndex).val
}
}
CheckBox {
id: audioPcCheck
width: parent.width
text: qsTr("Mute host PC speakers while streaming")
font.pointSize: 12
checked: !StreamingPreferences.playAudioOnHost
onCheckedChanged: {
StreamingPreferences.playAudioOnHost = !checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("You must restart any game currently in progress for this setting to take effect")
}
CheckBox {
id: muteOnFocusLossCheck
width: parent.width
text: qsTr("Mute audio stream when Moonlight is not the active window")
font.pointSize: 12
visible: SystemProperties.hasDesktopEnvironment
checked: StreamingPreferences.muteOnFocusLoss
onCheckedChanged: {
StreamingPreferences.muteOnFocusLoss = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("Mutes Moonlight's audio when you Alt+Tab out of the stream or click on a different window.")
}
}
}
GroupBox {
id: hostSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">" + qsTr("Host Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
CheckBox {
id: optimizeGameSettingsCheck
width: parent.width
text: qsTr("Optimize game settings for streaming")
font.pointSize: 12
checked: StreamingPreferences.gameOptimizations
onCheckedChanged: {
StreamingPreferences.gameOptimizations = checked
}
}
CheckBox {
id: quitAppAfter
width: parent.width
text: qsTr("Quit app on host PC after ending stream")
font.pointSize: 12
checked: StreamingPreferences.quitAppAfter
onCheckedChanged: {
StreamingPreferences.quitAppAfter = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr("This will close the app or game you are streaming when you end your stream. You will lose any unsaved progress!")
}
}
}
GroupBox {
id: uiSettingsGroupBox
width: (parent.width - (parent.leftPadding + parent.rightPadding))
padding: 12
title: "<font color=\"skyblue\">" + qsTr("UI Settings") + "</font>"
font.pointSize: 12
Column {
anchors.fill: parent
spacing: 5
Label {
width: parent.width
id: languageTitle
text: qsTr("Language")
font.pointSize: 12