2023-03-25 13:35:21 +08:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import FluentUI 1.0
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
|
2023-03-09 23:11:59 +08:00
|
|
|
|
property int fontStyle: FluText.Body
|
|
|
|
|
property color textColor: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
|
|
|
|
property int pixelSize : FluTheme.textSize
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
|
|
|
|
enum FontStyle {
|
|
|
|
|
Display,
|
|
|
|
|
TitleLarge,
|
|
|
|
|
Title,
|
|
|
|
|
Subtitle,
|
|
|
|
|
BodyLarge,
|
|
|
|
|
BodyStrong,
|
|
|
|
|
Body,
|
|
|
|
|
Caption
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 23:11:59 +08:00
|
|
|
|
id:text
|
2023-02-26 23:47:07 +08:00
|
|
|
|
color: textColor
|
2023-03-11 21:15:36 +08:00
|
|
|
|
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
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:
|
2023-02-28 23:57:55 +08:00
|
|
|
|
return text.pixelSize * 1.0
|
2023-02-28 18:29:00 +08:00
|
|
|
|
case FluText.Caption:
|
|
|
|
|
return text.pixelSize * 0.8
|
|
|
|
|
default:
|
|
|
|
|
return text.pixelSize * 1.0
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|