1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qcleanlooksstyle.h"
|
---|
43 | #include "qcleanlooksstyle_p.h"
|
---|
44 |
|
---|
45 | #if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
|
---|
46 |
|
---|
47 | #include "qwindowsstyle_p.h"
|
---|
48 | #include <qcombobox.h>
|
---|
49 | #include <qpushbutton.h>
|
---|
50 | #include <qpainter.h>
|
---|
51 | #include <qdir.h>
|
---|
52 | #include <qhash.h>
|
---|
53 | #include <qstyleoption.h>
|
---|
54 | #include <qapplication.h>
|
---|
55 | #include <qmainwindow.h>
|
---|
56 | #include <qfont.h>
|
---|
57 | #include <qgroupbox.h>
|
---|
58 | #include <qprocess.h>
|
---|
59 | #include <qpixmapcache.h>
|
---|
60 | #include <qdialogbuttonbox.h>
|
---|
61 | #include <qscrollbar.h>
|
---|
62 | #include <qspinbox.h>
|
---|
63 | #include <qslider.h>
|
---|
64 | #include <qsplitter.h>
|
---|
65 | #include <qprogressbar.h>
|
---|
66 | #include <qtoolbar.h>
|
---|
67 | #include <qwizard.h>
|
---|
68 | #include <qlibrary.h>
|
---|
69 | #include <private/qstylehelper_p.h>
|
---|
70 |
|
---|
71 | #define CL_MAX(a,b) (a)>(b) ? (a):(b) // ### qMin/qMax does not work for vc6
|
---|
72 | #define CL_MIN(a,b) (a)<(b) ? (a):(b) // remove this when it is working
|
---|
73 |
|
---|
74 | QT_BEGIN_NAMESPACE
|
---|
75 |
|
---|
76 | using namespace QStyleHelper;
|
---|
77 |
|
---|
78 | enum Direction {
|
---|
79 | TopDown,
|
---|
80 | FromLeft,
|
---|
81 | BottomUp,
|
---|
82 | FromRight
|
---|
83 | };
|
---|
84 |
|
---|
85 | // from windows style
|
---|
86 | static const int windowsItemFrame = 2; // menu item frame width
|
---|
87 | static const int windowsItemHMargin = 3; // menu item hor text margin
|
---|
88 | static const int windowsItemVMargin = 8; // menu item ver text margin
|
---|
89 | static const int windowsRightBorder = 15; // right border on windows
|
---|
90 |
|
---|
91 | /* XPM */
|
---|
92 | static const char * const dock_widget_close_xpm[] = {
|
---|
93 | "11 13 7 1",
|
---|
94 | " c None",
|
---|
95 | ". c #D5CFCB",
|
---|
96 | "+ c #8F8B88",
|
---|
97 | "@ c #6C6A67",
|
---|
98 | "# c #ABA6A3",
|
---|
99 | "$ c #B5B0AC",
|
---|
100 | "% c #A4A09D",
|
---|
101 | " ",
|
---|
102 | " +@@@@@@@+ ",
|
---|
103 | "+# #+",
|
---|
104 | "@ $@ @$ @",
|
---|
105 | "@ @@@ @@@ @",
|
---|
106 | "@ @@@@@ @",
|
---|
107 | "@ @@@ @",
|
---|
108 | "@ @@@@@ @",
|
---|
109 | "@ @@@ @@@ @",
|
---|
110 | "@ $@ @$ @",
|
---|
111 | "+% #+",
|
---|
112 | " +@@@@@@@+ ",
|
---|
113 | " "};
|
---|
114 |
|
---|
115 | static const char * const qt_cleanlooks_arrow_down_xpm[] = {
|
---|
116 | "11 7 2 1",
|
---|
117 | " c None",
|
---|
118 | "x c #000000",
|
---|
119 | " ",
|
---|
120 | " x x ",
|
---|
121 | " xxx xxx ",
|
---|
122 | " xxxxxxx ",
|
---|
123 | " xxxxx ",
|
---|
124 | " xxx ",
|
---|
125 | " x "};
|
---|
126 |
|
---|
127 | static const char * const qt_cleanlooks_arrow_up_xpm[] = {
|
---|
128 | "11 7 2 1",
|
---|
129 | " c None",
|
---|
130 | "x c #000000",
|
---|
131 | " x ",
|
---|
132 | " xxx ",
|
---|
133 | " xxxxx ",
|
---|
134 | " xxxxxxx ",
|
---|
135 | " xxx xxx ",
|
---|
136 | " x x ",
|
---|
137 | " "};
|
---|
138 |
|
---|
139 | static const char * const dock_widget_restore_xpm[] = {
|
---|
140 | "11 13 7 1",
|
---|
141 | " c None",
|
---|
142 | ". c #D5CFCB",
|
---|
143 | "+ c #8F8B88",
|
---|
144 | "@ c #6C6A67",
|
---|
145 | "# c #ABA6A3",
|
---|
146 | "$ c #B5B0AC",
|
---|
147 | "% c #A4A09D",
|
---|
148 | " ",
|
---|
149 | " +@@@@@@@+ ",
|
---|
150 | "+# #+",
|
---|
151 | "@ #@@@# @",
|
---|
152 | "@ @ @ @",
|
---|
153 | "@ #@@@# @ @",
|
---|
154 | "@ @ @ @ @",
|
---|
155 | "@ @ @@@ @",
|
---|
156 | "@ @ @ @",
|
---|
157 | "@ #@@@# @",
|
---|
158 | "+% #+",
|
---|
159 | " +@@@@@@@+ ",
|
---|
160 | " "};
|
---|
161 |
|
---|
162 | static const char * const workspace_minimize[] = {
|
---|
163 | "11 13 7 1",
|
---|
164 | " c None",
|
---|
165 | ". c #D5CFCB",
|
---|
166 | "+ c #8F8B88",
|
---|
167 | "@ c #6C6A67",
|
---|
168 | "# c #ABA6A3",
|
---|
169 | "$ c #B5B0AC",
|
---|
170 | "% c #A4A09D",
|
---|
171 | " ",
|
---|
172 | " +@@@@@@@+ ",
|
---|
173 | "+# #+",
|
---|
174 | "@ @",
|
---|
175 | "@ @",
|
---|
176 | "@ @",
|
---|
177 | "@ @@@@@@@ @",
|
---|
178 | "@ @@@@@@@ @",
|
---|
179 | "@ @",
|
---|
180 | "@ @",
|
---|
181 | "+% #+",
|
---|
182 | " +@@@@@@@+ ",
|
---|
183 | " "};
|
---|
184 |
|
---|
185 |
|
---|
186 | static const char * const qt_titlebar_context_help[] = {
|
---|
187 | "10 10 3 1",
|
---|
188 | " c None",
|
---|
189 | "# c #000000",
|
---|
190 | "+ c #444444",
|
---|
191 | " +####+ ",
|
---|
192 | " ### ### ",
|
---|
193 | " ## ## ",
|
---|
194 | " +##+ ",
|
---|
195 | " +## ",
|
---|
196 | " ## ",
|
---|
197 | " ## ",
|
---|
198 | " ",
|
---|
199 | " ## ",
|
---|
200 | " ## "};
|
---|
201 |
|
---|
202 | static const char * const qt_cleanlooks_radiobutton[] = {
|
---|
203 | "13 13 9 1",
|
---|
204 | " c None",
|
---|
205 | ". c #ABA094",
|
---|
206 | "+ c #B7ADA0",
|
---|
207 | "@ c #C4BBB2",
|
---|
208 | "# c #DDD4CD",
|
---|
209 | "$ c #E7E1E0",
|
---|
210 | "% c #F4EFED",
|
---|
211 | "& c #FFFAF9",
|
---|
212 | "* c #FCFEFB",
|
---|
213 | " #@...@# ",
|
---|
214 | " @+@#$$#+@ ",
|
---|
215 | " @+$%%***&@@ ",
|
---|
216 | "#+$%**&&**&+#",
|
---|
217 | "@@$&&******#@",
|
---|
218 | ".#**********.",
|
---|
219 | ".$&******&*&.",
|
---|
220 | ".$*&******&*.",
|
---|
221 | "+#********&#@",
|
---|
222 | "#+*********+#",
|
---|
223 | " @@*******@@ ",
|
---|
224 | " @+#%*%#+@ ",
|
---|
225 | " #@...+# "};
|
---|
226 |
|
---|
227 | static const char * const qt_cleanlooks_radiobutton_checked[] = {
|
---|
228 | "13 13 20 1",
|
---|
229 | " c None",
|
---|
230 | ". c #A8ABAE",
|
---|
231 | "+ c #596066",
|
---|
232 | "@ c #283138",
|
---|
233 | "# c #A9ACAF",
|
---|
234 | "$ c #A6A9AB",
|
---|
235 | "% c #6B7378",
|
---|
236 | "& c #8C9296",
|
---|
237 | "* c #A2A6AA",
|
---|
238 | "= c #61696F",
|
---|
239 | "- c #596065",
|
---|
240 | "; c #93989C",
|
---|
241 | "> c #777E83",
|
---|
242 | ", c #60686E",
|
---|
243 | "' c #252D33",
|
---|
244 | ") c #535B62",
|
---|
245 | "! c #21292E",
|
---|
246 | "~ c #242B31",
|
---|
247 | "{ c #1F262B",
|
---|
248 | "] c #41484E",
|
---|
249 | " ",
|
---|
250 | " ",
|
---|
251 | " ",
|
---|
252 | " .+@+# ",
|
---|
253 | " $%&*&=# ",
|
---|
254 | " -&;>,'+ ",
|
---|
255 | " @*>,)!@ ",
|
---|
256 | " +&,)~{+ ",
|
---|
257 | " #='!{]# ",
|
---|
258 | " #+@+# ",
|
---|
259 | " ",
|
---|
260 | " ",
|
---|
261 | " "};
|
---|
262 |
|
---|
263 |
|
---|
264 | static const char * const qt_scrollbar_button_arrow_left[] = {
|
---|
265 | "4 7 2 1",
|
---|
266 | " c None",
|
---|
267 | "* c #BFBFBF",
|
---|
268 | " *",
|
---|
269 | " **",
|
---|
270 | " ***",
|
---|
271 | "****",
|
---|
272 | " ***",
|
---|
273 | " **",
|
---|
274 | " *"};
|
---|
275 |
|
---|
276 | static const char * const qt_scrollbar_button_arrow_right[] = {
|
---|
277 | "4 7 2 1",
|
---|
278 | " c None",
|
---|
279 | "* c #BFBFBF",
|
---|
280 | "* ",
|
---|
281 | "** ",
|
---|
282 | "*** ",
|
---|
283 | "****",
|
---|
284 | "*** ",
|
---|
285 | "** ",
|
---|
286 | "* "};
|
---|
287 |
|
---|
288 | static const char * const qt_scrollbar_button_arrow_up[] = {
|
---|
289 | "7 4 2 1",
|
---|
290 | " c None",
|
---|
291 | "* c #BFBFBF",
|
---|
292 | " * ",
|
---|
293 | " *** ",
|
---|
294 | " ***** ",
|
---|
295 | "*******"};
|
---|
296 |
|
---|
297 | static const char * const qt_scrollbar_button_arrow_down[] = {
|
---|
298 | "7 4 2 1",
|
---|
299 | " c None",
|
---|
300 | "* c #BFBFBF",
|
---|
301 | "*******",
|
---|
302 | " ***** ",
|
---|
303 | " *** ",
|
---|
304 | " * "};
|
---|
305 |
|
---|
306 | static const char * const qt_spinbox_button_arrow_down[] = {
|
---|
307 | "7 4 2 1",
|
---|
308 | " c None",
|
---|
309 | "* c #BFBFBF",
|
---|
310 | "*******",
|
---|
311 | " ***** ",
|
---|
312 | " *** ",
|
---|
313 | " * "};
|
---|
314 |
|
---|
315 | static const char * const qt_spinbox_button_arrow_up[] = {
|
---|
316 | "7 4 2 1",
|
---|
317 | " c None",
|
---|
318 | "* c #BFBFBF",
|
---|
319 | " * ",
|
---|
320 | " *** ",
|
---|
321 | " ***** ",
|
---|
322 | "*******"};
|
---|
323 |
|
---|
324 | static const char * const qt_scrollbar_button_left[] = {
|
---|
325 | "16 16 6 1",
|
---|
326 | " c None",
|
---|
327 | ". c #BFBFBF",
|
---|
328 | "+ c #979797",
|
---|
329 | "# c #FAFAFA",
|
---|
330 | "< c #FAFAFA",
|
---|
331 | "* c #FAFAFA",
|
---|
332 | " .++++++++++++++",
|
---|
333 | ".+#############+",
|
---|
334 | "+# <+",
|
---|
335 | "+# <+",
|
---|
336 | "+# <+",
|
---|
337 | "+# <+",
|
---|
338 | "+# <+",
|
---|
339 | "+# <+",
|
---|
340 | "+# <+",
|
---|
341 | "+# <+",
|
---|
342 | "+# <+",
|
---|
343 | "+# <+",
|
---|
344 | "+# <+",
|
---|
345 | "+# <+",
|
---|
346 | ".+<<<<<<<<<<<<<+",
|
---|
347 | " .++++++++++++++"};
|
---|
348 |
|
---|
349 | static const char * const qt_scrollbar_button_right[] = {
|
---|
350 | "16 16 6 1",
|
---|
351 | " c None",
|
---|
352 | ". c #BFBFBF",
|
---|
353 | "+ c #979797",
|
---|
354 | "# c #FAFAFA",
|
---|
355 | "< c #FAFAFA",
|
---|
356 | "* c #FAFAFA",
|
---|
357 | "++++++++++++++. ",
|
---|
358 | "+#############+.",
|
---|
359 | "+# <+",
|
---|
360 | "+# <+",
|
---|
361 | "+# <+",
|
---|
362 | "+# <+",
|
---|
363 | "+# <+",
|
---|
364 | "+# <+",
|
---|
365 | "+# <+",
|
---|
366 | "+# <+",
|
---|
367 | "+# <+",
|
---|
368 | "+# <+",
|
---|
369 | "+# <+",
|
---|
370 | "+# <+",
|
---|
371 | "+<<<<<<<<<<<<<+.",
|
---|
372 | "++++++++++++++. "};
|
---|
373 |
|
---|
374 | static const char * const qt_scrollbar_button_up[] = {
|
---|
375 | "16 16 6 1",
|
---|
376 | " c None",
|
---|
377 | ". c #BFBFBF",
|
---|
378 | "+ c #979797",
|
---|
379 | "# c #FAFAFA",
|
---|
380 | "< c #FAFAFA",
|
---|
381 | "* c #FAFAFA",
|
---|
382 | " .++++++++++++. ",
|
---|
383 | ".+############+.",
|
---|
384 | "+# <+",
|
---|
385 | "+# <+",
|
---|
386 | "+# <+",
|
---|
387 | "+# <+",
|
---|
388 | "+# <+",
|
---|
389 | "+# <+",
|
---|
390 | "+# <+",
|
---|
391 | "+# <+",
|
---|
392 | "+# <+",
|
---|
393 | "+# <+",
|
---|
394 | "+# <+",
|
---|
395 | "+# <+",
|
---|
396 | "+<<<<<<<<<<<<<<+",
|
---|
397 | "++++++++++++++++"};
|
---|
398 |
|
---|
399 | static const char * const qt_scrollbar_button_down[] = {
|
---|
400 | "16 16 6 1",
|
---|
401 | " c None",
|
---|
402 | ". c #BFBFBF",
|
---|
403 | "+ c #979797",
|
---|
404 | "# c #FAFAFA",
|
---|
405 | "< c #FAFAFA",
|
---|
406 | "* c #FAFAFA",
|
---|
407 | "++++++++++++++++",
|
---|
408 | "+##############+",
|
---|
409 | "+# <+",
|
---|
410 | "+# <+",
|
---|
411 | "+# <+",
|
---|
412 | "+# <+",
|
---|
413 | "+# <+",
|
---|
414 | "+# <+",
|
---|
415 | "+# <+",
|
---|
416 | "+# <+",
|
---|
417 | "+# <+",
|
---|
418 | "+# <+",
|
---|
419 | "+# <+",
|
---|
420 | "+# <+",
|
---|
421 | ".+<<<<<<<<<<<<+.",
|
---|
422 | " .++++++++++++. "};
|
---|
423 |
|
---|
424 | static const char * const qt_cleanlooks_menuitem_checkbox_checked[] = {
|
---|
425 | "8 7 6 1",
|
---|
426 | " g None",
|
---|
427 | ". g #959595",
|
---|
428 | "+ g #676767",
|
---|
429 | "@ g #454545",
|
---|
430 | "# g #1D1D1D",
|
---|
431 | "0 g #101010",
|
---|
432 | " ..",
|
---|
433 | " .+ ",
|
---|
434 | " .+ ",
|
---|
435 | "0 .@ ",
|
---|
436 | "@#++. ",
|
---|
437 | " @# ",
|
---|
438 | " . "};
|
---|
439 |
|
---|
440 | static const char * const qt_cleanlooks_checkbox_checked[] = {
|
---|
441 | "13 13 3 1",
|
---|
442 | " c None",
|
---|
443 | ". c #272D33",
|
---|
444 | "% c #666666",
|
---|
445 |
|
---|
446 | " ",
|
---|
447 | " % ",
|
---|
448 | " %. ",
|
---|
449 | " %.% ",
|
---|
450 | " %.. ",
|
---|
451 | " %.% %.. ",
|
---|
452 | " %..%..% ",
|
---|
453 | " %...% ",
|
---|
454 | " %..% ",
|
---|
455 | " %.% ",
|
---|
456 | " % ",
|
---|
457 | " ",
|
---|
458 | " "};
|
---|
459 |
|
---|
460 | static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
|
---|
461 | const QColor &gradientStop, Direction direction = TopDown, QBrush bgBrush = QBrush())
|
---|
462 | {
|
---|
463 | int x = rect.center().x();
|
---|
464 | int y = rect.center().y();
|
---|
465 | QLinearGradient *gradient;
|
---|
466 | switch(direction) {
|
---|
467 | case FromLeft:
|
---|
468 | gradient = new QLinearGradient(rect.left(), y, rect.right(), y);
|
---|
469 | break;
|
---|
470 | case FromRight:
|
---|
471 | gradient = new QLinearGradient(rect.right(), y, rect.left(), y);
|
---|
472 | break;
|
---|
473 | case BottomUp:
|
---|
474 | gradient = new QLinearGradient(x, rect.bottom(), x, rect.top());
|
---|
475 | break;
|
---|
476 | case TopDown:
|
---|
477 | default:
|
---|
478 | gradient = new QLinearGradient(x, rect.top(), x, rect.bottom());
|
---|
479 | break;
|
---|
480 | }
|
---|
481 | if (bgBrush.gradient())
|
---|
482 | gradient->setStops(bgBrush.gradient()->stops());
|
---|
483 | else {
|
---|
484 | gradient->setColorAt(0, gradientStart);
|
---|
485 | gradient->setColorAt(1, gradientStop);
|
---|
486 | }
|
---|
487 | painter->fillRect(rect, *gradient);
|
---|
488 | delete gradient;
|
---|
489 | }
|
---|
490 |
|
---|
491 | static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
|
---|
492 | const QColor &gradientMid, const QColor &gradientStop, Direction direction = TopDown,
|
---|
493 | QBrush bgBrush = QBrush())
|
---|
494 | {
|
---|
495 | int x = rect.center().x();
|
---|
496 | int y = rect.center().y();
|
---|
497 | QLinearGradient *gradient;
|
---|
498 | bool horizontal = false;
|
---|
499 | switch(direction) {
|
---|
500 | case FromLeft:
|
---|
501 | horizontal = true;
|
---|
502 | gradient = new QLinearGradient(rect.left(), y, rect.right(), y);
|
---|
503 | break;
|
---|
504 | case FromRight:
|
---|
505 | horizontal = true;
|
---|
506 | gradient = new QLinearGradient(rect.right(), y, rect.left(), y);
|
---|
507 | break;
|
---|
508 | case BottomUp:
|
---|
509 | gradient = new QLinearGradient(x, rect.bottom(), x, rect.top());
|
---|
510 | break;
|
---|
511 | case TopDown:
|
---|
512 | default:
|
---|
513 | gradient = new QLinearGradient(x, rect.top(), x, rect.bottom());
|
---|
514 | break;
|
---|
515 | }
|
---|
516 | if (bgBrush.gradient())
|
---|
517 | gradient->setStops(bgBrush.gradient()->stops());
|
---|
518 | else {
|
---|
519 | int size = horizontal ? rect.width() : rect.height() ;
|
---|
520 | if (size > 4) {
|
---|
521 | float edge = 4.0/(float)size;
|
---|
522 | gradient->setColorAt(0, gradientStart);
|
---|
523 | gradient->setColorAt(edge, gradientMid.lighter(104));
|
---|
524 | gradient->setColorAt(1.0 - edge, gradientMid.darker(100));
|
---|
525 | gradient->setColorAt(1.0, gradientStop);
|
---|
526 | }
|
---|
527 | }
|
---|
528 | painter->fillRect(rect, *gradient);
|
---|
529 | delete gradient;
|
---|
530 | }
|
---|
531 |
|
---|
532 | static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
|
---|
533 | {
|
---|
534 | QColor dark;
|
---|
535 | dark.setHsv(option->palette.button().color().hue(),
|
---|
536 | CL_MIN(255, (int)(option->palette.button().color().saturation()*1.9)),
|
---|
537 | CL_MIN(255, (int)(option->palette.button().color().value()*0.7)));
|
---|
538 |
|
---|
539 | QColor highlight = option->palette.highlight().color();
|
---|
540 |
|
---|
541 | bool active = (option->titleBarState & QStyle::State_Active);
|
---|
542 | QColor titleBarHighlight(255, 255, 255, 60);
|
---|
543 |
|
---|
544 | if (sunken)
|
---|
545 | painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120));
|
---|
546 | else if (hover)
|
---|
547 | painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20));
|
---|
548 |
|
---|
549 | QColor mdiButtonGradientStartColor;
|
---|
550 | QColor mdiButtonGradientStopColor;
|
---|
551 |
|
---|
552 | mdiButtonGradientStartColor = QColor(0, 0, 0, 40);
|
---|
553 | mdiButtonGradientStopColor = QColor(255, 255, 255, 60);
|
---|
554 |
|
---|
555 | if (sunken)
|
---|
556 | titleBarHighlight = highlight.darker(130);
|
---|
557 |
|
---|
558 | QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom());
|
---|
559 | gradient.setColorAt(0, mdiButtonGradientStartColor);
|
---|
560 | gradient.setColorAt(1, mdiButtonGradientStopColor);
|
---|
561 | QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110));
|
---|
562 |
|
---|
563 | painter->setPen(QPen(mdiButtonBorderColor, 1));
|
---|
564 | const QLine lines[4] = {
|
---|
565 | QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
|
---|
566 | QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
|
---|
567 | QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
|
---|
568 | QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2)
|
---|
569 | };
|
---|
570 | painter->drawLines(lines, 4);
|
---|
571 | const QPoint points[4] = {
|
---|
572 | QPoint(tmp.left() + 1, tmp.top() + 1),
|
---|
573 | QPoint(tmp.right() - 1, tmp.top() + 1),
|
---|
574 | QPoint(tmp.left() + 1, tmp.bottom() - 1),
|
---|
575 | QPoint(tmp.right() - 1, tmp.bottom() - 1)
|
---|
576 | };
|
---|
577 | painter->drawPoints(points, 4);
|
---|
578 |
|
---|
579 | painter->setPen(titleBarHighlight);
|
---|
580 | painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
|
---|
581 | painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2);
|
---|
582 |
|
---|
583 | painter->setPen(QPen(gradient, 1));
|
---|
584 | painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2);
|
---|
585 | painter->drawPoint(tmp.right() , tmp.top() + 1);
|
---|
586 |
|
---|
587 | painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1);
|
---|
588 | painter->drawPoint(tmp.left() + 1, tmp.bottom());
|
---|
589 | painter->drawPoint(tmp.right() - 1, tmp.bottom());
|
---|
590 | painter->drawPoint(tmp.right() , tmp.bottom() - 1);
|
---|
591 | }
|
---|
592 |
|
---|
593 | /*!
|
---|
594 | \class QCleanlooksStyle
|
---|
595 | \brief The QCleanlooksStyle class provides a widget style similar to the
|
---|
596 | Clearlooks style available in GNOME.
|
---|
597 | \since 4.2
|
---|
598 |
|
---|
599 | The Cleanlooks style provides a look and feel for widgets
|
---|
600 | that closely resembles the Clearlooks style, introduced by Richard
|
---|
601 | Stellingwerff and Daniel Borgmann.
|
---|
602 |
|
---|
603 | \sa {Cleanlooks Style Widget Gallery}, QWindowsXPStyle, QMacStyle, QWindowsStyle,
|
---|
604 | QCDEStyle, QMotifStyle, QPlastiqueStyle
|
---|
605 | */
|
---|
606 |
|
---|
607 | /*!
|
---|
608 | Constructs a QCleanlooksStyle object.
|
---|
609 | */
|
---|
610 | QCleanlooksStyle::QCleanlooksStyle() : QWindowsStyle(*new QCleanlooksStylePrivate)
|
---|
611 | {
|
---|
612 | setObjectName(QLatin1String("CleanLooks"));
|
---|
613 | }
|
---|
614 |
|
---|
615 | /*!
|
---|
616 | \internal
|
---|
617 |
|
---|
618 | Constructs a QCleanlooksStyle object.
|
---|
619 | */
|
---|
620 | QCleanlooksStyle::QCleanlooksStyle(QCleanlooksStylePrivate &dd) : QWindowsStyle(dd)
|
---|
621 | {
|
---|
622 | }
|
---|
623 |
|
---|
624 | /*!
|
---|
625 | Destroys the QCleanlooksStyle object.
|
---|
626 | */
|
---|
627 | QCleanlooksStyle::~QCleanlooksStyle()
|
---|
628 | {
|
---|
629 | }
|
---|
630 |
|
---|
631 | /*!
|
---|
632 | \fn void QCleanlooksStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette,
|
---|
633 | bool enabled, const QString& text, QPalette::ColorRole textRole) const
|
---|
634 |
|
---|
635 | Draws the given \a text in the specified \a rectangle using the
|
---|
636 | provided \a painter and \a palette.
|
---|
637 |
|
---|
638 | Text is drawn using the painter's pen. If an explicit \a textRole
|
---|
639 | is specified, then the text is drawn using the \a palette's color
|
---|
640 | for the specified role. The \a enabled value indicates whether or
|
---|
641 | not the item is enabled; when reimplementing, this value should
|
---|
642 | influence how the item is drawn.
|
---|
643 |
|
---|
644 | The text is aligned and wrapped according to the specified \a
|
---|
645 | alignment.
|
---|
646 |
|
---|
647 | \sa Qt::Alignment
|
---|
648 | */
|
---|
649 | void QCleanlooksStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
|
---|
650 | bool enabled, const QString& text, QPalette::ColorRole textRole) const
|
---|
651 | {
|
---|
652 | if (text.isEmpty())
|
---|
653 | return;
|
---|
654 |
|
---|
655 | QPen savedPen = painter->pen();
|
---|
656 | if (textRole != QPalette::NoRole) {
|
---|
657 | painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
|
---|
658 | }
|
---|
659 | if (!enabled) {
|
---|
660 | QPen pen = painter->pen();
|
---|
661 | painter->setPen(pen);
|
---|
662 | }
|
---|
663 | painter->drawText(rect, alignment, text);
|
---|
664 | painter->setPen(savedPen);
|
---|
665 | }
|
---|
666 |
|
---|
667 | static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
|
---|
668 | {
|
---|
669 | const int maxFactor = 100;
|
---|
670 | QColor tmp = colorA;
|
---|
671 | tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
|
---|
672 | tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
|
---|
673 | tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
|
---|
674 | return tmp;
|
---|
675 | }
|
---|
676 |
|
---|
677 | /*!
|
---|
678 | \reimp
|
---|
679 | */
|
---|
680 | void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
|
---|
681 | const QStyleOption *option,
|
---|
682 | QPainter *painter, const QWidget *widget) const
|
---|
683 | {
|
---|
684 | Q_ASSERT(option);
|
---|
685 | QRect rect = option->rect;
|
---|
686 | int state = option->state;
|
---|
687 | QColor button = option->palette.button().color();
|
---|
688 | QColor buttonShadow = option->palette.button().color().darker(110);
|
---|
689 | QColor buttonShadowAlpha = buttonShadow;
|
---|
690 | buttonShadowAlpha.setAlpha(128);
|
---|
691 | QColor darkOutline;
|
---|
692 | QColor dark;
|
---|
693 | darkOutline.setHsv(button.hue(),
|
---|
694 | CL_MIN(255, (int)(button.saturation()*3.0)),
|
---|
695 | CL_MIN(255, (int)(button.value()*0.6)));
|
---|
696 | dark.setHsv(button.hue(),
|
---|
697 | CL_MIN(255, (int)(button.saturation()*1.9)),
|
---|
698 | CL_MIN(255, (int)(button.value()*0.7)));
|
---|
699 | QColor tabFrameColor = mergedColors(option->palette.background().color(),
|
---|
700 | dark.lighter(135), 60);
|
---|
701 |
|
---|
702 | switch(elem) {
|
---|
703 | #ifndef QT_NO_TABBAR
|
---|
704 | case PE_FrameTabBarBase:
|
---|
705 | if (const QStyleOptionTabBarBase *tbb
|
---|
706 | = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
|
---|
707 | painter->save();
|
---|
708 | painter->setPen(QPen(darkOutline.lighter(110), 0));
|
---|
709 | switch (tbb->shape) {
|
---|
710 | case QTabBar::RoundedNorth: {
|
---|
711 | QRegion region(tbb->rect);
|
---|
712 | region -= tbb->selectedTabRect;
|
---|
713 | painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
|
---|
714 | painter->setClipRegion(region);
|
---|
715 | painter->setPen(option->palette.light().color());
|
---|
716 | painter->drawLine(tbb->rect.topLeft() + QPoint(0, 1),
|
---|
717 | tbb->rect.topRight() + QPoint(0, 1));
|
---|
718 | }
|
---|
719 | break;
|
---|
720 | case QTabBar::RoundedWest:
|
---|
721 | painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
|
---|
722 | break;
|
---|
723 | case QTabBar::RoundedSouth:
|
---|
724 | painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
|
---|
725 | tbb->rect.right(), tbb->rect.bottom());
|
---|
726 | break;
|
---|
727 | case QTabBar::RoundedEast:
|
---|
728 | painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
|
---|
729 | break;
|
---|
730 | case QTabBar::TriangularNorth:
|
---|
731 | case QTabBar::TriangularEast:
|
---|
732 | case QTabBar::TriangularWest:
|
---|
733 | case QTabBar::TriangularSouth:
|
---|
734 | painter->restore();
|
---|
735 | QWindowsStyle::drawPrimitive(elem, option, painter, widget);
|
---|
736 | return;
|
---|
737 | }
|
---|
738 | painter->restore();
|
---|
739 | }
|
---|
740 | return;
|
---|
741 | #endif // QT_NO_TABBAR
|
---|
742 | case PE_IndicatorViewItemCheck:
|
---|
743 | {
|
---|
744 | QStyleOptionButton button;
|
---|
745 | button.QStyleOption::operator=(*option);
|
---|
746 | button.state &= ~State_MouseOver;
|
---|
747 | proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
|
---|
748 | }
|
---|
749 | return;
|
---|
750 | case PE_IndicatorHeaderArrow:
|
---|
751 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
---|
752 | QRect r = header->rect;
|
---|
753 | QImage arrow;
|
---|
754 | if (header->sortIndicator & QStyleOptionHeader::SortUp)
|
---|
755 | arrow = QImage(qt_cleanlooks_arrow_up_xpm);
|
---|
756 | else if (header->sortIndicator & QStyleOptionHeader::SortDown)
|
---|
757 | arrow = QImage(qt_cleanlooks_arrow_down_xpm);
|
---|
758 | if (!arrow.isNull()) {
|
---|
759 | r.setSize(arrow.size());
|
---|
760 | r.moveCenter(header->rect.center());
|
---|
761 | arrow.setColor(1, header->palette.foreground().color().rgba());
|
---|
762 | painter->drawImage(r, arrow);
|
---|
763 | }
|
---|
764 | }
|
---|
765 | break;
|
---|
766 | case PE_IndicatorButtonDropDown:
|
---|
767 | proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
|
---|
768 | break;
|
---|
769 | case PE_IndicatorToolBarSeparator:
|
---|
770 | {
|
---|
771 | QRect rect = option->rect;
|
---|
772 | const int margin = 6;
|
---|
773 | if (option->state & State_Horizontal) {
|
---|
774 | const int offset = rect.width()/2;
|
---|
775 | painter->setPen(QPen(option->palette.background().color().darker(110)));
|
---|
776 | painter->drawLine(rect.bottomLeft().x() + offset,
|
---|
777 | rect.bottomLeft().y() - margin,
|
---|
778 | rect.topLeft().x() + offset,
|
---|
779 | rect.topLeft().y() + margin);
|
---|
780 | painter->setPen(QPen(option->palette.background().color().lighter(110)));
|
---|
781 | painter->drawLine(rect.bottomLeft().x() + offset + 1,
|
---|
782 | rect.bottomLeft().y() - margin,
|
---|
783 | rect.topLeft().x() + offset + 1,
|
---|
784 | rect.topLeft().y() + margin);
|
---|
785 | } else { //Draw vertical separator
|
---|
786 | const int offset = rect.height()/2;
|
---|
787 | painter->setPen(QPen(option->palette.background().color().darker(110)));
|
---|
788 | painter->drawLine(rect.topLeft().x() + margin ,
|
---|
789 | rect.topLeft().y() + offset,
|
---|
790 | rect.topRight().x() - margin,
|
---|
791 | rect.topRight().y() + offset);
|
---|
792 | painter->setPen(QPen(option->palette.background().color().lighter(110)));
|
---|
793 | painter->drawLine(rect.topLeft().x() + margin ,
|
---|
794 | rect.topLeft().y() + offset + 1,
|
---|
795 | rect.topRight().x() - margin,
|
---|
796 | rect.topRight().y() + offset + 1);
|
---|
797 | }
|
---|
798 | }
|
---|
799 | break;
|
---|
800 | case PE_Frame:
|
---|
801 | painter->save();
|
---|
802 | painter->setPen(dark.lighter(108));
|
---|
803 | painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
---|
804 | painter->restore();
|
---|
805 | break;
|
---|
806 | case PE_FrameMenu:
|
---|
807 | painter->save();
|
---|
808 | {
|
---|
809 | painter->setPen(QPen(darkOutline, 1));
|
---|
810 | painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
---|
811 | QColor frameLight = option->palette.background().color().lighter(160);
|
---|
812 | QColor frameShadow = option->palette.background().color().darker(110);
|
---|
813 |
|
---|
814 | //paint beveleffect
|
---|
815 | QRect frame = option->rect.adjusted(1, 1, -1, -1);
|
---|
816 | painter->setPen(frameLight);
|
---|
817 | painter->drawLine(frame.topLeft(), frame.bottomLeft());
|
---|
818 | painter->drawLine(frame.topLeft(), frame.topRight());
|
---|
819 |
|
---|
820 | painter->setPen(frameShadow);
|
---|
821 | painter->drawLine(frame.topRight(), frame.bottomRight());
|
---|
822 | painter->drawLine(frame.bottomLeft(), frame.bottomRight());
|
---|
823 | }
|
---|
824 | painter->restore();
|
---|
825 | break;
|
---|
826 | case PE_FrameDockWidget:
|
---|
827 |
|
---|
828 | painter->save();
|
---|
829 | {
|
---|
830 | QColor softshadow = option->palette.background().color().darker(120);
|
---|
831 |
|
---|
832 | QRect rect= option->rect;
|
---|
833 | painter->setPen(softshadow);
|
---|
834 | painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
---|
835 | painter->setPen(QPen(option->palette.light(), 0));
|
---|
836 | painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1));
|
---|
837 | painter->setPen(QPen(option->palette.background().color().darker(120), 0));
|
---|
838 | painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1));
|
---|
839 | painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1));
|
---|
840 |
|
---|
841 | }
|
---|
842 | painter->restore();
|
---|
843 | break;
|
---|
844 | case PE_PanelButtonTool:
|
---|
845 | painter->save();
|
---|
846 | if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) {
|
---|
847 | QRect rect = option->rect;
|
---|
848 | QPen oldPen = painter->pen();
|
---|
849 |
|
---|
850 | if (widget && widget->inherits("QDockWidgetTitleButton")) {
|
---|
851 | if (option->state & State_MouseOver)
|
---|
852 | proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
|
---|
853 | } else {
|
---|
854 | proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
|
---|
855 | }
|
---|
856 | }
|
---|
857 | painter->restore();
|
---|
858 | break;
|
---|
859 | case PE_IndicatorDockWidgetResizeHandle:
|
---|
860 | {
|
---|
861 | QStyleOption dockWidgetHandle = *option;
|
---|
862 | bool horizontal = option->state & State_Horizontal;
|
---|
863 | if (horizontal)
|
---|
864 | dockWidgetHandle.state &= ~State_Horizontal;
|
---|
865 | else
|
---|
866 | dockWidgetHandle.state |= State_Horizontal;
|
---|
867 | proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);
|
---|
868 | }
|
---|
869 | break;
|
---|
870 | case PE_FrameWindow:
|
---|
871 | painter->save();
|
---|
872 | {
|
---|
873 | QRect rect= option->rect;
|
---|
874 | painter->setPen(QPen(dark.darker(150), 0));
|
---|
875 | painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
---|
876 | painter->setPen(QPen(option->palette.light(), 0));
|
---|
877 | painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
|
---|
878 | QPoint(rect.left() + 1, rect.bottom() - 1));
|
---|
879 | painter->setPen(QPen(option->palette.background().color().darker(120), 0));
|
---|
880 | painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
|
---|
881 | QPoint(rect.right() - 2, rect.bottom() - 1));
|
---|
882 | painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
|
---|
883 | QPoint(rect.right() - 1, rect.bottom() - 1));
|
---|
884 | }
|
---|
885 | painter->restore();
|
---|
886 | break;
|
---|
887 | #ifndef QT_NO_LINEEDIT
|
---|
888 | case PE_FrameLineEdit:
|
---|
889 | // fall through
|
---|
890 | #endif // QT_NO_LINEEDIT
|
---|
891 | #ifdef QT3_SUPPORT
|
---|
892 | if (widget && widget->inherits("Q3ToolBar")) {
|
---|
893 | proxy()->drawPrimitive(PE_Q3Separator, option, painter, widget);
|
---|
894 | break;
|
---|
895 | }
|
---|
896 | #endif
|
---|
897 | {
|
---|
898 | QPen oldPen = painter->pen();
|
---|
899 | if (option->state & State_Enabled) {
|
---|
900 | painter->setPen(QPen(option->palette.background(), 0));
|
---|
901 | painter->drawRect(rect.adjusted(0, 0, 0, 0));
|
---|
902 | painter->drawRect(rect.adjusted(1, 1, -1, -1));
|
---|
903 | } else {
|
---|
904 | painter->fillRect(rect, option->palette.background());
|
---|
905 | }
|
---|
906 | QRect r = rect.adjusted(0, 1, 0, -1);
|
---|
907 | painter->setPen(buttonShadowAlpha);
|
---|
908 | painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
|
---|
909 | const QPoint points[8] = {
|
---|
910 | QPoint(r.right() - 1, r.top()),
|
---|
911 | QPoint(r.right(), r.top() + 1),
|
---|
912 | QPoint(r.right() - 1, r.bottom()),
|
---|
913 | QPoint(r.right(), r.bottom() - 1),
|
---|
914 | QPoint(r.left() + 1, r.top() ),
|
---|
915 | QPoint(r.left(), r.top() + 1),
|
---|
916 | QPoint(r.left() + 1, r.bottom() ),
|
---|
917 | QPoint(r.left(), r.bottom() - 1)
|
---|
918 | };
|
---|
919 | painter->drawPoints(points, 8);
|
---|
920 | painter->setPen(QPen(option->palette.background().color(), 1));
|
---|
921 | painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
|
---|
922 |
|
---|
923 | if (option->state & State_HasFocus) {
|
---|
924 | QColor darkoutline = option->palette.highlight().color().darker(150);
|
---|
925 | QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
|
---|
926 | painter->setPen(QPen(innerline, 0));
|
---|
927 | painter->drawRect(rect.adjusted(1, 2, -2, -3));
|
---|
928 | painter->setPen(QPen(darkoutline, 0));
|
---|
929 | }
|
---|
930 | else {
|
---|
931 | QColor highlight = Qt::white;
|
---|
932 | highlight.setAlpha(130);
|
---|
933 | painter->setPen(option->palette.base().color().darker(120));
|
---|
934 | painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
|
---|
935 | QPoint(r.right() - 1, r.top() + 1));
|
---|
936 | painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
|
---|
937 | QPoint(r.left() + 1, r.bottom() - 1));
|
---|
938 | painter->setPen(option->palette.base().color());
|
---|
939 | painter->drawLine(QPoint(r.right() - 1, r.top() + 1),
|
---|
940 | QPoint(r.right() - 1, r.bottom() - 1));
|
---|
941 | painter->setPen(highlight);
|
---|
942 | painter->drawLine(QPoint(r.left() + 1, r.bottom() + 1),
|
---|
943 | QPoint(r.right() - 1, r.bottom() + 1));
|
---|
944 | painter->drawPoint(QPoint(r.left(), r.bottom()));
|
---|
945 | painter->drawPoint(QPoint(r.right(), r.bottom() ));
|
---|
946 | painter->setPen(QPen(darkOutline.lighter(115), 1));
|
---|
947 | }
|
---|
948 | painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
|
---|
949 | painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
|
---|
950 | painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom()));
|
---|
951 | const QPoint points2[4] = {
|
---|
952 | QPoint(r.right() - 1, r.bottom() - 1),
|
---|
953 | QPoint(r.right() - 1, r.top() + 1),
|
---|
954 | QPoint(r.left() + 1, r.bottom() - 1),
|
---|
955 | QPoint(r.left() + 1, r.top() + 1)
|
---|
956 | };
|
---|
957 | painter->drawPoints(points2, 4);
|
---|
958 | painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
|
---|
959 | painter->setPen(oldPen);
|
---|
960 | }
|
---|
961 | break;
|
---|
962 | case PE_IndicatorCheckBox:
|
---|
963 | painter->save();
|
---|
964 | if (const QStyleOptionButton *checkbox = qstyleoption_cast<const QStyleOptionButton*>(option)) {
|
---|
965 | QRect checkRect;
|
---|
966 | checkRect.setX(rect.left() );
|
---|
967 | checkRect.setY(rect.top() );
|
---|
968 | checkRect.setWidth(rect.width() - 1);
|
---|
969 | checkRect.setHeight(rect.height() - 1);
|
---|
970 | if (state & State_Sunken)
|
---|
971 | painter->setBrush(dark.lighter(130));
|
---|
972 | else
|
---|
973 | painter->setBrush(option->palette.base());
|
---|
974 | painter->setPen(QPen(dark.lighter(110), 0));
|
---|
975 | painter->drawRect(checkRect);
|
---|
976 | if (checkbox->state & (State_On | State_Sunken | State_NoChange)) {
|
---|
977 | QImage image(qt_cleanlooks_checkbox_checked);
|
---|
978 | QColor fillColor = option->palette.text().color();
|
---|
979 | image.setColor(1, fillColor.rgba());
|
---|
980 | fillColor.setAlpha(100);
|
---|
981 | image.setColor(2, fillColor.rgba());
|
---|
982 | painter->drawImage(rect, image);
|
---|
983 | if (checkbox->state & State_NoChange) {
|
---|
984 | QColor bgc = option->palette.background().color();
|
---|
985 | bgc.setAlpha(127);
|
---|
986 | painter->fillRect(checkRect.adjusted(1, 1, -1, -1), bgc);
|
---|
987 | }
|
---|
988 | }
|
---|
989 | }
|
---|
990 | painter->restore();
|
---|
991 | break;
|
---|
992 | case PE_IndicatorRadioButton:
|
---|
993 | painter->save();
|
---|
994 | {
|
---|
995 | painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
---|
996 | QRect checkRect = rect.adjusted(0, 0, 0, 0);
|
---|
997 | if (state & (State_On )) {
|
---|
998 | painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
|
---|
999 | painter->drawImage(checkRect, QImage(qt_cleanlooks_radiobutton_checked));
|
---|
1000 | }
|
---|
1001 | else if (state & State_Sunken) {
|
---|
1002 | painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
|
---|
1003 | QColor bgc = buttonShadow;
|
---|
1004 | painter->setRenderHint(QPainter::Antialiasing);
|
---|
1005 | painter->setBrush(bgc);
|
---|
1006 | painter->setPen(Qt::NoPen);
|
---|
1007 | painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); }
|
---|
1008 | else {
|
---|
1009 | painter->drawImage(rect, QImage(qt_cleanlooks_radiobutton));
|
---|
1010 | }
|
---|
1011 | }
|
---|
1012 | painter->restore();
|
---|
1013 | break;
|
---|
1014 | case PE_IndicatorToolBarHandle:
|
---|
1015 | painter->save();
|
---|
1016 | if (option->state & State_Horizontal) {
|
---|
1017 | for (int i = rect.height()/5; i <= 4*(rect.height()/5) ; ++i) {
|
---|
1018 | int y = rect.topLeft().y() + i + 1;
|
---|
1019 | int x1 = rect.topLeft().x() + 3;
|
---|
1020 | int x2 = rect.topRight().x() - 2;
|
---|
1021 |
|
---|
1022 | if (i % 2 == 0)
|
---|
1023 | painter->setPen(QPen(option->palette.light(), 0));
|
---|
1024 | else
|
---|
1025 | painter->setPen(QPen(dark.lighter(110), 0));
|
---|
1026 | painter->drawLine(x1, y, x2, y);
|
---|
1027 | }
|
---|
1028 | }
|
---|
1029 | else { //vertical toolbar
|
---|
1030 | for (int i = rect.width()/5; i <= 4*(rect.width()/5) ; ++i) {
|
---|
1031 | int x = rect.topLeft().x() + i + 1;
|
---|
1032 | int y1 = rect.topLeft().y() + 3;
|
---|
1033 | int y2 = rect.topLeft().y() + 5;
|
---|
1034 |
|
---|
1035 | if (i % 2 == 0)
|
---|
1036 | painter->setPen(QPen(option->palette.light(), 0));
|
---|
1037 | else
|
---|
1038 | painter->setPen(QPen(dark.lighter(110), 0));
|
---|
1039 | painter->drawLine(x, y1, x, y2);
|
---|
1040 | }
|
---|
1041 | }
|
---|
1042 | painter->restore();
|
---|
1043 | break;
|
---|
1044 | case PE_FrameDefaultButton:
|
---|
1045 | case PE_FrameFocusRect:
|
---|
1046 | if (const QStyleOptionFocusRect *focusFrame = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
|
---|
1047 | if (!(focusFrame->state & State_KeyboardFocusChange))
|
---|
1048 | return;
|
---|
1049 | QRect rect = focusFrame->rect;
|
---|
1050 | painter->save();
|
---|
1051 | painter->setBackgroundMode(Qt::TransparentMode);
|
---|
1052 | painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern));
|
---|
1053 | painter->setBrushOrigin(rect.topLeft());
|
---|
1054 | painter->setPen(Qt::NoPen);
|
---|
1055 | const QRect rects[4] = {
|
---|
1056 | QRect(rect.left(), rect.top(), rect.width(), 1), // Top
|
---|
1057 | QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom
|
---|
1058 | QRect(rect.left(), rect.top(), 1, rect.height()), // Left
|
---|
1059 | QRect(rect.right(), rect.top(), 1, rect.height()) // Right
|
---|
1060 | };
|
---|
1061 | painter->drawRects(rects, 4);
|
---|
1062 | painter->restore();
|
---|
1063 | }
|
---|
1064 | break;
|
---|
1065 | case PE_PanelButtonCommand:
|
---|
1066 | {
|
---|
1067 | bool isDefault = false;
|
---|
1068 | bool isFlat = false;
|
---|
1069 | bool isDown = (option->state & State_Sunken) || (option->state & State_On);
|
---|
1070 | QPen oldPen = painter->pen();
|
---|
1071 | QBrush oldBrush = painter->brush();
|
---|
1072 | QRect r;
|
---|
1073 |
|
---|
1074 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) {
|
---|
1075 | isDefault = (button->features & QStyleOptionButton::DefaultButton) && (button->state & State_Enabled);
|
---|
1076 | isFlat = (button->features & QStyleOptionButton::Flat);
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | if (isFlat && !isDown) {
|
---|
1080 | if (isDefault) {
|
---|
1081 | r = option->rect.adjusted(0, 1, 0, -1);
|
---|
1082 | painter->setPen(QPen(Qt::black, 0));
|
---|
1083 | const QLine lines[4] = {
|
---|
1084 | QLine(QPoint(r.left() + 2, r.top()),
|
---|
1085 | QPoint(r.right() - 2, r.top())),
|
---|
1086 | QLine(QPoint(r.left(), r.top() + 2),
|
---|
1087 | QPoint(r.left(), r.bottom() - 2)),
|
---|
1088 | QLine(QPoint(r.right(), r.top() + 2),
|
---|
1089 | QPoint(r.right(), r.bottom() - 2)),
|
---|
1090 | QLine(QPoint(r.left() + 2, r.bottom()),
|
---|
1091 | QPoint(r.right() - 2, r.bottom()))
|
---|
1092 | };
|
---|
1093 | painter->drawLines(lines, 4);
|
---|
1094 | const QPoint points[4] = {
|
---|
1095 | QPoint(r.right() - 1, r.bottom() - 1),
|
---|
1096 | QPoint(r.right() - 1, r.top() + 1),
|
---|
1097 | QPoint(r.left() + 1, r.bottom() - 1),
|
---|
1098 | QPoint(r.left() + 1, r.top() + 1)
|
---|
1099 | };
|
---|
1100 | painter->drawPoints(points, 4);
|
---|
1101 | painter->setPen(oldPen);
|
---|
1102 | }
|
---|
1103 | return;
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("pushbutton-%1").arg(isDefault))
|
---|
1107 | r = rect.adjusted(0, 1, 0, -1);
|
---|
1108 |
|
---|
1109 | bool isEnabled = (option->state & State_Enabled);
|
---|
1110 |
|
---|
1111 | QColor highlightedGradientStartColor = option->palette.button().color().lighter(107);
|
---|
1112 | QColor highlightedGradientMidColor = option->palette.button().color().lighter(105);
|
---|
1113 | QColor highlightedGradientStopColor = buttonShadow.lighter(107);
|
---|
1114 | QColor gradientStartColor = option->palette.button().color().lighter(108);
|
---|
1115 |
|
---|
1116 | QColor buttonColor = option->palette.button().color();
|
---|
1117 | QColor gradientMidColor = option->palette.button().color();
|
---|
1118 | QColor gradientStopColor;
|
---|
1119 | gradientStopColor.setHsv(buttonColor.hue(),
|
---|
1120 | CL_MIN(255, (int)(buttonColor.saturation()*1.9)),
|
---|
1121 | CL_MIN(255, (int)(buttonColor.value()*0.96)));
|
---|
1122 |
|
---|
1123 | QRect gradRect = rect.adjusted(1, 2, -1, -2);
|
---|
1124 | // gradient fill
|
---|
1125 | QRect innerBorder = r.adjusted(1, 1, -1, 0);
|
---|
1126 |
|
---|
1127 | if (isDown) {
|
---|
1128 | QBrush fillColor = gradientStopColor.darker(110);
|
---|
1129 | if (option->palette.button().gradient())
|
---|
1130 | fillColor = option->palette.button();
|
---|
1131 | p->fillRect(gradRect, fillColor);
|
---|
1132 | p->setPen(gradientStopColor.darker(125));
|
---|
1133 | p->drawLine(innerBorder.topLeft(), innerBorder.topRight());
|
---|
1134 | p->drawLine(innerBorder.topLeft(), innerBorder.bottomLeft());
|
---|
1135 | } else {
|
---|
1136 | if (isEnabled && option->state & State_MouseOver ) {
|
---|
1137 | qt_cleanlooks_draw_buttongradient(p, gradRect,
|
---|
1138 | highlightedGradientStartColor,
|
---|
1139 | highlightedGradientMidColor,
|
---|
1140 | highlightedGradientStopColor, TopDown, option->palette.button());
|
---|
1141 | } else {
|
---|
1142 | qt_cleanlooks_draw_buttongradient(p, gradRect,
|
---|
1143 | gradientStartColor,
|
---|
1144 | gradientMidColor,
|
---|
1145 | gradientStopColor, TopDown, option->palette.button());
|
---|
1146 | }
|
---|
1147 | }
|
---|
1148 |
|
---|
1149 | bool hasFocus = option->state & State_HasFocus;
|
---|
1150 |
|
---|
1151 | if (!isEnabled)
|
---|
1152 | p->setPen(QPen(dark.lighter(115)));
|
---|
1153 | else if (isDefault)
|
---|
1154 | p->setPen(QPen(Qt::black, 1));
|
---|
1155 | else
|
---|
1156 | p->setPen(QPen(darkOutline, 1));
|
---|
1157 |
|
---|
1158 | p->drawLine(QPoint(r.left(), r.top() + 2),
|
---|
1159 | QPoint(r.left(), r.bottom() - 2));
|
---|
1160 | p->drawLine(QPoint(r.right(), r.top() + 2),
|
---|
1161 | QPoint(r.right(), r.bottom() - 2));
|
---|
1162 | p->drawLine(QPoint(r.left() + 2, r.bottom()),
|
---|
1163 | QPoint(r.right() - 2, r.bottom()));
|
---|
1164 | const QPoint points[4] = {
|
---|
1165 | QPoint(r.right() - 1, r.bottom() - 1),
|
---|
1166 | QPoint(r.right() - 1, r.top() + 1),
|
---|
1167 | QPoint(r.left() + 1, r.bottom() - 1),
|
---|
1168 | QPoint(r.left() + 1, r.top() + 1)
|
---|
1169 | };
|
---|
1170 | p->drawPoints(points, 4);
|
---|
1171 |
|
---|
1172 | if (!isDefault && !hasFocus && isEnabled)
|
---|
1173 | p->setPen(QPen(darkOutline.darker(110), 0));
|
---|
1174 |
|
---|
1175 | p->drawLine(QPoint(r.left() + 2, r.top()),
|
---|
1176 | QPoint(r.right() - 2, r.top()));
|
---|
1177 |
|
---|
1178 | QColor highlight = Qt::white;
|
---|
1179 | highlight.setAlpha(110);
|
---|
1180 | p->setPen(highlight);
|
---|
1181 | p->drawLine(QPoint(r.left() + 1, r.top() + 2),
|
---|
1182 | QPoint(r.left() + 1, r.bottom() - 2));
|
---|
1183 | p->drawLine(QPoint(r.left() + 3, r.bottom() + 1),
|
---|
1184 | QPoint(r.right() - 3, r.bottom() + 1));
|
---|
1185 |
|
---|
1186 | QColor topShadow = darkOutline;
|
---|
1187 | topShadow.setAlpha(60);
|
---|
1188 |
|
---|
1189 | p->setPen(topShadow);
|
---|
1190 | const QPoint points2[8] = {
|
---|
1191 | QPoint(r.right(), r.top() + 1),
|
---|
1192 | QPoint(r.right() - 1, r.top() ),
|
---|
1193 | QPoint(r.right(), r.bottom() - 1),
|
---|
1194 | QPoint(r.right() - 1, r.bottom() ),
|
---|
1195 | QPoint(r.left() + 1, r.bottom()),
|
---|
1196 | QPoint(r.left(), r.bottom() - 1),
|
---|
1197 | QPoint(r.left() + 1, r.top()),
|
---|
1198 | QPoint(r.left(), r.top() + 1)
|
---|
1199 | };
|
---|
1200 | p->drawPoints(points2, 8);
|
---|
1201 |
|
---|
1202 | topShadow.setAlpha(30);
|
---|
1203 | p->setPen(topShadow);
|
---|
1204 |
|
---|
1205 | p->drawLine(QPoint(r.right() - 1, r.top() + 2),
|
---|
1206 | QPoint(r.right() - 1, r.bottom() - 2));
|
---|
1207 | p->drawLine(QPoint(r.left() + 2, r.top() - 1),
|
---|
1208 | QPoint(r.right() - 2, r.top() - 1));
|
---|
1209 |
|
---|
1210 | if (isDefault) {
|
---|
1211 | r.adjust(-1, -1, 1, 1);
|
---|
1212 | p->setPen(buttonShadowAlpha.darker(120));
|
---|
1213 | const QLine lines[4] = {
|
---|
1214 | QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)),
|
---|
1215 | QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)),
|
---|
1216 | QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)),
|
---|
1217 | QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3))
|
---|
1218 | };
|
---|
1219 | p->drawLines(lines, 4);
|
---|
1220 | const QPoint points3[8] = {
|
---|
1221 | r.topRight() + QPoint(-2, 1),
|
---|
1222 | r.topRight() + QPoint(-1, 2),
|
---|
1223 | r.bottomRight() + QPoint(-1, -2),
|
---|
1224 | r.bottomRight() + QPoint(-2, -1),
|
---|
1225 | r.topLeft() + QPoint(1, 2),
|
---|
1226 | r.topLeft() + QPoint(2, 1),
|
---|
1227 | r.bottomLeft() + QPoint(1, -2),
|
---|
1228 | r.bottomLeft() + QPoint(2, -1)
|
---|
1229 | };
|
---|
1230 | p->drawPoints(points3, 8);
|
---|
1231 | }
|
---|
1232 | painter->setPen(oldPen);
|
---|
1233 | painter->setBrush(oldBrush);
|
---|
1234 | END_STYLE_PIXMAPCACHE
|
---|
1235 | }
|
---|
1236 | break;
|
---|
1237 | #ifndef QT_NO_TABBAR
|
---|
1238 | case PE_FrameTabWidget:
|
---|
1239 | painter->save();
|
---|
1240 | {
|
---|
1241 | painter->fillRect(option->rect, tabFrameColor);
|
---|
1242 | }
|
---|
1243 | #ifndef QT_NO_TABWIDGET
|
---|
1244 | if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
|
---|
1245 | QColor borderColor = darkOutline.lighter(110);
|
---|
1246 | QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color());
|
---|
1247 | QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
|
---|
1248 |
|
---|
1249 | int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget);
|
---|
1250 | bool reverse = (twf->direction == Qt::RightToLeft);
|
---|
1251 | QRect tabBarRect;
|
---|
1252 |
|
---|
1253 | switch (twf->shape) {
|
---|
1254 | case QTabBar::RoundedNorth:
|
---|
1255 | if (reverse) {
|
---|
1256 | tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width()
|
---|
1257 | - twf->tabBarSize.width() + 1,
|
---|
1258 | twf->rect.top(),
|
---|
1259 | twf->tabBarSize.width(), borderThickness);
|
---|
1260 | } else {
|
---|
1261 | tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
|
---|
1262 | twf->rect.top(),
|
---|
1263 | twf->tabBarSize.width(), borderThickness);
|
---|
1264 | }
|
---|
1265 | break ;
|
---|
1266 | case QTabBar::RoundedWest:
|
---|
1267 | tabBarRect = QRect(twf->rect.left(),
|
---|
1268 | twf->rect.top() + twf->leftCornerWidgetSize.height(),
|
---|
1269 | borderThickness,
|
---|
1270 | twf->tabBarSize.height());
|
---|
1271 | tabBarRect = tabBarRect; //adjust
|
---|
1272 | break ;
|
---|
1273 | case QTabBar::RoundedEast:
|
---|
1274 | tabBarRect = QRect(twf->rect.right() - borderThickness + 1,
|
---|
1275 | twf->rect.top() + twf->leftCornerWidgetSize.height(),
|
---|
1276 | 0,
|
---|
1277 | twf->tabBarSize.height());
|
---|
1278 | break ;
|
---|
1279 | case QTabBar::RoundedSouth:
|
---|
1280 | if (reverse) {
|
---|
1281 | tabBarRect = QRect(twf->rect.right() - twf->leftCornerWidgetSize.width() - twf->tabBarSize.width() + 1,
|
---|
1282 | twf->rect.bottom() + 1,
|
---|
1283 | twf->tabBarSize.width(),
|
---|
1284 | borderThickness);
|
---|
1285 | } else {
|
---|
1286 | tabBarRect = QRect(twf->rect.left() + twf->leftCornerWidgetSize.width(),
|
---|
1287 | twf->rect.bottom() + 1,
|
---|
1288 | twf->tabBarSize.width(),
|
---|
1289 | borderThickness);
|
---|
1290 | }
|
---|
1291 | break;
|
---|
1292 | default:
|
---|
1293 | break;
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | QRegion region(twf->rect);
|
---|
1297 | region -= tabBarRect;
|
---|
1298 | painter->setClipRegion(region);
|
---|
1299 |
|
---|
1300 | // Outer border
|
---|
1301 | QLine leftLine = QLine(twf->rect.topLeft() + QPoint(0, 2), twf->rect.bottomLeft() - QPoint(0, 2));
|
---|
1302 | QLine rightLine = QLine(twf->rect.topRight(), twf->rect.bottomRight() - QPoint(0, 2));
|
---|
1303 | QLine bottomLine = QLine(twf->rect.bottomLeft() + QPoint(2, 0), twf->rect.bottomRight() - QPoint(2, 0));
|
---|
1304 | QLine topLine = QLine(twf->rect.topLeft(), twf->rect.topRight());
|
---|
1305 |
|
---|
1306 | painter->setPen(borderColor);
|
---|
1307 | painter->drawLine(topLine);
|
---|
1308 |
|
---|
1309 | // Inner border
|
---|
1310 | QLine innerLeftLine = QLine(leftLine.p1() + QPoint(1, 0), leftLine.p2() + QPoint(1, 0));
|
---|
1311 | QLine innerRightLine = QLine(rightLine.p1() - QPoint(1, -1), rightLine.p2() - QPoint(1, 0));
|
---|
1312 | QLine innerBottomLine = QLine(bottomLine.p1() - QPoint(0, 1), bottomLine.p2() - QPoint(0, 1));
|
---|
1313 | QLine innerTopLine = QLine(topLine.p1() + QPoint(0, 1), topLine.p2() + QPoint(-1, 1));
|
---|
1314 |
|
---|
1315 | // Rounded Corner
|
---|
1316 | QPoint leftBottomOuterCorner = QPoint(innerLeftLine.p2() + QPoint(0, 1));
|
---|
1317 | QPoint leftBottomInnerCorner1 = QPoint(leftLine.p2() + QPoint(0, 1));
|
---|
1318 | QPoint leftBottomInnerCorner2 = QPoint(bottomLine.p1() - QPoint(1, 0));
|
---|
1319 | QPoint rightBottomOuterCorner = QPoint(innerRightLine.p2() + QPoint(0, 1));
|
---|
1320 | QPoint rightBottomInnerCorner1 = QPoint(rightLine.p2() + QPoint(0, 1));
|
---|
1321 | QPoint rightBottomInnerCorner2 = QPoint(bottomLine.p2() + QPoint(1, 0));
|
---|
1322 | QPoint leftTopOuterCorner = QPoint(innerLeftLine.p1() - QPoint(0, 1));
|
---|
1323 | QPoint leftTopInnerCorner1 = QPoint(leftLine.p1() - QPoint(0, 1));
|
---|
1324 | QPoint leftTopInnerCorner2 = QPoint(topLine.p1() - QPoint(1, 0));
|
---|
1325 |
|
---|
1326 | painter->setPen(borderColor);
|
---|
1327 | painter->drawLine(leftLine);
|
---|
1328 | painter->drawLine(rightLine);
|
---|
1329 | painter->drawLine(bottomLine);
|
---|
1330 | painter->drawPoint(leftBottomOuterCorner);
|
---|
1331 | painter->drawPoint(rightBottomOuterCorner);
|
---|
1332 | painter->drawPoint(leftTopOuterCorner);
|
---|
1333 |
|
---|
1334 | painter->setPen(option->palette.light().color());
|
---|
1335 | painter->drawLine(innerLeftLine);
|
---|
1336 | painter->drawLine(innerTopLine);
|
---|
1337 |
|
---|
1338 | painter->setPen(buttonShadowAlpha);
|
---|
1339 | painter->drawLine(innerRightLine);
|
---|
1340 | painter->drawLine(innerBottomLine);
|
---|
1341 |
|
---|
1342 | painter->setPen(alphaCornerColor);
|
---|
1343 | const QPoint points[6] = {
|
---|
1344 | leftBottomInnerCorner1,
|
---|
1345 | leftBottomInnerCorner2,
|
---|
1346 | rightBottomInnerCorner1,
|
---|
1347 | rightBottomInnerCorner2,
|
---|
1348 | leftTopInnerCorner1,
|
---|
1349 | leftTopInnerCorner2
|
---|
1350 | };
|
---|
1351 | painter->drawPoints(points, 6);
|
---|
1352 | }
|
---|
1353 | #endif // QT_NO_TABWIDGET
|
---|
1354 | painter->restore();
|
---|
1355 | break ;
|
---|
1356 |
|
---|
1357 | case PE_FrameStatusBarItem:
|
---|
1358 | break;
|
---|
1359 | case PE_IndicatorTabClose:
|
---|
1360 | {
|
---|
1361 | Q_D(const QCleanlooksStyle);
|
---|
1362 | if (d->tabBarcloseButtonIcon.isNull())
|
---|
1363 | d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget);
|
---|
1364 | if ((option->state & State_Enabled) && (option->state & State_MouseOver))
|
---|
1365 | proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
|
---|
1366 | QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
|
---|
1367 | proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap);
|
---|
1368 | }
|
---|
1369 | break;
|
---|
1370 |
|
---|
1371 | #endif // QT_NO_TABBAR
|
---|
1372 | default:
|
---|
1373 | QWindowsStyle::drawPrimitive(elem, option, painter, widget);
|
---|
1374 | break;
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 |
|
---|
1378 | /*!
|
---|
1379 | \reimp
|
---|
1380 | */
|
---|
1381 | void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
|
---|
1382 | const QWidget *widget) const
|
---|
1383 | {
|
---|
1384 | QColor button = option->palette.button().color();
|
---|
1385 | QColor dark;
|
---|
1386 | dark.setHsv(button.hue(),
|
---|
1387 | CL_MIN(255, (int)(button.saturation()*1.9)),
|
---|
1388 | CL_MIN(255, (int)(button.value()*0.7)));
|
---|
1389 | QColor darkOutline;
|
---|
1390 | darkOutline.setHsv(button.hue(),
|
---|
1391 | CL_MIN(255, (int)(button.saturation()*2.0)),
|
---|
1392 | CL_MIN(255, (int)(button.value()*0.6)));
|
---|
1393 | QRect rect = option->rect;
|
---|
1394 | QColor shadow = mergedColors(option->palette.background().color().darker(120),
|
---|
1395 | dark.lighter(130), 60);
|
---|
1396 | QColor tabFrameColor = mergedColors(option->palette.background().color(),
|
---|
1397 | dark.lighter(135), 60);
|
---|
1398 |
|
---|
1399 | QColor highlight = option->palette.highlight().color();
|
---|
1400 |
|
---|
1401 | switch(element) {
|
---|
1402 | case CE_RadioButton: //fall through
|
---|
1403 | case CE_CheckBox:
|
---|
1404 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
---|
1405 | bool hover = (btn->state & State_MouseOver && btn->state & State_Enabled);
|
---|
1406 | if (hover)
|
---|
1407 | painter->fillRect(rect, btn->palette.background().color().lighter(104));
|
---|
1408 | QStyleOptionButton copy = *btn;
|
---|
1409 | copy.rect.adjust(2, 0, -2, 0);
|
---|
1410 | QWindowsStyle::drawControl(element, ©, painter, widget);
|
---|
1411 | }
|
---|
1412 | break;
|
---|
1413 | case CE_Splitter:
|
---|
1414 | painter->save();
|
---|
1415 | {
|
---|
1416 | // hover appearance
|
---|
1417 | QBrush fillColor = option->palette.background().color();
|
---|
1418 | if (option->state & State_MouseOver && option->state & State_Enabled)
|
---|
1419 | fillColor = fillColor.color().lighter(106);
|
---|
1420 |
|
---|
1421 | painter->fillRect(option->rect, fillColor);
|
---|
1422 |
|
---|
1423 | QColor grooveColor = mergedColors(dark.lighter(110), option->palette.button().color(),40);
|
---|
1424 | QColor gripShadow = grooveColor.darker(110);
|
---|
1425 | QPalette palette = option->palette;
|
---|
1426 | bool vertical = !(option->state & State_Horizontal);
|
---|
1427 | QRect scrollBarSlider = option->rect;
|
---|
1428 | int gripMargin = 4;
|
---|
1429 | //draw grips
|
---|
1430 | if (vertical) {
|
---|
1431 | for( int i = -20; i< 20 ; i += 2) {
|
---|
1432 | painter->setPen(QPen(gripShadow, 1));
|
---|
1433 | painter->drawLine(
|
---|
1434 | QPoint(scrollBarSlider.center().x() + i ,
|
---|
1435 | scrollBarSlider.top() + gripMargin),
|
---|
1436 | QPoint(scrollBarSlider.center().x() + i,
|
---|
1437 | scrollBarSlider.bottom() - gripMargin));
|
---|
1438 | painter->setPen(QPen(palette.light(), 1));
|
---|
1439 | painter->drawLine(
|
---|
1440 | QPoint(scrollBarSlider.center().x() + i + 1,
|
---|
1441 | scrollBarSlider.top() + gripMargin ),
|
---|
1442 | QPoint(scrollBarSlider.center().x() + i + 1,
|
---|
1443 | scrollBarSlider.bottom() - gripMargin));
|
---|
1444 | }
|
---|
1445 | } else {
|
---|
1446 | for (int i = -20; i < 20 ; i += 2) {
|
---|
1447 | painter->setPen(QPen(gripShadow, 1));
|
---|
1448 | painter->drawLine(
|
---|
1449 | QPoint(scrollBarSlider.left() + gripMargin ,
|
---|
1450 | scrollBarSlider.center().y()+ i),
|
---|
1451 | QPoint(scrollBarSlider.right() - gripMargin,
|
---|
1452 | scrollBarSlider.center().y()+ i));
|
---|
1453 | painter->setPen(QPen(palette.light(), 1));
|
---|
1454 | painter->drawLine(
|
---|
1455 | QPoint(scrollBarSlider.left() + gripMargin,
|
---|
1456 | scrollBarSlider.center().y() + 1 + i),
|
---|
1457 | QPoint(scrollBarSlider.right() - gripMargin,
|
---|
1458 | scrollBarSlider.center().y() + 1 + i));
|
---|
1459 |
|
---|
1460 | }
|
---|
1461 | }
|
---|
1462 | }
|
---|
1463 | painter->restore();
|
---|
1464 | break;
|
---|
1465 | #ifndef QT_NO_SIZEGRIP
|
---|
1466 | case CE_SizeGrip:
|
---|
1467 | painter->save();
|
---|
1468 | {
|
---|
1469 | int x, y, w, h;
|
---|
1470 | option->rect.getRect(&x, &y, &w, &h);
|
---|
1471 | int sw = qMin(h, w);
|
---|
1472 | if (h > w)
|
---|
1473 | painter->translate(0, h - w);
|
---|
1474 | else
|
---|
1475 | painter->translate(w - h, 0);
|
---|
1476 |
|
---|
1477 | int sx = x;
|
---|
1478 | int sy = y;
|
---|
1479 | int s = 4;
|
---|
1480 | if (option->direction == Qt::RightToLeft) {
|
---|
1481 | sx = x + sw;
|
---|
1482 | for (int i = 0; i < 4; ++i) {
|
---|
1483 | painter->setPen(QPen(option->palette.light().color(), 1));
|
---|
1484 | painter->drawLine(x, sy - 1 , sx + 1, sw);
|
---|
1485 | painter->setPen(QPen(dark.lighter(120), 1));
|
---|
1486 | painter->drawLine(x, sy, sx, sw);
|
---|
1487 | sx -= s;
|
---|
1488 | sy += s;
|
---|
1489 | }
|
---|
1490 | } else {
|
---|
1491 | for (int i = 0; i < 4; ++i) {
|
---|
1492 | painter->setPen(QPen(option->palette.light().color(), 1));
|
---|
1493 | painter->drawLine(sx - 1, sw, sw, sy - 1);
|
---|
1494 | painter->setPen(QPen(dark.lighter(120), 1));
|
---|
1495 | painter->drawLine(sx, sw, sw, sy);
|
---|
1496 | sx += s;
|
---|
1497 | sy += s;
|
---|
1498 | }
|
---|
1499 | }
|
---|
1500 | }
|
---|
1501 | painter->restore();
|
---|
1502 | break;
|
---|
1503 | #endif // QT_NO_SIZEGRIP
|
---|
1504 | #ifndef QT_NO_TOOLBAR
|
---|
1505 | case CE_ToolBar:
|
---|
1506 | painter->save();
|
---|
1507 | if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
|
---|
1508 | QRect rect = option->rect;
|
---|
1509 |
|
---|
1510 | bool paintLeftBorder = true;
|
---|
1511 | bool paintRightBorder = true;
|
---|
1512 | bool paintBottomBorder = true;
|
---|
1513 |
|
---|
1514 | switch (toolbar->toolBarArea) {
|
---|
1515 | case Qt::BottomToolBarArea:
|
---|
1516 | switch(toolbar->positionOfLine) {
|
---|
1517 | case QStyleOptionToolBar::Beginning:
|
---|
1518 | case QStyleOptionToolBar::OnlyOne:
|
---|
1519 | paintBottomBorder = false;
|
---|
1520 | default:
|
---|
1521 | break;
|
---|
1522 | }
|
---|
1523 | case Qt::TopToolBarArea:
|
---|
1524 | switch (toolbar->positionWithinLine) {
|
---|
1525 | case QStyleOptionToolBar::Beginning:
|
---|
1526 | paintLeftBorder = false;
|
---|
1527 | break;
|
---|
1528 | case QStyleOptionToolBar::End:
|
---|
1529 | paintRightBorder = false;
|
---|
1530 | break;
|
---|
1531 | case QStyleOptionToolBar::OnlyOne:
|
---|
1532 | paintRightBorder = false;
|
---|
1533 | paintLeftBorder = false;
|
---|
1534 | default:
|
---|
1535 | break;
|
---|
1536 | }
|
---|
1537 | if (toolbar->direction == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end
|
---|
1538 | bool tmp = paintLeftBorder;
|
---|
1539 | paintRightBorder=paintLeftBorder;
|
---|
1540 | paintLeftBorder=tmp;
|
---|
1541 | }
|
---|
1542 | break;
|
---|
1543 | case Qt::RightToolBarArea:
|
---|
1544 | switch (toolbar->positionOfLine) {
|
---|
1545 | case QStyleOptionToolBar::Beginning:
|
---|
1546 | case QStyleOptionToolBar::OnlyOne:
|
---|
1547 | paintRightBorder = false;
|
---|
1548 | break;
|
---|
1549 | default:
|
---|
1550 | break;
|
---|
1551 | }
|
---|
1552 | break;
|
---|
1553 | case Qt::LeftToolBarArea:
|
---|
1554 | switch (toolbar->positionOfLine) {
|
---|
1555 | case QStyleOptionToolBar::Beginning:
|
---|
1556 | case QStyleOptionToolBar::OnlyOne:
|
---|
1557 | paintLeftBorder = false;
|
---|
1558 | break;
|
---|
1559 | default:
|
---|
1560 | break;
|
---|
1561 | }
|
---|
1562 | break;
|
---|
1563 | default:
|
---|
1564 | break;
|
---|
1565 | }
|
---|
1566 |
|
---|
1567 | QColor light = option->palette.background().color().lighter(110);
|
---|
1568 |
|
---|
1569 | //draw top border
|
---|
1570 | painter->setPen(QPen(light));
|
---|
1571 | painter->drawLine(rect.topLeft().x(),
|
---|
1572 | rect.topLeft().y(),
|
---|
1573 | rect.topRight().x(),
|
---|
1574 | rect.topRight().y());
|
---|
1575 |
|
---|
1576 | if (paintLeftBorder) {
|
---|
1577 | painter->setPen(QPen(light));
|
---|
1578 | painter->drawLine(rect.topLeft().x(),
|
---|
1579 | rect.topLeft().y(),
|
---|
1580 | rect.bottomLeft().x(),
|
---|
1581 | rect.bottomLeft().y());
|
---|
1582 | }
|
---|
1583 |
|
---|
1584 | if (paintRightBorder) {
|
---|
1585 | painter->setPen(QPen(shadow));
|
---|
1586 | painter->drawLine(rect.topRight().x(),
|
---|
1587 | rect.topRight().y(),
|
---|
1588 | rect.bottomRight().x(),
|
---|
1589 | rect.bottomRight().y());
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | if (paintBottomBorder) {
|
---|
1593 | painter->setPen(QPen(shadow));
|
---|
1594 | painter->drawLine(rect.bottomLeft().x(),
|
---|
1595 | rect.bottomLeft().y(),
|
---|
1596 | rect.bottomRight().x(),
|
---|
1597 | rect.bottomRight().y());
|
---|
1598 | }
|
---|
1599 | }
|
---|
1600 | painter->restore();
|
---|
1601 | break;
|
---|
1602 | #endif // QT_NO_TOOLBAR
|
---|
1603 | #ifndef QT_NO_DOCKWIDGET
|
---|
1604 | case CE_DockWidgetTitle:
|
---|
1605 | painter->save();
|
---|
1606 | if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
|
---|
1607 | const QStyleOptionDockWidgetV2 *v2
|
---|
1608 | = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
|
---|
1609 | bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
---|
1610 |
|
---|
1611 | QRect rect = dwOpt->rect;
|
---|
1612 | QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
|
---|
1613 | QRect r = rect.adjusted(0, 0, -1, 0);
|
---|
1614 | if (verticalTitleBar)
|
---|
1615 | r.adjust(0, 0, 0, -1);
|
---|
1616 | painter->setPen(option->palette.light().color());
|
---|
1617 | painter->drawRect(r.adjusted(1, 1, 1, 1));
|
---|
1618 | painter->setPen(shadow);
|
---|
1619 | painter->drawRect(r);
|
---|
1620 |
|
---|
1621 | if (verticalTitleBar) {
|
---|
1622 | QRect r = rect;
|
---|
1623 | QSize s = r.size();
|
---|
1624 | s.transpose();
|
---|
1625 | r.setSize(s);
|
---|
1626 |
|
---|
1627 | titleRect = QRect(r.left() + rect.bottom()
|
---|
1628 | - titleRect.bottom(),
|
---|
1629 | r.top() + titleRect.left() - rect.left(),
|
---|
1630 | titleRect.height(), titleRect.width());
|
---|
1631 |
|
---|
1632 | painter->translate(r.left(), r.top() + r.width());
|
---|
1633 | painter->rotate(-90);
|
---|
1634 | painter->translate(-r.left(), -r.top());
|
---|
1635 |
|
---|
1636 | rect = r;
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | if (!dwOpt->title.isEmpty()) {
|
---|
1640 | QString titleText
|
---|
1641 | = painter->fontMetrics().elidedText(dwOpt->title,
|
---|
1642 | Qt::ElideRight, titleRect.width());
|
---|
1643 | proxy()->drawItemText(painter,
|
---|
1644 | titleRect,
|
---|
1645 | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
|
---|
1646 | dwOpt->state & State_Enabled, titleText,
|
---|
1647 | QPalette::WindowText);
|
---|
1648 | }
|
---|
1649 | }
|
---|
1650 | painter->restore();
|
---|
1651 | break;
|
---|
1652 | #endif // QT_NO_DOCKWIDGET
|
---|
1653 | case CE_HeaderSection:
|
---|
1654 | painter->save();
|
---|
1655 | // Draws the header in tables.
|
---|
1656 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
---|
1657 | QPixmap cache;
|
---|
1658 | QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
|
---|
1659 | pixmapName += QString::number(- int(header->position));
|
---|
1660 | pixmapName += QString::number(- int(header->orientation));
|
---|
1661 | QRect r = option->rect;
|
---|
1662 | QColor gradientStopColor;
|
---|
1663 | QColor gradientStartColor = option->palette.button().color();
|
---|
1664 | gradientStopColor.setHsv(gradientStartColor.hue(),
|
---|
1665 | CL_MIN(255, (int)(gradientStartColor.saturation()*2)),
|
---|
1666 | CL_MIN(255, (int)(gradientStartColor.value()*0.96)));
|
---|
1667 | QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
---|
1668 | if (option->palette.background().gradient()) {
|
---|
1669 | gradient.setStops(option->palette.background().gradient()->stops());
|
---|
1670 | } else {
|
---|
1671 | gradient.setColorAt(0, gradientStartColor);
|
---|
1672 | gradient.setColorAt(0.8, gradientStartColor);
|
---|
1673 | gradient.setColorAt(1, gradientStopColor);
|
---|
1674 | }
|
---|
1675 | painter->fillRect(r, gradient);
|
---|
1676 |
|
---|
1677 | if (!QPixmapCache::find(pixmapName, cache)) {
|
---|
1678 | cache = QPixmap(r.size());
|
---|
1679 | cache.fill(Qt::transparent);
|
---|
1680 | QRect pixmapRect(0, 0, r.width(), r.height());
|
---|
1681 | QPainter cachePainter(&cache);
|
---|
1682 | if (header->orientation == Qt::Vertical) {
|
---|
1683 | cachePainter.setPen(QPen(dark));
|
---|
1684 | cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
|
---|
1685 | if (header->position != QStyleOptionHeader::End) {
|
---|
1686 | cachePainter.setPen(QPen(shadow));
|
---|
1687 | cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, -1), pixmapRect.bottomRight() + QPoint(-3, -1)); cachePainter.setPen(QPen(option->palette.light().color()));
|
---|
1688 | cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, 0), pixmapRect.bottomRight() + QPoint(-3, 0)); }
|
---|
1689 | } else {
|
---|
1690 | cachePainter.setPen(QPen(dark));
|
---|
1691 | cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
|
---|
1692 | cachePainter.setPen(QPen(shadow));
|
---|
1693 | cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color()));
|
---|
1694 | cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); }
|
---|
1695 | cachePainter.end();
|
---|
1696 | QPixmapCache::insert(pixmapName, cache);
|
---|
1697 | }
|
---|
1698 | painter->drawPixmap(r.topLeft(), cache);
|
---|
1699 | }
|
---|
1700 | painter->restore();
|
---|
1701 | break;
|
---|
1702 | case CE_ProgressBarGroove:
|
---|
1703 | painter->save();
|
---|
1704 | {
|
---|
1705 | painter->fillRect(rect, option->palette.base());
|
---|
1706 | QColor borderColor = dark.lighter(110);
|
---|
1707 | painter->setPen(QPen(borderColor, 0));
|
---|
1708 | const QLine lines[4] = {
|
---|
1709 | QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())),
|
---|
1710 | QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())),
|
---|
1711 | QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)),
|
---|
1712 | QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1))
|
---|
1713 | };
|
---|
1714 | painter->drawLines(lines, 4);
|
---|
1715 | QColor alphaCorner = mergedColors(borderColor, option->palette.background().color());
|
---|
1716 | QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
|
---|
1717 |
|
---|
1718 | //corner smoothing
|
---|
1719 | painter->setPen(alphaCorner);
|
---|
1720 | const QPoint points[4] = {
|
---|
1721 | rect.topRight(),
|
---|
1722 | rect.topLeft(),
|
---|
1723 | rect.bottomRight(),
|
---|
1724 | rect.bottomLeft()
|
---|
1725 | };
|
---|
1726 | painter->drawPoints(points, 4);
|
---|
1727 |
|
---|
1728 | //inner shadow
|
---|
1729 | painter->setPen(innerShadow);
|
---|
1730 | painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
|
---|
1731 | QPoint(rect.right() - 1, rect.top() + 1));
|
---|
1732 | painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
|
---|
1733 | QPoint(rect.left() + 1, rect.bottom() + 1));
|
---|
1734 |
|
---|
1735 | }
|
---|
1736 | painter->restore();
|
---|
1737 | break;
|
---|
1738 | case CE_ProgressBarContents:
|
---|
1739 | painter->save();
|
---|
1740 | if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
---|
1741 | QRect rect = bar->rect;
|
---|
1742 | bool vertical = false;
|
---|
1743 | bool inverted = false;
|
---|
1744 | bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
|
---|
1745 |
|
---|
1746 | // Get extra style options if version 2
|
---|
1747 | if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
|
---|
1748 | vertical = (bar2->orientation == Qt::Vertical);
|
---|
1749 | inverted = bar2->invertedAppearance;
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 | // If the orientation is vertical, we use a transform to rotate
|
---|
1753 | // the progress bar 90 degrees clockwise. This way we can use the
|
---|
1754 | // same rendering code for both orientations.
|
---|
1755 | if (vertical) {
|
---|
1756 | rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
|
---|
1757 | QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0);
|
---|
1758 | m.rotate(90.0);
|
---|
1759 | painter->setTransform(m, true);
|
---|
1760 | }
|
---|
1761 |
|
---|
1762 | int maxWidth = rect.width() - 4;
|
---|
1763 | int minWidth = 4;
|
---|
1764 | qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
|
---|
1765 | int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
|
---|
1766 | int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth);
|
---|
1767 |
|
---|
1768 | bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
|
---|
1769 | if (inverted)
|
---|
1770 | reverse = !reverse;
|
---|
1771 |
|
---|
1772 | QRect progressBar;
|
---|
1773 | if (!indeterminate) {
|
---|
1774 | if (!reverse) {
|
---|
1775 | progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3);
|
---|
1776 | } else {
|
---|
1777 | progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3);
|
---|
1778 | }
|
---|
1779 | } else {
|
---|
1780 | Q_D(const QCleanlooksStyle);
|
---|
1781 | int slideWidth = ((rect.width() - 4) * 2) / 3;
|
---|
1782 | int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
|
---|
1783 | if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
|
---|
1784 | step = slideWidth - step;
|
---|
1785 | progressBar.setRect(rect.left() + 1 + step, rect.top() + 1,
|
---|
1786 | slideWidth / 2, rect.height() - 3);
|
---|
1787 | }
|
---|
1788 | QColor highlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
---|
1789 | painter->setPen(QPen(highlight.darker(140), 0));
|
---|
1790 |
|
---|
1791 | QColor highlightedGradientStartColor = highlight.lighter(100);
|
---|
1792 | QColor highlightedGradientStopColor = highlight.lighter(130);
|
---|
1793 |
|
---|
1794 | QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(),
|
---|
1795 | rect.bottomLeft().y()*2));
|
---|
1796 |
|
---|
1797 | gradient.setColorAt(0, highlightedGradientStartColor);
|
---|
1798 | gradient.setColorAt(1, highlightedGradientStopColor);
|
---|
1799 |
|
---|
1800 | painter->setBrush(gradient);
|
---|
1801 | painter->drawRect(progressBar);
|
---|
1802 |
|
---|
1803 | painter->setPen(QPen(highlight.lighter(120), 0));
|
---|
1804 | painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
|
---|
1805 | QPoint(progressBar.right(), progressBar.top() + 1));
|
---|
1806 | painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
|
---|
1807 | QPoint(progressBar.left() + 1, progressBar.bottom() - 1));
|
---|
1808 |
|
---|
1809 | painter->setPen(QPen(highlightedGradientStartColor, 7.0));//QPen(option->palette.highlight(), 3));
|
---|
1810 |
|
---|
1811 | painter->save();
|
---|
1812 | painter->setClipRect(progressBar.adjusted(2, 2, -1, -1));
|
---|
1813 | for (int x = progressBar.left() - 32; x < rect.right() ; x+=18) {
|
---|
1814 | painter->drawLine(x, progressBar.bottom() + 1, x + 23, progressBar.top() - 2);
|
---|
1815 | }
|
---|
1816 | painter->restore();
|
---|
1817 |
|
---|
1818 | }
|
---|
1819 | painter->restore();
|
---|
1820 | break;
|
---|
1821 | case CE_MenuBarItem:
|
---|
1822 | painter->save();
|
---|
1823 | if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
|
---|
1824 | {
|
---|
1825 | QStyleOptionMenuItem item = *mbi;
|
---|
1826 | item.rect = mbi->rect.adjusted(0, 3, 0, -1);
|
---|
1827 | QColor highlightOutline = highlight.darker(125);
|
---|
1828 | QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
|
---|
1829 |
|
---|
1830 | if (option->palette.button().gradient()) {
|
---|
1831 | gradient.setStops(option->palette.button().gradient()->stops());
|
---|
1832 | } else {
|
---|
1833 | gradient.setColorAt(0, option->palette.button().color());
|
---|
1834 | gradient.setColorAt(1, option->palette.button().color().darker(110));
|
---|
1835 | }
|
---|
1836 | painter->fillRect(rect, gradient);
|
---|
1837 |
|
---|
1838 | QCommonStyle::drawControl(element, &item, painter, widget);
|
---|
1839 |
|
---|
1840 | bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
|
---|
1841 | bool dis = !(mbi->state & State_Enabled);
|
---|
1842 |
|
---|
1843 | QRect r = option->rect;
|
---|
1844 | if (act) {
|
---|
1845 | qt_cleanlooks_draw_gradient(painter, r.adjusted(1, 1, -1, -1),
|
---|
1846 | highlight,
|
---|
1847 | highlightOutline, TopDown,
|
---|
1848 | option->palette.highlight());
|
---|
1849 |
|
---|
1850 | painter->setPen(QPen(highlightOutline, 0));
|
---|
1851 | const QLine lines[4] = {
|
---|
1852 | QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())),
|
---|
1853 | QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())),
|
---|
1854 | QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
|
---|
1855 | QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
|
---|
1856 | };
|
---|
1857 | painter->drawLines(lines, 4);
|
---|
1858 |
|
---|
1859 | //draw text
|
---|
1860 | QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
|
---|
1861 | uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
---|
1862 | if (!styleHint(SH_UnderlineShortcut, mbi, widget))
|
---|
1863 | alignment |= Qt::TextHideMnemonic;
|
---|
1864 | proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
|
---|
1865 | }
|
---|
1866 |
|
---|
1867 | }
|
---|
1868 | painter->restore();
|
---|
1869 | break;
|
---|
1870 | case CE_MenuItem:
|
---|
1871 | painter->save();
|
---|
1872 | // Draws one item in a popup menu.
|
---|
1873 | if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
---|
1874 | QColor highlightOutline = highlight.darker(125);
|
---|
1875 | QColor menuBackground = option->palette.background().color().lighter(104);
|
---|
1876 | QColor borderColor = option->palette.background().color().darker(160);
|
---|
1877 | QColor alphaCornerColor;
|
---|
1878 |
|
---|
1879 | if (widget) {
|
---|
1880 | // ### backgroundrole/foregroundrole should be part of the style option
|
---|
1881 | alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
|
---|
1882 | } else {
|
---|
1883 | alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
|
---|
1884 | }
|
---|
1885 | QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
|
---|
1886 | if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
---|
1887 | painter->fillRect(menuItem->rect, menuBackground);
|
---|
1888 | int w = 0;
|
---|
1889 | if (!menuItem->text.isEmpty()) {
|
---|
1890 | painter->setFont(menuItem->font);
|
---|
1891 | proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
|
---|
1892 | menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
|
---|
1893 | QPalette::Text);
|
---|
1894 | w = menuItem->fontMetrics.width(menuItem->text) + 5;
|
---|
1895 | }
|
---|
1896 | painter->setPen(shadow.lighter(106));
|
---|
1897 | bool reverse = menuItem->direction == Qt::RightToLeft;
|
---|
1898 | painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
|
---|
1899 | menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
|
---|
1900 | painter->restore();
|
---|
1901 | break;
|
---|
1902 | }
|
---|
1903 | bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
|
---|
1904 | if (selected) {
|
---|
1905 | QRect r = option->rect.adjusted(1, 0, -2, -1);
|
---|
1906 | qt_cleanlooks_draw_gradient(painter, r, highlight,
|
---|
1907 | highlightOutline, TopDown,
|
---|
1908 | highlight);
|
---|
1909 | r = r.adjusted(-1, 0, 1, 0);
|
---|
1910 | painter->setPen(QPen(highlightOutline, 0));
|
---|
1911 | const QLine lines[4] = {
|
---|
1912 | QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)),
|
---|
1913 | QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)),
|
---|
1914 | QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
|
---|
1915 | QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
|
---|
1916 | };
|
---|
1917 | painter->drawLines(lines, 4);
|
---|
1918 | } else {
|
---|
1919 | painter->fillRect(option->rect, menuBackground);
|
---|
1920 | }
|
---|
1921 |
|
---|
1922 | bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
|
---|
1923 | bool checked = menuItem->checked;
|
---|
1924 | bool sunken = menuItem->state & State_Sunken;
|
---|
1925 | bool enabled = menuItem->state & State_Enabled;
|
---|
1926 |
|
---|
1927 | bool ignoreCheckMark = false;
|
---|
1928 | int checkcol = qMax(menuItem->maxIconWidth, 20);
|
---|
1929 |
|
---|
1930 | #ifndef QT_NO_COMBOBOX
|
---|
1931 | if (qobject_cast<const QComboBox*>(widget))
|
---|
1932 | ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
|
---|
1933 | #endif
|
---|
1934 |
|
---|
1935 | if (!ignoreCheckMark) {
|
---|
1936 | // Check
|
---|
1937 | QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13);
|
---|
1938 | checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
|
---|
1939 | if (checkable) {
|
---|
1940 | if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
|
---|
1941 | // Radio button
|
---|
1942 | if (checked || sunken) {
|
---|
1943 | painter->setRenderHint(QPainter::Antialiasing);
|
---|
1944 | painter->setPen(Qt::NoPen);
|
---|
1945 |
|
---|
1946 | QPalette::ColorRole textRole = !enabled ? QPalette::Text:
|
---|
1947 | selected ? QPalette::HighlightedText : QPalette::ButtonText;
|
---|
1948 | painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole));
|
---|
1949 | painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4));
|
---|
1950 | }
|
---|
1951 | } else {
|
---|
1952 | // Check box
|
---|
1953 | if (menuItem->icon.isNull()) {
|
---|
1954 | if (checked || sunken) {
|
---|
1955 | QImage image(qt_cleanlooks_menuitem_checkbox_checked);
|
---|
1956 | if (enabled && (menuItem->state & State_Selected)) {
|
---|
1957 | image.setColor(1, 0x55ffffff);
|
---|
1958 | image.setColor(2, 0xAAffffff);
|
---|
1959 | image.setColor(3, 0xBBffffff);
|
---|
1960 | image.setColor(4, 0xFFffffff);
|
---|
1961 | image.setColor(5, 0x33ffffff);
|
---|
1962 | } else {
|
---|
1963 | image.setColor(1, 0x55000000);
|
---|
1964 | image.setColor(2, 0xAA000000);
|
---|
1965 | image.setColor(3, 0xBB000000);
|
---|
1966 | image.setColor(4, 0xFF000000);
|
---|
1967 | image.setColor(5, 0x33000000);
|
---|
1968 | }
|
---|
1969 | painter->drawImage(QPoint(checkRect.center().x() - image.width() / 2,
|
---|
1970 | checkRect.center().y() - image.height() / 2), image);
|
---|
1971 | }
|
---|
1972 | }
|
---|
1973 | }
|
---|
1974 | }
|
---|
1975 | } else { //ignore checkmark
|
---|
1976 | if (menuItem->icon.isNull())
|
---|
1977 | checkcol = 0;
|
---|
1978 | else
|
---|
1979 | checkcol = menuItem->maxIconWidth;
|
---|
1980 | }
|
---|
1981 |
|
---|
1982 | // Text and icon, ripped from windows style
|
---|
1983 | bool dis = !(menuItem->state & State_Enabled);
|
---|
1984 | bool act = menuItem->state & State_Selected;
|
---|
1985 | const QStyleOption *opt = option;
|
---|
1986 | const QStyleOptionMenuItem *menuitem = menuItem;
|
---|
1987 |
|
---|
1988 | QPainter *p = painter;
|
---|
1989 | QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
|
---|
1990 | QRect(menuitem->rect.x(), menuitem->rect.y(),
|
---|
1991 | checkcol, menuitem->rect.height()));
|
---|
1992 | if (!menuItem->icon.isNull()) {
|
---|
1993 | QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
---|
1994 | if (act && !dis)
|
---|
1995 | mode = QIcon::Active;
|
---|
1996 | QPixmap pixmap;
|
---|
1997 |
|
---|
1998 | int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
|
---|
1999 | QSize iconSize(smallIconSize, smallIconSize);
|
---|
2000 | #ifndef QT_NO_COMBOBOX
|
---|
2001 | if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
|
---|
2002 | iconSize = combo->iconSize();
|
---|
2003 | #endif // QT_NO_COMBOBOX
|
---|
2004 | if (checked)
|
---|
2005 | pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
|
---|
2006 | else
|
---|
2007 | pixmap = menuItem->icon.pixmap(iconSize, mode);
|
---|
2008 |
|
---|
2009 | int pixw = pixmap.width();
|
---|
2010 | int pixh = pixmap.height();
|
---|
2011 |
|
---|
2012 | QRect pmr(0, 0, pixw, pixh);
|
---|
2013 | pmr.moveCenter(vCheckRect.center());
|
---|
2014 | painter->setPen(menuItem->palette.text().color());
|
---|
2015 | if (checkable && checked) {
|
---|
2016 | QStyleOption opt = *option;
|
---|
2017 | if (act) {
|
---|
2018 | QColor activeColor = mergedColors(option->palette.background().color(),
|
---|
2019 | option->palette.highlight().color());
|
---|
2020 | opt.palette.setBrush(QPalette::Button, activeColor);
|
---|
2021 | }
|
---|
2022 | opt.state |= State_Sunken;
|
---|
2023 | opt.rect = vCheckRect;
|
---|
2024 | proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
|
---|
2025 | }
|
---|
2026 | painter->drawPixmap(pmr.topLeft(), pixmap);
|
---|
2027 | }
|
---|
2028 | if (selected) {
|
---|
2029 | painter->setPen(menuItem->palette.highlightedText().color());
|
---|
2030 | } else {
|
---|
2031 | painter->setPen(menuItem->palette.text().color());
|
---|
2032 | }
|
---|
2033 | int x, y, w, h;
|
---|
2034 | menuitem->rect.getRect(&x, &y, &w, &h);
|
---|
2035 | int tab = menuitem->tabWidth;
|
---|
2036 | QColor discol;
|
---|
2037 | if (dis) {
|
---|
2038 | discol = menuitem->palette.text().color();
|
---|
2039 | p->setPen(discol);
|
---|
2040 | }
|
---|
2041 | int xm = windowsItemFrame + checkcol + windowsItemHMargin;
|
---|
2042 | int xpos = menuitem->rect.x() + xm;
|
---|
2043 |
|
---|
2044 | QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
|
---|
2045 | QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
|
---|
2046 | QString s = menuitem->text;
|
---|
2047 | if (!s.isEmpty()) { // draw text
|
---|
2048 | p->save();
|
---|
2049 | int t = s.indexOf(QLatin1Char('\t'));
|
---|
2050 | int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
---|
2051 | if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
|
---|
2052 | text_flags |= Qt::TextHideMnemonic;
|
---|
2053 | text_flags |= Qt::AlignLeft;
|
---|
2054 | if (t >= 0) {
|
---|
2055 | QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
|
---|
2056 | QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
|
---|
2057 | if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
|
---|
2058 | p->setPen(menuitem->palette.light().color());
|
---|
2059 | p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1));
|
---|
2060 | p->setPen(discol);
|
---|
2061 | }
|
---|
2062 | p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
|
---|
2063 | s = s.left(t);
|
---|
2064 | }
|
---|
2065 | QFont font = menuitem->font;
|
---|
2066 | // font may not have any "hard" flags set. We override
|
---|
2067 | // the point size so that when it is resolved against the device, this font will win.
|
---|
2068 | // This is mainly to handle cases where someone sets the font on the window
|
---|
2069 | // and then the combo inherits it and passes it onward. At that point the resolve mask
|
---|
2070 | // is very, very weak. This makes it stonger.
|
---|
2071 | font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF());
|
---|
2072 |
|
---|
2073 | if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
|
---|
2074 | font.setBold(true);
|
---|
2075 |
|
---|
2076 | p->setFont(font);
|
---|
2077 | if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
|
---|
2078 | p->setPen(menuitem->palette.light().color());
|
---|
2079 | p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t));
|
---|
2080 | p->setPen(discol);
|
---|
2081 | }
|
---|
2082 | p->drawText(vTextRect, text_flags, s.left(t));
|
---|
2083 | p->restore();
|
---|
2084 | }
|
---|
2085 |
|
---|
2086 | // Arrow
|
---|
2087 | if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
|
---|
2088 | int dim = (menuItem->rect.height() - 4) / 2;
|
---|
2089 | PrimitiveElement arrow;
|
---|
2090 | arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
---|
2091 | int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
|
---|
2092 | QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
|
---|
2093 | QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
|
---|
2094 | QStyleOptionMenuItem newMI = *menuItem;
|
---|
2095 | newMI.rect = vSubMenuRect;
|
---|
2096 | newMI.state = !enabled ? State_None : State_Enabled;
|
---|
2097 | if (selected)
|
---|
2098 | newMI.palette.setColor(QPalette::ButtonText,
|
---|
2099 | newMI.palette.highlightedText().color());
|
---|
2100 | proxy()->drawPrimitive(arrow, &newMI, painter, widget);
|
---|
2101 | }
|
---|
2102 | }
|
---|
2103 | painter->restore();
|
---|
2104 | break;
|
---|
2105 | case CE_MenuHMargin:
|
---|
2106 | case CE_MenuVMargin:
|
---|
2107 | break;
|
---|
2108 | case CE_MenuEmptyArea:
|
---|
2109 | break;
|
---|
2110 | case CE_PushButtonLabel:
|
---|
2111 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
---|
2112 | QRect ir = button->rect;
|
---|
2113 | uint tf = Qt::AlignVCenter;
|
---|
2114 | if (styleHint(SH_UnderlineShortcut, button, widget))
|
---|
2115 | tf |= Qt::TextShowMnemonic;
|
---|
2116 | else
|
---|
2117 | tf |= Qt::TextHideMnemonic;
|
---|
2118 |
|
---|
2119 | if (!button->icon.isNull()) {
|
---|
2120 | //Center both icon and text
|
---|
2121 | QPoint point;
|
---|
2122 |
|
---|
2123 | QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
|
---|
2124 | : QIcon::Disabled;
|
---|
2125 | if (mode == QIcon::Normal && button->state & State_HasFocus)
|
---|
2126 | mode = QIcon::Active;
|
---|
2127 | QIcon::State state = QIcon::Off;
|
---|
2128 | if (button->state & State_On)
|
---|
2129 | state = QIcon::On;
|
---|
2130 |
|
---|
2131 | QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
|
---|
2132 | int w = pixmap.width();
|
---|
2133 | int h = pixmap.height();
|
---|
2134 |
|
---|
2135 | if (!button->text.isEmpty())
|
---|
2136 | w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
|
---|
2137 |
|
---|
2138 | point = QPoint(ir.x() + ir.width() / 2 - w / 2,
|
---|
2139 | ir.y() + ir.height() / 2 - h / 2);
|
---|
2140 |
|
---|
2141 | if (button->direction == Qt::RightToLeft)
|
---|
2142 | point.rx() += pixmap.width();
|
---|
2143 |
|
---|
2144 | painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
|
---|
2145 |
|
---|
2146 | if (button->direction == Qt::RightToLeft)
|
---|
2147 | ir.translate(-point.x() - 2, 0);
|
---|
2148 | else
|
---|
2149 | ir.translate(point.x() + pixmap.width(), 0);
|
---|
2150 |
|
---|
2151 | // left-align text if there is
|
---|
2152 | if (!button->text.isEmpty())
|
---|
2153 | tf |= Qt::AlignLeft;
|
---|
2154 |
|
---|
2155 | } else {
|
---|
2156 | tf |= Qt::AlignHCenter;
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | if (button->features & QStyleOptionButton::HasMenu)
|
---|
2160 | ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
|
---|
2161 | proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
|
---|
2162 | button->text, QPalette::ButtonText);
|
---|
2163 | }
|
---|
2164 | break;
|
---|
2165 | case CE_MenuBarEmptyArea:
|
---|
2166 | painter->save();
|
---|
2167 | {
|
---|
2168 | QColor shadow = mergedColors(option->palette.background().color().darker(120),
|
---|
2169 | dark.lighter(140), 60);
|
---|
2170 |
|
---|
2171 | QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
|
---|
2172 | gradient.setColorAt(0, option->palette.button().color());
|
---|
2173 | gradient.setColorAt(1, option->palette.button().color().darker(110));
|
---|
2174 | painter->fillRect(rect, gradient);
|
---|
2175 |
|
---|
2176 | #ifndef QT_NO_MAINWINDOW
|
---|
2177 | if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
|
---|
2178 | QPen oldPen = painter->pen();
|
---|
2179 | painter->setPen(QPen(shadow));
|
---|
2180 | painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
---|
2181 | }
|
---|
2182 | #endif // QT_NO_MAINWINDOW
|
---|
2183 | }
|
---|
2184 | painter->restore();
|
---|
2185 | break;
|
---|
2186 | #ifndef QT_NO_TABBAR
|
---|
2187 | case CE_TabBarTabShape:
|
---|
2188 | painter->save();
|
---|
2189 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
---|
2190 |
|
---|
2191 | bool rtlHorTabs = (tab->direction == Qt::RightToLeft
|
---|
2192 | && (tab->shape == QTabBar::RoundedNorth
|
---|
2193 | || tab->shape == QTabBar::RoundedSouth));
|
---|
2194 | bool selected = tab->state & State_Selected;
|
---|
2195 | bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
|
---|
2196 | || (rtlHorTabs
|
---|
2197 | && tab->position == QStyleOptionTab::Beginning));
|
---|
2198 | bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab;
|
---|
2199 | bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget);
|
---|
2200 |
|
---|
2201 | bool atBeginning = ((tab->position == (tab->direction == Qt::LeftToRight ?
|
---|
2202 | QStyleOptionTab::Beginning : QStyleOptionTab::End)) || onlyTab);
|
---|
2203 |
|
---|
2204 | bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
|
---|
2205 | bool previousSelected =
|
---|
2206 | ((!rtlHorTabs
|
---|
2207 | && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
|
---|
2208 | || (rtlHorTabs
|
---|
2209 | && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
|
---|
2210 | bool nextSelected =
|
---|
2211 | ((!rtlHorTabs
|
---|
2212 | && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
|
---|
2213 | || (rtlHorTabs
|
---|
2214 | && tab->selectedPosition
|
---|
2215 | == QStyleOptionTab::PreviousIsSelected));
|
---|
2216 | int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
|
---|
2217 | bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
|
---|
2218 | || (rtlHorTabs
|
---|
2219 | && tabBarAlignment == Qt::AlignRight);
|
---|
2220 |
|
---|
2221 | bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
|
---|
2222 | || (rtlHorTabs
|
---|
2223 | && tabBarAlignment == Qt::AlignLeft);
|
---|
2224 |
|
---|
2225 | QColor light = tab->palette.light().color();
|
---|
2226 | QColor midlight = tab->palette.midlight().color();
|
---|
2227 |
|
---|
2228 | QColor background = tab->palette.background().color();
|
---|
2229 | int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
|
---|
2230 | if (selected)
|
---|
2231 | borderThinkness /= 2;
|
---|
2232 | QRect r2(option->rect);
|
---|
2233 | int x1 = r2.left();
|
---|
2234 | int x2 = r2.right();
|
---|
2235 | int y1 = r2.top();
|
---|
2236 | int y2 = r2.bottom();
|
---|
2237 |
|
---|
2238 | QTransform rotMatrix;
|
---|
2239 | bool flip = false;
|
---|
2240 | painter->setPen(shadow);
|
---|
2241 | QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
---|
2242 | switch (tab->shape) {
|
---|
2243 | case QTabBar::RoundedNorth:
|
---|
2244 | break;
|
---|
2245 | case QTabBar::RoundedSouth:
|
---|
2246 | rotMatrix.rotate(180);
|
---|
2247 | rotMatrix.translate(0, -rect.height() + 1);
|
---|
2248 | rotMatrix.scale(-1, 1);
|
---|
2249 | painter->setTransform(rotMatrix, true);
|
---|
2250 | break;
|
---|
2251 | case QTabBar::RoundedWest:
|
---|
2252 | rotMatrix.rotate(180 + 90);
|
---|
2253 | rotMatrix.scale(-1, 1);
|
---|
2254 | flip = true;
|
---|
2255 | painter->setTransform(rotMatrix, true);
|
---|
2256 | break;
|
---|
2257 | case QTabBar::RoundedEast:
|
---|
2258 | rotMatrix.rotate(90);
|
---|
2259 | rotMatrix.translate(0, - rect.width() + 1);
|
---|
2260 | flip = true;
|
---|
2261 | painter->setTransform(rotMatrix, true);
|
---|
2262 | break;
|
---|
2263 | default:
|
---|
2264 | painter->restore();
|
---|
2265 | QWindowsStyle::drawControl(element, tab, painter, widget);
|
---|
2266 | return;
|
---|
2267 | }
|
---|
2268 |
|
---|
2269 | if (flip) {
|
---|
2270 | QRect tmp = rect;
|
---|
2271 | rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
|
---|
2272 | int temp = x1;
|
---|
2273 | x1 = y1;
|
---|
2274 | y1 = temp;
|
---|
2275 | temp = x2;
|
---|
2276 | x2 = y2;
|
---|
2277 | y2 = temp;
|
---|
2278 | }
|
---|
2279 |
|
---|
2280 | QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
---|
2281 | if (option->palette.button().gradient()) {
|
---|
2282 | if (selected)
|
---|
2283 | gradient.setStops(option->palette.background().gradient()->stops());
|
---|
2284 | else
|
---|
2285 | gradient.setStops(option->palette.background().gradient()->stops());
|
---|
2286 | }
|
---|
2287 | else if (selected) {
|
---|
2288 | gradient.setColorAt(0, option->palette.background().color().lighter(104));
|
---|
2289 | gradient.setColorAt(1, tabFrameColor);
|
---|
2290 | painter->fillRect(rect.adjusted(0, 2, 0, -1), gradient);
|
---|
2291 | } else {
|
---|
2292 | y1 += 2;
|
---|
2293 | gradient.setColorAt(0, option->palette.background().color());
|
---|
2294 | gradient.setColorAt(1, dark.lighter(120));
|
---|
2295 | painter->fillRect(rect.adjusted(0, 2, 0, -2), gradient);
|
---|
2296 | }
|
---|
2297 |
|
---|
2298 | // Delete border
|
---|
2299 | if (selected) {
|
---|
2300 | painter->setPen(QPen(activeHighlight, 0));
|
---|
2301 | painter->drawLine(x1 + 1, y1 + 1, x2 - 1, y1 + 1);
|
---|
2302 | painter->drawLine(x1 , y1 + 2, x2 , y1 + 2);
|
---|
2303 | } else {
|
---|
2304 | painter->setPen(dark);
|
---|
2305 | painter->drawLine(x1, y2 - 1, x2 + 2, y2 - 1 );
|
---|
2306 | if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedWest) {
|
---|
2307 | painter->setPen(light);
|
---|
2308 | painter->drawLine(x1, y2 , x2, y2 );
|
---|
2309 | }
|
---|
2310 | }
|
---|
2311 | // Left
|
---|
2312 | if (atBeginning || selected ) {
|
---|
2313 | painter->setPen(light);
|
---|
2314 | painter->drawLine(x1 + 1, y1 + 2 + 1, x1 + 1, y2 - ((onlyOne || atBeginning) && selected && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
|
---|
2315 | painter->drawPoint(x1 + 1, y1 + 1);
|
---|
2316 | painter->setPen(dark);
|
---|
2317 | painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || atBeginning) && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
|
---|
2318 | }
|
---|
2319 | // Top
|
---|
2320 | {
|
---|
2321 | int beg = x1 + (previousSelected ? 0 : 2);
|
---|
2322 | int end = x2 - (nextSelected ? 0 : 2);
|
---|
2323 | painter->setPen(light);
|
---|
2324 |
|
---|
2325 | if (!selected)painter->drawLine(beg - 2, y1 + 1, end, y1 + 1);
|
---|
2326 |
|
---|
2327 | if (selected)
|
---|
2328 | painter->setPen(QPen(activeHighlight.darker(150), 0));
|
---|
2329 | else
|
---|
2330 | painter->setPen(darkOutline);
|
---|
2331 | painter->drawLine(beg, y1 , end, y1);
|
---|
2332 |
|
---|
2333 | if (atBeginning|| selected) {
|
---|
2334 | painter->drawPoint(beg - 1, y1 + 1);
|
---|
2335 | } else if (!atBeginning) {
|
---|
2336 | painter->drawPoint(beg - 1, y1);
|
---|
2337 | painter->drawPoint(beg - 2, y1);
|
---|
2338 | if (!lastTab) {
|
---|
2339 | painter->setPen(dark.lighter(130));
|
---|
2340 | painter->drawPoint(end + 1, y1);
|
---|
2341 | painter->drawPoint(end + 2 , y1);
|
---|
2342 | painter->drawPoint(end + 2, y1 + 1);
|
---|
2343 | }
|
---|
2344 | }
|
---|
2345 | }
|
---|
2346 | // Right
|
---|
2347 | if (lastTab || selected || onlyOne || !nextSelected) {
|
---|
2348 | painter->setPen(darkOutline);
|
---|
2349 | painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2350 | if (selected)
|
---|
2351 | painter->setPen(QPen(activeHighlight.darker(150), 0));
|
---|
2352 | else
|
---|
2353 | painter->setPen(darkOutline);
|
---|
2354 | painter->drawPoint(x2 - 1, y1 + 1);
|
---|
2355 |
|
---|
2356 | if (selected) {
|
---|
2357 | painter->setPen(background.darker(110));
|
---|
2358 | painter->drawLine(x2 - 1, y1 + 3, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
---|
2359 | }
|
---|
2360 | }
|
---|
2361 | }
|
---|
2362 | painter->restore();
|
---|
2363 | break;
|
---|
2364 |
|
---|
2365 | #endif // QT_NO_TABBAR
|
---|
2366 | default:
|
---|
2367 | QWindowsStyle::drawControl(element,option,painter,widget);
|
---|
2368 | break;
|
---|
2369 | }
|
---|
2370 | }
|
---|
2371 |
|
---|
2372 | /*!
|
---|
2373 | \reimp
|
---|
2374 | */
|
---|
2375 | QPalette QCleanlooksStyle::standardPalette () const
|
---|
2376 | {
|
---|
2377 | QPalette palette = QWindowsStyle::standardPalette();
|
---|
2378 | palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(98, 140, 178));
|
---|
2379 | palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
|
---|
2380 | palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
|
---|
2381 |
|
---|
2382 | QColor backGround(239, 235, 231);
|
---|
2383 |
|
---|
2384 | QColor light = backGround.lighter(150);
|
---|
2385 | QColor base = Qt::white;
|
---|
2386 | QColor dark = QColor(170, 156, 143).darker(110);
|
---|
2387 | dark = backGround.darker(150);
|
---|
2388 | QColor darkDisabled = QColor(209, 200, 191).darker(110);
|
---|
2389 |
|
---|
2390 | //### Find the correct disabled text color
|
---|
2391 | palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190));
|
---|
2392 |
|
---|
2393 | palette.setBrush(QPalette::Window, backGround);
|
---|
2394 | palette.setBrush(QPalette::Mid, backGround.darker(130));
|
---|
2395 | palette.setBrush(QPalette::Light, light);
|
---|
2396 |
|
---|
2397 | palette.setBrush(QPalette::Active, QPalette::Base, base);
|
---|
2398 | palette.setBrush(QPalette::Inactive, QPalette::Base, base);
|
---|
2399 | palette.setBrush(QPalette::Disabled, QPalette::Base, backGround);
|
---|
2400 |
|
---|
2401 | palette.setBrush(QPalette::Midlight, palette.mid().color().lighter(110));
|
---|
2402 |
|
---|
2403 | palette.setBrush(QPalette::All, QPalette::Dark, dark);
|
---|
2404 | palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
---|
2405 |
|
---|
2406 | QColor button = backGround;
|
---|
2407 |
|
---|
2408 | palette.setBrush(QPalette::Button, button);
|
---|
2409 |
|
---|
2410 | QColor shadow = dark.darker(135);
|
---|
2411 | palette.setBrush(QPalette::Shadow, shadow);
|
---|
2412 | palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.lighter(150));
|
---|
2413 | palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff)));
|
---|
2414 | return palette;
|
---|
2415 | }
|
---|
2416 |
|
---|
2417 | /*!
|
---|
2418 | \reimp
|
---|
2419 | */
|
---|
2420 | void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
---|
2421 | QPainter *painter, const QWidget *widget) const
|
---|
2422 | {
|
---|
2423 | QColor button = option->palette.button().color();
|
---|
2424 | QColor dark;
|
---|
2425 | QColor grooveColor;
|
---|
2426 | QColor darkOutline;
|
---|
2427 | dark.setHsv(button.hue(),
|
---|
2428 | CL_MIN(255, (int)(button.saturation()*1.9)),
|
---|
2429 | CL_MIN(255, (int)(button.value()*0.7)));
|
---|
2430 | grooveColor.setHsv(button.hue(),
|
---|
2431 | CL_MIN(255, (int)(button.saturation()*2.6)),
|
---|
2432 | CL_MIN(255, (int)(button.value()*0.9)));
|
---|
2433 | darkOutline.setHsv(button.hue(),
|
---|
2434 | CL_MIN(255, (int)(button.saturation()*3.0)),
|
---|
2435 | CL_MIN(255, (int)(button.value()*0.6)));
|
---|
2436 |
|
---|
2437 | QColor alphaCornerColor;
|
---|
2438 | if (widget) {
|
---|
2439 | // ### backgroundrole/foregroundrole should be part of the style option
|
---|
2440 | alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
|
---|
2441 | } else {
|
---|
2442 | alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
|
---|
2443 | }
|
---|
2444 | QColor gripShadow = grooveColor.darker(110);
|
---|
2445 | QColor buttonShadow = option->palette.button().color().darker(110);
|
---|
2446 |
|
---|
2447 | QColor gradientStartColor = option->palette.button().color().lighter(108);
|
---|
2448 | QColor gradientStopColor = mergedColors(option->palette.button().color().darker(108), dark.lighter(150), 70);
|
---|
2449 |
|
---|
2450 | QColor highlightedGradientStartColor = option->palette.button().color();
|
---|
2451 | QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
|
---|
2452 |
|
---|
2453 | QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
|
---|
2454 | QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
|
---|
2455 |
|
---|
2456 | QColor buttonShadowAlpha = option->palette.background().color().darker(105);
|
---|
2457 |
|
---|
2458 | QPalette palette = option->palette;
|
---|
2459 |
|
---|
2460 | switch (control) {
|
---|
2461 | #ifndef QT_NO_SPINBOX
|
---|
2462 | case CC_SpinBox:
|
---|
2463 | if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
---|
2464 | QPixmap cache;
|
---|
2465 | QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
|
---|
2466 | if (!QPixmapCache::find(pixmapName, cache)) {
|
---|
2467 | cache = QPixmap(spinBox->rect.size());
|
---|
2468 | cache.fill(Qt::transparent);
|
---|
2469 | QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height());
|
---|
2470 | QPainter cachePainter(&cache);
|
---|
2471 |
|
---|
2472 | bool isEnabled = (spinBox->state & State_Enabled);
|
---|
2473 | //bool focus = isEnabled && (spinBox->state & State_HasFocus);
|
---|
2474 | bool hover = isEnabled && (spinBox->state & State_MouseOver);
|
---|
2475 | bool sunken = (spinBox->state & State_Sunken);
|
---|
2476 | bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
|
---|
2477 | bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
|
---|
2478 |
|
---|
2479 | QRect rect = pixmapRect;
|
---|
2480 | QStyleOptionSpinBox spinBoxCopy = *spinBox;
|
---|
2481 | spinBoxCopy.rect = pixmapRect;
|
---|
2482 | QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);
|
---|
2483 | QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);
|
---|
2484 |
|
---|
2485 | int fw = spinBoxCopy.frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0;
|
---|
2486 | cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw),
|
---|
2487 | option->palette.base());
|
---|
2488 |
|
---|
2489 | QRect r = rect.adjusted(0, 1, 0, -1);
|
---|
2490 | if (spinBox->frame) {
|
---|
2491 |
|
---|
2492 | QColor topShadow = darkOutline;
|
---|
2493 | topShadow.setAlpha(60);
|
---|
2494 | cachePainter.setPen(topShadow);
|
---|
2495 |
|
---|
2496 | // antialias corners
|
---|
2497 | const QPoint points[8] = {
|
---|
2498 | QPoint(r.right(), r.top() + 1),
|
---|
2499 | QPoint(r.right() - 1, r.top() ),
|
---|
2500 | QPoint(r.right(), r.bottom() - 1),
|
---|
2501 | QPoint(r.right() - 1, r.bottom() ),
|
---|
2502 | QPoint(r.left() + 1, r.bottom()),
|
---|
2503 | QPoint(r.left(), r.bottom() - 1),
|
---|
2504 | QPoint(r.left() + 1, r.top()),
|
---|
2505 | QPoint(r.left(), r.top() + 1)
|
---|
2506 | };
|
---|
2507 | cachePainter.drawPoints(points, 8);
|
---|
2508 |
|
---|
2509 | // draw frame
|
---|
2510 | topShadow.setAlpha(30);
|
---|
2511 | cachePainter.setPen(topShadow);
|
---|
2512 | cachePainter.drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
|
---|
2513 |
|
---|
2514 | cachePainter.setPen(QPen(option->palette.background().color(), 1));
|
---|
2515 | cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
|
---|
2516 | QColor highlight = Qt::white;
|
---|
2517 | highlight.setAlpha(130);
|
---|
2518 | cachePainter.setPen(option->palette.base().color().darker(120));
|
---|
2519 | cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
|
---|
2520 | QPoint(r.right() - 1, r.top() + 1));
|
---|
2521 | cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
|
---|
2522 | QPoint(r.left() + 1, r.bottom() - 1));
|
---|
2523 | cachePainter.setPen(option->palette.base().color());
|
---|
2524 | cachePainter.drawLine(QPoint(r.right() - 1, r.top() + 1),
|
---|
2525 | QPoint(r.right() - 1, r.bottom() - 1));
|
---|
2526 | cachePainter.drawLine(QPoint(r.left() + 1, r.bottom() - 1),
|
---|
2527 | QPoint(r.right() - 1, r.bottom() - 1));
|
---|
2528 | cachePainter.setPen(highlight);
|
---|
2529 | cachePainter.drawLine(QPoint(r.left() + 3, r.bottom() + 1),
|
---|
2530 | QPoint(r.right() - 3, r.bottom() + 1));
|
---|
2531 |
|
---|
2532 | cachePainter.setPen(QPen(darkOutline, 1));
|
---|
2533 |
|
---|
2534 | // top and bottom lines
|
---|
2535 | const QLine lines[4] = {
|
---|
2536 | QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())),
|
---|
2537 | QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())),
|
---|
2538 | QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)),
|
---|
2539 | QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
|
---|
2540 | };
|
---|
2541 | cachePainter.drawLines(lines, 4);
|
---|
2542 | }
|
---|
2543 |
|
---|
2544 | // gradients
|
---|
2545 | qt_cleanlooks_draw_gradient(&cachePainter, upRect,
|
---|
2546 | gradientStartColor.darker(106),
|
---|
2547 | gradientStopColor, TopDown, option->palette.button());
|
---|
2548 | qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(0, 0, 0, 1),
|
---|
2549 | gradientStartColor.darker(106),
|
---|
2550 | gradientStopColor, TopDown, option->palette.button());
|
---|
2551 | if (isEnabled) {
|
---|
2552 | if(upIsActive) {
|
---|
2553 | if (sunken) {
|
---|
2554 | cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), gradientStopColor.darker(110));
|
---|
2555 | } else if (hover) {
|
---|
2556 | qt_cleanlooks_draw_gradient(&cachePainter, upRect.adjusted(1, 0, 0, 0),
|
---|
2557 | gradientStartColor.lighter(110),
|
---|
2558 | gradientStopColor.lighter(110), TopDown, option->palette.button());
|
---|
2559 | }
|
---|
2560 | }
|
---|
2561 | if(downIsActive) {
|
---|
2562 | if (sunken) {
|
---|
2563 | cachePainter.fillRect(downRect.adjusted(1, 0, 0, 1), gradientStopColor.darker(110));
|
---|
2564 |
|
---|
2565 | } else if (hover) {
|
---|
2566 | qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(1, 0, 0, 1),
|
---|
2567 | gradientStartColor.lighter(110),
|
---|
2568 | gradientStopColor.lighter(110), TopDown, option->palette.button());
|
---|
2569 | }
|
---|
2570 | }
|
---|
2571 | }
|
---|
2572 |
|
---|
2573 | if (spinBox->frame) {
|
---|
2574 | // rounded corners
|
---|
2575 | const QPoint points[4] = {
|
---|
2576 | QPoint(r.left() + 1, r.bottom() - 1),
|
---|
2577 | QPoint(r.left() + 1, r.top() + 1),
|
---|
2578 | QPoint(r.right() - 1, r.bottom() - 1),
|
---|
2579 | QPoint(r.right() - 1, r.top() + 1)
|
---|
2580 | };
|
---|
2581 | cachePainter.drawPoints(points, 4);
|
---|
2582 |
|
---|
2583 | if (option->state & State_HasFocus) {
|
---|
2584 | QColor darkoutline = option->palette.highlight().color().darker(150);
|
---|
2585 | QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
|
---|
2586 | cachePainter.setPen(QPen(innerline, 0));
|
---|
2587 | if (spinBox->direction == Qt::LeftToRight) {
|
---|
2588 | cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3));
|
---|
2589 | cachePainter.setPen(QPen(darkoutline, 0));
|
---|
2590 | const QLine lines[4] = {
|
---|
2591 | QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())),
|
---|
2592 | QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())),
|
---|
2593 | QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)),
|
---|
2594 | QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
|
---|
2595 | };
|
---|
2596 | cachePainter.drawLines(lines, 4);
|
---|
2597 | cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
|
---|
2598 | cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
|
---|
2599 | cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
|
---|
2600 | } else {
|
---|
2601 | cachePainter.drawRect(rect.adjusted(downRect.width() + 2, 2, -2, -3));
|
---|
2602 | cachePainter.setPen(QPen(darkoutline, 0));
|
---|
2603 | cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.bottom()), QPoint(r.right()- 2 - 1, r.bottom()));
|
---|
2604 | cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.top()), QPoint(r.right() - 2 - 1, r.top()));
|
---|
2605 |
|
---|
2606 | cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
|
---|
2607 | cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
|
---|
2608 | cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
|
---|
2609 | cachePainter.drawLine(QPoint(r.left() + downRect.width() + 1, r.top()),
|
---|
2610 | QPoint(r.left() + downRect.width() + 1, r.bottom()));
|
---|
2611 | }
|
---|
2612 | }
|
---|
2613 | }
|
---|
2614 |
|
---|
2615 | // outline the up/down buttons
|
---|
2616 | cachePainter.setPen(darkOutline);
|
---|
2617 | QColor light = option->palette.light().color().lighter();
|
---|
2618 |
|
---|
2619 | if (spinBox->direction == Qt::RightToLeft) {
|
---|
2620 | cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
|
---|
2621 | cachePainter.setPen(light);
|
---|
2622 | cachePainter.drawLine(upRect.right() - 1, upRect.top() + 3, upRect.right() - 1, downRect.bottom() );
|
---|
2623 | } else {
|
---|
2624 | cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
|
---|
2625 | cachePainter.setPen(light);
|
---|
2626 | cachePainter.drawLine(upRect.left() + 1, upRect.top() , upRect.left() + 1, downRect.bottom() );
|
---|
2627 | }
|
---|
2628 | if (upIsActive && sunken) {
|
---|
2629 | cachePainter.setPen(gradientStopColor.darker(130));
|
---|
2630 | cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom());
|
---|
2631 | cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.right(), upRect.top() - 1);
|
---|
2632 | } else {
|
---|
2633 | cachePainter.setPen(light);
|
---|
2634 | cachePainter.drawLine(upRect.topLeft() + QPoint(1, -1), upRect.topRight() + QPoint(-1, -1));
|
---|
2635 | cachePainter.setPen(darkOutline);
|
---|
2636 | cachePainter.drawLine(upRect.bottomLeft(), upRect.bottomRight());
|
---|
2637 | }
|
---|
2638 | if (downIsActive && sunken) {
|
---|
2639 | cachePainter.setPen(gradientStopColor.darker(130));
|
---|
2640 | cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1);
|
---|
2641 | cachePainter.drawLine(downRect.left(), downRect.top(), downRect.right(), downRect.top());
|
---|
2642 | cachePainter.setPen(gradientStopColor.darker(110));
|
---|
2643 | cachePainter.drawLine(downRect.left(), downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1);
|
---|
2644 | } else {
|
---|
2645 | cachePainter.setPen(light);
|
---|
2646 | cachePainter.drawLine(downRect.topLeft() + QPoint(2,0), downRect.topRight());
|
---|
2647 | }
|
---|
2648 |
|
---|
2649 | if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
|
---|
2650 | int centerX = upRect.center().x();
|
---|
2651 | int centerY = upRect.center().y();
|
---|
2652 | cachePainter.setPen(spinBox->palette.foreground().color());
|
---|
2653 |
|
---|
2654 | // plus/minus
|
---|
2655 | if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
|
---|
2656 | cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
|
---|
2657 | cachePainter.drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
|
---|
2658 | } else {
|
---|
2659 | cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
|
---|
2660 | cachePainter.drawLine(centerX, centerY - 2, centerX, centerY + 2);
|
---|
2661 | }
|
---|
2662 |
|
---|
2663 | centerX = downRect.center().x();
|
---|
2664 | centerY = downRect.center().y();
|
---|
2665 | if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
|
---|
2666 | cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
|
---|
2667 | } else {
|
---|
2668 | cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
|
---|
2669 | }
|
---|
2670 | } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows){
|
---|
2671 | // arrows
|
---|
2672 | QImage upArrow(qt_spinbox_button_arrow_up);
|
---|
2673 | upArrow.setColor(1, spinBox->palette.foreground().color().rgba());
|
---|
2674 |
|
---|
2675 | cachePainter.drawImage(upRect.center().x() - upArrow.width() / 2,
|
---|
2676 | upRect.center().y() - upArrow.height() / 2,
|
---|
2677 | upArrow);
|
---|
2678 |
|
---|
2679 | QImage downArrow(qt_spinbox_button_arrow_down);
|
---|
2680 | downArrow.setColor(1, spinBox->palette.foreground().color().rgba());
|
---|
2681 |
|
---|
2682 | cachePainter.drawImage(downRect.center().x() - downArrow.width() / 2,
|
---|
2683 | downRect.center().y() - downArrow.height() / 2 + 1,
|
---|
2684 | downArrow);
|
---|
2685 | }
|
---|
2686 |
|
---|
2687 | QColor disabledColor = option->palette.background().color();
|
---|
2688 | disabledColor.setAlpha(150);
|
---|
2689 | if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
|
---|
2690 | cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), disabledColor);
|
---|
2691 | if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
|
---|
2692 | cachePainter.fillRect(downRect.adjusted(1, 0, 0, 0), disabledColor);
|
---|
2693 | }
|
---|
2694 | cachePainter.end();
|
---|
2695 | QPixmapCache::insert(pixmapName, cache);
|
---|
2696 | }
|
---|
2697 | painter->drawPixmap(spinBox->rect.topLeft(), cache);
|
---|
2698 | }
|
---|
2699 | break;
|
---|
2700 | #endif // QT_NO_SPINBOX
|
---|
2701 | case CC_TitleBar:
|
---|
2702 | painter->save();
|
---|
2703 | if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
|
---|
2704 | const int buttonMargin = 5;
|
---|
2705 | bool active = (titleBar->titleBarState & State_Active);
|
---|
2706 | QRect fullRect = titleBar->rect;
|
---|
2707 | QPalette palette = option->palette;
|
---|
2708 | QColor highlight = option->palette.highlight().color();
|
---|
2709 |
|
---|
2710 | QColor titleBarFrameBorder(active ? highlight.darker(180): dark.darker(110));
|
---|
2711 | QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120));
|
---|
2712 | QColor textColor(active ? 0xffffff : 0xff000000);
|
---|
2713 | QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
|
---|
2714 |
|
---|
2715 | #ifdef QT3_SUPPORT
|
---|
2716 | if (widget && widget->inherits("Q3DockWindowTitleBar")) {
|
---|
2717 | QStyleOptionDockWidgetV2 dockwidget;
|
---|
2718 | dockwidget.QStyleOption::operator=(*option);
|
---|
2719 | proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
|
---|
2720 | } else
|
---|
2721 | #endif // QT3_SUPPORT
|
---|
2722 | {
|
---|
2723 | // Fill title bar gradient
|
---|
2724 | QColor titlebarColor = QColor(active ? highlight: palette.background().color());
|
---|
2725 | QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
|
---|
2726 | option->rect.center().x(), option->rect.bottom());
|
---|
2727 |
|
---|
2728 | gradient.setColorAt(0, titlebarColor.lighter(114));
|
---|
2729 | gradient.setColorAt(0.5, titlebarColor.lighter(102));
|
---|
2730 | gradient.setColorAt(0.51, titlebarColor.darker(104));
|
---|
2731 | gradient.setColorAt(1, titlebarColor);
|
---|
2732 | painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient);
|
---|
2733 |
|
---|
2734 | // Frame and rounded corners
|
---|
2735 | painter->setPen(titleBarFrameBorder);
|
---|
2736 |
|
---|
2737 | // top outline
|
---|
2738 | painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
|
---|
2739 | painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
|
---|
2740 | const QPoint points[5] = {
|
---|
2741 | QPoint(fullRect.left() + 4, fullRect.top() + 1),
|
---|
2742 | QPoint(fullRect.left() + 3, fullRect.top() + 1),
|
---|
2743 | QPoint(fullRect.left() + 2, fullRect.top() + 2),
|
---|
2744 | QPoint(fullRect.left() + 1, fullRect.top() + 3),
|
---|
2745 | QPoint(fullRect.left() + 1, fullRect.top() + 4)
|
---|
2746 | };
|
---|
2747 | painter->drawPoints(points, 5);
|
---|
2748 |
|
---|
2749 | painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
|
---|
2750 | const QPoint points2[5] = {
|
---|
2751 | QPoint(fullRect.right() - 3, fullRect.top() + 1),
|
---|
2752 | QPoint(fullRect.right() - 4, fullRect.top() + 1),
|
---|
2753 | QPoint(fullRect.right() - 2, fullRect.top() + 2),
|
---|
2754 | QPoint(fullRect.right() - 1, fullRect.top() + 3),
|
---|
2755 | QPoint(fullRect.right() - 1, fullRect.top() + 4)
|
---|
2756 | };
|
---|
2757 | painter->drawPoints(points2, 5);
|
---|
2758 |
|
---|
2759 | // draw bottomline
|
---|
2760 | painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
|
---|
2761 |
|
---|
2762 | // top highlight
|
---|
2763 | painter->setPen(titleBarHighlight);
|
---|
2764 | painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
|
---|
2765 | }
|
---|
2766 | // draw title
|
---|
2767 | QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
|
---|
2768 | QFont font = painter->font();
|
---|
2769 | font.setBold(true);
|
---|
2770 | painter->setFont(font);
|
---|
2771 | painter->setPen(active? (titleBar->palette.text().color().lighter(120)) :
|
---|
2772 | titleBar->palette.text().color() );
|
---|
2773 | // Note workspace also does elliding but it does not use the correct font
|
---|
2774 | QString title = QFontMetrics(font).elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14);
|
---|
2775 | painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
|
---|
2776 | painter->setPen(Qt::white);
|
---|
2777 | if (active)
|
---|
2778 | painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
|
---|
2779 | // min button
|
---|
2780 | if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
|
---|
2781 | !(titleBar->titleBarState& Qt::WindowMinimized)) {
|
---|
2782 | QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
|
---|
2783 | if (minButtonRect.isValid()) {
|
---|
2784 | bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
|
---|
2785 | bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
|
---|
2786 | qt_cleanlooks_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
|
---|
2787 | QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin);
|
---|
2788 | painter->setPen(textColor);
|
---|
2789 | painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
|
---|
2790 | minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
|
---|
2791 | painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
|
---|
2792 | minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
|
---|
2793 | painter->setPen(textAlphaColor);
|
---|
2794 | painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
|
---|
2795 | minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
|
---|
2796 | painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
|
---|
2797 | minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
|
---|
2798 | }
|
---|
2799 | }
|
---|
2800 | // max button
|
---|
2801 | if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
|
---|
2802 | !(titleBar->titleBarState & Qt::WindowMaximized)) {
|
---|
2803 | QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
|
---|
2804 | if (maxButtonRect.isValid()) {
|
---|
2805 | bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
|
---|
2806 | bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
|
---|
2807 | qt_cleanlooks_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
|
---|
2808 |
|
---|
2809 | QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
---|
2810 |
|
---|
2811 | painter->setPen(textColor);
|
---|
2812 | painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
|
---|
2813 | painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
|
---|
2814 | maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
|
---|
2815 | painter->setPen(textAlphaColor);
|
---|
2816 | const QPoint points[4] = {
|
---|
2817 | maxButtonIconRect.topLeft(),
|
---|
2818 | maxButtonIconRect.topRight(),
|
---|
2819 | maxButtonIconRect.bottomLeft(),
|
---|
2820 | maxButtonIconRect.bottomRight()
|
---|
2821 | };
|
---|
2822 | painter->drawPoints(points, 4);
|
---|
2823 | }
|
---|
2824 | }
|
---|
2825 |
|
---|
2826 | // close button
|
---|
2827 | if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
|
---|
2828 | QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
|
---|
2829 | if (closeButtonRect.isValid()) {
|
---|
2830 | bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
|
---|
2831 | bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
|
---|
2832 | qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
|
---|
2833 | QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
---|
2834 | painter->setPen(textAlphaColor);
|
---|
2835 | const QLine lines[4] = {
|
---|
2836 | QLine(closeIconRect.left() + 1, closeIconRect.top(),
|
---|
2837 | closeIconRect.right(), closeIconRect.bottom() - 1),
|
---|
2838 | QLine(closeIconRect.left(), closeIconRect.top() + 1,
|
---|
2839 | closeIconRect.right() - 1, closeIconRect.bottom()),
|
---|
2840 | QLine(closeIconRect.right() - 1, closeIconRect.top(),
|
---|
2841 | closeIconRect.left(), closeIconRect.bottom() - 1),
|
---|
2842 | QLine(closeIconRect.right(), closeIconRect.top() + 1,
|
---|
2843 | closeIconRect.left() + 1, closeIconRect.bottom())
|
---|
2844 | };
|
---|
2845 | painter->drawLines(lines, 4);
|
---|
2846 | const QPoint points[4] = {
|
---|
2847 | closeIconRect.topLeft(),
|
---|
2848 | closeIconRect.topRight(),
|
---|
2849 | closeIconRect.bottomLeft(),
|
---|
2850 | closeIconRect.bottomRight()
|
---|
2851 | };
|
---|
2852 | painter->drawPoints(points, 4);
|
---|
2853 |
|
---|
2854 | painter->setPen(textColor);
|
---|
2855 | painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
|
---|
2856 | closeIconRect.right() - 1, closeIconRect.bottom() - 1);
|
---|
2857 | painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
|
---|
2858 | closeIconRect.right() - 1, closeIconRect.top() + 1);
|
---|
2859 | }
|
---|
2860 | }
|
---|
2861 |
|
---|
2862 | // normalize button
|
---|
2863 | if ((titleBar->subControls & SC_TitleBarNormalButton) &&
|
---|
2864 | (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
|
---|
2865 | (titleBar->titleBarState & Qt::WindowMinimized)) ||
|
---|
2866 | ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
|
---|
2867 | (titleBar->titleBarState & Qt::WindowMaximized)))) {
|
---|
2868 | QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
|
---|
2869 | if (normalButtonRect.isValid()) {
|
---|
2870 |
|
---|
2871 | bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
|
---|
2872 | bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
|
---|
2873 | QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
---|
2874 | qt_cleanlooks_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
|
---|
2875 |
|
---|
2876 | QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
|
---|
2877 | painter->setPen(textColor);
|
---|
2878 | painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
|
---|
2879 | painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
|
---|
2880 | frontWindowRect.right() - 1, frontWindowRect.top() + 1);
|
---|
2881 | painter->setPen(textAlphaColor);
|
---|
2882 | const QPoint points[4] = {
|
---|
2883 | frontWindowRect.topLeft(),
|
---|
2884 | frontWindowRect.topRight(),
|
---|
2885 | frontWindowRect.bottomLeft(),
|
---|
2886 | frontWindowRect.bottomRight()
|
---|
2887 | };
|
---|
2888 | painter->drawPoints(points, 4);
|
---|
2889 |
|
---|
2890 | QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
|
---|
2891 | QRegion clipRegion = backWindowRect;
|
---|
2892 | clipRegion -= frontWindowRect;
|
---|
2893 | painter->save();
|
---|
2894 | painter->setClipRegion(clipRegion);
|
---|
2895 | painter->setPen(textColor);
|
---|
2896 | painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
|
---|
2897 | painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
|
---|
2898 | backWindowRect.right() - 1, backWindowRect.top() + 1);
|
---|
2899 | painter->setPen(textAlphaColor);
|
---|
2900 | const QPoint points2[4] = {
|
---|
2901 | backWindowRect.topLeft(),
|
---|
2902 | backWindowRect.topRight(),
|
---|
2903 | backWindowRect.bottomLeft(),
|
---|
2904 | backWindowRect.bottomRight()
|
---|
2905 | };
|
---|
2906 | painter->drawPoints(points2, 4);
|
---|
2907 | painter->restore();
|
---|
2908 | }
|
---|
2909 | }
|
---|
2910 |
|
---|
2911 | // context help button
|
---|
2912 | if (titleBar->subControls & SC_TitleBarContextHelpButton
|
---|
2913 | && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
|
---|
2914 | QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
|
---|
2915 | if (contextHelpButtonRect.isValid()) {
|
---|
2916 | bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
|
---|
2917 | bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
|
---|
2918 | qt_cleanlooks_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
|
---|
2919 |
|
---|
2920 | QColor blend;
|
---|
2921 | QImage image(qt_titlebar_context_help);
|
---|
2922 | QColor alpha = textColor;
|
---|
2923 | alpha.setAlpha(128);
|
---|
2924 | image.setColor(1, textColor.rgba());
|
---|
2925 | image.setColor(2, alpha.rgba());
|
---|
2926 | painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
---|
2927 | painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image);
|
---|
2928 | }
|
---|
2929 | }
|
---|
2930 |
|
---|
2931 | // shade button
|
---|
2932 | if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
|
---|
2933 | QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
|
---|
2934 | if (shadeButtonRect.isValid()) {
|
---|
2935 | bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
|
---|
2936 | bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
|
---|
2937 | qt_cleanlooks_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
|
---|
2938 | QImage image(qt_scrollbar_button_arrow_up);
|
---|
2939 | image.setColor(1, textColor.rgba());
|
---|
2940 | painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image);
|
---|
2941 | }
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 | // unshade button
|
---|
2945 | if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
|
---|
2946 | QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
|
---|
2947 | if (unshadeButtonRect.isValid()) {
|
---|
2948 | bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
|
---|
2949 | bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
|
---|
2950 | qt_cleanlooks_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
|
---|
2951 | QImage image(qt_scrollbar_button_arrow_down);
|
---|
2952 | image.setColor(1, textColor.rgba());
|
---|
2953 | painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image);
|
---|
2954 | }
|
---|
2955 | }
|
---|
2956 |
|
---|
2957 | if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
|
---|
2958 | QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
|
---|
2959 | if (iconRect.isValid()) {
|
---|
2960 | if (!titleBar->icon.isNull()) {
|
---|
2961 | titleBar->icon.paint(painter, iconRect);
|
---|
2962 | } else {
|
---|
2963 | QStyleOption tool(0);
|
---|
2964 | tool.palette = titleBar->palette;
|
---|
2965 | QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
|
---|
2966 | tool.rect = iconRect;
|
---|
2967 | painter->save();
|
---|
2968 | proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
---|
2969 | painter->restore();
|
---|
2970 | }
|
---|
2971 | }
|
---|
2972 | }
|
---|
2973 | }
|
---|
2974 | painter->restore();
|
---|
2975 | break;
|
---|
2976 | #ifndef QT_NO_SCROLLBAR
|
---|
2977 | case CC_ScrollBar:
|
---|
2978 | painter->save();
|
---|
2979 | if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
---|
2980 | bool isEnabled = scrollBar->state & State_Enabled;
|
---|
2981 | bool reverse = scrollBar->direction == Qt::RightToLeft;
|
---|
2982 | bool horizontal = scrollBar->orientation == Qt::Horizontal;
|
---|
2983 | bool sunken = scrollBar->state & State_Sunken;
|
---|
2984 |
|
---|
2985 | painter->fillRect(option->rect, option->palette.background());
|
---|
2986 |
|
---|
2987 | QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
|
---|
2988 | QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
|
---|
2989 | QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
|
---|
2990 | QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
|
---|
2991 |
|
---|
2992 | // paint groove
|
---|
2993 | if (scrollBar->subControls & SC_ScrollBarGroove) {
|
---|
2994 | painter->setBrush(grooveColor);
|
---|
2995 | painter->setPen(Qt::NoPen);
|
---|
2996 | if (horizontal) {
|
---|
2997 | painter->drawRect(grooveRect);
|
---|
2998 | painter->setPen(darkOutline);
|
---|
2999 | painter->drawLine(grooveRect.topLeft(), grooveRect.topRight());
|
---|
3000 | painter->drawLine(grooveRect.bottomLeft(), grooveRect.bottomRight());
|
---|
3001 | } else {
|
---|
3002 | painter->drawRect(grooveRect);
|
---|
3003 | painter->setPen(darkOutline);
|
---|
3004 | painter->drawLine(grooveRect.topLeft(), grooveRect.bottomLeft());
|
---|
3005 | painter->drawLine(grooveRect.topRight(), grooveRect.bottomRight());
|
---|
3006 | }
|
---|
3007 | }
|
---|
3008 | //paint slider
|
---|
3009 | if (scrollBar->subControls & SC_ScrollBarSlider) {
|
---|
3010 | QRect pixmapRect = scrollBarSlider;
|
---|
3011 | if (horizontal)
|
---|
3012 | pixmapRect.adjust(-1, 0, 0, -1);
|
---|
3013 | else
|
---|
3014 | pixmapRect.adjust(0, -1, -1, 0);
|
---|
3015 |
|
---|
3016 | if (isEnabled) {
|
---|
3017 | QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
|
---|
3018 | pixmapRect.center().x(), pixmapRect.bottom());
|
---|
3019 | if (!horizontal)
|
---|
3020 | gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
|
---|
3021 | pixmapRect.right(), pixmapRect.center().y());
|
---|
3022 |
|
---|
3023 | if (option->palette.button().gradient()) {
|
---|
3024 | gradient.setStops(option->palette.button().gradient()->stops());
|
---|
3025 | } else {
|
---|
3026 | if (sunken || (option->state & State_MouseOver &&
|
---|
3027 | (scrollBar->activeSubControls & SC_ScrollBarSlider))) {
|
---|
3028 | gradient.setColorAt(0, gradientStartColor.lighter(110));
|
---|
3029 | gradient.setColorAt(1, gradientStopColor.lighter(110));
|
---|
3030 | } else {
|
---|
3031 | gradient.setColorAt(0, gradientStartColor);
|
---|
3032 | gradient.setColorAt(1, gradientStopColor);
|
---|
3033 | }
|
---|
3034 | }
|
---|
3035 | painter->setPen(QPen(darkOutline, 0));
|
---|
3036 | painter->setBrush(gradient);
|
---|
3037 | painter->drawRect(pixmapRect);
|
---|
3038 |
|
---|
3039 |
|
---|
3040 | //calculate offsets used by highlight and shadow
|
---|
3041 | int yoffset, xoffset;
|
---|
3042 | if (option->state & State_Horizontal) {
|
---|
3043 | xoffset = 0;
|
---|
3044 | yoffset = 1;
|
---|
3045 | } else {
|
---|
3046 | xoffset = 1;
|
---|
3047 | yoffset = 0;
|
---|
3048 | }
|
---|
3049 | //draw slider highlights
|
---|
3050 | painter->setPen(QPen(gradientStopColor, 0));
|
---|
3051 | painter->drawLine(scrollBarSlider.left() + xoffset,
|
---|
3052 | scrollBarSlider.bottom() - yoffset,
|
---|
3053 | scrollBarSlider.right() - xoffset,
|
---|
3054 | scrollBarSlider.bottom() - yoffset);
|
---|
3055 | painter->drawLine(scrollBarSlider.right() - xoffset,
|
---|
3056 | scrollBarSlider.top() + yoffset,
|
---|
3057 | scrollBarSlider.right() - xoffset,
|
---|
3058 | scrollBarSlider.bottom() - yoffset);
|
---|
3059 |
|
---|
3060 | //draw slider shadow
|
---|
3061 | painter->setPen(QPen(gradientStartColor, 0));
|
---|
3062 | painter->drawLine(scrollBarSlider.left() + xoffset,
|
---|
3063 | scrollBarSlider.top() + yoffset,
|
---|
3064 | scrollBarSlider.right() - xoffset,
|
---|
3065 | scrollBarSlider.top() + yoffset);
|
---|
3066 | painter->drawLine(scrollBarSlider.left() + xoffset,
|
---|
3067 | scrollBarSlider.top() + yoffset,
|
---|
3068 | scrollBarSlider.left() + xoffset,
|
---|
3069 | scrollBarSlider.bottom() - yoffset);
|
---|
3070 | } else {
|
---|
3071 | QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
|
---|
3072 | pixmapRect.center().x(), pixmapRect.bottom());
|
---|
3073 | if (!horizontal) {
|
---|
3074 | gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
|
---|
3075 | pixmapRect.right(), pixmapRect.center().y());
|
---|
3076 | }
|
---|
3077 | if (sunken) {
|
---|
3078 | gradient.setColorAt(0, gradientStartColor.lighter(110));
|
---|
3079 | gradient.setColorAt(1, gradientStopColor.lighter(110));
|
---|
3080 | } else {
|
---|
3081 | gradient.setColorAt(0, gradientStartColor);
|
---|
3082 | gradient.setColorAt(1, gradientStopColor);
|
---|
3083 | }
|
---|
3084 | painter->setPen(darkOutline);
|
---|
3085 | painter->setBrush(gradient);
|
---|
3086 | painter->drawRect(pixmapRect);
|
---|
3087 | }
|
---|
3088 | int gripMargin = 4;
|
---|
3089 | //draw grips
|
---|
3090 | if (horizontal) {
|
---|
3091 | for (int i = -3; i< 6 ; i += 3) {
|
---|
3092 | painter->setPen(QPen(gripShadow, 1));
|
---|
3093 | painter->drawLine(
|
---|
3094 | QPoint(scrollBarSlider.center().x() + i ,
|
---|
3095 | scrollBarSlider.top() + gripMargin),
|
---|
3096 | QPoint(scrollBarSlider.center().x() + i,
|
---|
3097 | scrollBarSlider.bottom() - gripMargin));
|
---|
3098 | painter->setPen(QPen(palette.light(), 1));
|
---|
3099 | painter->drawLine(
|
---|
3100 | QPoint(scrollBarSlider.center().x() + i + 1,
|
---|
3101 | scrollBarSlider.top() + gripMargin ),
|
---|
3102 | QPoint(scrollBarSlider.center().x() + i + 1,
|
---|
3103 | scrollBarSlider.bottom() - gripMargin));
|
---|
3104 | }
|
---|
3105 | } else {
|
---|
3106 | for (int i = -3; i < 6 ; i += 3) {
|
---|
3107 | painter->setPen(QPen(gripShadow, 1));
|
---|
3108 | painter->drawLine(
|
---|
3109 | QPoint(scrollBarSlider.left() + gripMargin ,
|
---|
3110 | scrollBarSlider.center().y()+ i),
|
---|
3111 | QPoint(scrollBarSlider.right() - gripMargin,
|
---|
3112 | scrollBarSlider.center().y()+ i));
|
---|
3113 | painter->setPen(QPen(palette.light(), 1));
|
---|
3114 | painter->drawLine(
|
---|
3115 | QPoint(scrollBarSlider.left() + gripMargin,
|
---|
3116 | scrollBarSlider.center().y() + 1 + i),
|
---|
3117 | QPoint(scrollBarSlider.right() - gripMargin,
|
---|
3118 | scrollBarSlider.center().y() + 1 + i));
|
---|
3119 | }
|
---|
3120 | }
|
---|
3121 | }
|
---|
3122 |
|
---|
3123 | // The SubLine (up/left) buttons
|
---|
3124 | if (scrollBar->subControls & SC_ScrollBarSubLine) {
|
---|
3125 | //int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
|
---|
3126 | QRect pixmapRect = scrollBarSubLine;
|
---|
3127 | if (isEnabled ) {
|
---|
3128 | QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
|
---|
3129 | // Gradients
|
---|
3130 | if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
|
---|
3131 | qt_cleanlooks_draw_gradient(painter,
|
---|
3132 | QRect(fillRect),
|
---|
3133 | gradientStopColor.darker(120),
|
---|
3134 | gradientStopColor.darker(120),
|
---|
3135 | horizontal ? TopDown : FromLeft, option->palette.button());
|
---|
3136 | } else {
|
---|
3137 | qt_cleanlooks_draw_gradient(painter,
|
---|
3138 | QRect(fillRect),
|
---|
3139 | gradientStartColor.lighter(105),
|
---|
3140 | gradientStopColor,
|
---|
3141 | horizontal ? TopDown : FromLeft, option->palette.button());
|
---|
3142 | }
|
---|
3143 | }
|
---|
3144 | // Details
|
---|
3145 | QImage subButton;
|
---|
3146 | if (horizontal) {
|
---|
3147 | subButton = QImage(reverse ? qt_scrollbar_button_right : qt_scrollbar_button_left);
|
---|
3148 | } else {
|
---|
3149 | subButton = QImage(qt_scrollbar_button_up);
|
---|
3150 | }
|
---|
3151 | subButton.setColor(1, alphaCornerColor.rgba());
|
---|
3152 | subButton.setColor(2, darkOutline.rgba());
|
---|
3153 | if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
|
---|
3154 | subButton.setColor(3, gradientStopColor.darker(140).rgba());
|
---|
3155 | subButton.setColor(4, gradientStopColor.darker(120).rgba());
|
---|
3156 | } else {
|
---|
3157 | subButton.setColor(3, gradientStartColor.lighter(105).rgba());
|
---|
3158 | subButton.setColor(4, gradientStopColor.rgba());
|
---|
3159 | }
|
---|
3160 | subButton.setColor(5, scrollBar->palette.text().color().rgba());
|
---|
3161 | painter->drawImage(pixmapRect, subButton);
|
---|
3162 |
|
---|
3163 | // Arrows
|
---|
3164 | PrimitiveElement arrow;
|
---|
3165 | if (option->state & State_Horizontal)
|
---|
3166 | arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft: PE_IndicatorArrowRight;
|
---|
3167 | else
|
---|
3168 | arrow = PE_IndicatorArrowUp;
|
---|
3169 | QStyleOption arrowOpt = *option;
|
---|
3170 | arrowOpt.rect = scrollBarSubLine.adjusted(3, 3, -2, -2);
|
---|
3171 | proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
|
---|
3172 |
|
---|
3173 |
|
---|
3174 | // The AddLine (down/right) button
|
---|
3175 | if (scrollBar->subControls & SC_ScrollBarAddLine) {
|
---|
3176 | QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));
|
---|
3177 | QRect pixmapRect = scrollBarAddLine;
|
---|
3178 | if (isEnabled) {
|
---|
3179 | QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
|
---|
3180 | // Gradients
|
---|
3181 | if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
|
---|
3182 | qt_cleanlooks_draw_gradient(painter,
|
---|
3183 | fillRect,
|
---|
3184 | gradientStopColor.darker(120),
|
---|
3185 | gradientStopColor.darker(120),
|
---|
3186 | horizontal ? TopDown: FromLeft, option->palette.button());
|
---|
3187 | } else {
|
---|
3188 | qt_cleanlooks_draw_gradient(painter,
|
---|
3189 | fillRect,
|
---|
3190 | gradientStartColor.lighter(105),
|
---|
3191 | gradientStopColor,
|
---|
3192 | horizontal ? TopDown : FromLeft, option->palette.button());
|
---|
3193 | }
|
---|
3194 | }
|
---|
3195 | // Details
|
---|
3196 | QImage addButton;
|
---|
3197 | if (horizontal) {
|
---|
3198 | addButton = QImage(reverse ? qt_scrollbar_button_left : qt_scrollbar_button_right);
|
---|
3199 | } else {
|
---|
3200 | addButton = QImage(qt_scrollbar_button_down);
|
---|
3201 | }
|
---|
3202 | addButton.setColor(1, alphaCornerColor.rgba());
|
---|
3203 | addButton.setColor(2, darkOutline.rgba());
|
---|
3204 | if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
|
---|
3205 | addButton.setColor(3, gradientStopColor.darker(140).rgba());
|
---|
3206 | addButton.setColor(4, gradientStopColor.darker(120).rgba());
|
---|
3207 | } else {
|
---|
3208 | addButton.setColor(3, gradientStartColor.lighter(105).rgba());
|
---|
3209 | addButton.setColor(4, gradientStopColor.rgba());
|
---|
3210 | }
|
---|
3211 | addButton.setColor(5, scrollBar->palette.text().color().rgba());
|
---|
3212 | painter->drawImage(pixmapRect, addButton);
|
---|
3213 |
|
---|
3214 | PrimitiveElement arrow;
|
---|
3215 | if (option->state & State_Horizontal)
|
---|
3216 | arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
|
---|
3217 | else
|
---|
3218 | arrow = PE_IndicatorArrowDown;
|
---|
3219 |
|
---|
3220 | QStyleOption arrowOpt = *option;
|
---|
3221 | arrowOpt.rect = scrollBarAddLine.adjusted(3, 3, -2, -2);
|
---|
3222 | proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
|
---|
3223 | }
|
---|
3224 | }
|
---|
3225 | }
|
---|
3226 | painter->restore();
|
---|
3227 | break;;
|
---|
3228 | #endif // QT_NO_SCROLLBAR
|
---|
3229 | #ifndef QT_NO_COMBOBOX
|
---|
3230 | case CC_ComboBox:
|
---|
3231 | painter->save();
|
---|
3232 | if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
---|
3233 | bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
|
---|
3234 | bool isEnabled = (comboBox->state & State_Enabled);
|
---|
3235 | bool focus = isEnabled && (comboBox->state & State_HasFocus);
|
---|
3236 | QPixmap cache;
|
---|
3237 | QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());
|
---|
3238 | if (sunken)
|
---|
3239 | pixmapName += QLatin1String("-sunken");
|
---|
3240 | if (comboBox->editable)
|
---|
3241 | pixmapName += QLatin1String("-editable");
|
---|
3242 | if (isEnabled)
|
---|
3243 | pixmapName += QLatin1String("-enabled");
|
---|
3244 |
|
---|
3245 | if (!QPixmapCache::find(pixmapName, cache)) {
|
---|
3246 | cache = QPixmap(comboBox->rect.size());
|
---|
3247 | cache.fill(Qt::transparent);
|
---|
3248 | QPainter cachePainter(&cache);
|
---|
3249 | QRect pixmapRect(0, 0, comboBox->rect.width(), comboBox->rect.height());
|
---|
3250 | QStyleOptionComboBox comboBoxCopy = *comboBox;
|
---|
3251 | comboBoxCopy.rect = pixmapRect;
|
---|
3252 |
|
---|
3253 | QRect rect = pixmapRect;
|
---|
3254 | QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
|
---|
3255 | SC_ComboBoxArrow, widget);
|
---|
3256 | QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
|
---|
3257 | SC_ComboBoxEditField, widget);
|
---|
3258 | // Draw a push button
|
---|
3259 | if (comboBox->editable) {
|
---|
3260 | QStyleOptionFrame buttonOption;
|
---|
3261 | buttonOption.QStyleOption::operator=(*comboBox);
|
---|
3262 | buttonOption.rect = rect;
|
---|
3263 | buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
|
---|
3264 |
|
---|
3265 | if (sunken) {
|
---|
3266 | buttonOption.state |= State_Sunken;
|
---|
3267 | buttonOption.state &= ~State_MouseOver;
|
---|
3268 | }
|
---|
3269 |
|
---|
3270 | proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
|
---|
3271 |
|
---|
3272 | //remove shadow from left side of edit field when pressed:
|
---|
3273 | if (comboBox->direction != Qt::RightToLeft)
|
---|
3274 | cachePainter.fillRect(editRect.left() - 1, editRect.top() + 1, editRect.left(),
|
---|
3275 | editRect.bottom() - 3, option->palette.base());
|
---|
3276 |
|
---|
3277 | cachePainter.setPen(dark.lighter(110));
|
---|
3278 | if (!sunken) {
|
---|
3279 | int borderSize = 2;
|
---|
3280 | if (comboBox->direction == Qt::RightToLeft) {
|
---|
3281 | cachePainter.drawLine(QPoint(downArrowRect.right() - 1, downArrowRect.top() + borderSize ),
|
---|
3282 | QPoint(downArrowRect.right() - 1, downArrowRect.bottom() - borderSize));
|
---|
3283 | cachePainter.setPen(option->palette.light().color());
|
---|
3284 | cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
|
---|
3285 | QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
|
---|
3286 | } else {
|
---|
3287 | cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
|
---|
3288 | QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
|
---|
3289 | cachePainter.setPen(option->palette.light().color());
|
---|
3290 | cachePainter.drawLine(QPoint(downArrowRect.left() + 1, downArrowRect.top() + borderSize),
|
---|
3291 | QPoint(downArrowRect.left() + 1, downArrowRect.bottom() - borderSize));
|
---|
3292 | }
|
---|
3293 | } else {
|
---|
3294 | if (comboBox->direction == Qt::RightToLeft) {
|
---|
3295 | cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + 2),
|
---|
3296 | QPoint(downArrowRect.right(), downArrowRect.bottom() - 2));
|
---|
3297 |
|
---|
3298 | } else {
|
---|
3299 | cachePainter.drawLine(QPoint(downArrowRect.left(), downArrowRect.top() + 2),
|
---|
3300 | QPoint(downArrowRect.left(), downArrowRect.bottom() - 2));
|
---|
3301 | }
|
---|
3302 | }
|
---|
3303 | } else {
|
---|
3304 | QStyleOptionButton buttonOption;
|
---|
3305 | buttonOption.QStyleOption::operator=(*comboBox);
|
---|
3306 | buttonOption.rect = rect;
|
---|
3307 | buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
|
---|
3308 | if (sunken) {
|
---|
3309 | buttonOption.state |= State_Sunken;
|
---|
3310 | buttonOption.state &= ~State_MouseOver;
|
---|
3311 | }
|
---|
3312 | proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
|
---|
3313 |
|
---|
3314 | cachePainter.setPen(buttonShadow.darker(102));
|
---|
3315 | int borderSize = 4;
|
---|
3316 |
|
---|
3317 | if (!sunken) {
|
---|
3318 | if (comboBox->direction == Qt::RightToLeft) {
|
---|
3319 | cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
|
---|
3320 | QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
|
---|
3321 | cachePainter.setPen(option->palette.light().color());
|
---|
3322 | cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
|
---|
3323 | QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
|
---|
3324 | } else {
|
---|
3325 | cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
|
---|
3326 | QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
|
---|
3327 | cachePainter.setPen(option->palette.light().color());
|
---|
3328 | cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
|
---|
3329 | QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
|
---|
3330 | }
|
---|
3331 | } else {
|
---|
3332 | cachePainter.setPen(dark.lighter(110));
|
---|
3333 | if (comboBox->direction == Qt::RightToLeft) {
|
---|
3334 | cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
|
---|
3335 | QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
|
---|
3336 |
|
---|
3337 | } else {
|
---|
3338 | cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
|
---|
3339 | QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
|
---|
3340 | }
|
---|
3341 | }
|
---|
3342 | }
|
---|
3343 |
|
---|
3344 |
|
---|
3345 | if (comboBox->subControls & SC_ComboBoxArrow) {
|
---|
3346 | if (comboBox->editable) {
|
---|
3347 | // Draw the down arrow
|
---|
3348 | QImage downArrow(qt_cleanlooks_arrow_down_xpm);
|
---|
3349 | downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
---|
3350 | cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
---|
3351 | downArrowRect.center().y() - downArrow.height() / 2 + 1, downArrow);
|
---|
3352 | } else {
|
---|
3353 | // Draw the up/down arrow
|
---|
3354 | QImage upArrow(qt_scrollbar_button_arrow_up);
|
---|
3355 | upArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
---|
3356 | QImage downArrow(qt_scrollbar_button_arrow_down);
|
---|
3357 | downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
---|
3358 | cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
---|
3359 | downArrowRect.center().y() - upArrow.height() - 1 , upArrow);
|
---|
3360 | cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
---|
3361 | downArrowRect.center().y() + 2, downArrow);
|
---|
3362 | }
|
---|
3363 | }
|
---|
3364 | // Draw the focus rect
|
---|
3365 | if (focus && !comboBox->editable
|
---|
3366 | && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) {
|
---|
3367 | QStyleOptionFocusRect focus;
|
---|
3368 | focus.rect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget)
|
---|
3369 | .adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2);
|
---|
3370 | proxy()->drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget);
|
---|
3371 | }
|
---|
3372 | cachePainter.end();
|
---|
3373 | QPixmapCache::insert(pixmapName, cache);
|
---|
3374 | }
|
---|
3375 | painter->drawPixmap(comboBox->rect.topLeft(), cache);
|
---|
3376 | }
|
---|
3377 | painter->restore();
|
---|
3378 | break;
|
---|
3379 | #endif // QT_NO_COMBOBOX
|
---|
3380 | #ifndef QT_NO_GROUPBOX
|
---|
3381 | case CC_GroupBox:
|
---|
3382 | painter->save();
|
---|
3383 | if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
---|
3384 | QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
|
---|
3385 | QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
|
---|
3386 | bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
|
---|
3387 |
|
---|
3388 | if(!flat) {
|
---|
3389 | if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
|
---|
3390 | QStyleOptionFrameV2 frame;
|
---|
3391 | frame.QStyleOption::operator=(*groupBox);
|
---|
3392 | frame.features = groupBox->features;
|
---|
3393 | frame.lineWidth = groupBox->lineWidth;
|
---|
3394 | frame.midLineWidth = groupBox->midLineWidth;
|
---|
3395 | frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
|
---|
3396 |
|
---|
3397 | painter->save();
|
---|
3398 | QRegion region(groupBox->rect);
|
---|
3399 | bool ltr = groupBox->direction == Qt::LeftToRight;
|
---|
3400 | region -= checkBoxRect.united(textRect).adjusted(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
|
---|
3401 | if (!groupBox->text.isEmpty() || groupBox->subControls & SC_GroupBoxCheckBox)
|
---|
3402 | painter->setClipRegion(region);
|
---|
3403 | frame.palette.setBrush(QPalette::Dark, option->palette.mid().color().lighter(110));
|
---|
3404 | proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter);
|
---|
3405 | painter->restore();
|
---|
3406 | }
|
---|
3407 | }
|
---|
3408 | // Draw title
|
---|
3409 | if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
|
---|
3410 | if (!groupBox->text.isEmpty()) {
|
---|
3411 | QColor textColor = groupBox->textColor;
|
---|
3412 | if (textColor.isValid())
|
---|
3413 | painter->setPen(textColor);
|
---|
3414 | int alignment = int(groupBox->textAlignment);
|
---|
3415 | if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
|
---|
3416 | alignment |= Qt::TextHideMnemonic;
|
---|
3417 | if (flat) {
|
---|
3418 | QFont font = painter->font();
|
---|
3419 | font.setBold(true);
|
---|
3420 | painter->setFont(font);
|
---|
3421 | if (groupBox->subControls & SC_GroupBoxCheckBox) {
|
---|
3422 | textRect.adjust(checkBoxRect.right() + 4, 0, checkBoxRect.right() + 4, 0);
|
---|
3423 | }
|
---|
3424 | }
|
---|
3425 | painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
|
---|
3426 | }
|
---|
3427 | }
|
---|
3428 | if (groupBox->subControls & SC_GroupBoxCheckBox) {
|
---|
3429 | QStyleOptionButton box;
|
---|
3430 | box.QStyleOption::operator=(*groupBox);
|
---|
3431 | box.rect = checkBoxRect;
|
---|
3432 | proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
|
---|
3433 | }
|
---|
3434 | }
|
---|
3435 | painter->restore();
|
---|
3436 | break;
|
---|
3437 | #endif // QT_NO_GROUPBOX
|
---|
3438 | #ifndef QT_NO_SLIDER
|
---|
3439 | case CC_Slider:
|
---|
3440 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
---|
3441 | QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
|
---|
3442 | QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
|
---|
3443 | QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
|
---|
3444 |
|
---|
3445 | bool horizontal = slider->orientation == Qt::Horizontal;
|
---|
3446 | bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
|
---|
3447 | bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
|
---|
3448 | QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
---|
3449 | QPixmap cache;
|
---|
3450 |
|
---|
3451 | QBrush oldBrush = painter->brush();
|
---|
3452 | QPen oldPen = painter->pen();
|
---|
3453 |
|
---|
3454 | QColor shadowAlpha(Qt::black);
|
---|
3455 | shadowAlpha.setAlpha(10);
|
---|
3456 | QColor highlightAlpha(Qt::white);
|
---|
3457 | highlightAlpha.setAlpha(80);
|
---|
3458 |
|
---|
3459 | if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
|
---|
3460 | QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size());
|
---|
3461 | QRect pixmapRect(0, 0, groove.width(), groove.height());
|
---|
3462 |
|
---|
3463 | // draw background groove
|
---|
3464 | if (!QPixmapCache::find(groovePixmapName, cache)) {
|
---|
3465 | cache = QPixmap(pixmapRect.size());
|
---|
3466 | cache.fill(Qt::transparent);
|
---|
3467 | QPainter groovePainter(&cache);
|
---|
3468 |
|
---|
3469 | groovePainter.setPen(shadowAlpha);
|
---|
3470 | groovePainter.drawLine(1, 0, groove.width(), 0);
|
---|
3471 | groovePainter.drawLine(0, 0, 0, groove.height() - 1);
|
---|
3472 |
|
---|
3473 | groovePainter.setPen(highlightAlpha);
|
---|
3474 | groovePainter.drawLine(1, groove.height() - 1, groove.width() - 1, groove.height() - 1);
|
---|
3475 | groovePainter.drawLine(groove.width() - 1, 1, groove.width() - 1, groove.height() - 1);
|
---|
3476 | QLinearGradient gradient;
|
---|
3477 | if (horizontal) {
|
---|
3478 | gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
|
---|
3479 | gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
|
---|
3480 | }
|
---|
3481 | else {
|
---|
3482 | gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
|
---|
3483 | gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
|
---|
3484 | }
|
---|
3485 | groovePainter.setPen(QPen(darkOutline.darker(110), 0));
|
---|
3486 | gradient.setColorAt(0, grooveColor.darker(110));//dark.lighter(120));
|
---|
3487 | gradient.setColorAt(1, grooveColor.lighter(110));//palette.button().color().darker(115));
|
---|
3488 | groovePainter.setBrush(gradient);
|
---|
3489 | groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
|
---|
3490 | groovePainter.end();
|
---|
3491 | QPixmapCache::insert(groovePixmapName, cache);
|
---|
3492 | }
|
---|
3493 | painter->drawPixmap(groove.topLeft(), cache);
|
---|
3494 |
|
---|
3495 | // draw blue groove highlight
|
---|
3496 | QRect clipRect;
|
---|
3497 | groovePixmapName += QLatin1String("_blue");
|
---|
3498 | if (!QPixmapCache::find(groovePixmapName, cache)) {
|
---|
3499 | cache = QPixmap(pixmapRect.size());
|
---|
3500 | cache.fill(Qt::transparent);
|
---|
3501 | QPainter groovePainter(&cache);
|
---|
3502 | QLinearGradient gradient;
|
---|
3503 | if (horizontal) {
|
---|
3504 | gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
|
---|
3505 | gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
|
---|
3506 | }
|
---|
3507 | else {
|
---|
3508 | gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
|
---|
3509 | gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
|
---|
3510 | }
|
---|
3511 | groovePainter.setPen(QPen(activeHighlight.darker(150), 0));
|
---|
3512 | gradient.setColorAt(0, activeHighlight.darker(120));
|
---|
3513 | gradient.setColorAt(1, activeHighlight.lighter(160));
|
---|
3514 | groovePainter.setBrush(gradient);
|
---|
3515 | groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
|
---|
3516 | groovePainter.end();
|
---|
3517 | QPixmapCache::insert(groovePixmapName, cache);
|
---|
3518 | }
|
---|
3519 | if (horizontal) {
|
---|
3520 | if (slider->upsideDown)
|
---|
3521 | clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height());
|
---|
3522 | else
|
---|
3523 | clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height());
|
---|
3524 | } else {
|
---|
3525 | if (slider->upsideDown)
|
---|
3526 | clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom());
|
---|
3527 | else
|
---|
3528 | clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top());
|
---|
3529 | }
|
---|
3530 | painter->save();
|
---|
3531 | painter->setClipRect(clipRect.adjusted(0, 0, 1, 1));
|
---|
3532 | painter->drawPixmap(groove.topLeft(), cache);
|
---|
3533 | painter->restore();
|
---|
3534 | }
|
---|
3535 |
|
---|
3536 | // draw handle
|
---|
3537 | if ((option->subControls & SC_SliderHandle) ) {
|
---|
3538 | QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
|
---|
3539 | if (!QPixmapCache::find(handlePixmapName, cache)) {
|
---|
3540 | cache = QPixmap(handle.size());
|
---|
3541 | cache.fill(Qt::transparent);
|
---|
3542 | QRect pixmapRect(0, 0, handle.width(), handle.height());
|
---|
3543 | QPainter handlePainter(&cache);
|
---|
3544 |
|
---|
3545 | QColor highlightedGradientStartColor = option->palette.button().color();
|
---|
3546 | QColor highlightedGradientStopColor = option->palette.light().color();
|
---|
3547 | QColor gradientStartColor = mergedColors(option->palette.button().color().lighter(155),
|
---|
3548 | dark.lighter(155), 50);
|
---|
3549 | QColor gradientStopColor = gradientStartColor.darker(108);
|
---|
3550 | QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);
|
---|
3551 |
|
---|
3552 | QColor gradientBgStartColor = gradientStartColor;
|
---|
3553 | QColor gradientBgStopColor = gradientStopColor;
|
---|
3554 |
|
---|
3555 | QColor outline = option->state & State_Enabled ? dark : dark.lighter(130);
|
---|
3556 | if (option->state & State_Enabled && option->activeSubControls & SC_SliderHandle) {
|
---|
3557 | gradientBgStartColor = option->palette.highlight().color().lighter(180);
|
---|
3558 | gradientBgStopColor = option->palette.highlight().color().lighter(110);
|
---|
3559 | outline = option->palette.highlight().color().darker(130);
|
---|
3560 | }
|
---|
3561 |
|
---|
3562 | // gradient fill
|
---|
3563 | QRect innerBorder = gradRect;
|
---|
3564 | QRect r = pixmapRect.adjusted(1, 1, -1, -1);
|
---|
3565 |
|
---|
3566 | qt_cleanlooks_draw_gradient(&handlePainter, gradRect,
|
---|
3567 | gradientBgStartColor,
|
---|
3568 | gradientBgStopColor,
|
---|
3569 | horizontal ? TopDown : FromLeft, option->palette.button());
|
---|
3570 |
|
---|
3571 | handlePainter.setPen(QPen(outline.darker(110), 1));
|
---|
3572 | handlePainter.drawLine(QPoint(r.left(), r.top() + 3), QPoint(r.left(), r.bottom() - 3));
|
---|
3573 | handlePainter.drawLine(QPoint(r.right(), r.top() + 3), QPoint(r.right(), r.bottom() - 3));
|
---|
3574 | handlePainter.drawLine(QPoint(r.left() + 3, r.bottom()), QPoint(r.right() - 3, r.bottom()));
|
---|
3575 |
|
---|
3576 | handlePainter.save();
|
---|
3577 | handlePainter.setRenderHint(QPainter::Antialiasing);
|
---|
3578 | handlePainter.translate(0.5, 0.5);
|
---|
3579 | const QLine lines[4] = {
|
---|
3580 | QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())),
|
---|
3581 | QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())),
|
---|
3582 | QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())),
|
---|
3583 | QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top()))
|
---|
3584 | };
|
---|
3585 | handlePainter.drawLines(lines, 4);
|
---|
3586 | handlePainter.restore();;
|
---|
3587 | handlePainter.setPen(QPen(outline.darker(130), 1));
|
---|
3588 | handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top()));
|
---|
3589 | QColor cornerAlpha = outline.darker(120);
|
---|
3590 | cornerAlpha.setAlpha(80);
|
---|
3591 |
|
---|
3592 | handlePainter.setPen(cornerAlpha);
|
---|
3593 | if (horizontal) {
|
---|
3594 | handlePainter.drawLine(QPoint(r.left() + 6, r.top()), QPoint(r.left() + 6, r.bottom()));
|
---|
3595 | handlePainter.drawLine(QPoint(r.right() - 6, r.top()), QPoint(r.right() - 6, r.bottom()));
|
---|
3596 | } else {
|
---|
3597 | handlePainter.drawLine(QPoint(r.left(), r.top() + 6), QPoint(r.right(), r.top() + 6));
|
---|
3598 | handlePainter.drawLine(QPoint(r.left(), r.bottom() - 6), QPoint(r.right(), r.bottom() - 6));
|
---|
3599 | }
|
---|
3600 |
|
---|
3601 | //handle shadow
|
---|
3602 | handlePainter.setPen(shadowAlpha);
|
---|
3603 | handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
|
---|
3604 | handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
|
---|
3605 | handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));
|
---|
3606 |
|
---|
3607 | qt_cleanlooks_draw_gradient(&handlePainter, horizontal ?
|
---|
3608 | gradRect.adjusted(6, 0, -6, 0) : gradRect.adjusted(0, 6, 0, -6),
|
---|
3609 | gradientStartColor,
|
---|
3610 | gradientStopColor.darker(106),
|
---|
3611 | horizontal ? TopDown : FromLeft,
|
---|
3612 | option->palette.button());
|
---|
3613 |
|
---|
3614 | //draw grips
|
---|
3615 | for (int i = -3; i< 6 ; i += 3) {
|
---|
3616 | for (int j = -3; j< 6 ; j += 3) {
|
---|
3617 | handlePainter.fillRect(r.center().x() + i, r.center().y() + j, 2, 2, highlightAlpha);
|
---|
3618 | handlePainter.setPen(gripShadow);
|
---|
3619 | handlePainter.drawPoint(r.center().x() + i, r.center().y() + j );
|
---|
3620 | }
|
---|
3621 | }
|
---|
3622 | handlePainter.end();
|
---|
3623 | QPixmapCache::insert(handlePixmapName, cache);
|
---|
3624 | }
|
---|
3625 |
|
---|
3626 | painter->drawPixmap(handle.topLeft(), cache);
|
---|
3627 |
|
---|
3628 | if (slider->state & State_HasFocus) {
|
---|
3629 | QStyleOptionFocusRect fropt;
|
---|
3630 | fropt.QStyleOption::operator=(*slider);
|
---|
3631 | fropt.rect = slider->rect;
|
---|
3632 | proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
|
---|
3633 | }
|
---|
3634 | }
|
---|
3635 | if (option->subControls & SC_SliderTickmarks) {
|
---|
3636 | painter->setPen(darkOutline);
|
---|
3637 | int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
|
---|
3638 | int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
|
---|
3639 | int interval = slider->tickInterval;
|
---|
3640 | if (interval <= 0) {
|
---|
3641 | interval = slider->singleStep;
|
---|
3642 | if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
|
---|
3643 | available)
|
---|
3644 | - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
|
---|
3645 | 0, available) < 3)
|
---|
3646 | interval = slider->pageStep;
|
---|
3647 | }
|
---|
3648 | if (interval <= 0)
|
---|
3649 | interval = 1;
|
---|
3650 |
|
---|
3651 | int v = slider->minimum;
|
---|
3652 | int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
|
---|
3653 | while (v <= slider->maximum + 1) {
|
---|
3654 | if (v == slider->maximum + 1 && interval == 1)
|
---|
3655 | break;
|
---|
3656 | const int v_ = qMin(v, slider->maximum);
|
---|
3657 | int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
|
---|
3658 | v_, (horizontal
|
---|
3659 | ? slider->rect.width()
|
---|
3660 | : slider->rect.height()) - len,
|
---|
3661 | slider->upsideDown) + len / 2;
|
---|
3662 | int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
|
---|
3663 |
|
---|
3664 | if (horizontal) {
|
---|
3665 | if (ticksAbove) {
|
---|
3666 | painter->drawLine(pos, slider->rect.top() + extra,
|
---|
3667 | pos, slider->rect.top() + tickSize);
|
---|
3668 | }
|
---|
3669 | if (ticksBelow) {
|
---|
3670 | painter->drawLine(pos, slider->rect.bottom() - extra,
|
---|
3671 | pos, slider->rect.bottom() - tickSize);
|
---|
3672 | }
|
---|
3673 | } else {
|
---|
3674 | if (ticksAbove) {
|
---|
3675 | painter->drawLine(slider->rect.left() + extra, pos,
|
---|
3676 | slider->rect.left() + tickSize, pos);
|
---|
3677 | }
|
---|
3678 | if (ticksBelow) {
|
---|
3679 | painter->drawLine(slider->rect.right() - extra, pos,
|
---|
3680 | slider->rect.right() - tickSize, pos);
|
---|
3681 | }
|
---|
3682 | }
|
---|
3683 | // in the case where maximum is max int
|
---|
3684 | int nextInterval = v + interval;
|
---|
3685 | if (nextInterval < v)
|
---|
3686 | break;
|
---|
3687 | v = nextInterval;
|
---|
3688 | }
|
---|
3689 | }
|
---|
3690 | painter->setBrush(oldBrush);
|
---|
3691 | painter->setPen(oldPen);
|
---|
3692 | }
|
---|
3693 | break;
|
---|
3694 | #endif // QT_NO_SLIDER
|
---|
3695 | #ifndef QT_NO_DIAL
|
---|
3696 | case CC_Dial:
|
---|
3697 | if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
|
---|
3698 | QStyleHelper::drawDial(dial, painter);
|
---|
3699 | break;
|
---|
3700 | #endif // QT_NO_DIAL
|
---|
3701 | default:
|
---|
3702 | QWindowsStyle::drawComplexControl(control, option, painter, widget);
|
---|
3703 | break;
|
---|
3704 | }
|
---|
3705 | }
|
---|
3706 |
|
---|
3707 | /*!
|
---|
3708 | \reimp
|
---|
3709 | */
|
---|
3710 | int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
---|
3711 | {
|
---|
3712 | int ret = -1;
|
---|
3713 | switch (metric) {
|
---|
3714 | case PM_ToolTipLabelFrameWidth:
|
---|
3715 | ret = 2;
|
---|
3716 | break;
|
---|
3717 | case PM_ButtonDefaultIndicator:
|
---|
3718 | ret = 0;
|
---|
3719 | break;
|
---|
3720 | case PM_ButtonShiftHorizontal:
|
---|
3721 | case PM_ButtonShiftVertical:
|
---|
3722 | ret = 0;
|
---|
3723 | break;
|
---|
3724 | case PM_MessageBoxIconSize:
|
---|
3725 | ret = 48;
|
---|
3726 | break;
|
---|
3727 | case PM_ListViewIconSize:
|
---|
3728 | ret = 24;
|
---|
3729 | break;
|
---|
3730 | case PM_DialogButtonsSeparator:
|
---|
3731 | case PM_SplitterWidth:
|
---|
3732 | ret = 6;
|
---|
3733 | break;
|
---|
3734 | case PM_ScrollBarSliderMin:
|
---|
3735 | ret = 26;
|
---|
3736 | break;
|
---|
3737 | case PM_MenuPanelWidth: //menu framewidth
|
---|
3738 | ret = 2;
|
---|
3739 | break;
|
---|
3740 | case PM_TitleBarHeight:
|
---|
3741 | ret = 24;
|
---|
3742 | break;
|
---|
3743 | case PM_ScrollBarExtent:
|
---|
3744 | ret = 15;
|
---|
3745 | break;
|
---|
3746 | case PM_SliderThickness:
|
---|
3747 | ret = 15;
|
---|
3748 | break;
|
---|
3749 | case PM_SliderLength:
|
---|
3750 | ret = 27;
|
---|
3751 | break;
|
---|
3752 | case PM_DockWidgetTitleMargin:
|
---|
3753 | ret = 1;
|
---|
3754 | break;
|
---|
3755 | case PM_MenuBarVMargin:
|
---|
3756 | ret = 1;
|
---|
3757 | break;
|
---|
3758 | case PM_DefaultFrameWidth:
|
---|
3759 | ret = 2;
|
---|
3760 | break;
|
---|
3761 | case PM_SpinBoxFrameWidth:
|
---|
3762 | ret = 3;
|
---|
3763 | break;
|
---|
3764 | case PM_MenuBarItemSpacing:
|
---|
3765 | ret = 6;
|
---|
3766 | case PM_MenuBarHMargin:
|
---|
3767 | ret = 0;
|
---|
3768 | break;
|
---|
3769 | case PM_ToolBarHandleExtent:
|
---|
3770 | ret = 9;
|
---|
3771 | break;
|
---|
3772 | case PM_ToolBarItemSpacing:
|
---|
3773 | ret = 2;
|
---|
3774 | break;
|
---|
3775 | case PM_ToolBarFrameWidth:
|
---|
3776 | ret = 0;
|
---|
3777 | break;
|
---|
3778 | case PM_ToolBarItemMargin:
|
---|
3779 | ret = 1;
|
---|
3780 | break;
|
---|
3781 | case PM_SmallIconSize:
|
---|
3782 | ret = 16;
|
---|
3783 | break;
|
---|
3784 | case PM_ButtonIconSize:
|
---|
3785 | ret = 24;
|
---|
3786 | break;
|
---|
3787 | case PM_MenuVMargin:
|
---|
3788 | case PM_MenuHMargin:
|
---|
3789 | ret = 0;
|
---|
3790 | break;
|
---|
3791 | case PM_DockWidgetTitleBarButtonMargin:
|
---|
3792 | ret = 4;
|
---|
3793 | break;
|
---|
3794 | case PM_MaximumDragDistance:
|
---|
3795 | return -1;
|
---|
3796 | case PM_TabCloseIndicatorWidth:
|
---|
3797 | case PM_TabCloseIndicatorHeight:
|
---|
3798 | return 20;
|
---|
3799 | default:
|
---|
3800 | break;
|
---|
3801 | }
|
---|
3802 |
|
---|
3803 | return ret != -1 ? ret : QWindowsStyle::pixelMetric(metric, option, widget);
|
---|
3804 | }
|
---|
3805 |
|
---|
3806 | /*!
|
---|
3807 | \reimp
|
---|
3808 | */
|
---|
3809 | QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
---|
3810 | const QSize &size, const QWidget *widget) const
|
---|
3811 | {
|
---|
3812 | QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
|
---|
3813 | switch (type) {
|
---|
3814 | case CT_PushButton:
|
---|
3815 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
---|
3816 | if (!btn->text.isEmpty() && newSize.width() < 80)
|
---|
3817 | newSize.setWidth(80);
|
---|
3818 | if (!btn->icon.isNull() && btn->iconSize.height() > 16)
|
---|
3819 | newSize -= QSize(0, 2);
|
---|
3820 | newSize += QSize(0, 1);
|
---|
3821 | }
|
---|
3822 | if (const QPushButton *button = qobject_cast<const QPushButton *>(widget)) {
|
---|
3823 | if (qobject_cast<const QDialogButtonBox *>(button->parentWidget())) {
|
---|
3824 | if (newSize.height() < 32)
|
---|
3825 | newSize.setHeight(32);
|
---|
3826 | }
|
---|
3827 | }
|
---|
3828 | break;
|
---|
3829 | #ifndef QT_NO_GROUPBOX
|
---|
3830 | case CT_GroupBox:
|
---|
3831 | // Since we use a bold font we have to recalculate base width
|
---|
3832 | if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) {
|
---|
3833 | QFont font = gb->font();
|
---|
3834 | font.setBold(true);
|
---|
3835 | QFontMetrics metrics(font);
|
---|
3836 | int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' '));
|
---|
3837 | if (gb->isCheckable()) {
|
---|
3838 | baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget);
|
---|
3839 | baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget);
|
---|
3840 | }
|
---|
3841 | newSize.setWidth(qMax(baseWidth, newSize.width()));
|
---|
3842 | }
|
---|
3843 | newSize += QSize(0, 1);
|
---|
3844 | break;
|
---|
3845 | #endif //QT_NO_GROUPBOX
|
---|
3846 | case CT_RadioButton:
|
---|
3847 | case CT_CheckBox:
|
---|
3848 | newSize += QSize(0, 1);
|
---|
3849 | break;
|
---|
3850 | case CT_ToolButton:
|
---|
3851 | #ifndef QT_NO_TOOLBAR
|
---|
3852 | if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
|
---|
3853 | newSize += QSize(4, 6);
|
---|
3854 | #endif // QT_NO_TOOLBAR
|
---|
3855 | break;
|
---|
3856 | case CT_SpinBox:
|
---|
3857 | newSize += QSize(0, -2);
|
---|
3858 | break;
|
---|
3859 | case CT_ComboBox:
|
---|
3860 | newSize += QSize(2, 4);
|
---|
3861 | break;
|
---|
3862 | case CT_LineEdit:
|
---|
3863 | newSize += QSize(0, 4);
|
---|
3864 | break;
|
---|
3865 | case CT_MenuBarItem:
|
---|
3866 | newSize += QSize(0, 2);
|
---|
3867 | break;
|
---|
3868 | case CT_MenuItem:
|
---|
3869 | if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
---|
3870 | if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
---|
3871 | if (!menuItem->text.isEmpty()) {
|
---|
3872 | newSize.setHeight(menuItem->fontMetrics.height());
|
---|
3873 | }
|
---|
3874 | }
|
---|
3875 | #ifndef QT_NO_COMBOBOX
|
---|
3876 | else if (!menuItem->icon.isNull()) {
|
---|
3877 | if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) {
|
---|
3878 | newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height()));
|
---|
3879 | }
|
---|
3880 | }
|
---|
3881 | #endif // QT_NO_COMBOBOX
|
---|
3882 | }
|
---|
3883 | break;
|
---|
3884 | case CT_SizeGrip:
|
---|
3885 | newSize += QSize(4, 4);
|
---|
3886 | break;
|
---|
3887 | case CT_MdiControls:
|
---|
3888 | if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
|
---|
3889 | int width = 0;
|
---|
3890 | if (styleOpt->subControls & SC_MdiMinButton)
|
---|
3891 | width += 19 + 1;
|
---|
3892 | if (styleOpt->subControls & SC_MdiNormalButton)
|
---|
3893 | width += 19 + 1;
|
---|
3894 | if (styleOpt->subControls & SC_MdiCloseButton)
|
---|
3895 | width += 19 + 1;
|
---|
3896 | newSize = QSize(width, 19);
|
---|
3897 | } else {
|
---|
3898 | newSize = QSize(60, 19);
|
---|
3899 | }
|
---|
3900 | break;
|
---|
3901 | default:
|
---|
3902 | break;
|
---|
3903 | }
|
---|
3904 | return newSize;
|
---|
3905 | }
|
---|
3906 |
|
---|
3907 | /*!
|
---|
3908 | \reimp
|
---|
3909 | */
|
---|
3910 | void QCleanlooksStyle::polish(QApplication *app)
|
---|
3911 | {
|
---|
3912 | QWindowsStyle::polish(app);
|
---|
3913 | }
|
---|
3914 |
|
---|
3915 | /*!
|
---|
3916 | \reimp
|
---|
3917 | */
|
---|
3918 | void QCleanlooksStyle::polish(QWidget *widget)
|
---|
3919 | {
|
---|
3920 | QWindowsStyle::polish(widget);
|
---|
3921 | if (qobject_cast<QAbstractButton*>(widget)
|
---|
3922 | #ifndef QT_NO_COMBOBOX
|
---|
3923 | || qobject_cast<QComboBox *>(widget)
|
---|
3924 | #endif
|
---|
3925 | #ifndef QT_NO_PROGRESSBAR
|
---|
3926 | || qobject_cast<QProgressBar *>(widget)
|
---|
3927 | #endif
|
---|
3928 | #ifndef QT_NO_SCROLLBAR
|
---|
3929 | || qobject_cast<QScrollBar *>(widget)
|
---|
3930 | #endif
|
---|
3931 | #ifndef QT_NO_SPLITTER
|
---|
3932 | || qobject_cast<QSplitterHandle *>(widget)
|
---|
3933 | #endif
|
---|
3934 | || qobject_cast<QAbstractSlider *>(widget)
|
---|
3935 | #ifndef QT_NO_SPINBOX
|
---|
3936 | || qobject_cast<QAbstractSpinBox *>(widget)
|
---|
3937 | #endif
|
---|
3938 | || (widget->inherits("QWorkspaceChild"))
|
---|
3939 | || (widget->inherits("QDockSeparator"))
|
---|
3940 | || (widget->inherits("QDockWidgetSeparator"))
|
---|
3941 | ) {
|
---|
3942 | widget->setAttribute(Qt::WA_Hover, true);
|
---|
3943 | }
|
---|
3944 | }
|
---|
3945 |
|
---|
3946 | /*!
|
---|
3947 | \reimp
|
---|
3948 | */
|
---|
3949 | void QCleanlooksStyle::polish(QPalette &pal)
|
---|
3950 | {
|
---|
3951 | QWindowsStyle::polish(pal);
|
---|
3952 | //this is a workaround for some themes such as Human, where the contrast
|
---|
3953 | //between text and background is too low.
|
---|
3954 | QColor highlight = pal.highlight().color();
|
---|
3955 | QColor highlightText = pal.highlightedText().color();
|
---|
3956 | if (qAbs(qGray(highlight.rgb()) - qGray(highlightText.rgb())) < 150) {
|
---|
3957 | if (qGray(highlightText.rgb()) < 128)
|
---|
3958 | pal.setBrush(QPalette::Highlight, highlight.lighter(145));
|
---|
3959 | }
|
---|
3960 | }
|
---|
3961 |
|
---|
3962 | /*!
|
---|
3963 | \reimp
|
---|
3964 | */
|
---|
3965 | void QCleanlooksStyle::unpolish(QWidget *widget)
|
---|
3966 | {
|
---|
3967 | QWindowsStyle::unpolish(widget);
|
---|
3968 | if (qobject_cast<QAbstractButton*>(widget)
|
---|
3969 | #ifndef QT_NO_COMBOBOX
|
---|
3970 | || qobject_cast<QComboBox *>(widget)
|
---|
3971 | #endif
|
---|
3972 | #ifndef QT_NO_PROGRESSBAR
|
---|
3973 | || qobject_cast<QProgressBar *>(widget)
|
---|
3974 | #endif
|
---|
3975 | #ifndef QT_NO_SCROLLBAR
|
---|
3976 | || qobject_cast<QScrollBar *>(widget)
|
---|
3977 | #endif
|
---|
3978 | #ifndef QT_NO_SPLITTER
|
---|
3979 | || qobject_cast<QSplitterHandle *>(widget)
|
---|
3980 | #endif
|
---|
3981 | || qobject_cast<QAbstractSlider *>(widget)
|
---|
3982 | #ifndef QT_NO_SPINBOX
|
---|
3983 | || qobject_cast<QAbstractSpinBox *>(widget)
|
---|
3984 | #endif
|
---|
3985 | || (widget->inherits("QWorkspaceChild"))
|
---|
3986 | || (widget->inherits("QDockSeparator"))
|
---|
3987 | || (widget->inherits("QDockWidgetSeparator"))
|
---|
3988 | ) {
|
---|
3989 | widget->setAttribute(Qt::WA_Hover, false);
|
---|
3990 | }
|
---|
3991 | }
|
---|
3992 |
|
---|
3993 | /*!
|
---|
3994 | \reimp
|
---|
3995 | */
|
---|
3996 | void QCleanlooksStyle::unpolish(QApplication *app)
|
---|
3997 | {
|
---|
3998 | QWindowsStyle::unpolish(app);
|
---|
3999 | }
|
---|
4000 |
|
---|
4001 | /*!
|
---|
4002 | \reimp
|
---|
4003 | */
|
---|
4004 | QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
---|
4005 | SubControl subControl, const QWidget *widget) const
|
---|
4006 | {
|
---|
4007 | QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
|
---|
4008 |
|
---|
4009 | switch (control) {
|
---|
4010 | #ifndef QT_NO_SLIDER
|
---|
4011 | case CC_Slider:
|
---|
4012 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
---|
4013 | int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
|
---|
4014 | switch (subControl) {
|
---|
4015 | case SC_SliderHandle: {
|
---|
4016 | if (slider->orientation == Qt::Horizontal) {
|
---|
4017 | rect.setHeight(proxy()->pixelMetric(PM_SliderThickness));
|
---|
4018 | rect.setWidth(proxy()->pixelMetric(PM_SliderLength));
|
---|
4019 | int centerY = slider->rect.center().y() - rect.height() / 2;
|
---|
4020 | if (slider->tickPosition & QSlider::TicksAbove)
|
---|
4021 | centerY += tickSize;
|
---|
4022 | if (slider->tickPosition & QSlider::TicksBelow)
|
---|
4023 | centerY -= tickSize;
|
---|
4024 | rect.moveTop(centerY);
|
---|
4025 | } else {
|
---|
4026 | rect.setWidth(proxy()->pixelMetric(PM_SliderThickness));
|
---|
4027 | rect.setHeight(proxy()->pixelMetric(PM_SliderLength));
|
---|
4028 | int centerX = slider->rect.center().x() - rect.width() / 2;
|
---|
4029 | if (slider->tickPosition & QSlider::TicksAbove)
|
---|
4030 | centerX += tickSize;
|
---|
4031 | if (slider->tickPosition & QSlider::TicksBelow)
|
---|
4032 | centerX -= tickSize;
|
---|
4033 | rect.moveLeft(centerX);
|
---|
4034 | }
|
---|
4035 | }
|
---|
4036 | break;
|
---|
4037 | case SC_SliderGroove: {
|
---|
4038 | QPoint grooveCenter = slider->rect.center();
|
---|
4039 | if (slider->orientation == Qt::Horizontal) {
|
---|
4040 | rect.setHeight(7);
|
---|
4041 | if (slider->tickPosition & QSlider::TicksAbove)
|
---|
4042 | grooveCenter.ry() += tickSize;
|
---|
4043 | if (slider->tickPosition & QSlider::TicksBelow)
|
---|
4044 | grooveCenter.ry() -= tickSize;
|
---|
4045 | } else {
|
---|
4046 | rect.setWidth(7);
|
---|
4047 | if (slider->tickPosition & QSlider::TicksAbove)
|
---|
4048 | grooveCenter.rx() += tickSize;
|
---|
4049 | if (slider->tickPosition & QSlider::TicksBelow)
|
---|
4050 | grooveCenter.rx() -= tickSize;
|
---|
4051 | }
|
---|
4052 | rect.moveCenter(grooveCenter);
|
---|
4053 | break;
|
---|
4054 | }
|
---|
4055 | default:
|
---|
4056 | break;
|
---|
4057 | }
|
---|
4058 | }
|
---|
4059 | break;
|
---|
4060 | #endif // QT_NO_SLIDER
|
---|
4061 | case CC_ScrollBar:
|
---|
4062 | break;
|
---|
4063 | #ifndef QT_NO_SPINBOX
|
---|
4064 | case CC_SpinBox:
|
---|
4065 | if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
---|
4066 | QSize bs;
|
---|
4067 | int center = spinbox->rect.height() / 2;
|
---|
4068 | int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
|
---|
4069 | int y = fw;
|
---|
4070 | bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
|
---|
4071 | bs.setWidth(15);
|
---|
4072 | int x, lx, rx;
|
---|
4073 | x = spinbox->rect.width() - y - bs.width() + 2;
|
---|
4074 | lx = fw;
|
---|
4075 | rx = x - fw;
|
---|
4076 | switch (subControl) {
|
---|
4077 | case SC_SpinBoxUp:
|
---|
4078 | if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
|
---|
4079 | return QRect();
|
---|
4080 | rect = QRect(x, fw, bs.width(), center - fw);
|
---|
4081 | break;
|
---|
4082 | case SC_SpinBoxDown:
|
---|
4083 | if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
|
---|
4084 | return QRect();
|
---|
4085 |
|
---|
4086 | rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - fw + 1);
|
---|
4087 | break;
|
---|
4088 | case SC_SpinBoxEditField:
|
---|
4089 | if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
|
---|
4090 | rect = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
|
---|
4091 | } else {
|
---|
4092 | rect = QRect(lx, fw, rx - qMax(fw - 1, 0), spinbox->rect.height() - 2*fw);
|
---|
4093 | }
|
---|
4094 | break;
|
---|
4095 | case SC_SpinBoxFrame:
|
---|
4096 | rect = spinbox->rect;
|
---|
4097 | default:
|
---|
4098 | break;
|
---|
4099 | }
|
---|
4100 | rect = visualRect(spinbox->direction, spinbox->rect, rect);
|
---|
4101 | }
|
---|
4102 | break;
|
---|
4103 | #endif // Qt_NO_SPINBOX
|
---|
4104 | #ifndef QT_NO_GROUPBOX
|
---|
4105 | case CC_GroupBox:
|
---|
4106 | if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
---|
4107 | int topMargin = 0;
|
---|
4108 | int topHeight = 0;
|
---|
4109 | int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
|
---|
4110 | bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
|
---|
4111 | if (!groupBox->text.isEmpty()) {
|
---|
4112 | topHeight = groupBox->fontMetrics.height();
|
---|
4113 | if (verticalAlignment & Qt::AlignVCenter)
|
---|
4114 | topMargin = topHeight / 2;
|
---|
4115 | else if (verticalAlignment & Qt::AlignTop)
|
---|
4116 | topMargin = topHeight;
|
---|
4117 | }
|
---|
4118 | QRect frameRect = groupBox->rect;
|
---|
4119 | frameRect.setTop(topMargin);
|
---|
4120 | if (subControl == SC_GroupBoxFrame) {
|
---|
4121 | return rect;
|
---|
4122 | }
|
---|
4123 | else if (subControl == SC_GroupBoxContents) {
|
---|
4124 | if( flat ) {
|
---|
4125 | int margin = 0;
|
---|
4126 | int leftMarginExtension = 16;
|
---|
4127 | rect = frameRect.adjusted(leftMarginExtension + margin, margin + topHeight, -margin, -margin);
|
---|
4128 | }
|
---|
4129 | break;
|
---|
4130 | }
|
---|
4131 | if(flat) {
|
---|
4132 | if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
|
---|
4133 | //Prepare metrics for a bold font
|
---|
4134 | QFont font = widget->font();
|
---|
4135 | font.setBold(true);
|
---|
4136 | QFontMetrics fontMetrics(font);
|
---|
4137 |
|
---|
4138 | QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(2, 2);
|
---|
4139 | if (subControl == SC_GroupBoxCheckBox) {
|
---|
4140 | int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
|
---|
4141 | int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
|
---|
4142 | rect.setWidth(indicatorWidth);
|
---|
4143 | rect.setHeight(indicatorHeight);
|
---|
4144 | rect.moveTop((fontMetrics.height() - indicatorHeight) / 2 + 2);
|
---|
4145 | } else if (subControl == SC_GroupBoxLabel) {
|
---|
4146 | rect.setSize(textRect);
|
---|
4147 | }
|
---|
4148 | }
|
---|
4149 | }
|
---|
4150 | }
|
---|
4151 | return rect;
|
---|
4152 | #ifndef QT_NO_COMBOBOX
|
---|
4153 | case CC_ComboBox:
|
---|
4154 | switch (subControl) {
|
---|
4155 | case SC_ComboBoxArrow:
|
---|
4156 | rect = visualRect(option->direction, option->rect, rect);
|
---|
4157 | rect.setRect(rect.right() - 18, rect.top() - 2,
|
---|
4158 | 19, rect.height() + 4);
|
---|
4159 | rect = visualRect(option->direction, option->rect, rect);
|
---|
4160 | break;
|
---|
4161 | case SC_ComboBoxEditField: {
|
---|
4162 | int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
|
---|
4163 | rect = visualRect(option->direction, option->rect, rect);
|
---|
4164 | rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
|
---|
4165 | option->rect.width() - 19 - 2 * frameWidth,
|
---|
4166 | option->rect.height() - 2 * frameWidth);
|
---|
4167 | if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
---|
4168 | if (!box->editable) {
|
---|
4169 | rect.adjust(2, 0, 0, 0);
|
---|
4170 | if (box->state & (State_Sunken | State_On))
|
---|
4171 | rect.translate(1, 1);
|
---|
4172 | }
|
---|
4173 | }
|
---|
4174 | rect = visualRect(option->direction, option->rect, rect);
|
---|
4175 | break;
|
---|
4176 | }
|
---|
4177 | default:
|
---|
4178 | break;
|
---|
4179 | }
|
---|
4180 | break;
|
---|
4181 | #endif // QT_NO_COMBOBOX
|
---|
4182 | #endif //QT_NO_GROUPBOX
|
---|
4183 | case CC_TitleBar:
|
---|
4184 | if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
|
---|
4185 | SubControl sc = subControl;
|
---|
4186 | QRect &ret = rect;
|
---|
4187 | const int indent = 3;
|
---|
4188 | const int controlTopMargin = 3;
|
---|
4189 | const int controlBottomMargin = 3;
|
---|
4190 | const int controlWidthMargin = 2;
|
---|
4191 | const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ;
|
---|
4192 | const int delta = controlHeight + controlWidthMargin;
|
---|
4193 | int offset = 0;
|
---|
4194 |
|
---|
4195 | bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
|
---|
4196 | bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
|
---|
4197 |
|
---|
4198 | switch (sc) {
|
---|
4199 | case SC_TitleBarLabel:
|
---|
4200 | if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
|
---|
4201 | ret = tb->rect;
|
---|
4202 | if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
|
---|
4203 | ret.adjust(delta, 0, -delta, 0);
|
---|
4204 | if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
|
---|
4205 | ret.adjust(0, 0, -delta, 0);
|
---|
4206 | if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
|
---|
4207 | ret.adjust(0, 0, -delta, 0);
|
---|
4208 | if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
|
---|
4209 | ret.adjust(0, 0, -delta, 0);
|
---|
4210 | if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
|
---|
4211 | ret.adjust(0, 0, -delta, 0);
|
---|
4212 | }
|
---|
4213 | break;
|
---|
4214 | case SC_TitleBarContextHelpButton:
|
---|
4215 | if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
|
---|
4216 | offset += delta;
|
---|
4217 | case SC_TitleBarMinButton:
|
---|
4218 | if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
|
---|
4219 | offset += delta;
|
---|
4220 | else if (sc == SC_TitleBarMinButton)
|
---|
4221 | break;
|
---|
4222 | case SC_TitleBarNormalButton:
|
---|
4223 | if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
|
---|
4224 | offset += delta;
|
---|
4225 | else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
|
---|
4226 | offset += delta;
|
---|
4227 | else if (sc == SC_TitleBarNormalButton)
|
---|
4228 | break;
|
---|
4229 | case SC_TitleBarMaxButton:
|
---|
4230 | if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
|
---|
4231 | offset += delta;
|
---|
4232 | else if (sc == SC_TitleBarMaxButton)
|
---|
4233 | break;
|
---|
4234 | case SC_TitleBarShadeButton:
|
---|
4235 | if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
|
---|
4236 | offset += delta;
|
---|
4237 | else if (sc == SC_TitleBarShadeButton)
|
---|
4238 | break;
|
---|
4239 | case SC_TitleBarUnshadeButton:
|
---|
4240 | if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
|
---|
4241 | offset += delta;
|
---|
4242 | else if (sc == SC_TitleBarUnshadeButton)
|
---|
4243 | break;
|
---|
4244 | case SC_TitleBarCloseButton:
|
---|
4245 | if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
|
---|
4246 | offset += delta;
|
---|
4247 | else if (sc == SC_TitleBarCloseButton)
|
---|
4248 | break;
|
---|
4249 | ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
|
---|
4250 | controlHeight, controlHeight);
|
---|
4251 | break;
|
---|
4252 | case SC_TitleBarSysMenu:
|
---|
4253 | if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
|
---|
4254 | ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
|
---|
4255 | controlHeight, controlHeight);
|
---|
4256 | }
|
---|
4257 | break;
|
---|
4258 | default:
|
---|
4259 | break;
|
---|
4260 | }
|
---|
4261 | ret = visualRect(tb->direction, tb->rect, ret);
|
---|
4262 | }
|
---|
4263 | break;
|
---|
4264 | default:
|
---|
4265 | break;
|
---|
4266 | }
|
---|
4267 |
|
---|
4268 | return rect;
|
---|
4269 | }
|
---|
4270 |
|
---|
4271 |
|
---|
4272 | /*!
|
---|
4273 | \reimp
|
---|
4274 | */
|
---|
4275 | QRect QCleanlooksStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
|
---|
4276 | {
|
---|
4277 | return QWindowsStyle::itemPixmapRect(r, flags, pixmap);
|
---|
4278 | }
|
---|
4279 |
|
---|
4280 | /*!
|
---|
4281 | \reimp
|
---|
4282 | */
|
---|
4283 | void QCleanlooksStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
|
---|
4284 | int alignment, const QPixmap &pixmap) const
|
---|
4285 | {
|
---|
4286 | QWindowsStyle::drawItemPixmap(painter, rect, alignment, pixmap);
|
---|
4287 | }
|
---|
4288 |
|
---|
4289 | /*!
|
---|
4290 | \reimp
|
---|
4291 | */
|
---|
4292 | QStyle::SubControl QCleanlooksStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
|
---|
4293 | const QPoint &pt, const QWidget *w) const
|
---|
4294 | {
|
---|
4295 | return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
|
---|
4296 | }
|
---|
4297 |
|
---|
4298 | /*!
|
---|
4299 | \reimp
|
---|
4300 | */
|
---|
4301 | QPixmap QCleanlooksStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
---|
4302 | const QStyleOption *opt) const
|
---|
4303 | {
|
---|
4304 | return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
---|
4305 | }
|
---|
4306 |
|
---|
4307 | /*!
|
---|
4308 | \reimp
|
---|
4309 | */
|
---|
4310 | int QCleanlooksStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
---|
4311 | QStyleHintReturn *returnData) const
|
---|
4312 | {
|
---|
4313 | int ret = 0;
|
---|
4314 | switch (hint) {
|
---|
4315 | case SH_ScrollBar_MiddleClickAbsolutePosition:
|
---|
4316 | ret = true;
|
---|
4317 | break;
|
---|
4318 | case SH_EtchDisabledText:
|
---|
4319 | ret = 1;
|
---|
4320 | break;
|
---|
4321 | case SH_Menu_AllowActiveAndDisabled:
|
---|
4322 | ret = false;
|
---|
4323 | break;
|
---|
4324 | case SH_MainWindow_SpaceBelowMenuBar:
|
---|
4325 | ret = 0;
|
---|
4326 | break;
|
---|
4327 | case SH_MenuBar_MouseTracking:
|
---|
4328 | ret = 1;
|
---|
4329 | break;
|
---|
4330 | case SH_TitleBar_AutoRaise:
|
---|
4331 | ret = 1;
|
---|
4332 | break;
|
---|
4333 | case SH_TitleBar_NoBorder:
|
---|
4334 | ret = 1;
|
---|
4335 | break;
|
---|
4336 | case SH_ItemView_ShowDecorationSelected:
|
---|
4337 | ret = true;
|
---|
4338 | break;
|
---|
4339 | case SH_Table_GridLineColor:
|
---|
4340 | if (option) {
|
---|
4341 | ret = option->palette.background().color().darker(120).rgb();
|
---|
4342 | break;
|
---|
4343 | }
|
---|
4344 | case SH_ComboBox_Popup:
|
---|
4345 | #ifdef QT3_SUPPORT
|
---|
4346 | if (widget && widget->inherits("Q3ComboBox"))
|
---|
4347 | return 0;
|
---|
4348 | #endif
|
---|
4349 | if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
|
---|
4350 | ret = !cmb->editable;
|
---|
4351 | else
|
---|
4352 | ret = 0;
|
---|
4353 | break;
|
---|
4354 | case SH_WindowFrame_Mask:
|
---|
4355 | ret = 1;
|
---|
4356 | if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
|
---|
4357 | //left rounded corner
|
---|
4358 | mask->region = option->rect;
|
---|
4359 | mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1);
|
---|
4360 | mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1);
|
---|
4361 | mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1);
|
---|
4362 | mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2);
|
---|
4363 |
|
---|
4364 | //right rounded corner
|
---|
4365 | mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1);
|
---|
4366 | mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1);
|
---|
4367 | mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1);
|
---|
4368 | mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2);
|
---|
4369 | }
|
---|
4370 | break;
|
---|
4371 | case SH_MessageBox_TextInteractionFlags:
|
---|
4372 | ret = Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;
|
---|
4373 | break;
|
---|
4374 | case SH_DialogButtonBox_ButtonsHaveIcons:
|
---|
4375 | ret = true;
|
---|
4376 | break;
|
---|
4377 | case SH_MessageBox_CenterButtons:
|
---|
4378 | ret = false;
|
---|
4379 | break;
|
---|
4380 | #ifndef QT_NO_WIZARD
|
---|
4381 | case SH_WizardStyle:
|
---|
4382 | ret = QWizard::ClassicStyle;
|
---|
4383 | break;
|
---|
4384 | #endif
|
---|
4385 | case SH_ItemView_ArrowKeysNavigateIntoChildren:
|
---|
4386 | ret = false;
|
---|
4387 | break;
|
---|
4388 | case SH_Menu_SubMenuPopupDelay:
|
---|
4389 | ret = 225; // default from GtkMenu
|
---|
4390 | break;
|
---|
4391 | default:
|
---|
4392 | ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
|
---|
4393 | break;
|
---|
4394 | }
|
---|
4395 | return ret;
|
---|
4396 | }
|
---|
4397 |
|
---|
4398 | /*! \reimp */
|
---|
4399 | QRect QCleanlooksStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
|
---|
4400 | {
|
---|
4401 | QRect r = QWindowsStyle::subElementRect(sr, opt, w);
|
---|
4402 | switch (sr) {
|
---|
4403 | case SE_PushButtonFocusRect:
|
---|
4404 | r.adjust(0, 1, 0, -1);
|
---|
4405 | break;
|
---|
4406 | case SE_DockWidgetTitleBarText: {
|
---|
4407 | const QStyleOptionDockWidgetV2 *v2
|
---|
4408 | = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
|
---|
4409 | bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
---|
4410 | if (verticalTitleBar) {
|
---|
4411 | r.adjust(0, 0, 0, -4);
|
---|
4412 | } else {
|
---|
4413 | if (opt->direction == Qt::LeftToRight)
|
---|
4414 | r.adjust(4, 0, 0, 0);
|
---|
4415 | else
|
---|
4416 | r.adjust(0, 0, -4, 0);
|
---|
4417 | }
|
---|
4418 |
|
---|
4419 | break;
|
---|
4420 | }
|
---|
4421 | case SE_ProgressBarContents:
|
---|
4422 | r = subElementRect(SE_ProgressBarGroove, opt, w);
|
---|
4423 | break;
|
---|
4424 | default:
|
---|
4425 | break;
|
---|
4426 | }
|
---|
4427 | return r;
|
---|
4428 | }
|
---|
4429 |
|
---|
4430 | /*!
|
---|
4431 | \internal
|
---|
4432 | */
|
---|
4433 | QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon,
|
---|
4434 | const QStyleOption *option,
|
---|
4435 | const QWidget *widget) const
|
---|
4436 | {
|
---|
4437 | return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
|
---|
4438 | }
|
---|
4439 |
|
---|
4440 | /*!
|
---|
4441 | \reimp
|
---|
4442 | */
|
---|
4443 | QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
---|
4444 | const QWidget *widget) const
|
---|
4445 | {
|
---|
4446 | QPixmap pixmap;
|
---|
4447 |
|
---|
4448 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
---|
4449 | switch (standardPixmap) {
|
---|
4450 | case SP_TitleBarNormalButton:
|
---|
4451 | return QPixmap((const char **)dock_widget_restore_xpm);
|
---|
4452 | case SP_TitleBarMinButton:
|
---|
4453 | return QPixmap((const char **)workspace_minimize);
|
---|
4454 | case SP_TitleBarCloseButton:
|
---|
4455 | case SP_DockWidgetCloseButton:
|
---|
4456 | return QPixmap((const char **)dock_widget_close_xpm);
|
---|
4457 |
|
---|
4458 | default:
|
---|
4459 | break;
|
---|
4460 | }
|
---|
4461 | #endif //QT_NO_IMAGEFORMAT_XPM
|
---|
4462 |
|
---|
4463 | return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
|
---|
4464 | }
|
---|
4465 |
|
---|
4466 | QT_END_NAMESPACE
|
---|
4467 |
|
---|
4468 | #endif // QT_NO_STYLE_CLEANLOOKS || QT_PLUGIN
|
---|