Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qstylefactory.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #include "qstylefactory.h" | - | ||||||
41 | #include "qstyleplugin.h" | - | ||||||
42 | #include "private/qfactoryloader_p.h" | - | ||||||
43 | #include "qmutex.h" | - | ||||||
44 | - | |||||||
45 | #include "qapplication.h" | - | ||||||
46 | #include "qwindowsstyle_p.h" | - | ||||||
47 | #ifndef QT_NO_STYLE_FUSION | - | ||||||
48 | #include "qfusionstyle_p.h" | - | ||||||
49 | #ifndef QT_NO_STYLE_ANDROID | - | ||||||
50 | #include "qandroidstyle_p.h" | - | ||||||
51 | #endif | - | ||||||
52 | #endif | - | ||||||
53 | #ifndef QT_NO_STYLE_WINDOWSXP | - | ||||||
54 | #include "qwindowsxpstyle_p.h" | - | ||||||
55 | #endif | - | ||||||
56 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - | ||||||
57 | #include "qwindowsvistastyle_p.h" | - | ||||||
58 | #endif | - | ||||||
59 | #ifndef QT_NO_STYLE_WINDOWSCE | - | ||||||
60 | #include "qwindowscestyle_p.h" | - | ||||||
61 | #endif | - | ||||||
62 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - | ||||||
63 | #include "qwindowsmobilestyle_p.h" | - | ||||||
64 | #endif | - | ||||||
65 | - | |||||||
66 | #if !defined(QT_NO_STYLE_MAC) && defined(Q_OS_MAC) | - | ||||||
67 | # include "qmacstyle_mac_p.h" | - | ||||||
68 | #endif | - | ||||||
69 | - | |||||||
70 | QT_BEGIN_NAMESPACE | - | ||||||
71 | - | |||||||
72 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||
73 | (QStyleFactoryInterface_iid, QLatin1String("/styles"), Qt::CaseInsensitive)) | - | ||||||
74 | - | |||||||
75 | /*! | - | ||||||
76 | \class QStyleFactory | - | ||||||
77 | \brief The QStyleFactory class creates QStyle objects. | - | ||||||
78 | - | |||||||
79 | \ingroup appearance | - | ||||||
80 | \inmodule QtWidgets | - | ||||||
81 | - | |||||||
82 | The QStyle class is an abstract base class that encapsulates the | - | ||||||
83 | look and feel of a GUI. QStyleFactory creates a QStyle object | - | ||||||
84 | using the create() function and a key identifying the style. The | - | ||||||
85 | styles are either built-in or dynamically loaded from a style | - | ||||||
86 | plugin (see QStylePlugin). | - | ||||||
87 | - | |||||||
88 | The valid keys can be retrieved using the keys() | - | ||||||
89 | function. Typically they include "windows" and "fusion". | - | ||||||
90 | Depending on the platform, "windowsxp", "windowsvista" | - | ||||||
91 | and "macintosh" may be available. | - | ||||||
92 | Note that keys are case insensitive. | - | ||||||
93 | - | |||||||
94 | \sa QStyle | - | ||||||
95 | */ | - | ||||||
96 | - | |||||||
97 | /*! | - | ||||||
98 | Creates and returns a QStyle object that matches the given \a key, or | - | ||||||
99 | returns 0 if no matching style is found. | - | ||||||
100 | - | |||||||
101 | Both built-in styles and styles from style plugins are queried for a | - | ||||||
102 | matching style. | - | ||||||
103 | - | |||||||
104 | \note The keys used are case insensitive. | - | ||||||
105 | - | |||||||
106 | \sa keys() | - | ||||||
107 | */ | - | ||||||
108 | QStyle *QStyleFactory::create(const QString& key) | - | ||||||
109 | { | - | ||||||
110 | QStyle *ret = 0; | - | ||||||
111 | QString style = key.toLower(); | - | ||||||
112 | #ifndef QT_NO_STYLE_WINDOWS | - | ||||||
113 | if (style == QLatin1String("windows"))
| 0 | ||||||
114 | ret = new QWindowsStyle; never executed: ret = new QWindowsStyle; | 0 | ||||||
115 | else | - | ||||||
116 | #endif | - | ||||||
117 | #ifndef QT_NO_STYLE_WINDOWSCE | - | ||||||
118 | if (style == QLatin1String("windowsce")) | - | ||||||
119 | ret = new QWindowsCEStyle; | - | ||||||
120 | else | - | ||||||
121 | #endif | - | ||||||
122 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - | ||||||
123 | if (style == QLatin1String("windowsmobile")) | - | ||||||
124 | ret = new QWindowsMobileStyle; | - | ||||||
125 | else | - | ||||||
126 | #endif | - | ||||||
127 | #ifndef QT_NO_STYLE_WINDOWSXP | - | ||||||
128 | if (style == QLatin1String("windowsxp")) | - | ||||||
129 | ret = new QWindowsXPStyle; | - | ||||||
130 | else | - | ||||||
131 | #endif | - | ||||||
132 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - | ||||||
133 | if (style == QLatin1String("windowsvista")) | - | ||||||
134 | ret = new QWindowsVistaStyle; | - | ||||||
135 | else | - | ||||||
136 | #endif | - | ||||||
137 | #ifndef QT_NO_STYLE_FUSION | - | ||||||
138 | if (style == QLatin1String("fusion"))
| 0 | ||||||
139 | ret = new QFusionStyle; never executed: ret = new QFusionStyle; | 0 | ||||||
140 | else | - | ||||||
141 | #endif | - | ||||||
142 | #ifndef QT_NO_STYLE_ANDROID | - | ||||||
143 | if (style == QLatin1String("android")) | - | ||||||
144 | ret = new QAndroidStyle; | - | ||||||
145 | else | - | ||||||
146 | #endif | - | ||||||
147 | #ifndef QT_NO_STYLE_MAC | - | ||||||
148 | if (style.startsWith(QLatin1String("macintosh"))) { | - | ||||||
149 | ret = new QMacStyle; | - | ||||||
150 | # ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||
151 | if (style == QLatin1String("macintosh")) | - | ||||||
152 | style += QLatin1String(" (aqua)"); | - | ||||||
153 | # endif | - | ||||||
154 | } else | - | ||||||
155 | #endif | - | ||||||
156 | { } // Keep these here - they make the #ifdefery above work never executed: end of block | 0 | ||||||
157 | if (!ret)
| 0 | ||||||
158 | ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); never executed: ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); | 0 | ||||||
159 | if(ret)
| 0 | ||||||
160 | ret->setObjectName(style); never executed: ret->setObjectName(style); | 0 | ||||||
161 | return ret; never executed: return ret; | 0 | ||||||
162 | } | - | ||||||
163 | - | |||||||
164 | /*! | - | ||||||
165 | Returns the list of valid keys, i.e. the keys this factory can | - | ||||||
166 | create styles for. | - | ||||||
167 | - | |||||||
168 | \sa create() | - | ||||||
169 | */ | - | ||||||
170 | QStringList QStyleFactory::keys() | - | ||||||
171 | { | - | ||||||
172 | QStringList list; | - | ||||||
173 | typedef QMultiMap<int, QString> PluginKeyMap; | - | ||||||
174 | - | |||||||
175 | const PluginKeyMap keyMap = loader()->keyMap(); | - | ||||||
176 | const PluginKeyMap::const_iterator cend = keyMap.constEnd(); | - | ||||||
177 | for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it)
| 0 | ||||||
178 | list.append(it.value()); never executed: list.append(it.value()); | 0 | ||||||
179 | #ifndef QT_NO_STYLE_WINDOWS | - | ||||||
180 | if (!list.contains(QLatin1String("Windows")))
| 0 | ||||||
181 | list << QLatin1String("Windows"); never executed: list << QLatin1String("Windows"); | 0 | ||||||
182 | #endif | - | ||||||
183 | #ifndef QT_NO_STYLE_WINDOWSCE | - | ||||||
184 | if (!list.contains(QLatin1String("WindowsCE"))) | - | ||||||
185 | list << QLatin1String("WindowsCE"); | - | ||||||
186 | #endif | - | ||||||
187 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - | ||||||
188 | if (!list.contains(QLatin1String("WindowsMobile"))) | - | ||||||
189 | list << QLatin1String("WindowsMobile"); | - | ||||||
190 | #endif | - | ||||||
191 | #ifndef QT_NO_STYLE_WINDOWSXP | - | ||||||
192 | if (!list.contains(QLatin1String("WindowsXP")) && | - | ||||||
193 | (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) | - | ||||||
194 | list << QLatin1String("WindowsXP"); | - | ||||||
195 | #endif | - | ||||||
196 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - | ||||||
197 | if (!list.contains(QLatin1String("WindowsVista")) && | - | ||||||
198 | (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) | - | ||||||
199 | list << QLatin1String("WindowsVista"); | - | ||||||
200 | #endif | - | ||||||
201 | #ifndef QT_NO_STYLE_ANDROID | - | ||||||
202 | if (!list.contains(QLatin1String("Android"))) | - | ||||||
203 | list << QLatin1String("Android"); | - | ||||||
204 | #endif | - | ||||||
205 | #ifndef QT_NO_STYLE_FUSION | - | ||||||
206 | if (!list.contains(QLatin1String("Fusion")))
| 0 | ||||||
207 | list << QLatin1String("Fusion"); never executed: list << QLatin1String("Fusion"); | 0 | ||||||
208 | #endif | - | ||||||
209 | #ifndef QT_NO_STYLE_MAC | - | ||||||
210 | QString mstyle = QLatin1String("Macintosh"); | - | ||||||
211 | # ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||
212 | mstyle += QLatin1String(" (aqua)"); | - | ||||||
213 | # endif | - | ||||||
214 | if (!list.contains(mstyle)) | - | ||||||
215 | list << mstyle; | - | ||||||
216 | #endif | - | ||||||
217 | return list; never executed: return list; | 0 | ||||||
218 | } | - | ||||||
219 | - | |||||||
220 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |