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