fix: prevent changing material font to non material

Also swap places with sans font
Closes #1224
This commit is contained in:
2 * r + 2 * t 2026-03-19 22:46:41 +11:00
parent 3e057c829d
commit ab91536059

View file

@ -19,28 +19,27 @@ CollapsibleSection {
showBackground: true
CollapsibleSection {
id: materialFontSection
title: qsTr("Material font family")
id: sansFontSection
title: qsTr("Sans-serif font family")
expanded: true
showBackground: true
nested: true
Loader {
id: materialFontLoader
Layout.fillWidth: true
Layout.preferredHeight: item ? Math.min(item.contentHeight, 300) : 0
active: materialFontSection.expanded
active: sansFontSection.expanded
sourceComponent: StyledListView {
id: materialFontList
property alias contentHeight: materialFontList.contentHeight
id: sansFontList
property alias contentHeight: sansFontList.contentHeight
clip: true
spacing: Appearance.spacing.small / 2
model: Qt.fontFamilies()
StyledScrollBar.vertical: StyledScrollBar {
flickable: materialFontList
flickable: sansFontList
}
delegate: StyledRect {
@ -49,7 +48,7 @@ CollapsibleSection {
width: ListView.view.width
readonly property bool isCurrent: modelData === rootPane.fontFamilyMaterial
readonly property bool isCurrent: modelData === rootPane.fontFamilySans
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, isCurrent ? Colours.tPalette.m3surfaceContainer.a : 0)
radius: Appearance.rounding.normal
border.width: isCurrent ? 1 : 0
@ -57,13 +56,13 @@ CollapsibleSection {
StateLayer {
function onClicked(): void {
rootPane.fontFamilyMaterial = modelData;
rootPane.fontFamilySans = modelData;
rootPane.saveConfig();
}
}
RowLayout {
id: fontFamilyMaterialRow
id: fontFamilySansRow
anchors.left: parent.left
anchors.right: parent.right
@ -92,7 +91,7 @@ CollapsibleSection {
}
}
implicitHeight: fontFamilyMaterialRow.implicitHeight + Appearance.padding.normal * 2
implicitHeight: fontFamilySansRow.implicitHeight + Appearance.padding.normal * 2
}
}
}
@ -178,27 +177,28 @@ CollapsibleSection {
}
CollapsibleSection {
id: sansFontSection
title: qsTr("Sans-serif font family")
id: materialFontSection
title: qsTr("Material font family")
expanded: false
showBackground: true
nested: true
Loader {
id: materialFontLoader
Layout.fillWidth: true
Layout.preferredHeight: item ? Math.min(item.contentHeight, 300) : 0
active: sansFontSection.expanded
active: materialFontSection.expanded
sourceComponent: StyledListView {
id: sansFontList
property alias contentHeight: sansFontList.contentHeight
id: materialFontList
property alias contentHeight: materialFontList.contentHeight
clip: true
spacing: Appearance.spacing.small / 2
model: Qt.fontFamilies()
model: Qt.fontFamilies().filter(f => f.startsWith("Material Symbols"))
StyledScrollBar.vertical: StyledScrollBar {
flickable: sansFontList
flickable: materialFontList
}
delegate: StyledRect {
@ -207,7 +207,7 @@ CollapsibleSection {
width: ListView.view.width
readonly property bool isCurrent: modelData === rootPane.fontFamilySans
readonly property bool isCurrent: modelData === rootPane.fontFamilyMaterial
color: Qt.alpha(Colours.tPalette.m3surfaceContainer, isCurrent ? Colours.tPalette.m3surfaceContainer.a : 0)
radius: Appearance.rounding.normal
border.width: isCurrent ? 1 : 0
@ -215,13 +215,13 @@ CollapsibleSection {
StateLayer {
function onClicked(): void {
rootPane.fontFamilySans = modelData;
rootPane.fontFamilyMaterial = modelData;
rootPane.saveConfig();
}
}
RowLayout {
id: fontFamilySansRow
id: fontFamilyMaterialRow
anchors.left: parent.left
anchors.right: parent.right
@ -250,7 +250,7 @@ CollapsibleSection {
}
}
implicitHeight: fontFamilySansRow.implicitHeight + Appearance.padding.normal * 2
implicitHeight: fontFamilyMaterialRow.implicitHeight + Appearance.padding.normal * 2
}
}
}