Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include "qstylefactory.h"
5#include "qstyleplugin.h"
6#include "private/qfactoryloader_p.h"
7#include "qmutex.h"
8
9#include "qapplication.h"
10#include "qwindowsstyle_p.h"
11#if QT_CONFIG(style_fusion)
12#include "qfusionstyle_p.h"
13#endif
14
16
17using namespace Qt::StringLiterals;
18
21
22
56{
57 QStyle *ret = nullptr;
58 QString style = key.toLower();
59#if QT_CONFIG(style_windows)
60 if (style == "windows"_L1)
61 ret = new QWindowsStyle;
62 else
63#endif
64#if QT_CONFIG(style_fusion)
65 if (style == "fusion"_L1)
66 ret = new QFusionStyle;
67 else
68#endif
69#if defined(Q_OS_MACOS) && QT_DEPRECATED_SINCE(6, 0)
70 if (style == "macintosh"_L1) {
71 qWarning() << "The style key 'macintosh' is deprecated. Please use 'macos' instead.";
72 style = QStringLiteral("macos");
73 } else
74#endif
75 { } // Keep these here - they make the #ifdefery above work
76 if (!ret)
77 ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style);
78 if (ret) {
79 ret->setObjectName(style);
80 ret->setName(style);
81 }
82 return ret;
83}
84
92{
94 typedef QMultiMap<int, QString> PluginKeyMap;
95
96 const PluginKeyMap keyMap = loader()->keyMap();
97 const PluginKeyMap::const_iterator cend = keyMap.constEnd();
98 for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it)
99 list.append(it.value());
100#if QT_CONFIG(style_windows)
101 if (!list.contains("Windows"_L1))
102 list << "Windows"_L1;
103#endif
104#if QT_CONFIG(style_fusion)
105 if (!list.contains("Fusion"_L1))
106 list << "Fusion"_L1;
107#endif
108 return list;
109}
110
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString toLower() const &
Definition qstring.h:435
static QStringList keys()
Returns the list of valid keys, i.e.
static QStyle * create(const QString &)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ CaseInsensitive
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS)
#define qWarning
Definition qlogging.h:166
return ret
GLuint64 key
#define QStringLiteral(str)
#define QStyleFactoryInterface_iid
static const struct @450 keyMap[]
QList< int > list
[14]
bool contains(const AT &t) const noexcept
Definition qlist.h:45