Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qstylefactory.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
// Qt-Security score:significant reason:default
4
5
#
include
"qstylefactory.h"
6
#
include
"qstyleplugin.h"
7
#
include
"private/qfactoryloader_p.h"
8
#
include
"qmutex.h"
9
10
#
include
"qapplication.h"
11
#
include
"qwindowsstyle_p.h"
12
#
if
QT_CONFIG
(
style_fusion
)
13
#
include
"qfusionstyle_p.h"
14
#
endif
15
16
QT_BEGIN_NAMESPACE
17
18
using
namespace
Qt::StringLiterals;
19
20
Q_GLOBAL_STATIC_WITH_ARGS
(QFactoryLoader, loader,
21
(
QStyleFactoryInterface_iid
,
"/styles"_L1
, Qt::CaseInsensitive))
22
23
/*!
24
\class QStyleFactory
25
\brief The QStyleFactory class creates QStyle objects.
26
27
\ingroup appearance
28
\inmodule QtWidgets
29
30
The QStyle class is an abstract base class that encapsulates the
31
look and feel of a GUI. QStyleFactory creates a QStyle object
32
using the create() function and a key identifying the style. The
33
styles are either built-in or dynamically loaded from a style
34
plugin (see QStylePlugin).
35
36
Use the keys() function to retrieve the valid keys. The built-in
37
styles, typically "windows" and "fusion", are always available. The
38
platform styles are plugins and are available on their platform only:
39
"windows11", which follows the Windows 11 Fluent design, and
40
"windowsvista" on Windows, "macos" on \macos, and "android" on Android.
41
The keys are case-insensitive.
42
43
\sa QStyle
44
*/
45
46
/*!
47
Creates and returns a QStyle object that matches the given \a key, or
48
returns \nullptr if no matching style is found.
49
50
Both built-in styles and styles from style plugins are queried for a
51
matching style.
52
53
\note The keys are case-insensitive.
54
55
\sa keys()
56
*/
57
QStyle *QStyleFactory::create(
const
QString& key)
58
{
59
QStyle *ret =
nullptr
;
60
QString style = key.toLower();
61
#
if
QT_CONFIG
(
style_windows
)
62
if
(style ==
"windows"_L1
)
63
ret =
new
QWindowsStyle;
64
else
65
#
endif
66
#
if
QT_CONFIG
(
style_fusion
)
67
if
(style ==
"fusion"_L1
)
68
ret =
new
QFusionStyle;
69
else
70
#
endif
71
#
if
defined
(
Q_OS_MACOS
)
&&
QT_DEPRECATED_SINCE
(
6
,
0
)
72
if
(style ==
"macintosh"_L1
) {
73
qWarning() <<
"The style key 'macintosh' is deprecated. Please use 'macos' instead."
;
74
style = QStringLiteral(
"macos"
);
75
}
else
76
#
endif
77
{ }
// Keep these here - they make the #ifdefery above work
78
if
(!ret)
79
ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style);
80
if
(ret) {
81
ret->setObjectName(style);
82
ret->setName(style);
83
}
84
return
ret;
85
}
86
87
/*!
88
Returns the list of valid keys, i.e. the keys this factory can
89
create styles for.
90
91
\sa create()
92
*/
93
QStringList QStyleFactory::keys()
94
{
95
QStringList list;
96
typedef
QMultiMap<
int
, QString> PluginKeyMap;
97
98
const
PluginKeyMap keyMap = loader()->keyMap();
99
const
PluginKeyMap::const_iterator cend = keyMap.constEnd();
100
for
(PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it)
101
list.append(it.value());
102
#
if
QT_CONFIG
(
style_windows
)
103
if
(!list.contains(
"Windows"_L1
))
104
list <<
"Windows"_L1
;
105
#
endif
106
#
if
QT_CONFIG
(
style_fusion
)
107
if
(!list.contains(
"Fusion"_L1
))
108
list <<
"Fusion"_L1
;
109
#
endif
110
return
list;
111
}
112
113
QT_END_NAMESPACE
Q_GLOBAL_STATIC_WITH_ARGS
Q_GLOBAL_STATIC_WITH_ARGS(PermissionStatusHash, g_permissionStatusHash,({ { qMetaTypeId< QCameraPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QMicrophonePermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QBluetoothPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QContactsPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QCalendarPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QLocationPermission >(), Qt::PermissionStatus::Undetermined } }))
QStyleFactoryInterface_iid
#define QStyleFactoryInterface_iid
Definition
qstyleplugin.h:17
qtbase
src
widgets
styles
qstylefactory.cpp
Generated on
for Qt by
1.18.0