qstylesheetstyle_default.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qstylesheetstyle_default.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34/* This is the default Qt style sheet.-
35-
36 IMPORTANT: This style sheet is primarily meant for defining feature-
37 capablities of styles. Do NOT add default styling rules here. When in-
38 doubt ask the stylesheet maintainer.-
39-
40 The stylesheet in here used to be in a CSS file, but was moved here to-
41 avoid parsing overhead.-
42*/-
43-
44#include "private/qcssparser_p.h"-
45#include "qstylesheetstyle_p.h"-
46-
47#ifndef QT_NO_STYLE_STYLESHEET-
48-
49QT_BEGIN_NAMESPACE-
50-
51using namespace QCss;-
52-
53// This is the class name of the selector.-
54// Use an empty string where you would use '*' in CSS.-
55// Ex. QHeaderView-
56-
57#define SET_ELEMENT_NAME(x) \-
58 bSelector.elementName = (x)-
59-
60// This acts as both pseudo state and sub control. The first parameter is the-
61// string name, and the second is the PseudoClass_* constant.-
62// The sub control specifier is always the first, and has the type-
63// PseudoClass_Unknown.-
64// If there is no PseudoClass_Unknown as the first pseudo, it is assumed to be-
65// a pseudo state.-
66// Ex. QComboBox::drop-down:enabled-
67// ^ ^-
68-
69#define ADD_PSEUDO(x, y) \-
70 pseudo.type = (y); \-
71 pseudo.name = (x); \-
72 bSelector.pseudos << pseudo-
73-
74// This is attributes. The third parameter is AttributeSelector::*-
75// Ex. QComboBox[style="QWindowsXPStyle"]-
76// ^ ^-
77-
78#define ADD_ATTRIBUTE_SELECTOR(x, y, z) \-
79 attr.name = (x); \-
80 attr.value = (y); \-
81 attr.valueMatchCriterium = (z); \-
82 bSelector.attributeSelectors << attr-
83-
84// Adds the current basic selector to the rule.-
85// Several basic selectors behave as AND (space in CSS).-
86-
87#define ADD_BASIC_SELECTOR \-
88 selector.basicSelectors << bSelector; \-
89 bSelector.ids.clear(); \-
90 bSelector.pseudos.clear(); \-
91 bSelector.attributeSelectors.clear()-
92-
93// Adds the current selector to the rule.-
94// Several selectors behave as OR (comma in CSS).-
95-
96#define ADD_SELECTOR \-
97 styleRule.selectors << selector; \-
98 selector.basicSelectors.clear()-
99-
100// Sets the name of a property.-
101// Ex. background: red;-
102// ^-
103-
104#define SET_PROPERTY(x, y) \-
105 decl.d->property = (x); \-
106 decl.d->propertyId = (y)-
107-
108// Adds a value to the current property.-
109// The first parameter should be Value::KnownIdentifier if the value can be-
110// found among the Value_* constants, in which case the second should be that-
111// constant. Otherwise the first parameter is Value::Identifier and the second-
112// is a string.-
113// Adding more values is the same as seperating by spaces in CSS.-
114// Ex. border: 2px solid black;-
115// ^ ^ ^-
116-
117#define ADD_VALUE(x, y) \-
118 value.type = (x); \-
119 value.variant = (y); \-
120 decl.d->values << value-
121-
122// Adds the current declaration to the rule.-
123// Ex. border: 2px solid black;-
124// \----------------------/-
125-
126#define ADD_DECLARATION \-
127 styleRule.declarations << decl; \-
128 decl.d.detach(); \-
129 decl.d->values.clear()-
130-
131// Adds the rule to the stylesheet.-
132// Use at the end of every CSS block.-
133-
134#define ADD_STYLE_RULE \-
135 sheet.styleRules << styleRule; \-
136 styleRule.selectors.clear(); \-
137 styleRule.declarations.clear()-
138-
139StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const-
140{-
141 StyleSheet sheet;-
142 StyleRule styleRule;-
143 BasicSelector bSelector;-
144 Selector selector;-
145 Declaration decl;-
146 QCss::Value value;-
147 Pseudo pseudo;-
148 AttributeSelector attr;-
149-
150 // pixmap based style doesn't support any features-
151 bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")
baseStyle()->i...s("QMacStyle")Description
TRUEnever evaluated
FALSEnever evaluated
0
152 || baseStyle()->inherits("QWindowsXPStyle")
baseStyle()->i...ndowsXPStyle")Description
TRUEnever evaluated
FALSEnever evaluated
0
153 || baseStyle()->inherits("QGtkStyle");
baseStyle()->i...s("QGtkStyle")Description
TRUEnever evaluated
FALSEnever evaluated
0
154-
155-
156 /*QLineEdit {-
157 -qt-background-role: base;-
158 border: native;-
159 -qt-style-features: background-color;-
160 }*/-
161 {-
162 SET_ELEMENT_NAME(QLatin1String("QLineEdit"));-
163 ADD_BASIC_SELECTOR;-
164 ADD_SELECTOR;-
165-
166 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
167 ADD_VALUE(Value::KnownIdentifier, Value_Base);-
168 ADD_DECLARATION;-
169-
170 SET_PROPERTY(QLatin1String("border"), Border);-
171 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
172 ADD_DECLARATION;-
173-
174 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
175 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
176 ADD_DECLARATION;-
177-
178 ADD_STYLE_RULE;-
179 }-
180-
181 /*QLineEdit:no-frame {-
182 border: none;-
183 }*/-
184 {-
185 SET_ELEMENT_NAME(QLatin1String("QLineEdit"));-
186 ADD_PSEUDO(QLatin1String("no-frame"), PseudoClass_Frameless);-
187 ADD_BASIC_SELECTOR;-
188 ADD_SELECTOR;-
189-
190 SET_PROPERTY(QLatin1String("border"), Border);-
191 ADD_VALUE(Value::KnownIdentifier, Value_None);-
192 ADD_DECLARATION;-
193-
194 ADD_STYLE_RULE;-
195 }-
196-
197 /*QFrame {-
198 border: native;-
199 }*/-
200 {-
201 SET_ELEMENT_NAME(QLatin1String("QFrame"));-
202 ADD_BASIC_SELECTOR;-
203 ADD_SELECTOR;-
204-
205 SET_PROPERTY(QLatin1String("border"), Border);-
206 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
207 ADD_DECLARATION;-
208-
209 ADD_STYLE_RULE;-
210 }-
211-
212 /*QLabel, QToolBox {-
213 background: none;-
214 border-image: none;-
215 }*/-
216 {-
217 SET_ELEMENT_NAME(QLatin1String("QLabel"));-
218 ADD_BASIC_SELECTOR;-
219 ADD_SELECTOR;-
220-
221 SET_ELEMENT_NAME(QLatin1String("QToolBox"));-
222 ADD_BASIC_SELECTOR;-
223 ADD_SELECTOR;-
224-
225 SET_PROPERTY(QLatin1String("background"), Background);-
226 ADD_VALUE(Value::KnownIdentifier, Value_None);-
227 ADD_DECLARATION;-
228-
229 SET_PROPERTY(QLatin1String("border-image"), BorderImage);-
230 ADD_VALUE(Value::KnownIdentifier, Value_None);-
231 ADD_DECLARATION;-
232-
233 ADD_STYLE_RULE;-
234 }-
235-
236 /*QGroupBox {-
237 border: native;-
238 }*/-
239 {-
240 SET_ELEMENT_NAME(QLatin1String("QGroupBox"));-
241 ADD_BASIC_SELECTOR;-
242 ADD_SELECTOR;-
243-
244 SET_PROPERTY(QLatin1String("border"), Border);-
245 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
246 ADD_DECLARATION;-
247-
248 ADD_STYLE_RULE;-
249 }-
250-
251-
252 /*QToolTip {-
253 -qt-background-role: window;-
254 border: native;-
255 }*/-
256 {-
257 SET_ELEMENT_NAME(QLatin1String("QToolTip"));-
258 ADD_BASIC_SELECTOR;-
259 ADD_SELECTOR;-
260-
261 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
262 ADD_VALUE(Value::KnownIdentifier, Value_Window);-
263 ADD_DECLARATION;-
264-
265 SET_PROPERTY(QLatin1String("border"), Border);-
266 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
267 ADD_DECLARATION;-
268-
269 ADD_STYLE_RULE;-
270 }-
271-
272 /*QPushButton, QToolButton {-
273 border-style: native;-
274 -qt-style-features: background-color; //only for not pixmap based styles-
275 }*/-
276 {-
277 SET_ELEMENT_NAME(QLatin1String("QPushButton"));-
278 ADD_BASIC_SELECTOR;-
279 ADD_SELECTOR;-
280-
281 SET_ELEMENT_NAME(QLatin1String("QToolButton"));-
282 ADD_BASIC_SELECTOR;-
283 ADD_SELECTOR;-
284-
285 SET_PROPERTY(QLatin1String("border-style"), BorderStyles);-
286 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
287 ADD_DECLARATION;-
288-
289 if (!styleIsPixmapBased) {
!styleIsPixmapBasedDescription
TRUEnever evaluated
FALSEnever evaluated
0
290 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
291 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
292 ADD_DECLARATION;-
293 }
never executed: end of block
0
294-
295-
296 ADD_STYLE_RULE;-
297 }-
298-
299-
300 /*QComboBox {-
301 border: native;-
302 -qt-style-features: background-color background-gradient; //only for not pixmap based styles-
303 -qt-background-role: base;-
304 }*/-
305-
306 {-
307 SET_ELEMENT_NAME(QLatin1String("QComboBox"));-
308 ADD_BASIC_SELECTOR;-
309 ADD_SELECTOR;-
310-
311 SET_PROPERTY(QLatin1String("border"), Border);-
312 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
313 ADD_DECLARATION;-
314-
315 if (!styleIsPixmapBased) {
!styleIsPixmapBasedDescription
TRUEnever evaluated
FALSEnever evaluated
0
316 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
317 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
318 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-gradient"));-
319 ADD_DECLARATION;-
320 }
never executed: end of block
0
321-
322 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
323 ADD_VALUE(Value::KnownIdentifier, Value_Base);-
324 ADD_DECLARATION;-
325-
326 ADD_STYLE_RULE;-
327 }-
328-
329 /*QComboBox[style="QPlastiqueStyle"][readOnly="true"],-
330 QComboBox[style="QFusionStyle"][readOnly="true"],-
331 QComboBox[style="QCleanlooksStyle"][readOnly="true"]-
332 {-
333 -qt-background-role: button;-
334 }*/-
335 if (baseStyle()->inherits("QPlastiqueStyle") || baseStyle()->inherits("QCleanlooksStyle") || baseStyle()->inherits("QFusionStyle"))
baseStyle()->i...astiqueStyle")Description
TRUEnever evaluated
FALSEnever evaluated
baseStyle()->i...anlooksStyle")Description
TRUEnever evaluated
FALSEnever evaluated
baseStyle()->i...QFusionStyle")Description
TRUEnever evaluated
FALSEnever evaluated
0
336 {-
337 SET_ELEMENT_NAME(QLatin1String("QComboBox"));-
338 ADD_ATTRIBUTE_SELECTOR(QLatin1String("readOnly"), QLatin1String("true"), AttributeSelector::MatchEqual);-
339 ADD_BASIC_SELECTOR;-
340 ADD_SELECTOR;-
341-
342 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
343 ADD_VALUE(Value::KnownIdentifier, Value_Button);-
344 ADD_DECLARATION;-
345-
346 ADD_STYLE_RULE;-
347 }
never executed: end of block
0
348-
349 /*QAbstractSpinBox {-
350 border: native;-
351 -qt-style-features: background-color;-
352 -qt-background-role: base;-
353 }*/-
354 {-
355 SET_ELEMENT_NAME(QLatin1String("QAbstractSpinBox"));-
356 ADD_BASIC_SELECTOR;-
357 ADD_SELECTOR;-
358-
359 SET_PROPERTY(QLatin1String("border"), Border);-
360 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
361 ADD_DECLARATION;-
362-
363 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
364 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
365 ADD_DECLARATION;-
366-
367 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
368 ADD_VALUE(Value::KnownIdentifier, Value_Base);-
369 ADD_DECLARATION;-
370-
371 ADD_STYLE_RULE;-
372 }-
373-
374 /*QMenu {-
375 -qt-background-role: window;-
376 }*/-
377 {-
378 SET_ELEMENT_NAME(QLatin1String("QMenu"));-
379 ADD_BASIC_SELECTOR;-
380 ADD_SELECTOR;-
381-
382 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
383 ADD_VALUE(Value::KnownIdentifier, Value_Window);-
384 ADD_DECLARATION;-
385-
386 ADD_STYLE_RULE;-
387 }-
388 /*QMenu::item {-
389 -qt-style-features: background-color;-
390 }*/-
391 if (!styleIsPixmapBased) {
!styleIsPixmapBasedDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 SET_ELEMENT_NAME(QLatin1String("QMenu"));-
393 ADD_PSEUDO(QLatin1String("item"), PseudoClass_Unknown);-
394 ADD_BASIC_SELECTOR;-
395 ADD_SELECTOR;-
396-
397 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
398 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
399 ADD_DECLARATION;-
400-
401 ADD_STYLE_RULE;-
402 }
never executed: end of block
0
403-
404 /*QHeaderView {-
405 -qt-background-role: window;-
406 }*/-
407 {-
408 SET_ELEMENT_NAME(QLatin1String("QHeaderView"));-
409 ADD_BASIC_SELECTOR;-
410 ADD_SELECTOR;-
411-
412 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
413 ADD_VALUE(Value::KnownIdentifier, Value_Window);-
414 ADD_DECLARATION;-
415-
416 ADD_STYLE_RULE;-
417 }-
418-
419 /*QTableCornerButton::section, QHeaderView::section {-
420 -qt-background-role: button;-
421 -qt-style-features: background-color; //if style is not pixmap based-
422 border: native;-
423 }*/-
424 {-
425 SET_ELEMENT_NAME(QLatin1String("QTableCornerButton"));-
426 ADD_PSEUDO(QLatin1String("section"), PseudoClass_Unknown);-
427 ADD_BASIC_SELECTOR;-
428 ADD_SELECTOR;-
429-
430 SET_ELEMENT_NAME(QLatin1String("QHeaderView"));-
431 ADD_PSEUDO(QLatin1String("section"), PseudoClass_Unknown);-
432 ADD_BASIC_SELECTOR;-
433 ADD_SELECTOR;-
434-
435 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
436 ADD_VALUE(Value::KnownIdentifier, Value_Button);-
437 ADD_DECLARATION;-
438-
439 if (!styleIsPixmapBased) {
!styleIsPixmapBasedDescription
TRUEnever evaluated
FALSEnever evaluated
0
440 SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures);-
441 ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color"));-
442 ADD_DECLARATION;-
443 }
never executed: end of block
0
444-
445 SET_PROPERTY(QLatin1String("border"), Border);-
446 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
447 ADD_DECLARATION;-
448-
449 ADD_STYLE_RULE;-
450 }-
451-
452 /*QProgressBar {-
453 -qt-background-role: base;-
454 }*/-
455 {-
456 SET_ELEMENT_NAME(QLatin1String("QProgressBar"));-
457 ADD_BASIC_SELECTOR;-
458 ADD_SELECTOR;-
459-
460 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
461 ADD_VALUE(Value::KnownIdentifier, Value_Base);-
462 ADD_DECLARATION;-
463-
464 ADD_STYLE_RULE;-
465 }-
466-
467 /*QScrollBar {-
468 -qt-background-role: window;-
469 }*/-
470 {-
471 SET_ELEMENT_NAME(QLatin1String("QScrollBar"));-
472 ADD_BASIC_SELECTOR;-
473 ADD_SELECTOR;-
474-
475 SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole);-
476 ADD_VALUE(Value::KnownIdentifier, Value_Window);-
477 ADD_DECLARATION;-
478-
479 ADD_STYLE_RULE;-
480 }-
481-
482 /*QDockWidget {-
483 border: native;-
484 }*/-
485 {-
486 SET_ELEMENT_NAME(QLatin1String("QDockWidget"));-
487 ADD_BASIC_SELECTOR;-
488 ADD_SELECTOR;-
489-
490 SET_PROPERTY(QLatin1String("border"), Border);-
491 ADD_VALUE(Value::KnownIdentifier, Value_Native);-
492 ADD_DECLARATION;-
493-
494 ADD_STYLE_RULE;-
495 }-
496-
497 sheet.origin = StyleSheetOrigin_UserAgent;-
498 sheet.buildIndexes();-
499 return sheet;
never executed: return sheet;
0
500}-
501-
502#endif // #ifndef QT_NO_STYLE_STYLESHEET-
503-
504QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9