forked from qt-creator/qt-creator
Utils: Introduce StyleHelper::UiFont() for centralized font definitions
Custom font sizes of UI texts like titles and subtitles were usually defined on the spot in code. With the upcoming focus on unified fonts and colors in Qt Creator, a centralization of font styles in needed. This adds the font getter function StyleHelper::UiFont() and the enum UiElement that specifies types as H1..H6 and some custom ones. Change-Id: Ie0d6e6fb51fe24d8aee6b4242941cbff45fe3853 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
@@ -938,4 +938,36 @@ QColor StyleHelper::ensureReadableOn(const QColor &background, const QColor &des
|
||||
return foreground;
|
||||
}
|
||||
|
||||
QFont StyleHelper::UiFont(UiElement element)
|
||||
{
|
||||
QFont font;
|
||||
|
||||
constexpr qreal panelTitleSize = HostOsInfo::isMacHost() ? 10 : 7.5;
|
||||
|
||||
switch (element) {
|
||||
case UiElementH1:
|
||||
font.setPointSizeF(font.pointSizeF() * 1.6);
|
||||
font.setBold(true);
|
||||
break;
|
||||
case UiElementH2:
|
||||
font.setPointSizeF(font.pointSizeF() * 1.2);
|
||||
font.setBold(true);
|
||||
break;
|
||||
case UiElementH3:
|
||||
break;
|
||||
case UiElementH4:
|
||||
break;
|
||||
case UiElementPanelTitle: {
|
||||
font.setPointSizeF(panelTitleSize);
|
||||
font.setBold(true);
|
||||
break;
|
||||
}
|
||||
case UiElementPanelSubtitle:
|
||||
font.setPointSizeF(panelTitleSize);
|
||||
break;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -47,6 +47,15 @@ enum ToolbarStyle {
|
||||
};
|
||||
constexpr ToolbarStyle defaultToolbarStyle = ToolbarStyleCompact;
|
||||
|
||||
enum UiElement {
|
||||
UiElementH1,
|
||||
UiElementH2,
|
||||
UiElementH3,
|
||||
UiElementH4,
|
||||
UiElementPanelTitle,
|
||||
UiElementPanelSubtitle,
|
||||
};
|
||||
|
||||
// Height of the project explorer navigation bar
|
||||
QTCREATOR_UTILS_EXPORT int navigationWidgetHeight();
|
||||
QTCREATOR_UTILS_EXPORT void setToolbarStyle(ToolbarStyle style);
|
||||
@@ -73,6 +82,8 @@ QTCREATOR_UTILS_EXPORT QColor sidebarShadow();
|
||||
QTCREATOR_UTILS_EXPORT QColor toolBarDropShadowColor();
|
||||
QTCREATOR_UTILS_EXPORT QColor notTooBrightHighlightColor();
|
||||
|
||||
QTCREATOR_UTILS_EXPORT QFont UiFont(UiElement element);
|
||||
|
||||
// Sets the base color and makes sure all top level widgets are updated
|
||||
QTCREATOR_UTILS_EXPORT void setBaseColor(const QColor &color);
|
||||
|
||||
|
Reference in New Issue
Block a user