refactor: migrate bar to new font API

This commit is contained in:
2 * r + 2 * t 2026-04-21 01:09:55 +10:00
parent 3a30fcc730
commit 77dbcf5a88
15 changed files with 41 additions and 51 deletions

View file

@ -86,8 +86,7 @@ Item {
id: metrics
text: root.windowTitle
font.pointSize: root.Tokens.font.size.smaller
font.family: root.Tokens.font.family.mono
font: root.Tokens.font.mono.small
elide: Qt.ElideRight
elideWidth: root.maxHeight - icon.height
@ -112,8 +111,7 @@ Item {
anchors.top: icon.bottom
anchors.topMargin: Tokens.spacing.small
font.pointSize: metrics.font.pointSize
font.family: metrics.font.family
font: metrics.font
color: root.colour
opacity: root.current === this ? 1 : 0

View file

@ -43,8 +43,7 @@ StyledRect {
horizontalAlignment: StyledText.AlignHCenter
text: Time.format("ddd\nd")
font.pointSize: Tokens.font.size.smaller
font.family: Tokens.font.family.sans
font: Tokens.font.body.small
color: root.colour
}
@ -63,8 +62,7 @@ StyledRect {
horizontalAlignment: StyledText.AlignHCenter
text: Time.format(GlobalConfig.services.useTwelveHourClock ? "hh\nmm\nA" : "hh\nmm")
font.pointSize: Tokens.font.size.smaller
font.family: Tokens.font.family.mono
font: Tokens.font.mono.small
color: root.colour
}
}

View file

@ -8,8 +8,8 @@ import qs.utils
Item {
id: root
implicitWidth: Math.round(Tokens.font.size.large * 1.2)
implicitHeight: Math.round(Tokens.font.size.large * 1.2)
implicitWidth: Math.round(Tokens.font.body.large.pointSize * 1.2)
implicitHeight: Math.round(Tokens.font.body.large.pointSize * 1.2)
MouseArea {
anchors.fill: parent
@ -30,8 +30,8 @@ Item {
id: caelestiaLogo
Logo {
implicitWidth: Math.round(Tokens.font.size.large * 1.6)
implicitHeight: Math.round(Tokens.font.size.large * 1.6)
implicitWidth: Math.round(Tokens.font.body.large.pointSize * 1.6)
implicitHeight: Math.round(Tokens.font.body.large.pointSize * 1.6)
}
}
@ -40,7 +40,7 @@ Item {
ColouredIcon {
source: SysInfo.osLogo
implicitSize: Math.round(Tokens.font.size.large * 1.2)
implicitSize: Math.round(Tokens.font.body.large.pointSize * 1.2)
colour: Colours.palette.m3tertiary
}
}

View file

@ -29,7 +29,6 @@ Item {
text: "power_settings_new"
color: Colours.palette.m3error
font.bold: true
font.pointSize: Tokens.font.size.normal
font: Tokens.font.icon.builders.medium.weight(Font.Bold).build()
}
}

View file

@ -136,7 +136,7 @@ StyledRect {
animate: true
text: Hypr.kbLayout
color: root.colour
font.family: Tokens.font.family.mono
font: Tokens.font.mono.medium
}
}

View file

@ -100,7 +100,7 @@ StyledRect {
anchors.bottom: parent.bottom
anchors.bottomMargin: Config.bar.tray.background ? Tokens.padding.extraSmall : -Tokens.padding.extraSmall
text: "expand_less"
font.pointSize: Tokens.font.size.large
font: Tokens.font.icon.large
rotation: root.expanded ? 180 : 0
Behavior on rotation {

View file

@ -13,8 +13,8 @@ MouseArea {
required property SystemTrayItem modelData
acceptedButtons: Qt.LeftButton | Qt.RightButton
implicitWidth: Tokens.font.size.small * 2
implicitHeight: Tokens.font.size.small * 2
implicitWidth: Tokens.font.body.small.pointSize * 2
implicitHeight: Tokens.font.body.small.pointSize * 2
onClicked: event => {
if (event.button === Qt.LeftButton)

View file

@ -46,7 +46,7 @@ Item {
StyledText {
Layout.fillWidth: true
text: Hypr.activeToplevel?.title ?? ""
font.pointSize: Tokens.font.size.normal
font: Tokens.font.body.medium
elide: Text.ElideRight
}
@ -77,7 +77,7 @@ Item {
text: "chevron_right"
font.pointSize: Tokens.font.size.large
font: Tokens.font.icon.large
}
}
}

View file

@ -34,7 +34,7 @@ Item {
StyledText {
text: qsTr("Output device")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
Repeater {
@ -55,7 +55,7 @@ Item {
StyledText {
Layout.topMargin: Tokens.spacing.medium
text: qsTr("Input device")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
Repeater {
@ -75,7 +75,7 @@ Item {
Layout.topMargin: Tokens.spacing.medium
Layout.bottomMargin: -Tokens.spacing.extraSmall
text: qsTr("Volume (%1)").arg(Audio.muted ? qsTr("Muted") : `${Math.round(Audio.volume * 100)}%`)
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
CustomMouseArea {

View file

@ -72,8 +72,7 @@ Column {
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Performance Degraded")
color: Colours.palette.m3onError
font.family: Tokens.font.family.mono
font.weight: 500
font: Tokens.font.mono.builders.medium.weight(500).build()
}
MaterialIcon {
@ -214,7 +213,7 @@ Column {
anchors.centerIn: parent
text: parent.icon
font.pointSize: Tokens.font.size.large
font: Tokens.font.icon.large
color: profiles.current === text ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
fill: profiles.current === text ? 1 : 0

View file

@ -22,7 +22,7 @@ ColumnLayout {
Layout.topMargin: Tokens.padding.medium
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("Bluetooth")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
Toggle {
@ -57,7 +57,7 @@ ColumnLayout {
return available;
}
color: Colours.palette.m3onSurfaceVariant
font.pointSize: Tokens.font.size.small
font: Tokens.font.body.small
}
Repeater {

View file

@ -29,7 +29,7 @@ ColumnLayout {
Layout.topMargin: visible ? Tokens.padding.medium : 0
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("Wireless")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
Toggle {
@ -47,7 +47,7 @@ ColumnLayout {
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("%1 networks available").arg(Nmcli.networks.length) // qmllint disable missing-property
color: Colours.palette.m3onSurfaceVariant
font.pointSize: Tokens.font.size.small
font: Tokens.font.body.small
}
Repeater {
@ -97,7 +97,7 @@ ColumnLayout {
MaterialIcon {
visible: networkItem.modelData.isSecure
text: "lock"
font.pointSize: Tokens.font.size.small
font: Tokens.font.icon.small
}
StyledText {
@ -106,7 +106,7 @@ ColumnLayout {
Layout.fillWidth: true
text: networkItem.modelData.ssid
elide: Text.ElideRight
font.weight: networkItem.modelData.active ? 500 : 400
font: Tokens.font.body.builders.medium.weight(networkItem.modelData.active ? 500 : 400).build()
color: networkItem.modelData.active ? Colours.palette.m3primary : Colours.palette.m3onSurface
}
@ -221,7 +221,7 @@ ColumnLayout {
Layout.topMargin: visible ? Tokens.padding.medium : 0
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("Ethernet")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
StyledText {
@ -231,7 +231,7 @@ ColumnLayout {
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("%1 devices available").arg(Nmcli.ethernetDevices.length)
color: Colours.palette.m3onSurfaceVariant
font.pointSize: Tokens.font.size.small
font: Tokens.font.body.small
}
Repeater {
@ -283,7 +283,7 @@ ColumnLayout {
Layout.fillWidth: true
text: ethernetItem.modelData.interface || qsTr("Unknown")
elide: Text.ElideRight
font.weight: ethernetItem.modelData.connected ? 500 : 400
font: Tokens.font.body.builders.medium.weight(ethernetItem.modelData.connected ? 500 : 400).build()
color: ethernetItem.modelData.connected ? Colours.palette.m3primary : Colours.palette.m3onSurface
}

View file

@ -148,8 +148,7 @@ StackView {
id: labelMetrics
text: item.modelData.text
font.pointSize: label.font.pointSize
font.family: label.font.family
font: label.font
elide: Text.ElideRight
elideWidth: root.Tokens.sizes.bar.trayMenuWidth - (icon.active ? icon.implicitWidth + label.anchors.leftMargin : 0) - (expand.active ? expand.implicitWidth + root.Tokens.spacing.medium : 0)

View file

@ -177,14 +177,13 @@ ColumnLayout {
MaterialIcon {
Layout.alignment: Qt.AlignHCenter
text: "lock"
font.pointSize: Tokens.font.size.extraLarge * 2
font: Tokens.font.icon.builders.extraLarge.size(Tokens.font.icon.extraLarge.pointSize * 2).build()
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Enter password")
font.pointSize: Tokens.font.size.large
font.weight: 500
font: Tokens.font.body.builders.large.weight(500).build()
}
StyledText {
@ -201,7 +200,7 @@ ColumnLayout {
return qsTr("Network: Unknown");
}
color: Colours.palette.m3outline
font.pointSize: Tokens.font.size.small
font: Tokens.font.body.small
}
Timer {
@ -249,8 +248,7 @@ ColumnLayout {
return "";
}
color: connectButton.hasError ? Colours.palette.m3error : Colours.palette.m3onSurfaceVariant
font.pointSize: Tokens.font.size.small
font.weight: 400
font: Tokens.font.body.builders.small.weight(400).build()
wrapMode: Text.WordWrap
Layout.maximumWidth: parent.width - Tokens.padding.extraLargeIncreased
}
@ -375,8 +373,7 @@ ColumnLayout {
anchors.centerIn: parent
text: qsTr("Password")
color: Colours.palette.m3outline
font.pointSize: Tokens.font.size.normal
font.family: Tokens.font.family.mono
font: Tokens.font.mono.medium
opacity: passwordContainer.passwordBuffer ? 0 : 1
Behavior on opacity {
@ -391,7 +388,7 @@ ColumnLayout {
anchors.centerIn: parent
implicitWidth: fullWidth
implicitHeight: Tokens.font.size.normal
implicitHeight: Tokens.font.body.medium.pointSize
orientation: Qt.Horizontal
spacing: Tokens.spacing.extraSmall
@ -471,7 +468,7 @@ ColumnLayout {
id: cancelButton
Layout.fillWidth: true
Layout.minimumHeight: Tokens.font.size.normal + Tokens.padding.medium * 2
Layout.minimumHeight: Tokens.font.body.medium.pointSize + Tokens.padding.normal * 2
inactiveColour: Colours.palette.m3secondaryContainer
inactiveOnColour: Colours.palette.m3onSecondaryContainer
text: qsTr("Cancel")
@ -486,7 +483,7 @@ ColumnLayout {
property bool hasError: false
Layout.fillWidth: true
Layout.minimumHeight: Tokens.font.size.normal + Tokens.padding.medium * 2
Layout.minimumHeight: Tokens.font.body.medium.pointSize + Tokens.padding.normal * 2
inactiveColour: Colours.palette.m3primary
inactiveOnColour: Colours.palette.m3onPrimary
text: qsTr("Connect")

View file

@ -27,7 +27,7 @@ ColumnLayout {
Layout.topMargin: Tokens.padding.medium
Layout.rightMargin: Tokens.padding.extraSmall
text: qsTr("Keyboard Layouts")
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
}
ListView {
@ -155,7 +155,7 @@ ColumnLayout {
Layout.fillWidth: true
text: kb.activeLabel
elide: Text.ElideRight
font.weight: 500
font: Tokens.font.body.builders.medium.weight(500).build()
color: Colours.palette.m3primary
}