Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqstylekitfont.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7
8QQStyleKitFont::QQStyleKitFont(QObject *parent)
10{
11}
12
13#define DEFINE_FONT_GETTER(scopeName, scopeEnum)
14 QFont QQStyleKitFont::scopeName() const
15 {
16 return m_fonts[int(QQuickTheme::scopeEnum)];
17 }
18
19DEFINE_FONT_GETTER(system, System)
20DEFINE_FONT_GETTER(button, Button)
21DEFINE_FONT_GETTER(checkBox, CheckBox)
22DEFINE_FONT_GETTER(comboBox, ComboBox)
23DEFINE_FONT_GETTER(groupBox, GroupBox)
24DEFINE_FONT_GETTER(itemView, ItemView)
25DEFINE_FONT_GETTER(label, Label)
26DEFINE_FONT_GETTER(listView, ListView)
27DEFINE_FONT_GETTER(menu, Menu)
28DEFINE_FONT_GETTER(menuBar, MenuBar)
29DEFINE_FONT_GETTER(radioButton, RadioButton)
30DEFINE_FONT_GETTER(spinBox, SpinBox)
31DEFINE_FONT_GETTER(switchControl, Switch)
32DEFINE_FONT_GETTER(tabBar, TabBar)
33DEFINE_FONT_GETTER(textArea, TextArea)
34DEFINE_FONT_GETTER(textField, TextField)
35DEFINE_FONT_GETTER(toolBar, ToolBar)
36DEFINE_FONT_GETTER(toolTip, ToolTip)
37DEFINE_FONT_GETTER(tumbler, Tumbler)
38
39#define DEFINE_FONT_SETTER(scopeName, scopeEnum, signal)
40 void QQStyleKitFont::set##scopeName(const QFont &font)
41 {
42 setFontForScope(QQuickTheme::scopeEnum, font, &QQStyleKitFont::signal);
43 }
44
45DEFINE_FONT_SETTER(System, System, systemChanged)
46DEFINE_FONT_SETTER(Button, Button, buttonChanged)
47DEFINE_FONT_SETTER(CheckBox, CheckBox, checkBoxChanged)
48DEFINE_FONT_SETTER(ComboBox, ComboBox, comboBoxChanged)
49DEFINE_FONT_SETTER(GroupBox, GroupBox, groupBoxChanged)
50DEFINE_FONT_SETTER(ItemView, ItemView, itemViewChanged)
51DEFINE_FONT_SETTER(Label, Label, labelChanged)
52DEFINE_FONT_SETTER(ListView, ListView, listViewChanged)
53DEFINE_FONT_SETTER(Menu, Menu, menuChanged)
54DEFINE_FONT_SETTER(MenuBar, MenuBar, menuBarChanged)
55DEFINE_FONT_SETTER(RadioButton, RadioButton, radioButtonChanged)
56DEFINE_FONT_SETTER(SpinBox, SpinBox, spinBoxChanged)
57DEFINE_FONT_SETTER(SwitchControl, Switch, switchControlChanged)
58DEFINE_FONT_SETTER(TabBar, TabBar, tabBarChanged)
59DEFINE_FONT_SETTER(TextArea, TextArea, textAreaChanged)
60DEFINE_FONT_SETTER(TextField, TextField, textFieldChanged)
61DEFINE_FONT_SETTER(ToolBar, ToolBar, toolBarChanged)
62DEFINE_FONT_SETTER(ToolTip, ToolTip, toolTipChanged)
63DEFINE_FONT_SETTER(Tumbler, Tumbler, tumblerChanged)
64
65void QQStyleKitFont::setFontForScope(QQuickTheme::Scope scope, const QFont &font, void (QQStyleKitFont::*signal)())
66{
67 const int index = int(scope);
68 if (isSet(scope) && m_fonts[index] == font)
69 return;
70
71 m_fonts[index] = font;
72 markSet(scope);
73 emit (this->*signal)();
74}
75
76// The fallback font is used to resolve unset fonts
77// The theme fonts fallback to the style fonts and
78// style fonts fallback to the fallback style fonts
79QQStyleKitFont *QQStyleKitFont::fallbackFont() const
80{
81 return m_fallback;
82}
83
84void QQStyleKitFont::setFallbackFont(QQStyleKitFont *fallback)
85{
86 if (m_fallback == fallback)
87 return;
88
89 m_fallback = fallback;
90 emit fallbackFontChanged();
91}
92
93QFont QQStyleKitFont::fontForScope(QQuickTheme::Scope scope) const
94{
95 return m_fonts[int(scope)];
96}
97
98QT_END_NAMESPACE
99#include "moc_qqstylekitfont_p.cpp"
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:105
Combined button and popup list for selecting options.
#define DEFINE_FONT_GETTER(scopeName, scopeEnum)
#define DEFINE_FONT_SETTER(scopeName, scopeEnum, signal)