Apply changes to preferences when loading the settings page

This commit is contained in:
Cameron Gutman
2018-09-07 23:16:13 -07:00
parent 77b767ae5b
commit 4381f7a973
+44 -19
View File
@@ -118,6 +118,9 @@ ScrollView {
currentIndex = i currentIndex = i
} }
} }
// Persist the selected value
activated(currentIndex)
} }
id: resolutionComboBox id: resolutionComboBox
@@ -150,11 +153,17 @@ ScrollView {
} }
// ::onActivated must be used, as it only listens for when the index is changed by a human // ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : { onActivated : {
prefs.width = parseInt(resolutionListModel.get(currentIndex).video_width) var selectedWidth = parseInt(resolutionListModel.get(currentIndex).video_width)
prefs.height = parseInt(resolutionListModel.get(currentIndex).video_height) var selectedHeight = parseInt(resolutionListModel.get(currentIndex).video_height)
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps); // Only modify the bitrate if the values actually changed
slider.value = prefs.bitrateKbps if (prefs.width !== selectedWidth || prefs.height !== selectedHeight) {
prefs.width = selectedWidth
prefs.height = selectedHeight
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps);
slider.value = prefs.bitrateKbps
}
} }
} }
@@ -180,6 +189,9 @@ ScrollView {
currentIndex = i currentIndex = i
} }
} }
// Persist the selected value
activated(currentIndex)
} }
id: fpsComboBox id: fpsComboBox
@@ -199,10 +211,15 @@ ScrollView {
} }
// ::onActivated must be used, as it only listens for when the index is changed by a human // ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : { onActivated : {
prefs.fps = parseInt(fpsListModel.get(currentIndex).video_fps) var selectedFps = parseInt(fpsListModel.get(currentIndex).video_fps)
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps); // Only modify the bitrate if the values actually changed
slider.value = prefs.bitrateKbps if (prefs.fps !== selectedFps) {
prefs.fps = selectedFps
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps);
slider.value = prefs.bitrateKbps
}
} }
} }
} }
@@ -262,8 +279,10 @@ ScrollView {
var thisWm = windowModeListModel.get(i).val; var thisWm = windowModeListModel.get(i).val;
if (savedWm === thisWm) { if (savedWm === thisWm) {
currentIndex = i currentIndex = i
break
} }
} }
activated(currentIndex)
} }
id: windowModeComboBox id: windowModeComboBox
@@ -328,12 +347,14 @@ ScrollView {
Component.onCompleted: { Component.onCompleted: {
var saved_audio = prefs.audioConfig var saved_audio = prefs.audioConfig
currentIndex = 0 currentIndex = 0
for(var i = 0; i < audioListModel.count; i++) { for (var i = 0; i < audioListModel.count; i++) {
var el_audio= audioListModel.get(i).val; var el_audio = audioListModel.get(i).val;
if(saved_audio === el_audio) { if (saved_audio === el_audio) {
currentIndex = i currentIndex = i
} break
}
} }
activated(currentIndex)
} }
id: audioComboBox id: audioComboBox
@@ -455,12 +476,14 @@ ScrollView {
Component.onCompleted: { Component.onCompleted: {
var saved_vds = prefs.videoDecoderSelection var saved_vds = prefs.videoDecoderSelection
currentIndex = 0 currentIndex = 0
for(var i = 0; i < decoderListModel.count; i++) { for (var i = 0; i < decoderListModel.count; i++) {
var el_vds = decoderListModel.get(i).val; var el_vds = decoderListModel.get(i).val;
if(saved_vds === el_vds) { if (saved_vds === el_vds) {
currentIndex = i currentIndex = i
} break
}
} }
activated(currentIndex)
} }
id: decoderComboBox id: decoderComboBox
@@ -503,10 +526,12 @@ ScrollView {
currentIndex = 0 currentIndex = 0
for(var i = 0; i < codecListModel.count; i++) { for(var i = 0; i < codecListModel.count; i++) {
var el_vcc = codecListModel.get(i).val; var el_vcc = codecListModel.get(i).val;
if(saved_vcc === el_vcc) { if (saved_vcc === el_vcc) {
currentIndex = i currentIndex = i
} break
}
} }
activated(currentIndex)
} }
id: codecComboBox id: codecComboBox