FluentUI/src/controls/FluText.qml

73 lines
1.6 KiB
QML
Raw Normal View History

2023-02-26 23:47:07 +08:00
import QtQuick 2.15
2023-02-28 18:29:00 +08:00
import FluentUI 1.0
2023-02-26 23:47:07 +08:00
Text {
id:text
enum FontStyle {
Display,
TitleLarge,
Title,
Subtitle,
BodyLarge,
BodyStrong,
Body,
Caption
}
2023-02-27 18:46:39 +08:00
property int fontStyle: FluText.Body
property color textColor: FluApp.isDark ? "#FFFFFF" : "#1A1A1A"
property int pixelSize : 14
2023-02-26 23:47:07 +08:00
color: textColor
2023-02-28 18:29:00 +08:00
font.bold: {
switch (fontStyle) {
case FluText.Display:
return true
case FluText.TitleLarge:
return true
case FluText.Title:
return true
case FluText.Subtitle:
return true
case FluText.BodyLarge:
return false
case FluText.BodyStrong:
return true
case FluText.Body:
return false
case FluText.Caption:
return false
default:
return false
}
2023-02-26 23:47:07 +08:00
}
2023-02-28 18:29:00 +08:00
font.pixelSize: {
2023-02-26 23:47:07 +08:00
switch (fontStyle) {
2023-02-28 18:29:00 +08:00
case FluText.Display:
return text.pixelSize * 4
case FluText.TitleLarge:
return text.pixelSize * 2
case FluText.Title:
return text.pixelSize * 1.5
case FluText.Subtitle:
return text.pixelSize * 0.9
case FluText.BodyLarge:
return text.pixelSize * 1.1
case FluText.BodyStrong:
return text.pixelSize * 1.0
case FluText.Body:
return text.font.pixelSize = 14
case FluText.Caption:
return text.pixelSize * 0.8
default:
return text.pixelSize * 1.0
2023-02-26 23:47:07 +08:00
}
}
2023-02-28 18:29:00 +08:00
2023-02-26 23:47:07 +08:00
}