linux.x86.linphone/Linphone/view/Control/Button/Settings/ComboSetting.qml
data ae94b325b1 Fix: Multiple UI bugs - settings display, dark mode, double buttons
- ComboSetting: Fix saved values not showing for language/accent color
  - Add valueRole/textRole and fix comparison logic

- TextField: Fix CardDAV username/realm not displaying when saved
  - Re-establish Qt.binding after Windows password workaround

- Dark Mode fixes:
  - ComboBox popup: Add background color for dark mode
  - DisplaySettingsLayout: Fix typo main2_500main -> main2_500_main
  - CallsWindow: Add window background color for dark mode

- Double buttons fix:
  - CallPage: Clear rightPanelStackView on component creation
  - CallHistoryLayout: Remove explicit sizes, add Layout.alignment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-08 07:19:07 +01:00

76 lines
2.3 KiB
QML

import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import Linphone
import 'qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js' as Utils
RowLayout {
id: mainItem
property string titleText
property string subTitleText
property string propertyName
property var propertyOwner
property var propertyOwnerGui
property alias entries: comboBox.model
property alias model: comboBox.model
property alias textRole: comboBox.textRole
property alias flagRole: comboBox.flagRole
property alias currentIndex: comboBox.currentIndex
property alias currentValue: comboBox.currentValue
property alias listView: comboBox.listView
spacing: Utils.getSizeWithScreenRatio(20)
ColumnLayout {
Layout.minimumHeight: Utils.getSizeWithScreenRatio(32)
Layout.fillWidth: true
spacing: Utils.getSizeWithScreenRatio(4)
visible: titleText.length > 0
Text {
text: titleText
font: Typography.p2l
wrapMode: Text.WordWrap
color: DefaultStyle.main2_600
Layout.fillWidth: true
}
Text {
text: subTitleText
font: Typography.p1
wrapMode: Text.WordWrap
visible: subTitleText.length > 0
color: DefaultStyle.main2_600
Layout.fillWidth: true
}
}
ComboBox {
id: comboBox
Layout.alignment: titleText.length > 0 ? (Qt.AlignRight | Qt.AlignVCenter) : Qt.AlignLeft
Layout.preferredHeight: Utils.getSizeWithScreenRatio(49)
Layout.preferredWidth: titleText.length > 0 ? Utils.getSizeWithScreenRatio(200) : undefined
Layout.fillWidth: titleText.length === 0
oneLine: true
valueRole: "value"
textRole: "text"
currentIndex: Utils.findIndex(model, function (entry) {
var currentVal = propertyOwnerGui
? propertyOwnerGui.core[mainItem.propertyName]
: propertyOwner[mainItem.propertyName]
// Compare entry.value with the stored value (both are simple strings like "en", "orange")
return entry.value === currentVal
})
onCurrentValueChanged: {
var storedVal = propertyOwnerGui
? propertyOwnerGui.core[mainItem.propertyName]
: propertyOwner[mainItem.propertyName]
// currentValue is now just the value string (e.g., "en", "orange")
binding.when = currentValue !== storedVal
}
Binding {
id: binding
target: propertyOwnerGui ? propertyOwnerGui.core : propertyOwner
property: mainItem.propertyName
value: comboBox.currentValue
when: false
}
}
}