Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | #include "private/qcssparser_p.h" | - |
51 | #include "qstylesheetstyle_p.h" | - |
52 | | - |
53 | #ifndef QT_NO_STYLE_STYLESHEET | - |
54 | | - |
55 | QT_BEGIN_NAMESPACE | - |
56 | | - |
57 | using namespace QCss; | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | #define SET_ELEMENT_NAME(x) \ | - |
64 | bSelector.elementName = (x) | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | #define ADD_PSEUDO(x, y) \ | - |
76 | pseudo.type = (y); \ | - |
77 | pseudo.name = (x); \ | - |
78 | bSelector.pseudos << pseudo | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | | - |
84 | #define ADD_ATTRIBUTE_SELECTOR(x, y, z) \ | - |
85 | attr.name = (x); \ | - |
86 | attr.value = (y); \ | - |
87 | attr.valueMatchCriterium = (z); \ | - |
88 | bSelector.attributeSelectors << attr | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | #define ADD_BASIC_SELECTOR \ | - |
94 | selector.basicSelectors << bSelector; \ | - |
95 | bSelector.ids.clear(); \ | - |
96 | bSelector.pseudos.clear(); \ | - |
97 | bSelector.attributeSelectors.clear() | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | #define ADD_SELECTOR \ | - |
103 | styleRule.selectors << selector; \ | - |
104 | selector.basicSelectors.clear() | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | #define SET_PROPERTY(x, y) \ | - |
111 | decl.d->property = (x); \ | - |
112 | decl.d->propertyId = (y) | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | #define ADD_VALUE(x, y) \ | - |
124 | value.type = (x); \ | - |
125 | value.variant = (y); \ | - |
126 | decl.d->values << value | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | #define ADD_DECLARATION \ | - |
133 | styleRule.declarations << decl; \ | - |
134 | decl.d.detach(); \ | - |
135 | decl.d->values.clear() | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | #define ADD_STYLE_RULE \ | - |
141 | sheet.styleRules << styleRule; \ | - |
142 | styleRule.selectors.clear(); \ | - |
143 | styleRule.declarations.clear() | - |
144 | | - |
145 | StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const | - |
146 | { | - |
147 | StyleSheet sheet; | - |
148 | StyleRule styleRule; | - |
149 | BasicSelector bSelector; | - |
150 | Selector selector; | - |
151 | Declaration decl; | - |
152 | QCss::Value value; | - |
153 | Pseudo pseudo; | - |
154 | AttributeSelector attr; | - |
155 | | - |
156 | | - |
157 | bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")TRUE | never evaluated | FALSE | never evaluated |
| 0 |
158 | || baseStyle()->inherits("QWindowsXPStyle");TRUE | never evaluated | FALSE | never evaluated |
| 0 |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | { | - |
167 | SET_ELEMENT_NAME(QLatin1String("QLineEdit")); | - |
168 | ADD_BASIC_SELECTOR; | - |
169 | ADD_SELECTOR; | - |
170 | | - |
171 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
172 | ADD_VALUE(Value::KnownIdentifier, Value_Base); | - |
173 | ADD_DECLARATION; | - |
174 | | - |
175 | SET_PROPERTY(QLatin1String("border"), Border); | - |
176 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
177 | ADD_DECLARATION; | - |
178 | | - |
179 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
180 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
181 | ADD_DECLARATION; | - |
182 | | - |
183 | ADD_STYLE_RULE; | - |
184 | } | - |
185 | | - |
186 | | - |
187 | | - |
188 | | - |
189 | { | - |
190 | SET_ELEMENT_NAME(QLatin1String("QLineEdit")); | - |
191 | ADD_PSEUDO(QLatin1String("no-frame"), PseudoClass_Frameless); | - |
192 | ADD_BASIC_SELECTOR; | - |
193 | ADD_SELECTOR; | - |
194 | | - |
195 | SET_PROPERTY(QLatin1String("border"), Border); | - |
196 | ADD_VALUE(Value::KnownIdentifier, Value_None); | - |
197 | ADD_DECLARATION; | - |
198 | | - |
199 | ADD_STYLE_RULE; | - |
200 | } | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | { | - |
206 | SET_ELEMENT_NAME(QLatin1String("QFrame")); | - |
207 | ADD_BASIC_SELECTOR; | - |
208 | ADD_SELECTOR; | - |
209 | | - |
210 | SET_PROPERTY(QLatin1String("border"), Border); | - |
211 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
212 | ADD_DECLARATION; | - |
213 | | - |
214 | ADD_STYLE_RULE; | - |
215 | } | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | { | - |
222 | SET_ELEMENT_NAME(QLatin1String("QLabel")); | - |
223 | ADD_BASIC_SELECTOR; | - |
224 | ADD_SELECTOR; | - |
225 | | - |
226 | SET_ELEMENT_NAME(QLatin1String("QToolBox")); | - |
227 | ADD_BASIC_SELECTOR; | - |
228 | ADD_SELECTOR; | - |
229 | | - |
230 | SET_PROPERTY(QLatin1String("background"), Background); | - |
231 | ADD_VALUE(Value::KnownIdentifier, Value_None); | - |
232 | ADD_DECLARATION; | - |
233 | | - |
234 | SET_PROPERTY(QLatin1String("border-image"), BorderImage); | - |
235 | ADD_VALUE(Value::KnownIdentifier, Value_None); | - |
236 | ADD_DECLARATION; | - |
237 | | - |
238 | ADD_STYLE_RULE; | - |
239 | } | - |
240 | | - |
241 | | - |
242 | | - |
243 | | - |
244 | { | - |
245 | SET_ELEMENT_NAME(QLatin1String("QGroupBox")); | - |
246 | ADD_BASIC_SELECTOR; | - |
247 | ADD_SELECTOR; | - |
248 | | - |
249 | SET_PROPERTY(QLatin1String("border"), Border); | - |
250 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
251 | ADD_DECLARATION; | - |
252 | | - |
253 | ADD_STYLE_RULE; | - |
254 | } | - |
255 | | - |
256 | | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | { | - |
262 | SET_ELEMENT_NAME(QLatin1String("QToolTip")); | - |
263 | ADD_BASIC_SELECTOR; | - |
264 | ADD_SELECTOR; | - |
265 | | - |
266 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
267 | ADD_VALUE(Value::KnownIdentifier, Value_Window); | - |
268 | ADD_DECLARATION; | - |
269 | | - |
270 | SET_PROPERTY(QLatin1String("border"), Border); | - |
271 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
272 | ADD_DECLARATION; | - |
273 | | - |
274 | ADD_STYLE_RULE; | - |
275 | } | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | { | - |
282 | SET_ELEMENT_NAME(QLatin1String("QPushButton")); | - |
283 | ADD_BASIC_SELECTOR; | - |
284 | ADD_SELECTOR; | - |
285 | | - |
286 | SET_ELEMENT_NAME(QLatin1String("QToolButton")); | - |
287 | ADD_BASIC_SELECTOR; | - |
288 | ADD_SELECTOR; | - |
289 | | - |
290 | SET_PROPERTY(QLatin1String("border-style"), BorderStyles); | - |
291 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
292 | ADD_DECLARATION; | - |
293 | | - |
294 | if (!styleIsPixmapBased) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
295 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
296 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
297 | ADD_DECLARATION; | - |
298 | } never executed: end of block | 0 |
299 | | - |
300 | | - |
301 | ADD_STYLE_RULE; | - |
302 | } | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | { | - |
312 | SET_ELEMENT_NAME(QLatin1String("QComboBox")); | - |
313 | ADD_BASIC_SELECTOR; | - |
314 | ADD_SELECTOR; | - |
315 | | - |
316 | SET_PROPERTY(QLatin1String("border"), Border); | - |
317 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
318 | ADD_DECLARATION; | - |
319 | | - |
320 | if (!styleIsPixmapBased) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
321 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
322 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
323 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-gradient")); | - |
324 | ADD_DECLARATION; | - |
325 | } never executed: end of block | 0 |
326 | | - |
327 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
328 | ADD_VALUE(Value::KnownIdentifier, Value_Base); | - |
329 | ADD_DECLARATION; | - |
330 | | - |
331 | ADD_STYLE_RULE; | - |
332 | } | - |
333 | | - |
334 | | - |
335 | | - |
336 | | - |
337 | | - |
338 | | - |
339 | | - |
340 | if (baseStyle()->inherits("QPlastiqueStyle") || baseStyle()->inherits("QCleanlooksStyle") || baseStyle()->inherits("QFusionStyle"))TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
341 | { | - |
342 | SET_ELEMENT_NAME(QLatin1String("QComboBox")); | - |
343 | ADD_ATTRIBUTE_SELECTOR(QLatin1String("readOnly"), QLatin1String("true"), AttributeSelector::MatchEqual); | - |
344 | ADD_BASIC_SELECTOR; | - |
345 | ADD_SELECTOR; | - |
346 | | - |
347 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
348 | ADD_VALUE(Value::KnownIdentifier, Value_Button); | - |
349 | ADD_DECLARATION; | - |
350 | | - |
351 | ADD_STYLE_RULE; | - |
352 | } never executed: end of block | 0 |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | { | - |
360 | SET_ELEMENT_NAME(QLatin1String("QAbstractSpinBox")); | - |
361 | ADD_BASIC_SELECTOR; | - |
362 | ADD_SELECTOR; | - |
363 | | - |
364 | SET_PROPERTY(QLatin1String("border"), Border); | - |
365 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
366 | ADD_DECLARATION; | - |
367 | | - |
368 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
369 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
370 | ADD_DECLARATION; | - |
371 | | - |
372 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
373 | ADD_VALUE(Value::KnownIdentifier, Value_Base); | - |
374 | ADD_DECLARATION; | - |
375 | | - |
376 | ADD_STYLE_RULE; | - |
377 | } | - |
378 | | - |
379 | | - |
380 | | - |
381 | | - |
382 | { | - |
383 | SET_ELEMENT_NAME(QLatin1String("QMenu")); | - |
384 | ADD_BASIC_SELECTOR; | - |
385 | ADD_SELECTOR; | - |
386 | | - |
387 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
388 | ADD_VALUE(Value::KnownIdentifier, Value_Window); | - |
389 | ADD_DECLARATION; | - |
390 | | - |
391 | ADD_STYLE_RULE; | - |
392 | } | - |
393 | | - |
394 | | - |
395 | | - |
396 | if (!styleIsPixmapBased) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
397 | SET_ELEMENT_NAME(QLatin1String("QMenu")); | - |
398 | ADD_PSEUDO(QLatin1String("item"), PseudoClass_Unknown); | - |
399 | ADD_BASIC_SELECTOR; | - |
400 | ADD_SELECTOR; | - |
401 | | - |
402 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
403 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
404 | ADD_DECLARATION; | - |
405 | | - |
406 | ADD_STYLE_RULE; | - |
407 | } never executed: end of block | 0 |
408 | | - |
409 | | - |
410 | | - |
411 | | - |
412 | { | - |
413 | SET_ELEMENT_NAME(QLatin1String("QHeaderView")); | - |
414 | ADD_BASIC_SELECTOR; | - |
415 | ADD_SELECTOR; | - |
416 | | - |
417 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
418 | ADD_VALUE(Value::KnownIdentifier, Value_Window); | - |
419 | ADD_DECLARATION; | - |
420 | | - |
421 | ADD_STYLE_RULE; | - |
422 | } | - |
423 | | - |
424 | | - |
425 | | - |
426 | | - |
427 | | - |
428 | | - |
429 | { | - |
430 | SET_ELEMENT_NAME(QLatin1String("QTableCornerButton")); | - |
431 | ADD_PSEUDO(QLatin1String("section"), PseudoClass_Unknown); | - |
432 | ADD_BASIC_SELECTOR; | - |
433 | ADD_SELECTOR; | - |
434 | | - |
435 | SET_ELEMENT_NAME(QLatin1String("QHeaderView")); | - |
436 | ADD_PSEUDO(QLatin1String("section"), PseudoClass_Unknown); | - |
437 | ADD_BASIC_SELECTOR; | - |
438 | ADD_SELECTOR; | - |
439 | | - |
440 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
441 | ADD_VALUE(Value::KnownIdentifier, Value_Button); | - |
442 | ADD_DECLARATION; | - |
443 | | - |
444 | if (!styleIsPixmapBased) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
445 | SET_PROPERTY(QLatin1String("-qt-style-features"), QtStyleFeatures); | - |
446 | ADD_VALUE(Value::Identifier, QString::fromLatin1("background-color")); | - |
447 | ADD_DECLARATION; | - |
448 | } never executed: end of block | 0 |
449 | | - |
450 | SET_PROPERTY(QLatin1String("border"), Border); | - |
451 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
452 | ADD_DECLARATION; | - |
453 | | - |
454 | ADD_STYLE_RULE; | - |
455 | } | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | { | - |
461 | SET_ELEMENT_NAME(QLatin1String("QProgressBar")); | - |
462 | ADD_BASIC_SELECTOR; | - |
463 | ADD_SELECTOR; | - |
464 | | - |
465 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
466 | ADD_VALUE(Value::KnownIdentifier, Value_Base); | - |
467 | ADD_DECLARATION; | - |
468 | | - |
469 | ADD_STYLE_RULE; | - |
470 | } | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | { | - |
476 | SET_ELEMENT_NAME(QLatin1String("QScrollBar")); | - |
477 | ADD_BASIC_SELECTOR; | - |
478 | ADD_SELECTOR; | - |
479 | | - |
480 | SET_PROPERTY(QLatin1String("-qt-background-role"), QtBackgroundRole); | - |
481 | ADD_VALUE(Value::KnownIdentifier, Value_Window); | - |
482 | ADD_DECLARATION; | - |
483 | | - |
484 | ADD_STYLE_RULE; | - |
485 | } | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | { | - |
491 | SET_ELEMENT_NAME(QLatin1String("QDockWidget")); | - |
492 | ADD_BASIC_SELECTOR; | - |
493 | ADD_SELECTOR; | - |
494 | | - |
495 | SET_PROPERTY(QLatin1String("border"), Border); | - |
496 | ADD_VALUE(Value::KnownIdentifier, Value_Native); | - |
497 | ADD_DECLARATION; | - |
498 | | - |
499 | ADD_STYLE_RULE; | - |
500 | } | - |
501 | | - |
502 | sheet.origin = StyleSheetOrigin_UserAgent; | - |
503 | sheet.buildIndexes(); | - |
504 | return sheet; never executed: return sheet; | 0 |
505 | } | - |
506 | | - |
507 | #endif // #ifndef QT_NO_STYLE_STYLESHEET | - |
508 | | - |
509 | QT_END_NAMESPACE | - |
| | |