forked from qt-creator/qt-creator
Utils: Align enum StyleHelper::UiElement with upcoming design system #3
The Qt Creator Design System defines display headings H1 and H2 with a "Titillium Web" font face. This change introduces the "Titillium Web" based as new H1 and H2 and lets the WelcomeScreen code obtain them via StyleHelper::UiFont(). It is supposed to not change the visual appearance. Change-Id: Ia2c5ac14858e574c4ffd31af1ed80ac1781cd970 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -933,6 +933,15 @@ QColor StyleHelper::ensureReadableOn(const QColor &background, const QColor &des
|
|||||||
return foreground;
|
return foreground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QStringList brandFontFamilies()
|
||||||
|
{
|
||||||
|
const static QStringList families = []{
|
||||||
|
const int id = QFontDatabase::addApplicationFont(":/studiofonts/TitilliumWeb-Regular.ttf");
|
||||||
|
return id >= 0 ? QFontDatabase::applicationFontFamilies(id) : QStringList();
|
||||||
|
}();
|
||||||
|
return families;
|
||||||
|
}
|
||||||
|
|
||||||
QFont StyleHelper::UiFont(UiElement element)
|
QFont StyleHelper::UiFont(UiElement element)
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
@@ -941,8 +950,14 @@ QFont StyleHelper::UiFont(UiElement element)
|
|||||||
|
|
||||||
switch (element) {
|
switch (element) {
|
||||||
case UiElementH1:
|
case UiElementH1:
|
||||||
|
font.setFamilies(brandFontFamilies());
|
||||||
|
font.setPixelSize(30);
|
||||||
|
font.setWeight(QFont::Light);
|
||||||
|
font.setWordSpacing(2);
|
||||||
break;
|
break;
|
||||||
case UiElementH2:
|
case UiElementH2:
|
||||||
|
font.setFamilies(brandFontFamilies());
|
||||||
|
font.setPixelSize(16);
|
||||||
break;
|
break;
|
||||||
case UiElementH3:
|
case UiElementH3:
|
||||||
font.setPointSizeF(font.pointSizeF() * 1.6);
|
font.setPointSizeF(font.pointSizeF() * 1.6);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -177,7 +178,7 @@ void WelcomePageButton::setSize(Size size)
|
|||||||
const int hMargin = size == SizeSmall ? 12 : 26;
|
const int hMargin = size == SizeSmall ? 12 : 26;
|
||||||
const int vMargin = size == SizeSmall ? 2 : 4;
|
const int vMargin = size == SizeSmall ? 2 : 4;
|
||||||
d->m_layout->setContentsMargins(hMargin, vMargin, hMargin, vMargin);
|
d->m_layout->setContentsMargins(hMargin, vMargin, hMargin, vMargin);
|
||||||
d->m_label->setFont(size == SizeSmall ? font() : WelcomePageHelpers::brandFont());
|
d->m_label->setFont(size == SizeSmall ? font() : StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WelcomePageButton::setWithAccentColor(bool withAccent)
|
void WelcomePageButton::setWithAccentColor(bool withAccent)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QEasingCurve>
|
#include <QEasingCurve>
|
||||||
#include <QFontDatabase>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QHoverEvent>
|
#include <QHoverEvent>
|
||||||
@@ -46,21 +45,6 @@ static QFont sizedFont(int size, const QWidget *widget)
|
|||||||
|
|
||||||
namespace WelcomePageHelpers {
|
namespace WelcomePageHelpers {
|
||||||
|
|
||||||
QFont brandFont()
|
|
||||||
{
|
|
||||||
const static QFont f = []{
|
|
||||||
const int id = QFontDatabase::addApplicationFont(":/studiofonts/TitilliumWeb-Regular.ttf");
|
|
||||||
QFont result;
|
|
||||||
result.setPixelSize(16);
|
|
||||||
if (id >= 0) {
|
|
||||||
const QStringList fontFamilies = QFontDatabase::applicationFontFamilies(id);
|
|
||||||
result.setFamilies(fontFamilies);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}();
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *panelBar(QWidget *parent)
|
QWidget *panelBar(QWidget *parent)
|
||||||
{
|
{
|
||||||
auto frame = new QWidget(parent);
|
auto frame = new QWidget(parent);
|
||||||
@@ -83,7 +67,7 @@ SearchBox::SearchBox(QWidget *parent)
|
|||||||
m_lineEdit = new FancyLineEdit;
|
m_lineEdit = new FancyLineEdit;
|
||||||
m_lineEdit->setFiltering(true);
|
m_lineEdit->setFiltering(true);
|
||||||
m_lineEdit->setFrame(false);
|
m_lineEdit->setFrame(false);
|
||||||
m_lineEdit->setFont(WelcomePageHelpers::brandFont());
|
m_lineEdit->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
m_lineEdit->setMinimumHeight(33);
|
m_lineEdit->setMinimumHeight(33);
|
||||||
m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
|
|
||||||
@@ -801,7 +785,7 @@ ListModel *SectionedGridView::addSection(const Section §ion, const QList<Lis
|
|||||||
}.emerge();
|
}.emerge();
|
||||||
m_sectionLabels.append(sectionLabel);
|
m_sectionLabels.append(sectionLabel);
|
||||||
sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
|
sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
|
||||||
sectionLabel->setFont(Core::WelcomePageHelpers::brandFont());
|
sectionLabel->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
auto scrollArea = qobject_cast<QScrollArea *>(widget(0));
|
auto scrollArea = qobject_cast<QScrollArea *>(widget(0));
|
||||||
auto vbox = qobject_cast<QVBoxLayout *>(scrollArea->widget()->layout());
|
auto vbox = qobject_cast<QVBoxLayout *>(scrollArea->widget()->layout());
|
||||||
|
|
||||||
@@ -858,7 +842,7 @@ void SectionedGridView::zoomInSection(const Section §ion)
|
|||||||
noMargin
|
noMargin
|
||||||
}.emerge();
|
}.emerge();
|
||||||
sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
|
sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
|
||||||
sectionLabel->setFont(Core::WelcomePageHelpers::brandFont());
|
sectionLabel->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
|
|
||||||
auto gridView = new GridView(zoomedInWidget);
|
auto gridView = new GridView(zoomedInWidget);
|
||||||
gridView->setItemDelegate(m_itemDelegate);
|
gridView->setItemDelegate(m_itemDelegate);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ constexpr QSize GridItemImageSize(GridItemWidth - GridItemGap
|
|||||||
- GridItemGap - 1 // Upper margin + 1 pixel
|
- GridItemGap - 1 // Upper margin + 1 pixel
|
||||||
- 67); // Bottom margin (for title + tags)
|
- 67); // Bottom margin (for title + tags)
|
||||||
|
|
||||||
CORE_EXPORT QFont brandFont();
|
|
||||||
CORE_EXPORT QWidget *panelBar(QWidget *parent = nullptr);
|
CORE_EXPORT QWidget *panelBar(QWidget *parent = nullptr);
|
||||||
|
|
||||||
} // namespace WelcomePageHelpers
|
} // namespace WelcomePageHelpers
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
@@ -583,11 +583,11 @@ public:
|
|||||||
manageSessionsButton->setOnClicked([] { SessionManager::showSessionManager(); });
|
manageSessionsButton->setOnClicked([] { SessionManager::showSessionManager(); });
|
||||||
|
|
||||||
auto sessionsLabel = new QLabel(this);
|
auto sessionsLabel = new QLabel(this);
|
||||||
sessionsLabel->setFont(brandFont());
|
sessionsLabel->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
sessionsLabel->setText(Tr::tr("Sessions"));
|
sessionsLabel->setText(Tr::tr("Sessions"));
|
||||||
|
|
||||||
auto recentProjectsLabel = new QLabel(this);
|
auto recentProjectsLabel = new QLabel(this);
|
||||||
recentProjectsLabel->setFont(brandFont());
|
recentProjectsLabel->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
recentProjectsLabel->setText(Tr::tr("Projects"));
|
recentProjectsLabel->setText(Tr::tr("Projects"));
|
||||||
|
|
||||||
auto sessionsList = new TreeView(this, "Sessions");
|
auto sessionsList = new TreeView(this, "Sessions");
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
|
||||||
@@ -175,10 +176,7 @@ public:
|
|||||||
|
|
||||||
hbox->addSpacing(16);
|
hbox->addSpacing(16);
|
||||||
|
|
||||||
QFont welcomeFont = brandFont();
|
const QFont welcomeFont = StyleHelper::UiFont(StyleHelper::UiElementH1);
|
||||||
welcomeFont.setPixelSize(30);
|
|
||||||
welcomeFont.setWeight(QFont::Light);
|
|
||||||
welcomeFont.setWordSpacing(2);
|
|
||||||
|
|
||||||
auto welcomeLabel = new QLabel("Welcome to");
|
auto welcomeLabel = new QLabel("Welcome to");
|
||||||
welcomeLabel->setFont(welcomeFont);
|
welcomeLabel->setFont(welcomeFont);
|
||||||
@@ -263,7 +261,7 @@ public:
|
|||||||
vbox->addItem(newVBox);
|
vbox->addItem(newVBox);
|
||||||
|
|
||||||
auto newLabel = new QLabel(Tr::tr("New to Qt?"), mainWidget);
|
auto newLabel = new QLabel(Tr::tr("New to Qt?"), mainWidget);
|
||||||
newLabel->setFont(brandFont());
|
newLabel->setFont(StyleHelper::UiFont(StyleHelper::UiElementH2));
|
||||||
newLabel->setAlignment(Qt::AlignHCenter);
|
newLabel->setAlignment(Qt::AlignHCenter);
|
||||||
newVBox->addWidget(newLabel);
|
newVBox->addWidget(newLabel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user