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
+28 -3
View File
@@ -118,6 +118,9 @@ ScrollView {
currentIndex = i
}
}
// Persist the selected value
activated(currentIndex)
}
id: resolutionComboBox
@@ -150,13 +153,19 @@ ScrollView {
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
prefs.width = parseInt(resolutionListModel.get(currentIndex).video_width)
prefs.height = parseInt(resolutionListModel.get(currentIndex).video_height)
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 (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
}
}
}
ComboBox {
// ignore setting the index at first, and actually set it when the component is loaded
@@ -180,6 +189,9 @@ ScrollView {
currentIndex = i
}
}
// Persist the selected value
activated(currentIndex)
}
id: fpsComboBox
@@ -199,13 +211,18 @@ ScrollView {
}
// ::onActivated must be used, as it only listens for when the index is changed by a human
onActivated : {
prefs.fps = parseInt(fpsListModel.get(currentIndex).video_fps)
var selectedFps = parseInt(fpsListModel.get(currentIndex).video_fps)
// Only modify the bitrate if the values actually changed
if (prefs.fps !== selectedFps) {
prefs.fps = selectedFps
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps);
slider.value = prefs.bitrateKbps
}
}
}
}
Label {
width: parent.width
@@ -262,8 +279,10 @@ ScrollView {
var thisWm = windowModeListModel.get(i).val;
if (savedWm === thisWm) {
currentIndex = i
break
}
}
activated(currentIndex)
}
id: windowModeComboBox
@@ -332,8 +351,10 @@ ScrollView {
var el_audio = audioListModel.get(i).val;
if (saved_audio === el_audio) {
currentIndex = i
break
}
}
activated(currentIndex)
}
id: audioComboBox
@@ -459,8 +480,10 @@ ScrollView {
var el_vds = decoderListModel.get(i).val;
if (saved_vds === el_vds) {
currentIndex = i
break
}
}
activated(currentIndex)
}
id: decoderComboBox
@@ -505,8 +528,10 @@ ScrollView {
var el_vcc = codecListModel.get(i).val;
if (saved_vcc === el_vcc) {
currentIndex = i
break
}
}
activated(currentIndex)
}
id: codecComboBox