From fb28890eb2107c5ce75cf48945920a13a1a153bc Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 11 Dec 2023 11:59:45 +0100 Subject: [PATCH] Utils: Introduce H5, H6 and "H6 Capital" Ui fonts As defined by the new Qt Creator design system. Change-Id: Ib67b35ea552cf88c4b89481b72e690e04a57bbb7 Reviewed-by: Alessandro Portale --- src/libs/utils/stylehelper.cpp | 16 ++++++++++++++++ src/libs/utils/stylehelper.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index a33a34b3cf1..cad39b430ca 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -967,6 +967,17 @@ QFont StyleHelper::uiFont(UiElement element) font.setPointSizeF(font.pointSizeF() * 1.2); font.setBold(true); break; + case UiElementH5: + font.setPointSizeF(font.pointSizeF() * 1.2); + font.setWeight(QFont::DemiBold); + break; + case UiElementH6: + font.setWeight(QFont::DemiBold); + break; + case UiElementH6Capital: + font.setWeight(QFont::DemiBold); + font.setCapitalization(QFont::AllUppercase); + break; case UiElementCaptionStrong: font.setPointSizeF(panelTitleSize); font.setWeight(QFont::DemiBold); @@ -989,10 +1000,15 @@ QString StyleHelper::fontToCssProperties(const QFont &font) const QString fontShorthand = fontStyle + " " + QString::number(font.weight()) + " " + fontSize + " " + font.family(); const QString textDecoration = QLatin1String(font.underline() ? "underline" : "none"); + const QString textTransform = QLatin1String(font.capitalization() == QFont::AllUppercase + ? "uppercase" + : font.capitalization() == QFont::AllLowercase + ? "lowercase" : "none"); const QString propertyTemplate = "%1: %2"; const QStringList cssProperties = { propertyTemplate.arg("font").arg(fontShorthand), propertyTemplate.arg("text-decoration").arg(textDecoration), + propertyTemplate.arg("text-transform").arg(textTransform), propertyTemplate.arg("word-spacing").arg(font.wordSpacing()), }; const QString fontCssStyle = cssProperties.join("; "); diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index e45bde570bb..d9b17255783 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -52,6 +52,9 @@ enum UiElement { UiElementH2, UiElementH3, UiElementH4, + UiElementH5, + UiElementH6, + UiElementH6Capital, UiElementCaptionStrong, UiElementCaption, };