mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Settings/Fonts: improving filtering performance.
This commit is contained in:
@@ -86,7 +86,6 @@ ColumnLayout {
|
||||
label: I18n.tr("settings.general.fonts.default.label")
|
||||
description: I18n.tr("settings.general.fonts.default.description")
|
||||
model: FontService.availableFonts
|
||||
modelReady: FontService.fontsLoaded
|
||||
currentKey: Settings.data.ui.fontDefault
|
||||
placeholder: I18n.tr("settings.general.fonts.default.placeholder")
|
||||
searchPlaceholder: I18n.tr("settings.general.fonts.default.search-placeholder")
|
||||
@@ -99,7 +98,6 @@ ColumnLayout {
|
||||
label: I18n.tr("settings.general.fonts.monospace.label")
|
||||
description: I18n.tr("settings.general.fonts.monospace.description")
|
||||
model: FontService.monospaceFonts
|
||||
modelReady: FontService.fontsLoaded
|
||||
currentKey: Settings.data.ui.fontFixed
|
||||
placeholder: I18n.tr("settings.general.fonts.monospace.placeholder")
|
||||
searchPlaceholder: I18n.tr("settings.general.fonts.monospace.search-placeholder")
|
||||
|
||||
@@ -18,7 +18,6 @@ RowLayout {
|
||||
property string placeholder: ""
|
||||
property string searchPlaceholder: I18n.tr("placeholders.search")
|
||||
property Component delegate: null
|
||||
property bool modelReady: true
|
||||
|
||||
readonly property real preferredHeight: Style.baseWidgetSize * 1.1
|
||||
|
||||
@@ -95,21 +94,6 @@ RowLayout {
|
||||
}
|
||||
|
||||
onSearchTextChanged: filterModel()
|
||||
onModelChanged: filterModel()
|
||||
onModelReadyChanged: {
|
||||
if (modelReady) {
|
||||
filterModel();
|
||||
}
|
||||
}
|
||||
Component.onCompleted: filterModel()
|
||||
|
||||
// Watch for model content changes (e.g., async font loading)
|
||||
//Connections {
|
||||
// target: root.model
|
||||
// function onCountChanged() {
|
||||
// filterModel();
|
||||
// }
|
||||
//}
|
||||
|
||||
NLabel {
|
||||
label: root.label
|
||||
@@ -154,8 +138,13 @@ RowLayout {
|
||||
pointSize: Style.fontSizeM
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
color: (combo.currentIndex >= 0 && combo.currentIndex < filteredModel.count) ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
text: (combo.currentIndex >= 0 && combo.currentIndex < filteredModel.count) ? filteredModel.get(combo.currentIndex).name : root.placeholder
|
||||
|
||||
// Look up current selection directly in source model by key
|
||||
readonly property int sourceIndex: root.findIndexByKey(root.currentKey)
|
||||
readonly property bool hasSelection: sourceIndex >= 0 && sourceIndex < root.model.count
|
||||
|
||||
color: hasSelection ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
text: hasSelection ? root.model.get(sourceIndex).name : root.placeholder
|
||||
}
|
||||
|
||||
indicator: NIcon {
|
||||
|
||||
Reference in New Issue
Block a user