forked from qt-creator/qt-creator
Utils: Add a manual test for StyleHelper::uiFont
Visualizes the predefined ui fonts. Change-Id: Ic0af15ab149b213a59bf8e22cf7e17ab9042c54e Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -3,3 +3,4 @@ add_subdirectory(infolabel)
|
|||||||
add_subdirectory(layoutbuilder)
|
add_subdirectory(layoutbuilder)
|
||||||
add_subdirectory(manhattanstyle)
|
add_subdirectory(manhattanstyle)
|
||||||
add_subdirectory(tracing)
|
add_subdirectory(tracing)
|
||||||
|
add_subdirectory(uifonts)
|
||||||
|
14
tests/manual/widgets/uifonts/CMakeLists.txt
Normal file
14
tests/manual/widgets/uifonts/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
add_qtc_test(tst_manual_widgets_uifonts
|
||||||
|
MANUALTEST
|
||||||
|
DEPENDS Qt::Gui Utils
|
||||||
|
SOURCES
|
||||||
|
tst_manual_widgets_uifonts.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(FONTS_BASE "${QtCreator_SOURCE_DIR}/src/share/3rdparty/studiofonts/")
|
||||||
|
qt_add_resources(tst_manual_widgets_uifonts
|
||||||
|
tst_manual_widgets_uifonts_rcc
|
||||||
|
BASE ${FONTS_BASE}
|
||||||
|
PREFIX "studiofonts"
|
||||||
|
FILES "${FONTS_BASE}/TitilliumWeb-Regular.ttf"
|
||||||
|
)
|
50
tests/manual/widgets/uifonts/tst_manual_widgets_uifonts.cpp
Normal file
50
tests/manual/widgets/uifonts/tst_manual_widgets_uifonts.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (C) 2022 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
static const struct {
|
||||||
|
StyleHelper::UiElement uiElement;
|
||||||
|
const QString name;
|
||||||
|
} uiElements[] = {
|
||||||
|
{ StyleHelper::UiElementH1, "H1" },
|
||||||
|
{ StyleHelper::UiElementH2, "H2" },
|
||||||
|
{ StyleHelper::UiElementH3, "H3" },
|
||||||
|
{ StyleHelper::UiElementH4, "H4" },
|
||||||
|
{ StyleHelper::UiElementCaptionStrong, "Caption strong" },
|
||||||
|
{ StyleHelper::UiElementCaption, "Caption" },
|
||||||
|
};
|
||||||
|
static const QString textSample("AaBbCcXxYyZz123");
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
Grid fontLabels {};
|
||||||
|
for (auto uiElement : uiElements) {
|
||||||
|
const QFont font = StyleHelper::uiFont(uiElement.uiElement);
|
||||||
|
auto *uiElementLabel = new QLabel(uiElement.name);
|
||||||
|
uiElementLabel->setFont(font);
|
||||||
|
auto *sampleLabel = new QLabel(textSample);
|
||||||
|
sampleLabel->setFont(font);
|
||||||
|
fontLabels.addItems({uiElementLabel, sampleLabel, font.toString(), br});
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
windowTitle("Utils::StyleHelper::uiFont"),
|
||||||
|
Group {
|
||||||
|
title("As QFont in QLabel"),
|
||||||
|
fontLabels,
|
||||||
|
},
|
||||||
|
}.emerge()->show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
12
tests/manual/widgets/uifonts/uifonts.qbs
Normal file
12
tests/manual/widgets/uifonts/uifonts.qbs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
CppApplication {
|
||||||
|
name: "Manual Test Utils UiFonts"
|
||||||
|
Depends { name: "Utils" }
|
||||||
|
files: "tst_manual_widgets_uifonts.cpp"
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "studiofonts"
|
||||||
|
prefix: "../../../../src/share/3rdparty/studiofonts/"
|
||||||
|
files: "studiofonts.qrc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -7,5 +7,6 @@ Project {
|
|||||||
"layoutbuilder/layoutbuilder.qbs",
|
"layoutbuilder/layoutbuilder.qbs",
|
||||||
"manhattanstyle/manhattanstyle.qbs",
|
"manhattanstyle/manhattanstyle.qbs",
|
||||||
"tracing/tracing.qbs",
|
"tracing/tracing.qbs",
|
||||||
|
"uifonts/uifonts.qbs",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user