Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui 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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qstylefactory.h" | - |
43 | #include "qstyleplugin.h" | - |
44 | #include "private/qfactoryloader_p.h" | - |
45 | #include "qmutex.h" | - |
46 | | - |
47 | #include "qapplication.h" | - |
48 | #include "qwindowsstyle_p.h" | - |
49 | #ifndef QT_NO_STYLE_FUSION | - |
50 | #include "qfusionstyle_p.h" | - |
51 | #endif | - |
52 | #ifndef QT_NO_STYLE_GTK | - |
53 | #include "qgtkstyle_p.h" | - |
54 | #endif | - |
55 | #ifndef QT_NO_STYLE_WINDOWSXP | - |
56 | #include "qwindowsxpstyle_p.h" | - |
57 | #endif | - |
58 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - |
59 | #include "qwindowsvistastyle_p.h" | - |
60 | #endif | - |
61 | #ifndef QT_NO_STYLE_WINDOWSCE | - |
62 | #include "qwindowscestyle_p.h" | - |
63 | #endif | - |
64 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - |
65 | #include "qwindowsmobilestyle_p.h" | - |
66 | #endif | - |
67 | | - |
68 | #if !defined(QT_NO_STYLE_MAC) && defined(Q_OS_MAC) | - |
69 | # include "qmacstyle_mac_p.h" | - |
70 | #endif | - |
71 | | - |
72 | QT_BEGIN_NAMESPACE | - |
73 | | - |
74 | #ifndef QT_NO_LIBRARY | - |
75 | Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:220 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:136 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:136 | yes Evaluation Count:84 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:136 | no Evaluation Count:0 |
| 0-220 |
76 | (QStyleFactoryInterface_iid, QLatin1String("/styles"), Qt::CaseInsensitive)) | - |
77 | #endif | - |
78 | | - |
79 | /*! | - |
80 | \class QStyleFactory | - |
81 | \brief The QStyleFactory class creates QStyle objects. | - |
82 | | - |
83 | \ingroup appearance | - |
84 | \inmodule QtWidgets | - |
85 | | - |
86 | The QStyle class is an abstract base class that encapsulates the | - |
87 | look and feel of a GUI. QStyleFactory creates a QStyle object | - |
88 | using the create() function and a key identifying the style. The | - |
89 | styles are either built-in or dynamically loaded from a style | - |
90 | plugin (see QStylePlugin). | - |
91 | | - |
92 | The valid keys can be retrieved using the keys() | - |
93 | function. Typically they include "windows" and "fusion". | - |
94 | Depending on the platform, "windowsxp", "windowsvista", "gtk" | - |
95 | and "macintosh" may be available. | - |
96 | Note that keys are case insensitive. | - |
97 | | - |
98 | \sa QStyle | - |
99 | */ | - |
100 | | - |
101 | /*! | - |
102 | Creates and returns a QStyle object that matches the given \a key, or | - |
103 | returns 0 if no matching style is found. | - |
104 | | - |
105 | Both built-in styles and styles from style plugins are queried for a | - |
106 | matching style. | - |
107 | | - |
108 | \note The keys used are case insensitive. | - |
109 | | - |
110 | \sa keys() | - |
111 | */ | - |
112 | QStyle *QStyleFactory::create(const QString& key) | - |
113 | { | - |
114 | QStyle *ret = 0; executed (the execution status of this line is deduced): QStyle *ret = 0; | - |
115 | QString style = key.toLower(); executed (the execution status of this line is deduced): QString style = key.toLower(); | - |
116 | #ifndef QT_NO_STYLE_WINDOWS | - |
117 | if (style == QLatin1String("windows")) evaluated: style == QLatin1String("windows") yes Evaluation Count:495 | yes Evaluation Count:199 |
| 199-495 |
118 | ret = new QWindowsStyle; executed: ret = new QWindowsStyle; Execution Count:495 | 495 |
119 | else | - |
120 | #endif | - |
121 | #ifndef QT_NO_STYLE_WINDOWSCE | - |
122 | if (style == QLatin1String("windowsce")) | - |
123 | ret = new QWindowsCEStyle; | - |
124 | else | - |
125 | #endif | - |
126 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - |
127 | if (style == QLatin1String("windowsmobile")) | - |
128 | ret = new QWindowsMobileStyle; | - |
129 | else | - |
130 | #endif | - |
131 | #ifndef QT_NO_STYLE_WINDOWSXP | - |
132 | if (style == QLatin1String("windowsxp")) | - |
133 | ret = new QWindowsXPStyle; | - |
134 | else | - |
135 | #endif | - |
136 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - |
137 | if (style == QLatin1String("windowsvista")) | - |
138 | ret = new QWindowsVistaStyle; | - |
139 | else | - |
140 | #endif | - |
141 | #ifndef QT_NO_STYLE_FUSION | - |
142 | if (style == QLatin1String("fusion")) evaluated: style == QLatin1String("fusion") yes Evaluation Count:198 | yes Evaluation Count:1 |
| 1-198 |
143 | ret = new QFusionStyle; executed: ret = new QFusionStyle; Execution Count:198 | 198 |
144 | else | - |
145 | #endif | - |
146 | #ifndef QT_NO_STYLE_GTK | - |
147 | if (style == QLatin1String("gtk") || style == QLatin1String("gtk+")) | - |
148 | ret = new QGtkStyle; | - |
149 | else | - |
150 | #endif | - |
151 | #ifndef QT_NO_STYLE_MAC | - |
152 | if (style.startsWith(QLatin1String("macintosh"))) { | - |
153 | ret = new QMacStyle; | - |
154 | # ifdef Q_WS_MAC | - |
155 | if (style == QLatin1String("macintosh")) | - |
156 | style += QLatin1String(" (aqua)"); | - |
157 | # endif | - |
158 | } else | - |
159 | #endif | - |
160 | { } // Keep these here - they make the #ifdefery above work executed: } Execution Count:1 | 1 |
161 | #ifndef QT_NO_LIBRARY | - |
162 | if (!ret) evaluated: !ret yes Evaluation Count:1 | yes Evaluation Count:693 |
| 1-693 |
163 | ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); executed: ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); Execution Count:1 | 1 |
164 | #endif | - |
165 | if(ret) evaluated: ret yes Evaluation Count:693 | yes Evaluation Count:1 |
| 1-693 |
166 | ret->setObjectName(style); executed: ret->setObjectName(style); Execution Count:693 | 693 |
167 | return ret; executed: return ret; Execution Count:694 | 694 |
168 | } | - |
169 | | - |
170 | /*! | - |
171 | Returns the list of valid keys, i.e. the keys this factory can | - |
172 | create styles for. | - |
173 | | - |
174 | \sa create() | - |
175 | */ | - |
176 | QStringList QStyleFactory::keys() | - |
177 | { | - |
178 | QStringList list; executed (the execution status of this line is deduced): QStringList list; | - |
179 | #ifndef QT_NO_LIBRARY | - |
180 | typedef QMultiMap<int, QString> PluginKeyMap; executed (the execution status of this line is deduced): typedef QMultiMap<int, QString> PluginKeyMap; | - |
181 | | - |
182 | const PluginKeyMap keyMap = loader()->keyMap(); executed (the execution status of this line is deduced): const PluginKeyMap keyMap = loader()->keyMap(); | - |
183 | const PluginKeyMap::const_iterator cend = keyMap.constEnd(); executed (the execution status of this line is deduced): const PluginKeyMap::const_iterator cend = keyMap.constEnd(); | - |
184 | for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it) partially evaluated: it != cend no Evaluation Count:0 | yes Evaluation Count:219 |
| 0-219 |
185 | list.append(it.value()); never executed: list.append(it.value()); | 0 |
186 | #endif | - |
187 | #ifndef QT_NO_STYLE_WINDOWS | - |
188 | if (!list.contains(QLatin1String("Windows"))) partially evaluated: !list.contains(QLatin1String("Windows")) yes Evaluation Count:219 | no Evaluation Count:0 |
| 0-219 |
189 | list << QLatin1String("Windows"); executed: list << QLatin1String("Windows"); Execution Count:219 | 219 |
190 | #endif | - |
191 | #ifndef QT_NO_STYLE_WINDOWSCE | - |
192 | if (!list.contains(QLatin1String("WindowsCE"))) | - |
193 | list << QLatin1String("WindowsCE"); | - |
194 | #endif | - |
195 | #ifndef QT_NO_STYLE_WINDOWSMOBILE | - |
196 | if (!list.contains(QLatin1String("WindowsMobile"))) | - |
197 | list << QLatin1String("WindowsMobile"); | - |
198 | #endif | - |
199 | #ifndef QT_NO_STYLE_WINDOWSXP | - |
200 | if (!list.contains(QLatin1String("WindowsXP")) && | - |
201 | (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) | - |
202 | list << QLatin1String("WindowsXP"); | - |
203 | #endif | - |
204 | #ifndef QT_NO_STYLE_WINDOWSVISTA | - |
205 | if (!list.contains(QLatin1String("WindowsVista")) && | - |
206 | (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) | - |
207 | list << QLatin1String("WindowsVista"); | - |
208 | #endif | - |
209 | #ifndef QT_NO_STYLE_GTK | - |
210 | if (!list.contains(QLatin1String("GTK+"))) | - |
211 | list << QLatin1String("GTK+"); | - |
212 | #endif | - |
213 | #ifndef QT_NO_STYLE_FUSION | - |
214 | if (!list.contains(QLatin1String("Fusion"))) partially evaluated: !list.contains(QLatin1String("Fusion")) yes Evaluation Count:219 | no Evaluation Count:0 |
| 0-219 |
215 | list << QLatin1String("Fusion"); executed: list << QLatin1String("Fusion"); Execution Count:219 | 219 |
216 | #endif | - |
217 | #ifndef QT_NO_STYLE_MAC | - |
218 | QString mstyle = QLatin1String("Macintosh"); | - |
219 | # ifdef Q_WS_MAC | - |
220 | mstyle += QLatin1String(" (aqua)"); | - |
221 | # endif | - |
222 | if (!list.contains(mstyle)) | - |
223 | list << mstyle; | - |
224 | #endif | - |
225 | return list; executed: return list; Execution Count:219 | 219 |
226 | } | - |
227 | | - |
228 | QT_END_NAMESPACE | - |
229 | | - |
| | |