mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2025-03-05 07:07:18 +00:00
Reload the FPS and window mode comboboxes after changing language
Fixes #765
This commit is contained in:
parent
e3a7b54f90
commit
22924a1e92
1 changed files with 51 additions and 30 deletions
|
@ -11,6 +11,8 @@ Flickable {
|
||||||
id: settingsPage
|
id: settingsPage
|
||||||
objectName: qsTr("Settings")
|
objectName: qsTr("Settings")
|
||||||
|
|
||||||
|
signal languageChanged()
|
||||||
|
|
||||||
boundsBehavior: Flickable.OvershootBounds
|
boundsBehavior: Flickable.OvershootBounds
|
||||||
|
|
||||||
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
|
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
|
||||||
|
@ -465,6 +467,7 @@ Flickable {
|
||||||
// ignore setting the index at first, and actually set it when the component is loaded
|
// ignore setting the index at first, and actually set it when the component is loaded
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
reinitialize()
|
reinitialize()
|
||||||
|
languageChanged.connect(reinitialize)
|
||||||
}
|
}
|
||||||
|
|
||||||
id: fpsComboBox
|
id: fpsComboBox
|
||||||
|
@ -531,28 +534,53 @@ Flickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoResizingComboBox {
|
AutoResizingComboBox {
|
||||||
// ignore setting the index at first, and actually set it when the component is loaded
|
function createModel() {
|
||||||
Component.onCompleted: {
|
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) {
|
if (!visible) {
|
||||||
// Do nothing if the control won't even be visible
|
// Do nothing if the control won't even be visible
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the recommended option based on the OS
|
model = createModel()
|
||||||
for (var i = 0; i < windowModeListModel.count; i++) {
|
|
||||||
var thisWm = windowModeListModel.get(i).val;
|
|
||||||
if (thisWm === StreamingPreferences.recommendedFullScreenMode) {
|
|
||||||
windowModeListModel.get(i).text += qsTr(" (Recommended)")
|
|
||||||
windowModeListModel.move(i, 0, 1);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentIndex = 0
|
currentIndex = 0
|
||||||
|
|
||||||
|
// Set the current value based on the saved preferences
|
||||||
var savedWm = StreamingPreferences.windowMode
|
var savedWm = StreamingPreferences.windowMode
|
||||||
for (var i = 0; i < windowModeListModel.count; i++) {
|
for (var i = 0; i < model.count; i++) {
|
||||||
var thisWm = windowModeListModel.get(i).val;
|
var thisWm = model.get(i).val;
|
||||||
if (savedWm === thisWm) {
|
if (savedWm === thisWm) {
|
||||||
currentIndex = i
|
currentIndex = i
|
||||||
break
|
break
|
||||||
|
@ -562,28 +590,18 @@ Flickable {
|
||||||
activated(currentIndex)
|
activated(currentIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
reinitialize()
|
||||||
|
languageChanged.connect(reinitialize)
|
||||||
|
}
|
||||||
|
|
||||||
id: windowModeComboBox
|
id: windowModeComboBox
|
||||||
visible: SystemProperties.hasDesktopEnvironment
|
visible: SystemProperties.hasDesktopEnvironment
|
||||||
enabled: !SystemProperties.rendererAlwaysFullScreen
|
enabled: !SystemProperties.rendererAlwaysFullScreen
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
textRole: "text"
|
textRole: "text"
|
||||||
model: ListModel {
|
|
||||||
id: windowModeListModel
|
|
||||||
ListElement {
|
|
||||||
text: qsTr("Fullscreen")
|
|
||||||
val: StreamingPreferences.WM_FULLSCREEN
|
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
text: qsTr("Borderless windowed")
|
|
||||||
val: StreamingPreferences.WM_FULLSCREEN_DESKTOP
|
|
||||||
}
|
|
||||||
ListElement {
|
|
||||||
text: qsTr("Windowed")
|
|
||||||
val: StreamingPreferences.WM_WINDOWED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onActivated: {
|
onActivated: {
|
||||||
StreamingPreferences.windowMode = windowModeListModel.get(currentIndex).val
|
StreamingPreferences.windowMode = model.get(currentIndex).val
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip.delay: 1000
|
ToolTip.delay: 1000
|
||||||
|
@ -867,6 +885,9 @@ Flickable {
|
||||||
// Force the back operation to pop any AppView pages that exist.
|
// Force the back operation to pop any AppView pages that exist.
|
||||||
// The AppView stops working after retranslate() for some reason.
|
// The AppView stops working after retranslate() for some reason.
|
||||||
window.clearOnBack = true
|
window.clearOnBack = true
|
||||||
|
|
||||||
|
// Signal other controls to adjust their text
|
||||||
|
languageChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue