mirror of
https://github.com/developersu/ClearClock.git
synced 2025-05-14 19:20:26 +03:00
Fixed fontFamilyComboBox
This commit is contained in:
parent
ca95ddc64b
commit
94d85dbcc4
2 changed files with 10 additions and 26 deletions
|
@ -58,31 +58,6 @@ Item {
|
|||
property int cfg_dateShadowXOffset
|
||||
property int cfg_dateShadowYOffset
|
||||
|
||||
|
||||
function fixFontFamilyChange(id, comboBox) {
|
||||
// HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined
|
||||
if (id) {
|
||||
for (var i = 0, j = fontsModel.count; i < j; ++i) {
|
||||
if (fontsModel.get(i).value === id) {
|
||||
comboBox.currentIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCfg_clockFontFamilyChanged: {
|
||||
fixFontFamilyChange(cfg_clockFontFamily, clockFontFamilyComboBox)
|
||||
}
|
||||
|
||||
onCfg_dayFontFamilyChanged: {
|
||||
fixFontFamilyChange(cfg_dayFontFamily, dayFontFamilyComboBox)
|
||||
}
|
||||
|
||||
onCfg_dateFontFamilyChanged: {
|
||||
fixFontFamilyChange(cfg_dateFontFamily, dateFontFamilyComboBox)
|
||||
}
|
||||
|
||||
ListModel {
|
||||
id: fontsModel
|
||||
Component.onCompleted: {
|
||||
|
|
|
@ -44,7 +44,16 @@ QtLayouts.RowLayout {
|
|||
QtLayouts.Layout.minimumWidth: Kirigami.Units.gridUnit * 10
|
||||
model: fontModel
|
||||
textRole: "text"
|
||||
currentIndex: fontValue
|
||||
currentIndex: getIdFromModel()
|
||||
|
||||
function getIdFromModel(){
|
||||
for(var i = 0; i < model.count; i++){
|
||||
if(model.get(i).value === fontValue){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
var current = model.get(currentIndex)
|
||||
|
|
Loading…
Reference in a new issue