0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 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 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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 <private/qstylehelper_p.h>
|
|
48 |
#include "qwindowsstyle_p.h"
|
|
49 |
#include <qcombobox.h>
|
|
50 |
#include <qpushbutton.h>
|
|
51 |
#include <qpainter.h>
|
|
52 |
#include <qdir.h>
|
|
53 |
#include <qhash.h>
|
|
54 |
#include <qstyleoption.h>
|
|
55 |
#include <qapplication.h>
|
|
56 |
#include <qmainwindow.h>
|
|
57 |
#include <qfont.h>
|
|
58 |
#include <qgroupbox.h>
|
|
59 |
#include <qprocess.h>
|
|
60 |
#include <qpixmapcache.h>
|
|
61 |
#include <qdialogbuttonbox.h>
|
|
62 |
#include <qscrollbar.h>
|
|
63 |
#include <qspinbox.h>
|
|
64 |
#include <qslider.h>
|
|
65 |
#include <qsplitter.h>
|
|
66 |
#include <qprogressbar.h>
|
|
67 |
#include <qtoolbar.h>
|
|
68 |
#include <qwizard.h>
|
|
69 |
#include <qlibrary.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_LINEDIT
|
|
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 |
QColor highlightText = option->palette.highlightedText().color();
|
|
1401 |
|
|
1402 |
switch(element) {
|
|
1403 |
case CE_RadioButton: //fall through
|
|
1404 |
case CE_CheckBox:
|
|
1405 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|
1406 |
bool hover = (btn->state & State_MouseOver && btn->state & State_Enabled);
|
|
1407 |
if (hover)
|
|
1408 |
painter->fillRect(rect, btn->palette.background().color().lighter(104));
|
|
1409 |
QStyleOptionButton copy = *btn;
|
|
1410 |
copy.rect.adjust(2, 0, -2, 0);
|
|
1411 |
QWindowsStyle::drawControl(element, ©, painter, widget);
|
|
1412 |
}
|
|
1413 |
break;
|
|
1414 |
case CE_Splitter:
|
|
1415 |
painter->save();
|
|
1416 |
{
|
|
1417 |
// hover appearance
|
|
1418 |
QBrush fillColor = option->palette.background().color();
|
|
1419 |
if (option->state & State_MouseOver && option->state & State_Enabled)
|
|
1420 |
fillColor = fillColor.color().lighter(106);
|
|
1421 |
|
|
1422 |
painter->fillRect(option->rect, fillColor);
|
|
1423 |
|
|
1424 |
QColor grooveColor = mergedColors(dark.lighter(110), option->palette.button().color(),40);
|
|
1425 |
QColor gripShadow = grooveColor.darker(110);
|
|
1426 |
QPalette palette = option->palette;
|
|
1427 |
bool vertical = !(option->state & State_Horizontal);
|
|
1428 |
QRect scrollBarSlider = option->rect;
|
|
1429 |
int gripMargin = 4;
|
|
1430 |
//draw grips
|
|
1431 |
if (vertical) {
|
|
1432 |
for( int i = -20; i< 20 ; i += 2) {
|
|
1433 |
painter->setPen(QPen(gripShadow, 1));
|
|
1434 |
painter->drawLine(
|
|
1435 |
QPoint(scrollBarSlider.center().x() + i ,
|
|
1436 |
scrollBarSlider.top() + gripMargin),
|
|
1437 |
QPoint(scrollBarSlider.center().x() + i,
|
|
1438 |
scrollBarSlider.bottom() - gripMargin));
|
|
1439 |
painter->setPen(QPen(palette.light(), 1));
|
|
1440 |
painter->drawLine(
|
|
1441 |
QPoint(scrollBarSlider.center().x() + i + 1,
|
|
1442 |
scrollBarSlider.top() + gripMargin ),
|
|
1443 |
QPoint(scrollBarSlider.center().x() + i + 1,
|
|
1444 |
scrollBarSlider.bottom() - gripMargin));
|
|
1445 |
}
|
|
1446 |
} else {
|
|
1447 |
for (int i = -20; i < 20 ; i += 2) {
|
|
1448 |
painter->setPen(QPen(gripShadow, 1));
|
|
1449 |
painter->drawLine(
|
|
1450 |
QPoint(scrollBarSlider.left() + gripMargin ,
|
|
1451 |
scrollBarSlider.center().y()+ i),
|
|
1452 |
QPoint(scrollBarSlider.right() - gripMargin,
|
|
1453 |
scrollBarSlider.center().y()+ i));
|
|
1454 |
painter->setPen(QPen(palette.light(), 1));
|
|
1455 |
painter->drawLine(
|
|
1456 |
QPoint(scrollBarSlider.left() + gripMargin,
|
|
1457 |
scrollBarSlider.center().y() + 1 + i),
|
|
1458 |
QPoint(scrollBarSlider.right() - gripMargin,
|
|
1459 |
scrollBarSlider.center().y() + 1 + i));
|
|
1460 |
|
|
1461 |
}
|
|
1462 |
}
|
|
1463 |
}
|
|
1464 |
painter->restore();
|
|
1465 |
break;
|
|
1466 |
#ifndef QT_NO_SIZEGRIP
|
|
1467 |
case CE_SizeGrip:
|
|
1468 |
painter->save();
|
|
1469 |
{
|
|
1470 |
int x, y, w, h;
|
|
1471 |
option->rect.getRect(&x, &y, &w, &h);
|
|
1472 |
int sw = qMin(h, w);
|
|
1473 |
if (h > w)
|
|
1474 |
painter->translate(0, h - w);
|
|
1475 |
else
|
|
1476 |
painter->translate(w - h, 0);
|
|
1477 |
|
|
1478 |
int sx = x;
|
|
1479 |
int sy = y;
|
|
1480 |
int s = 4;
|
|
1481 |
if (option->direction == Qt::RightToLeft) {
|
|
1482 |
sx = x + sw;
|
|
1483 |
for (int i = 0; i < 4; ++i) {
|
|
1484 |
painter->setPen(QPen(option->palette.light().color(), 1));
|
|
1485 |
painter->drawLine(x, sy - 1 , sx + 1, sw);
|
|
1486 |
painter->setPen(QPen(dark.lighter(120), 1));
|
|
1487 |
painter->drawLine(x, sy, sx, sw);
|
|
1488 |
sx -= s;
|
|
1489 |
sy += s;
|
|
1490 |
}
|
|
1491 |
} else {
|
|
1492 |
for (int i = 0; i < 4; ++i) {
|
|
1493 |
painter->setPen(QPen(option->palette.light().color(), 1));
|
|
1494 |
painter->drawLine(sx - 1, sw, sw, sy - 1);
|
|
1495 |
painter->setPen(QPen(dark.lighter(120), 1));
|
|
1496 |
painter->drawLine(sx, sw, sw, sy);
|
|
1497 |
sx += s;
|
|
1498 |
sy += s;
|
|
1499 |
}
|
|
1500 |
}
|
|
1501 |
}
|
|
1502 |
painter->restore();
|
|
1503 |
break;
|
|
1504 |
#endif // QT_NO_SIZEGRIP
|
|
1505 |
#ifndef QT_NO_TOOLBAR
|
|
1506 |
case CE_ToolBar:
|
|
1507 |
painter->save();
|
|
1508 |
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
|
|
1509 |
QRect rect = option->rect;
|
|
1510 |
|
|
1511 |
bool paintLeftBorder = true;
|
|
1512 |
bool paintRightBorder = true;
|
|
1513 |
bool paintBottomBorder = true;
|
|
1514 |
|
|
1515 |
switch (toolbar->toolBarArea) {
|
|
1516 |
case Qt::BottomToolBarArea:
|
|
1517 |
switch(toolbar->positionOfLine) {
|
|
1518 |
case QStyleOptionToolBar::Beginning:
|
|
1519 |
case QStyleOptionToolBar::OnlyOne:
|
|
1520 |
paintBottomBorder = false;
|
|
1521 |
default:
|
|
1522 |
break;
|
|
1523 |
}
|
|
1524 |
case Qt::TopToolBarArea:
|
|
1525 |
switch (toolbar->positionWithinLine) {
|
|
1526 |
case QStyleOptionToolBar::Beginning:
|
|
1527 |
paintLeftBorder = false;
|
|
1528 |
break;
|
|
1529 |
case QStyleOptionToolBar::End:
|
|
1530 |
paintRightBorder = false;
|
|
1531 |
break;
|
|
1532 |
case QStyleOptionToolBar::OnlyOne:
|
|
1533 |
paintRightBorder = false;
|
|
1534 |
paintLeftBorder = false;
|
|
1535 |
default:
|
|
1536 |
break;
|
|
1537 |
}
|
|
1538 |
if (toolbar->direction == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end
|
|
1539 |
bool tmp = paintLeftBorder;
|
|
1540 |
paintRightBorder=paintLeftBorder;
|
|
1541 |
paintLeftBorder=tmp;
|
|
1542 |
}
|
|
1543 |
break;
|
|
1544 |
case Qt::RightToolBarArea:
|
|
1545 |
switch (toolbar->positionOfLine) {
|
|
1546 |
case QStyleOptionToolBar::Beginning:
|
|
1547 |
case QStyleOptionToolBar::OnlyOne:
|
|
1548 |
paintRightBorder = false;
|
|
1549 |
break;
|
|
1550 |
default:
|
|
1551 |
break;
|
|
1552 |
}
|
|
1553 |
break;
|
|
1554 |
case Qt::LeftToolBarArea:
|
|
1555 |
switch (toolbar->positionOfLine) {
|
|
1556 |
case QStyleOptionToolBar::Beginning:
|
|
1557 |
case QStyleOptionToolBar::OnlyOne:
|
|
1558 |
paintLeftBorder = false;
|
|
1559 |
break;
|
|
1560 |
default:
|
|
1561 |
break;
|
|
1562 |
}
|
|
1563 |
break;
|
|
1564 |
default:
|
|
1565 |
break;
|
|
1566 |
}
|
|
1567 |
|
|
1568 |
QColor light = option->palette.background().color().lighter(110);
|
|
1569 |
|
|
1570 |
//draw top border
|
|
1571 |
painter->setPen(QPen(light));
|
|
1572 |
painter->drawLine(rect.topLeft().x(),
|
|
1573 |
rect.topLeft().y(),
|
|
1574 |
rect.topRight().x(),
|
|
1575 |
rect.topRight().y());
|
|
1576 |
|
|
1577 |
if (paintLeftBorder) {
|
|
1578 |
painter->setPen(QPen(light));
|
|
1579 |
painter->drawLine(rect.topLeft().x(),
|
|
1580 |
rect.topLeft().y(),
|
|
1581 |
rect.bottomLeft().x(),
|
|
1582 |
rect.bottomLeft().y());
|
|
1583 |
}
|
|
1584 |
|
|
1585 |
if (paintRightBorder) {
|
|
1586 |
painter->setPen(QPen(shadow));
|
|
1587 |
painter->drawLine(rect.topRight().x(),
|
|
1588 |
rect.topRight().y(),
|
|
1589 |
rect.bottomRight().x(),
|
|
1590 |
rect.bottomRight().y());
|
|
1591 |
}
|
|
1592 |
|
|
1593 |
if (paintBottomBorder) {
|
|
1594 |
painter->setPen(QPen(shadow));
|
|
1595 |
painter->drawLine(rect.bottomLeft().x(),
|
|
1596 |
rect.bottomLeft().y(),
|
|
1597 |
rect.bottomRight().x(),
|
|
1598 |
rect.bottomRight().y());
|
|
1599 |
}
|
|
1600 |
}
|
|
1601 |
painter->restore();
|
|
1602 |
break;
|
|
1603 |
#endif // QT_NO_TOOLBAR
|
|
1604 |
#ifndef QT_NO_DOCKWIDGET
|
|
1605 |
case CE_DockWidgetTitle:
|
|
1606 |
painter->save();
|
|
1607 |
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
|
|
1608 |
const QStyleOptionDockWidgetV2 *v2
|
|
1609 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
|
|
1610 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
|
1611 |
|
|
1612 |
QRect rect = dwOpt->rect;
|
|
1613 |
QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
|
|
1614 |
QRect r = rect.adjusted(0, 0, -1, 0);
|
|
1615 |
if (verticalTitleBar)
|
|
1616 |
r.adjust(0, 0, 0, -1);
|
|
1617 |
painter->setPen(option->palette.light().color());
|
|
1618 |
painter->drawRect(r.adjusted(1, 1, 1, 1));
|
|
1619 |
painter->setPen(shadow);
|
|
1620 |
painter->drawRect(r);
|
|
1621 |
|
|
1622 |
if (verticalTitleBar) {
|
|
1623 |
QRect r = rect;
|
|
1624 |
QSize s = r.size();
|
|
1625 |
s.transpose();
|
|
1626 |
r.setSize(s);
|
|
1627 |
|
|
1628 |
titleRect = QRect(r.left() + rect.bottom()
|
|
1629 |
- titleRect.bottom(),
|
|
1630 |
r.top() + titleRect.left() - rect.left(),
|
|
1631 |
titleRect.height(), titleRect.width());
|
|
1632 |
|
|
1633 |
painter->translate(r.left(), r.top() + r.width());
|
|
1634 |
painter->rotate(-90);
|
|
1635 |
painter->translate(-r.left(), -r.top());
|
|
1636 |
|
|
1637 |
rect = r;
|
|
1638 |
}
|
|
1639 |
|
|
1640 |
if (!dwOpt->title.isEmpty()) {
|
|
1641 |
QString titleText
|
|
1642 |
= painter->fontMetrics().elidedText(dwOpt->title,
|
|
1643 |
Qt::ElideRight, titleRect.width());
|
|
1644 |
proxy()->drawItemText(painter,
|
|
1645 |
titleRect,
|
|
1646 |
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
|
|
1647 |
dwOpt->state & State_Enabled, titleText,
|
|
1648 |
QPalette::WindowText);
|
|
1649 |
}
|
|
1650 |
}
|
|
1651 |
painter->restore();
|
|
1652 |
break;
|
|
1653 |
#endif // QT_NO_DOCKWIDGET
|
|
1654 |
case CE_HeaderSection:
|
|
1655 |
painter->save();
|
|
1656 |
// Draws the header in tables.
|
|
1657 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
|
1658 |
QPixmap cache;
|
|
1659 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size());
|
|
1660 |
pixmapName += QString::number(- int(header->position));
|
|
1661 |
pixmapName += QString::number(- int(header->orientation));
|
|
1662 |
QRect r = option->rect;
|
|
1663 |
QColor gradientStopColor;
|
|
1664 |
QColor gradientStartColor = option->palette.button().color();
|
|
1665 |
gradientStopColor.setHsv(gradientStartColor.hue(),
|
|
1666 |
CL_MIN(255, (int)(gradientStartColor.saturation()*2)),
|
|
1667 |
CL_MIN(255, (int)(gradientStartColor.value()*0.96)));
|
|
1668 |
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
|
1669 |
if (option->palette.background().gradient()) {
|
|
1670 |
gradient.setStops(option->palette.background().gradient()->stops());
|
|
1671 |
} else {
|
|
1672 |
gradient.setColorAt(0, gradientStartColor);
|
|
1673 |
gradient.setColorAt(0.8, gradientStartColor);
|
|
1674 |
gradient.setColorAt(1, gradientStopColor);
|
|
1675 |
}
|
|
1676 |
painter->fillRect(r, gradient);
|
|
1677 |
|
|
1678 |
if (!QPixmapCache::find(pixmapName, cache)) {
|
|
1679 |
cache = QPixmap(r.size());
|
|
1680 |
cache.fill(Qt::transparent);
|
|
1681 |
QRect pixmapRect(0, 0, r.width(), r.height());
|
|
1682 |
QPainter cachePainter(&cache);
|
|
1683 |
if (header->orientation == Qt::Vertical) {
|
|
1684 |
cachePainter.setPen(QPen(dark));
|
|
1685 |
cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
|
|
1686 |
if (header->position != QStyleOptionHeader::End) {
|
|
1687 |
cachePainter.setPen(QPen(shadow));
|
|
1688 |
cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, -1), pixmapRect.bottomRight() + QPoint(-3, -1)); cachePainter.setPen(QPen(option->palette.light().color()));
|
|
1689 |
cachePainter.drawLine(pixmapRect.bottomLeft() + QPoint(3, 0), pixmapRect.bottomRight() + QPoint(-3, 0)); }
|
|
1690 |
} else {
|
|
1691 |
cachePainter.setPen(QPen(dark));
|
|
1692 |
cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
|
|
1693 |
cachePainter.setPen(QPen(shadow));
|
|
1694 |
cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color()));
|
|
1695 |
cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); }
|
|
1696 |
cachePainter.end();
|
|
1697 |
QPixmapCache::insert(pixmapName, cache);
|
|
1698 |
}
|
|
1699 |
painter->drawPixmap(r.topLeft(), cache);
|
|
1700 |
}
|
|
1701 |
painter->restore();
|
|
1702 |
break;
|
|
1703 |
case CE_ProgressBarGroove:
|
|
1704 |
painter->save();
|
|
1705 |
{
|
|
1706 |
painter->fillRect(rect, option->palette.base());
|
|
1707 |
QColor borderColor = dark.lighter(110);
|
|
1708 |
painter->setPen(QPen(borderColor, 0));
|
|
1709 |
const QLine lines[4] = {
|
|
1710 |
QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())),
|
|
1711 |
QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())),
|
|
1712 |
QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)),
|
|
1713 |
QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1))
|
|
1714 |
};
|
|
1715 |
painter->drawLines(lines, 4);
|
|
1716 |
QColor alphaCorner = mergedColors(borderColor, option->palette.background().color());
|
|
1717 |
QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
|
|
1718 |
|
|
1719 |
//corner smoothing
|
|
1720 |
painter->setPen(alphaCorner);
|
|
1721 |
const QPoint points[4] = {
|
|
1722 |
rect.topRight(),
|
|
1723 |
rect.topLeft(),
|
|
1724 |
rect.bottomRight(),
|
|
1725 |
rect.bottomLeft()
|
|
1726 |
};
|
|
1727 |
painter->drawPoints(points, 4);
|
|
1728 |
|
|
1729 |
//inner shadow
|
|
1730 |
painter->setPen(innerShadow);
|
|
1731 |
painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
|
|
1732 |
QPoint(rect.right() - 1, rect.top() + 1));
|
|
1733 |
painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
|
|
1734 |
QPoint(rect.left() + 1, rect.bottom() + 1));
|
|
1735 |
|
|
1736 |
}
|
|
1737 |
painter->restore();
|
|
1738 |
break;
|
|
1739 |
case CE_ProgressBarContents:
|
|
1740 |
painter->save();
|
|
1741 |
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
|
1742 |
QRect rect = bar->rect;
|
|
1743 |
bool vertical = false;
|
|
1744 |
bool inverted = false;
|
|
1745 |
bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
|
|
1746 |
|
|
1747 |
// Get extra style options if version 2
|
|
1748 |
if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
|
|
1749 |
vertical = (bar2->orientation == Qt::Vertical);
|
|
1750 |
inverted = bar2->invertedAppearance;
|
|
1751 |
}
|
|
1752 |
|
|
1753 |
// If the orientation is vertical, we use a transform to rotate
|
|
1754 |
// the progress bar 90 degrees clockwise. This way we can use the
|
|
1755 |
// same rendering code for both orientations.
|
|
1756 |
if (vertical) {
|
|
1757 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
|
|
1758 |
QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0);
|
|
1759 |
m.rotate(90.0);
|
|
1760 |
painter->setTransform(m, true);
|
|
1761 |
}
|
|
1762 |
|
|
1763 |
int maxWidth = rect.width() - 4;
|
|
1764 |
int minWidth = 4;
|
|
1765 |
qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
|
|
1766 |
int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
|
|
1767 |
int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth);
|
|
1768 |
|
|
1769 |
bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
|
|
1770 |
if (inverted)
|
|
1771 |
reverse = !reverse;
|
|
1772 |
|
|
1773 |
QRect progressBar;
|
|
1774 |
if (!indeterminate) {
|
|
1775 |
if (!reverse) {
|
|
1776 |
progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3);
|
|
1777 |
} else {
|
|
1778 |
progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3);
|
|
1779 |
}
|
|
1780 |
} else {
|
|
1781 |
Q_D(const QCleanlooksStyle);
|
|
1782 |
int slideWidth = ((rect.width() - 4) * 2) / 3;
|
|
1783 |
int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
|
|
1784 |
if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
|
|
1785 |
step = slideWidth - step;
|
|
1786 |
progressBar.setRect(rect.left() + 1 + step, rect.top() + 1,
|
|
1787 |
slideWidth / 2, rect.height() - 3);
|
|
1788 |
}
|
|
1789 |
QColor highlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
|
1790 |
painter->setPen(QPen(highlight.darker(140), 0));
|
|
1791 |
|
|
1792 |
QColor highlightedGradientStartColor = highlight.lighter(100);
|
|
1793 |
QColor highlightedGradientStopColor = highlight.lighter(130);
|
|
1794 |
|
|
1795 |
QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(),
|
|
1796 |
rect.bottomLeft().y()*2));
|
|
1797 |
|
|
1798 |
gradient.setColorAt(0, highlightedGradientStartColor);
|
|
1799 |
gradient.setColorAt(1, highlightedGradientStopColor);
|
|
1800 |
|
|
1801 |
painter->setBrush(gradient);
|
|
1802 |
painter->drawRect(progressBar);
|
|
1803 |
|
|
1804 |
painter->setPen(QPen(highlight.lighter(120), 0));
|
|
1805 |
painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
|
|
1806 |
QPoint(progressBar.right(), progressBar.top() + 1));
|
|
1807 |
painter->drawLine(QPoint(progressBar.left() + 1, progressBar.top() + 1),
|
|
1808 |
QPoint(progressBar.left() + 1, progressBar.bottom() - 1));
|
|
1809 |
|
|
1810 |
painter->setPen(QPen(highlightedGradientStartColor, 7.0));//QPen(option->palette.highlight(), 3));
|
|
1811 |
|
|
1812 |
painter->save();
|
|
1813 |
painter->setClipRect(progressBar.adjusted(2, 2, -1, -1));
|
|
1814 |
for (int x = progressBar.left() - 32; x < rect.right() ; x+=18) {
|
|
1815 |
painter->drawLine(x, progressBar.bottom() + 1, x + 23, progressBar.top() - 2);
|
|
1816 |
}
|
|
1817 |
painter->restore();
|
|
1818 |
|
|
1819 |
}
|
|
1820 |
painter->restore();
|
|
1821 |
break;
|
|
1822 |
case CE_MenuBarItem:
|
|
1823 |
painter->save();
|
|
1824 |
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
|
|
1825 |
{
|
|
1826 |
QStyleOptionMenuItem item = *mbi;
|
|
1827 |
item.rect = mbi->rect.adjusted(0, 3, 0, -1);
|
|
1828 |
QColor highlightOutline = highlight.darker(125);
|
|
1829 |
QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
|
|
1830 |
|
|
1831 |
if (option->palette.button().gradient()) {
|
|
1832 |
gradient.setStops(option->palette.button().gradient()->stops());
|
|
1833 |
} else {
|
|
1834 |
gradient.setColorAt(0, option->palette.button().color());
|
|
1835 |
gradient.setColorAt(1, option->palette.button().color().darker(110));
|
|
1836 |
}
|
|
1837 |
painter->fillRect(rect, gradient);
|
|
1838 |
|
|
1839 |
QCommonStyle::drawControl(element, &item, painter, widget);
|
|
1840 |
|
|
1841 |
bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
|
|
1842 |
bool dis = !(mbi->state & State_Enabled);
|
|
1843 |
|
|
1844 |
QRect r = option->rect;
|
|
1845 |
if (act) {
|
|
1846 |
qt_cleanlooks_draw_gradient(painter, r.adjusted(1, 1, -1, -1),
|
|
1847 |
highlight,
|
|
1848 |
highlightOutline, TopDown,
|
|
1849 |
option->palette.highlight());
|
|
1850 |
|
|
1851 |
painter->setPen(QPen(highlightOutline, 0));
|
|
1852 |
const QLine lines[4] = {
|
|
1853 |
QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())),
|
|
1854 |
QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())),
|
|
1855 |
QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
|
|
1856 |
QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
|
|
1857 |
};
|
|
1858 |
painter->drawLines(lines, 4);
|
|
1859 |
|
|
1860 |
//draw text
|
|
1861 |
QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
|
|
1862 |
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
|
1863 |
if (!styleHint(SH_UnderlineShortcut, mbi, widget))
|
|
1864 |
alignment |= Qt::TextHideMnemonic;
|
|
1865 |
proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
|
|
1866 |
}
|
|
1867 |
|
|
1868 |
}
|
|
1869 |
painter->restore();
|
|
1870 |
break;
|
|
1871 |
case CE_MenuItem:
|
|
1872 |
painter->save();
|
|
1873 |
// Draws one item in a popup menu.
|
|
1874 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
|
1875 |
QColor highlightOutline = highlight.darker(125);
|
|
1876 |
QColor menuBackground = option->palette.background().color().lighter(104);
|
|
1877 |
QColor borderColor = option->palette.background().color().darker(160);
|
|
1878 |
QColor alphaCornerColor;
|
|
1879 |
|
|
1880 |
if (widget) {
|
|
1881 |
// ### backgroundrole/foregroundrole should be part of the style option
|
|
1882 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), borderColor);
|
|
1883 |
} else {
|
|
1884 |
alphaCornerColor = mergedColors(option->palette.background().color(), borderColor);
|
|
1885 |
}
|
|
1886 |
QColor alphaTextColor = mergedColors(option->palette.background().color(), option->palette.text().color());
|
|
1887 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
|
1888 |
painter->fillRect(menuItem->rect, menuBackground);
|
|
1889 |
int w = 0;
|
|
1890 |
if (!menuItem->text.isEmpty()) {
|
|
1891 |
painter->setFont(menuItem->font);
|
|
1892 |
proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
|
|
1893 |
menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
|
|
1894 |
QPalette::Text);
|
|
1895 |
w = menuItem->fontMetrics.width(menuItem->text) + 5;
|
|
1896 |
}
|
|
1897 |
painter->setPen(shadow.lighter(106));
|
|
1898 |
bool reverse = menuItem->direction == Qt::RightToLeft;
|
|
1899 |
painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
|
|
1900 |
menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
|
|
1901 |
painter->restore();
|
|
1902 |
break;
|
|
1903 |
}
|
|
1904 |
bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
|
|
1905 |
if (selected) {
|
|
1906 |
QRect r = option->rect.adjusted(1, 0, -2, -1);
|
|
1907 |
qt_cleanlooks_draw_gradient(painter, r, highlight,
|
|
1908 |
highlightOutline, TopDown,
|
|
1909 |
highlight);
|
|
1910 |
r = r.adjusted(-1, 0, 1, 0);
|
|
1911 |
painter->setPen(QPen(highlightOutline, 0));
|
|
1912 |
const QLine lines[4] = {
|
|
1913 |
QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)),
|
|
1914 |
QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)),
|
|
1915 |
QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
|
|
1916 |
QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
|
|
1917 |
};
|
|
1918 |
painter->drawLines(lines, 4);
|
|
1919 |
} else {
|
|
1920 |
painter->fillRect(option->rect, menuBackground);
|
|
1921 |
}
|
|
1922 |
|
|
1923 |
bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
|
|
1924 |
bool checked = menuItem->checked;
|
|
1925 |
bool sunken = menuItem->state & State_Sunken;
|
|
1926 |
bool enabled = menuItem->state & State_Enabled;
|
|
1927 |
|
|
1928 |
bool ignoreCheckMark = false;
|
|
1929 |
int checkcol = qMax(menuItem->maxIconWidth, 20);
|
|
1930 |
|
|
1931 |
#ifndef QT_NO_COMBOBOX
|
|
1932 |
if (qobject_cast<const QComboBox*>(widget))
|
|
1933 |
ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
|
|
1934 |
#endif
|
|
1935 |
|
|
1936 |
if (!ignoreCheckMark) {
|
|
1937 |
// Check
|
|
1938 |
QRect checkRect(option->rect.left() + 7, option->rect.center().y() - 6, 13, 13);
|
|
1939 |
checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
|
|
1940 |
if (checkable) {
|
|
1941 |
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
|
|
1942 |
// Radio button
|
|
1943 |
if (checked || sunken) {
|
|
1944 |
painter->setRenderHint(QPainter::Antialiasing);
|
|
1945 |
painter->setPen(Qt::NoPen);
|
|
1946 |
|
|
1947 |
QPalette::ColorRole textRole = !enabled ? QPalette::Text:
|
|
1948 |
selected ? QPalette::HighlightedText : QPalette::ButtonText;
|
|
1949 |
painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole));
|
|
1950 |
painter->drawEllipse(checkRect.adjusted(4, 4, -4, -4));
|
|
1951 |
}
|
|
1952 |
} else {
|
|
1953 |
// Check box
|
|
1954 |
if (menuItem->icon.isNull()) {
|
|
1955 |
if (checked || sunken) {
|
|
1956 |
QImage image(qt_cleanlooks_menuitem_checkbox_checked);
|
|
1957 |
if (enabled && (menuItem->state & State_Selected)) {
|
|
1958 |
image.setColor(1, 0x55ffffff);
|
|
1959 |
image.setColor(2, 0xAAffffff);
|
|
1960 |
image.setColor(3, 0xBBffffff);
|
|
1961 |
image.setColor(4, 0xFFffffff);
|
|
1962 |
image.setColor(5, 0x33ffffff);
|
|
1963 |
} else {
|
|
1964 |
image.setColor(1, 0x55000000);
|
|
1965 |
image.setColor(2, 0xAA000000);
|
|
1966 |
image.setColor(3, 0xBB000000);
|
|
1967 |
image.setColor(4, 0xFF000000);
|
|
1968 |
image.setColor(5, 0x33000000);
|
|
1969 |
}
|
|
1970 |
painter->drawImage(QPoint(checkRect.center().x() - image.width() / 2,
|
|
1971 |
checkRect.center().y() - image.height() / 2), image);
|
|
1972 |
}
|
|
1973 |
}
|
|
1974 |
}
|
|
1975 |
}
|
|
1976 |
} else { //ignore checkmark
|
|
1977 |
if (menuItem->icon.isNull())
|
|
1978 |
checkcol = 0;
|
|
1979 |
else
|
|
1980 |
checkcol = menuItem->maxIconWidth;
|
|
1981 |
}
|
|
1982 |
|
|
1983 |
// Text and icon, ripped from windows style
|
|
1984 |
bool dis = !(menuItem->state & State_Enabled);
|
|
1985 |
bool act = menuItem->state & State_Selected;
|
|
1986 |
const QStyleOption *opt = option;
|
|
1987 |
const QStyleOptionMenuItem *menuitem = menuItem;
|
|
1988 |
|
|
1989 |
QPainter *p = painter;
|
|
1990 |
QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
|
|
1991 |
QRect(menuitem->rect.x(), menuitem->rect.y(),
|
|
1992 |
checkcol, menuitem->rect.height()));
|
|
1993 |
if (!menuItem->icon.isNull()) {
|
|
1994 |
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
|
1995 |
if (act && !dis)
|
|
1996 |
mode = QIcon::Active;
|
|
1997 |
QPixmap pixmap;
|
|
1998 |
|
|
1999 |
int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
|
|
2000 |
QSize iconSize(smallIconSize, smallIconSize);
|
|
2001 |
#ifndef QT_NO_COMBOBOX
|
|
2002 |
if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
|
|
2003 |
iconSize = combo->iconSize();
|
|
2004 |
#endif // QT_NO_COMBOBOX
|
|
2005 |
if (checked)
|
|
2006 |
pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
|
|
2007 |
else
|
|
2008 |
pixmap = menuItem->icon.pixmap(iconSize, mode);
|
|
2009 |
|
|
2010 |
int pixw = pixmap.width();
|
|
2011 |
int pixh = pixmap.height();
|
|
2012 |
|
|
2013 |
QRect pmr(0, 0, pixw, pixh);
|
|
2014 |
pmr.moveCenter(vCheckRect.center());
|
|
2015 |
painter->setPen(menuItem->palette.text().color());
|
|
2016 |
if (checkable && checked) {
|
|
2017 |
QStyleOption opt = *option;
|
|
2018 |
if (act) {
|
|
2019 |
QColor activeColor = mergedColors(option->palette.background().color(),
|
|
2020 |
option->palette.highlight().color());
|
|
2021 |
opt.palette.setBrush(QPalette::Button, activeColor);
|
|
2022 |
}
|
|
2023 |
opt.state |= State_Sunken;
|
|
2024 |
opt.rect = vCheckRect;
|
|
2025 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
|
|
2026 |
}
|
|
2027 |
painter->drawPixmap(pmr.topLeft(), pixmap);
|
|
2028 |
}
|
|
2029 |
if (selected) {
|
|
2030 |
painter->setPen(menuItem->palette.highlightedText().color());
|
|
2031 |
} else {
|
|
2032 |
painter->setPen(menuItem->palette.text().color());
|
|
2033 |
}
|
|
2034 |
int x, y, w, h;
|
|
2035 |
menuitem->rect.getRect(&x, &y, &w, &h);
|
|
2036 |
int tab = menuitem->tabWidth;
|
|
2037 |
QColor discol;
|
|
2038 |
if (dis) {
|
|
2039 |
discol = menuitem->palette.text().color();
|
|
2040 |
p->setPen(discol);
|
|
2041 |
}
|
|
2042 |
int xm = windowsItemFrame + checkcol + windowsItemHMargin;
|
|
2043 |
int xpos = menuitem->rect.x() + xm;
|
|
2044 |
|
|
2045 |
QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
|
|
2046 |
QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
|
|
2047 |
QString s = menuitem->text;
|
|
2048 |
if (!s.isEmpty()) { // draw text
|
|
2049 |
p->save();
|
|
2050 |
int t = s.indexOf(QLatin1Char('\t'));
|
|
2051 |
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
|
2052 |
if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
|
|
2053 |
text_flags |= Qt::TextHideMnemonic;
|
|
2054 |
text_flags |= Qt::AlignLeft;
|
|
2055 |
if (t >= 0) {
|
|
2056 |
QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
|
|
2057 |
QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
|
|
2058 |
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
|
|
2059 |
p->setPen(menuitem->palette.light().color());
|
|
2060 |
p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1));
|
|
2061 |
p->setPen(discol);
|
|
2062 |
}
|
|
2063 |
p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
|
|
2064 |
s = s.left(t);
|
|
2065 |
}
|
|
2066 |
QFont font = menuitem->font;
|
|
2067 |
// font may not have any "hard" flags set. We override
|
|
2068 |
// the point size so that when it is resolved against the device, this font will win.
|
|
2069 |
// This is mainly to handle cases where someone sets the font on the window
|
|
2070 |
// and then the combo inherits it and passes it onward. At that point the resolve mask
|
|
2071 |
// is very, very weak. This makes it stonger.
|
|
2072 |
font.setPointSizeF(menuItem->font.pointSizeF());
|
|
2073 |
|
|
2074 |
if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
|
|
2075 |
font.setBold(true);
|
|
2076 |
|
|
2077 |
p->setFont(font);
|
|
2078 |
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
|
|
2079 |
p->setPen(menuitem->palette.light().color());
|
|
2080 |
p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t));
|
|
2081 |
p->setPen(discol);
|
|
2082 |
}
|
|
2083 |
p->drawText(vTextRect, text_flags, s.left(t));
|
|
2084 |
p->restore();
|
|
2085 |
}
|
|
2086 |
|
|
2087 |
// Arrow
|
|
2088 |
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
|
|
2089 |
int dim = (menuItem->rect.height() - 4) / 2;
|
|
2090 |
PrimitiveElement arrow;
|
|
2091 |
arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
|
2092 |
int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
|
|
2093 |
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
|
|
2094 |
QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
|
|
2095 |
QStyleOptionMenuItem newMI = *menuItem;
|
|
2096 |
newMI.rect = vSubMenuRect;
|
|
2097 |
newMI.state = !enabled ? State_None : State_Enabled;
|
|
2098 |
if (selected)
|
|
2099 |
newMI.palette.setColor(QPalette::ButtonText,
|
|
2100 |
newMI.palette.highlightedText().color());
|
|
2101 |
proxy()->drawPrimitive(arrow, &newMI, painter, widget);
|
|
2102 |
}
|
|
2103 |
}
|
|
2104 |
painter->restore();
|
|
2105 |
break;
|
|
2106 |
case CE_MenuHMargin:
|
|
2107 |
case CE_MenuVMargin:
|
|
2108 |
break;
|
|
2109 |
case CE_MenuEmptyArea:
|
|
2110 |
break;
|
|
2111 |
case CE_PushButtonLabel:
|
|
2112 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|
2113 |
QRect ir = button->rect;
|
|
2114 |
uint tf = Qt::AlignVCenter;
|
|
2115 |
if (styleHint(SH_UnderlineShortcut, button, widget))
|
|
2116 |
tf |= Qt::TextShowMnemonic;
|
|
2117 |
else
|
|
2118 |
tf |= Qt::TextHideMnemonic;
|
|
2119 |
|
|
2120 |
if (!button->icon.isNull()) {
|
|
2121 |
//Center both icon and text
|
|
2122 |
QPoint point;
|
|
2123 |
|
|
2124 |
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
|
|
2125 |
: QIcon::Disabled;
|
|
2126 |
if (mode == QIcon::Normal && button->state & State_HasFocus)
|
|
2127 |
mode = QIcon::Active;
|
|
2128 |
QIcon::State state = QIcon::Off;
|
|
2129 |
if (button->state & State_On)
|
|
2130 |
state = QIcon::On;
|
|
2131 |
|
|
2132 |
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
|
|
2133 |
int w = pixmap.width();
|
|
2134 |
int h = pixmap.height();
|
|
2135 |
|
|
2136 |
if (!button->text.isEmpty())
|
|
2137 |
w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
|
|
2138 |
|
|
2139 |
point = QPoint(ir.x() + ir.width() / 2 - w / 2,
|
|
2140 |
ir.y() + ir.height() / 2 - h / 2);
|
|
2141 |
|
|
2142 |
if (button->direction == Qt::RightToLeft)
|
|
2143 |
point.rx() += pixmap.width();
|
|
2144 |
|
|
2145 |
painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
|
|
2146 |
|
|
2147 |
if (button->direction == Qt::RightToLeft)
|
|
2148 |
ir.translate(-point.x() - 2, 0);
|
|
2149 |
else
|
|
2150 |
ir.translate(point.x() + pixmap.width(), 0);
|
|
2151 |
|
|
2152 |
// left-align text if there is
|
|
2153 |
if (!button->text.isEmpty())
|
|
2154 |
tf |= Qt::AlignLeft;
|
|
2155 |
|
|
2156 |
} else {
|
|
2157 |
tf |= Qt::AlignHCenter;
|
|
2158 |
}
|
|
2159 |
|
|
2160 |
if (button->features & QStyleOptionButton::HasMenu)
|
|
2161 |
ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
|
|
2162 |
proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
|
|
2163 |
button->text, QPalette::ButtonText);
|
|
2164 |
}
|
|
2165 |
break;
|
|
2166 |
case CE_MenuBarEmptyArea:
|
|
2167 |
painter->save();
|
|
2168 |
{
|
|
2169 |
QColor shadow = mergedColors(option->palette.background().color().darker(120),
|
|
2170 |
dark.lighter(140), 60);
|
|
2171 |
|
|
2172 |
QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()*2));
|
|
2173 |
gradient.setColorAt(0, option->palette.button().color());
|
|
2174 |
gradient.setColorAt(1, option->palette.button().color().darker(110));
|
|
2175 |
painter->fillRect(rect, gradient);
|
|
2176 |
|
|
2177 |
#ifndef QT_NO_MAINWINDOW
|
|
2178 |
if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
|
|
2179 |
QPen oldPen = painter->pen();
|
|
2180 |
painter->setPen(QPen(shadow));
|
|
2181 |
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
|
2182 |
}
|
|
2183 |
#endif // QT_NO_MAINWINDOW
|
|
2184 |
}
|
|
2185 |
painter->restore();
|
|
2186 |
break;
|
|
2187 |
#ifndef QT_NO_TABBAR
|
|
2188 |
case CE_TabBarTabShape:
|
|
2189 |
painter->save();
|
|
2190 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
|
2191 |
|
|
2192 |
bool rtlHorTabs = (tab->direction == Qt::RightToLeft
|
|
2193 |
&& (tab->shape == QTabBar::RoundedNorth
|
|
2194 |
|| tab->shape == QTabBar::RoundedSouth));
|
|
2195 |
bool selected = tab->state & State_Selected;
|
|
2196 |
bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
|
|
2197 |
|| (rtlHorTabs
|
|
2198 |
&& tab->position == QStyleOptionTab::Beginning));
|
|
2199 |
bool onlyTab = tab->position == QStyleOptionTab::OnlyOneTab;
|
|
2200 |
bool leftCornerWidget = (tab->cornerWidgets & QStyleOptionTab::LeftCornerWidget);
|
|
2201 |
|
|
2202 |
bool atBeginning = ((tab->position == (tab->direction == Qt::LeftToRight ?
|
|
2203 |
QStyleOptionTab::Beginning : QStyleOptionTab::End)) || onlyTab);
|
|
2204 |
|
|
2205 |
bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
|
|
2206 |
bool previousSelected =
|
|
2207 |
((!rtlHorTabs
|
|
2208 |
&& tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
|
|
2209 |
|| (rtlHorTabs
|
|
2210 |
&& tab->selectedPosition == QStyleOptionTab::NextIsSelected));
|
|
2211 |
bool nextSelected =
|
|
2212 |
((!rtlHorTabs
|
|
2213 |
&& tab->selectedPosition == QStyleOptionTab::NextIsSelected)
|
|
2214 |
|| (rtlHorTabs
|
|
2215 |
&& tab->selectedPosition
|
|
2216 |
== QStyleOptionTab::PreviousIsSelected));
|
|
2217 |
int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget);
|
|
2218 |
bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
|
|
2219 |
|| (rtlHorTabs
|
|
2220 |
&& tabBarAlignment == Qt::AlignRight);
|
|
2221 |
|
|
2222 |
bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
|
|
2223 |
|| (rtlHorTabs
|
|
2224 |
&& tabBarAlignment == Qt::AlignLeft);
|
|
2225 |
|
|
2226 |
QColor light = tab->palette.light().color();
|
|
2227 |
QColor midlight = tab->palette.midlight().color();
|
|
2228 |
|
|
2229 |
QColor background = tab->palette.background().color();
|
|
2230 |
int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
|
|
2231 |
if (selected)
|
|
2232 |
borderThinkness /= 2;
|
|
2233 |
QRect r2(option->rect);
|
|
2234 |
int x1 = r2.left();
|
|
2235 |
int x2 = r2.right();
|
|
2236 |
int y1 = r2.top();
|
|
2237 |
int y2 = r2.bottom();
|
|
2238 |
|
|
2239 |
QTransform rotMatrix;
|
|
2240 |
bool flip = false;
|
|
2241 |
painter->setPen(shadow);
|
|
2242 |
QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
|
2243 |
switch (tab->shape) {
|
|
2244 |
case QTabBar::RoundedNorth:
|
|
2245 |
break;
|
|
2246 |
case QTabBar::RoundedSouth:
|
|
2247 |
rotMatrix.rotate(180);
|
|
2248 |
rotMatrix.translate(0, -rect.height() + 1);
|
|
2249 |
rotMatrix.scale(-1, 1);
|
|
2250 |
painter->setTransform(rotMatrix, true);
|
|
2251 |
break;
|
|
2252 |
case QTabBar::RoundedWest:
|
|
2253 |
rotMatrix.rotate(180 + 90);
|
|
2254 |
rotMatrix.scale(-1, 1);
|
|
2255 |
flip = true;
|
|
2256 |
painter->setTransform(rotMatrix, true);
|
|
2257 |
break;
|
|
2258 |
case QTabBar::RoundedEast:
|
|
2259 |
rotMatrix.rotate(90);
|
|
2260 |
rotMatrix.translate(0, - rect.width() + 1);
|
|
2261 |
flip = true;
|
|
2262 |
painter->setTransform(rotMatrix, true);
|
|
2263 |
break;
|
|
2264 |
default:
|
|
2265 |
painter->restore();
|
|
2266 |
QWindowsStyle::drawControl(element, tab, painter, widget);
|
|
2267 |
return;
|
|
2268 |
}
|
|
2269 |
|
|
2270 |
if (flip) {
|
|
2271 |
QRect tmp = rect;
|
|
2272 |
rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
|
|
2273 |
int temp = x1;
|
|
2274 |
x1 = y1;
|
|
2275 |
y1 = temp;
|
|
2276 |
temp = x2;
|
|
2277 |
x2 = y2;
|
|
2278 |
y2 = temp;
|
|
2279 |
}
|
|
2280 |
|
|
2281 |
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
|
2282 |
if (option->palette.button().gradient()) {
|
|
2283 |
if (selected)
|
|
2284 |
gradient.setStops(option->palette.background().gradient()->stops());
|
|
2285 |
else
|
|
2286 |
gradient.setStops(option->palette.background().gradient()->stops());
|
|
2287 |
}
|
|
2288 |
else if (selected) {
|
|
2289 |
gradient.setColorAt(0, option->palette.background().color().lighter(104));
|
|
2290 |
gradient.setColorAt(1, tabFrameColor);
|
|
2291 |
painter->fillRect(rect.adjusted(0, 2, 0, -1), gradient);
|
|
2292 |
} else {
|
|
2293 |
y1 += 2;
|
|
2294 |
gradient.setColorAt(0, option->palette.background().color());
|
|
2295 |
gradient.setColorAt(1, dark.lighter(120));
|
|
2296 |
painter->fillRect(rect.adjusted(0, 2, 0, -2), gradient);
|
|
2297 |
}
|
|
2298 |
|
|
2299 |
// Delete border
|
|
2300 |
if (selected) {
|
|
2301 |
painter->setPen(QPen(activeHighlight, 0));
|
|
2302 |
painter->drawLine(x1 + 1, y1 + 1, x2 - 1, y1 + 1);
|
|
2303 |
painter->drawLine(x1 , y1 + 2, x2 , y1 + 2);
|
|
2304 |
} else {
|
|
2305 |
painter->setPen(dark);
|
|
2306 |
painter->drawLine(x1, y2 - 1, x2 + 2, y2 - 1 );
|
|
2307 |
if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedWest) {
|
|
2308 |
painter->setPen(light);
|
|
2309 |
painter->drawLine(x1, y2 , x2, y2 );
|
|
2310 |
}
|
|
2311 |
}
|
|
2312 |
// Left
|
|
2313 |
if (atBeginning || selected ) {
|
|
2314 |
painter->setPen(light);
|
|
2315 |
painter->drawLine(x1 + 1, y1 + 2 + 1, x1 + 1, y2 - ((onlyOne || atBeginning) && selected && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
|
|
2316 |
painter->drawPoint(x1 + 1, y1 + 1);
|
|
2317 |
painter->setPen(dark);
|
|
2318 |
painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || atBeginning) && leftAligned ? 0 : borderThinkness) - (atBeginning && leftCornerWidget ? 1 : 0));
|
|
2319 |
}
|
|
2320 |
// Top
|
|
2321 |
{
|
|
2322 |
int beg = x1 + (previousSelected ? 0 : 2);
|
|
2323 |
int end = x2 - (nextSelected ? 0 : 2);
|
|
2324 |
painter->setPen(light);
|
|
2325 |
|
|
2326 |
if (!selected)painter->drawLine(beg - 2, y1 + 1, end, y1 + 1);
|
|
2327 |
|
|
2328 |
if (selected)
|
|
2329 |
painter->setPen(QPen(activeHighlight.darker(150), 0));
|
|
2330 |
else
|
|
2331 |
painter->setPen(darkOutline);
|
|
2332 |
painter->drawLine(beg, y1 , end, y1);
|
|
2333 |
|
|
2334 |
if (atBeginning|| selected) {
|
|
2335 |
painter->drawPoint(beg - 1, y1 + 1);
|
|
2336 |
} else if (!atBeginning) {
|
|
2337 |
painter->drawPoint(beg - 1, y1);
|
|
2338 |
painter->drawPoint(beg - 2, y1);
|
|
2339 |
if (!lastTab) {
|
|
2340 |
painter->setPen(dark.lighter(130));
|
|
2341 |
painter->drawPoint(end + 1, y1);
|
|
2342 |
painter->drawPoint(end + 2 , y1);
|
|
2343 |
painter->drawPoint(end + 2, y1 + 1);
|
|
2344 |
}
|
|
2345 |
}
|
|
2346 |
}
|
|
2347 |
// Right
|
|
2348 |
if (lastTab || selected || onlyOne || !nextSelected) {
|
|
2349 |
painter->setPen(darkOutline);
|
|
2350 |
painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
|
2351 |
if (selected)
|
|
2352 |
painter->setPen(QPen(activeHighlight.darker(150), 0));
|
|
2353 |
else
|
|
2354 |
painter->setPen(darkOutline);
|
|
2355 |
painter->drawPoint(x2 - 1, y1 + 1);
|
|
2356 |
|
|
2357 |
if (selected) {
|
|
2358 |
painter->setPen(background.darker(110));
|
|
2359 |
painter->drawLine(x2 - 1, y1 + 3, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
|
|
2360 |
}
|
|
2361 |
}
|
|
2362 |
}
|
|
2363 |
painter->restore();
|
|
2364 |
break;
|
|
2365 |
|
|
2366 |
#endif // QT_NO_TABBAR
|
|
2367 |
default:
|
|
2368 |
QWindowsStyle::drawControl(element,option,painter,widget);
|
|
2369 |
break;
|
|
2370 |
}
|
|
2371 |
}
|
|
2372 |
|
|
2373 |
/*!
|
|
2374 |
\reimp
|
|
2375 |
*/
|
|
2376 |
QPalette QCleanlooksStyle::standardPalette () const
|
|
2377 |
{
|
|
2378 |
QPalette palette = QWindowsStyle::standardPalette();
|
|
2379 |
palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(98, 140, 178));
|
|
2380 |
palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(145, 141, 126));
|
|
2381 |
palette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126));
|
|
2382 |
|
|
2383 |
QColor backGround(239, 235, 231);
|
|
2384 |
|
|
2385 |
QColor light = backGround.lighter(150);
|
|
2386 |
QColor base = Qt::white;
|
|
2387 |
QColor dark = QColor(170, 156, 143).darker(110);
|
|
2388 |
dark = backGround.darker(150);
|
|
2389 |
QColor darkDisabled = QColor(209, 200, 191).darker(110);
|
|
2390 |
|
|
2391 |
//### Find the correct disabled text color
|
|
2392 |
palette.setBrush(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190));
|
|
2393 |
|
|
2394 |
palette.setBrush(QPalette::Window, backGround);
|
|
2395 |
palette.setBrush(QPalette::Mid, backGround.darker(130));
|
|
2396 |
palette.setBrush(QPalette::Light, light);
|
|
2397 |
|
|
2398 |
palette.setBrush(QPalette::Active, QPalette::Base, base);
|
|
2399 |
palette.setBrush(QPalette::Inactive, QPalette::Base, base);
|
|
2400 |
palette.setBrush(QPalette::Disabled, QPalette::Base, backGround);
|
|
2401 |
|
|
2402 |
palette.setBrush(QPalette::Midlight, palette.mid().color().lighter(110));
|
|
2403 |
|
|
2404 |
palette.setBrush(QPalette::All, QPalette::Dark, dark);
|
|
2405 |
palette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
|
|
2406 |
|
|
2407 |
QColor button = backGround;
|
|
2408 |
|
|
2409 |
palette.setBrush(QPalette::Button, button);
|
|
2410 |
|
|
2411 |
QColor shadow = dark.darker(135);
|
|
2412 |
palette.setBrush(QPalette::Shadow, shadow);
|
|
2413 |
palette.setBrush(QPalette::Disabled, QPalette::Shadow, shadow.lighter(150));
|
|
2414 |
palette.setBrush(QPalette::HighlightedText, QColor(QRgb(0xffffffff)));
|
|
2415 |
return palette;
|
|
2416 |
}
|
|
2417 |
|
|
2418 |
/*!
|
|
2419 |
\reimp
|
|
2420 |
*/
|
|
2421 |
void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
|
2422 |
QPainter *painter, const QWidget *widget) const
|
|
2423 |
{
|
|
2424 |
QColor button = option->palette.button().color();
|
|
2425 |
QColor dark;
|
|
2426 |
QColor grooveColor;
|
|
2427 |
QColor darkOutline;
|
|
2428 |
dark.setHsv(button.hue(),
|
|
2429 |
CL_MIN(255, (int)(button.saturation()*1.9)),
|
|
2430 |
CL_MIN(255, (int)(button.value()*0.7)));
|
|
2431 |
grooveColor.setHsv(button.hue(),
|
|
2432 |
CL_MIN(255, (int)(button.saturation()*2.6)),
|
|
2433 |
CL_MIN(255, (int)(button.value()*0.9)));
|
|
2434 |
darkOutline.setHsv(button.hue(),
|
|
2435 |
CL_MIN(255, (int)(button.saturation()*3.0)),
|
|
2436 |
CL_MIN(255, (int)(button.value()*0.6)));
|
|
2437 |
|
|
2438 |
QColor alphaCornerColor;
|
|
2439 |
if (widget) {
|
|
2440 |
// ### backgroundrole/foregroundrole should be part of the style option
|
|
2441 |
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
|
|
2442 |
} else {
|
|
2443 |
alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
|
|
2444 |
}
|
|
2445 |
QColor gripShadow = grooveColor.darker(110);
|
|
2446 |
QColor buttonShadow = option->palette.button().color().darker(110);
|
|
2447 |
|
|
2448 |
QColor gradientStartColor = option->palette.button().color().lighter(108);
|
|
2449 |
QColor gradientStopColor = mergedColors(option->palette.button().color().darker(108), dark.lighter(150), 70);
|
|
2450 |
|
|
2451 |
QColor highlightedGradientStartColor = option->palette.button().color();
|
|
2452 |
QColor highlightedGradientStopColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 85);
|
|
2453 |
|
|
2454 |
QColor highlightedDarkInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 35);
|
|
2455 |
QColor highlightedLightInnerBorderColor = mergedColors(option->palette.button().color(), option->palette.highlight().color(), 58);
|
|
2456 |
|
|
2457 |
QColor buttonShadowAlpha = option->palette.background().color().darker(105);
|
|
2458 |
|
|
2459 |
QPalette palette = option->palette;
|
|
2460 |
|
|
2461 |
switch (control) {
|
|
2462 |
#ifndef QT_NO_SPINBOX
|
|
2463 |
case CC_SpinBox:
|
|
2464 |
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
|
2465 |
QPixmap cache;
|
|
2466 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
|
|
2467 |
if (!QPixmapCache::find(pixmapName, cache)) {
|
|
2468 |
cache = QPixmap(spinBox->rect.size());
|
|
2469 |
cache.fill(Qt::transparent);
|
|
2470 |
QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height());
|
|
2471 |
QPainter cachePainter(&cache);
|
|
2472 |
|
|
2473 |
bool isEnabled = (spinBox->state & State_Enabled);
|
|
2474 |
//bool focus = isEnabled && (spinBox->state & State_HasFocus);
|
|
2475 |
bool hover = isEnabled && (spinBox->state & State_MouseOver);
|
|
2476 |
bool sunken = (spinBox->state & State_Sunken);
|
|
2477 |
bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
|
|
2478 |
bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
|
|
2479 |
|
|
2480 |
QRect rect = pixmapRect;
|
|
2481 |
QStyleOptionSpinBox spinBoxCopy = *spinBox;
|
|
2482 |
spinBoxCopy.rect = pixmapRect;
|
|
2483 |
QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);
|
|
2484 |
QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);
|
|
2485 |
|
|
2486 |
int fw = spinBoxCopy.frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0;
|
|
2487 |
cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw),
|
|
2488 |
option->palette.base());
|
|
2489 |
|
|
2490 |
QRect r = rect.adjusted(0, 1, 0, -1);
|
|
2491 |
if (spinBox->frame) {
|
|
2492 |
|
|
2493 |
QColor topShadow = darkOutline;
|
|
2494 |
topShadow.setAlpha(60);
|
|
2495 |
cachePainter.setPen(topShadow);
|
|
2496 |
|
|
2497 |
// antialias corners
|
|
2498 |
const QPoint points[8] = {
|
|
2499 |
QPoint(r.right(), r.top() + 1),
|
|
2500 |
QPoint(r.right() - 1, r.top() ),
|
|
2501 |
QPoint(r.right(), r.bottom() - 1),
|
|
2502 |
QPoint(r.right() - 1, r.bottom() ),
|
|
2503 |
QPoint(r.left() + 1, r.bottom()),
|
|
2504 |
QPoint(r.left(), r.bottom() - 1),
|
|
2505 |
QPoint(r.left() + 1, r.top()),
|
|
2506 |
QPoint(r.left(), r.top() + 1)
|
|
2507 |
};
|
|
2508 |
cachePainter.drawPoints(points, 8);
|
|
2509 |
|
|
2510 |
// draw frame
|
|
2511 |
topShadow.setAlpha(30);
|
|
2512 |
cachePainter.setPen(topShadow);
|
|
2513 |
cachePainter.drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
|
|
2514 |
|
|
2515 |
cachePainter.setPen(QPen(option->palette.background().color(), 1));
|
|
2516 |
cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
|
|
2517 |
QColor highlight = Qt::white;
|
|
2518 |
highlight.setAlpha(130);
|
|
2519 |
cachePainter.setPen(option->palette.base().color().darker(120));
|
|
2520 |
cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
|
|
2521 |
QPoint(r.right() - 1, r.top() + 1));
|
|
2522 |
cachePainter.drawLine(QPoint(r.left() + 1, r.top() + 1),
|
|
2523 |
QPoint(r.left() + 1, r.bottom() - 1));
|
|
2524 |
cachePainter.setPen(option->palette.base().color());
|
|
2525 |
cachePainter.drawLine(QPoint(r.right() - 1, r.top() + 1),
|
|
2526 |
QPoint(r.right() - 1, r.bottom() - 1));
|
|
2527 |
cachePainter.drawLine(QPoint(r.left() + 1, r.bottom() - 1),
|
|
2528 |
QPoint(r.right() - 1, r.bottom() - 1));
|
|
2529 |
cachePainter.setPen(highlight);
|
|
2530 |
cachePainter.drawLine(QPoint(r.left() + 3, r.bottom() + 1),
|
|
2531 |
QPoint(r.right() - 3, r.bottom() + 1));
|
|
2532 |
|
|
2533 |
cachePainter.setPen(QPen(darkOutline, 1));
|
|
2534 |
|
|
2535 |
// top and bottom lines
|
|
2536 |
const QLine lines[4] = {
|
|
2537 |
QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())),
|
|
2538 |
QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())),
|
|
2539 |
QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)),
|
|
2540 |
QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
|
|
2541 |
};
|
|
2542 |
cachePainter.drawLines(lines, 4);
|
|
2543 |
}
|
|
2544 |
|
|
2545 |
// gradients
|
|
2546 |
qt_cleanlooks_draw_gradient(&cachePainter, upRect,
|
|
2547 |
gradientStartColor.darker(106),
|
|
2548 |
gradientStopColor, TopDown, option->palette.button());
|
|
2549 |
qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(0, 0, 0, 1),
|
|
2550 |
gradientStartColor.darker(106),
|
|
2551 |
gradientStopColor, TopDown, option->palette.button());
|
|
2552 |
if (isEnabled) {
|
|
2553 |
if(upIsActive) {
|
|
2554 |
if (sunken) {
|
|
2555 |
cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), gradientStopColor.darker(110));
|
|
2556 |
} else if (hover) {
|
|
2557 |
qt_cleanlooks_draw_gradient(&cachePainter, upRect.adjusted(1, 0, 0, 0),
|
|
2558 |
gradientStartColor.lighter(110),
|
|
2559 |
gradientStopColor.lighter(110), TopDown, option->palette.button());
|
|
2560 |
}
|
|
2561 |
}
|
|
2562 |
if(downIsActive) {
|
|
2563 |
if (sunken) {
|
|
2564 |
cachePainter.fillRect(downRect.adjusted(1, 0, 0, 1), gradientStopColor.darker(110));
|
|
2565 |
|
|
2566 |
} else if (hover) {
|
|
2567 |
qt_cleanlooks_draw_gradient(&cachePainter, downRect.adjusted(1, 0, 0, 1),
|
|
2568 |
gradientStartColor.lighter(110),
|
|
2569 |
gradientStopColor.lighter(110), TopDown, option->palette.button());
|
|
2570 |
}
|
|
2571 |
}
|
|
2572 |
}
|
|
2573 |
|
|
2574 |
if (spinBox->frame) {
|
|
2575 |
// rounded corners
|
|
2576 |
const QPoint points[4] = {
|
|
2577 |
QPoint(r.left() + 1, r.bottom() - 1),
|
|
2578 |
QPoint(r.left() + 1, r.top() + 1),
|
|
2579 |
QPoint(r.right() - 1, r.bottom() - 1),
|
|
2580 |
QPoint(r.right() - 1, r.top() + 1)
|
|
2581 |
};
|
|
2582 |
cachePainter.drawPoints(points, 4);
|
|
2583 |
|
|
2584 |
if (option->state & State_HasFocus) {
|
|
2585 |
QColor darkoutline = option->palette.highlight().color().darker(150);
|
|
2586 |
QColor innerline = mergedColors(option->palette.highlight().color(), Qt::white);
|
|
2587 |
cachePainter.setPen(QPen(innerline, 0));
|
|
2588 |
if (spinBox->direction == Qt::LeftToRight) {
|
|
2589 |
cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3));
|
|
2590 |
cachePainter.setPen(QPen(darkoutline, 0));
|
|
2591 |
const QLine lines[4] = {
|
|
2592 |
QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())),
|
|
2593 |
QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())),
|
|
2594 |
QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)),
|
|
2595 |
QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
|
|
2596 |
};
|
|
2597 |
cachePainter.drawLines(lines, 4);
|
|
2598 |
cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
|
|
2599 |
cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
|
|
2600 |
cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
|
|
2601 |
} else {
|
|
2602 |
cachePainter.drawRect(rect.adjusted(downRect.width() + 2, 2, -2, -3));
|
|
2603 |
cachePainter.setPen(QPen(darkoutline, 0));
|
|
2604 |
cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.bottom()), QPoint(r.right()- 2 - 1, r.bottom()));
|
|
2605 |
cachePainter.drawLine(QPoint(r.left() + downRect.width(), r.top()), QPoint(r.right() - 2 - 1, r.top()));
|
|
2606 |
|
|
2607 |
cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
|
|
2608 |
cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
|
|
2609 |
cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
|
|
2610 |
cachePainter.drawLine(QPoint(r.left() + downRect.width() + 1, r.top()),
|
|
2611 |
QPoint(r.left() + downRect.width() + 1, r.bottom()));
|
|
2612 |
}
|
|
2613 |
}
|
|
2614 |
}
|
|
2615 |
|
|
2616 |
// outline the up/down buttons
|
|
2617 |
cachePainter.setPen(darkOutline);
|
|
2618 |
QColor light = option->palette.light().color().lighter();
|
|
2619 |
|
|
2620 |
if (spinBox->direction == Qt::RightToLeft) {
|
|
2621 |
cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
|
|
2622 |
cachePainter.setPen(light);
|
|
2623 |
cachePainter.drawLine(upRect.right() - 1, upRect.top() + 3, upRect.right() - 1, downRect.bottom() );
|
|
2624 |
} else {
|
|
2625 |
cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
|
|
2626 |
cachePainter.setPen(light);
|
|
2627 |
cachePainter.drawLine(upRect.left() + 1, upRect.top() , upRect.left() + 1, downRect.bottom() );
|
|
2628 |
}
|
|
2629 |
if (upIsActive && sunken) {
|
|
2630 |
cachePainter.setPen(gradientStopColor.darker(130));
|
|
2631 |
cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom());
|
|
2632 |
cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.right(), upRect.top() - 1);
|
|
2633 |
} else {
|
|
2634 |
cachePainter.setPen(light);
|
|
2635 |
cachePainter.drawLine(upRect.topLeft() + QPoint(1, -1), upRect.topRight() + QPoint(-1, -1));
|
|
2636 |
cachePainter.setPen(darkOutline);
|
|
2637 |
cachePainter.drawLine(upRect.bottomLeft(), upRect.bottomRight());
|
|
2638 |
}
|
|
2639 |
if (downIsActive && sunken) {
|
|
2640 |
cachePainter.setPen(gradientStopColor.darker(130));
|
|
2641 |
cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1);
|
|
2642 |
cachePainter.drawLine(downRect.left(), downRect.top(), downRect.right(), downRect.top());
|
|
2643 |
cachePainter.setPen(gradientStopColor.darker(110));
|
|
2644 |
cachePainter.drawLine(downRect.left(), downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1);
|
|
2645 |
} else {
|
|
2646 |
cachePainter.setPen(light);
|
|
2647 |
cachePainter.drawLine(downRect.topLeft() + QPoint(2,0), downRect.topRight());
|
|
2648 |
}
|
|
2649 |
|
|
2650 |
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
|
|
2651 |
int centerX = upRect.center().x();
|
|
2652 |
int centerY = upRect.center().y();
|
|
2653 |
cachePainter.setPen(spinBox->palette.foreground().color());
|
|
2654 |
|
|
2655 |
// plus/minus
|
|
2656 |
if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
|
|
2657 |
cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
|
|
2658 |
cachePainter.drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
|
|
2659 |
} else {
|
|
2660 |
cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
|
|
2661 |
cachePainter.drawLine(centerX, centerY - 2, centerX, centerY + 2);
|
|
2662 |
}
|
|
2663 |
|
|
2664 |
centerX = downRect.center().x();
|
|
2665 |
centerY = downRect.center().y();
|
|
2666 |
if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
|
|
2667 |
cachePainter.drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
|
|
2668 |
} else {
|
|
2669 |
cachePainter.drawLine(centerX - 2, centerY, centerX + 2, centerY);
|
|
2670 |
}
|
|
2671 |
} else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows){
|
|
2672 |
// arrows
|
|
2673 |
QImage upArrow(qt_spinbox_button_arrow_up);
|
|
2674 |
upArrow.setColor(1, spinBox->palette.foreground().color().rgba());
|
|
2675 |
|
|
2676 |
cachePainter.drawImage(upRect.center().x() - upArrow.width() / 2,
|
|
2677 |
upRect.center().y() - upArrow.height() / 2,
|
|
2678 |
upArrow);
|
|
2679 |
|
|
2680 |
QImage downArrow(qt_spinbox_button_arrow_down);
|
|
2681 |
downArrow.setColor(1, spinBox->palette.foreground().color().rgba());
|
|
2682 |
|
|
2683 |
cachePainter.drawImage(downRect.center().x() - downArrow.width() / 2,
|
|
2684 |
downRect.center().y() - downArrow.height() / 2 + 1,
|
|
2685 |
downArrow);
|
|
2686 |
}
|
|
2687 |
|
|
2688 |
QColor disabledColor = option->palette.background().color();
|
|
2689 |
disabledColor.setAlpha(150);
|
|
2690 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
|
|
2691 |
cachePainter.fillRect(upRect.adjusted(1, 0, 0, 0), disabledColor);
|
|
2692 |
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
|
|
2693 |
cachePainter.fillRect(downRect.adjusted(1, 0, 0, 0), disabledColor);
|
|
2694 |
}
|
|
2695 |
cachePainter.end();
|
|
2696 |
QPixmapCache::insert(pixmapName, cache);
|
|
2697 |
}
|
|
2698 |
painter->drawPixmap(spinBox->rect.topLeft(), cache);
|
|
2699 |
}
|
|
2700 |
break;
|
|
2701 |
#endif // QT_NO_SPINBOX
|
|
2702 |
case CC_TitleBar:
|
|
2703 |
painter->save();
|
|
2704 |
if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
|
|
2705 |
const int buttonMargin = 5;
|
|
2706 |
bool active = (titleBar->titleBarState & State_Active);
|
|
2707 |
QRect fullRect = titleBar->rect;
|
|
2708 |
QPalette palette = option->palette;
|
|
2709 |
QColor highlight = option->palette.highlight().color();
|
|
2710 |
|
|
2711 |
QColor titleBarFrameBorder(active ? highlight.darker(180): dark.darker(110));
|
|
2712 |
QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120));
|
|
2713 |
QColor textColor(active ? 0xffffff : 0xff000000);
|
|
2714 |
QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
|
|
2715 |
|
|
2716 |
#ifdef QT3_SUPPORT
|
|
2717 |
if (widget && widget->inherits("Q3DockWindowTitleBar")) {
|
|
2718 |
QStyleOptionDockWidgetV2 dockwidget;
|
|
2719 |
dockwidget.QStyleOption::operator=(*option);
|
|
2720 |
proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);
|
|
2721 |
} else
|
|
2722 |
#endif // QT3_SUPPORT
|
|
2723 |
{
|
|
2724 |
// Fill title bar gradient
|
|
2725 |
QColor titlebarColor = QColor(active ? highlight: palette.background().color());
|
|
2726 |
QColor titleBarGradientStop(active ? highlight.darker(150): palette.background().color().darker(120));
|
|
2727 |
QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
|
|
2728 |
option->rect.center().x(), option->rect.bottom());
|
|
2729 |
|
|
2730 |
gradient.setColorAt(0, titlebarColor.lighter(114));
|
|
2731 |
gradient.setColorAt(0.5, titlebarColor.lighter(102));
|
|
2732 |
gradient.setColorAt(0.51, titlebarColor.darker(104));
|
|
2733 |
gradient.setColorAt(1, titlebarColor);
|
|
2734 |
painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient);
|
|
2735 |
|
|
2736 |
// Frame and rounded corners
|
|
2737 |
painter->setPen(titleBarFrameBorder);
|
|
2738 |
|
|
2739 |
// top outline
|
|
2740 |
painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
|
|
2741 |
painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
|
|
2742 |
const QPoint points[5] = {
|
|
2743 |
QPoint(fullRect.left() + 4, fullRect.top() + 1),
|
|
2744 |
QPoint(fullRect.left() + 3, fullRect.top() + 1),
|
|
2745 |
QPoint(fullRect.left() + 2, fullRect.top() + 2),
|
|
2746 |
QPoint(fullRect.left() + 1, fullRect.top() + 3),
|
|
2747 |
QPoint(fullRect.left() + 1, fullRect.top() + 4)
|
|
2748 |
};
|
|
2749 |
painter->drawPoints(points, 5);
|
|
2750 |
|
|
2751 |
painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
|
|
2752 |
const QPoint points2[5] = {
|
|
2753 |
QPoint(fullRect.right() - 3, fullRect.top() + 1),
|
|
2754 |
QPoint(fullRect.right() - 4, fullRect.top() + 1),
|
|
2755 |
QPoint(fullRect.right() - 2, fullRect.top() + 2),
|
|
2756 |
QPoint(fullRect.right() - 1, fullRect.top() + 3),
|
|
2757 |
QPoint(fullRect.right() - 1, fullRect.top() + 4)
|
|
2758 |
};
|
|
2759 |
painter->drawPoints(points2, 5);
|
|
2760 |
|
|
2761 |
// draw bottomline
|
|
2762 |
painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
|
|
2763 |
|
|
2764 |
// top highlight
|
|
2765 |
painter->setPen(titleBarHighlight);
|
|
2766 |
painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
|
|
2767 |
}
|
|
2768 |
// draw title
|
|
2769 |
QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
|
|
2770 |
QFont font = painter->font();
|
|
2771 |
font.setBold(true);
|
|
2772 |
painter->setFont(font);
|
|
2773 |
painter->setPen(active? (titleBar->palette.text().color().lighter(120)) :
|
|
2774 |
titleBar->palette.text().color() );
|
|
2775 |
// Note workspace also does elliding but it does not use the correct font
|
|
2776 |
QString title = QFontMetrics(font).elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14);
|
|
2777 |
painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
|
|
2778 |
painter->setPen(Qt::white);
|
|
2779 |
if (active)
|
|
2780 |
painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
|
|
2781 |
// min button
|
|
2782 |
if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
|
|
2783 |
!(titleBar->titleBarState& Qt::WindowMinimized)) {
|
|
2784 |
QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
|
|
2785 |
if (minButtonRect.isValid()) {
|
|
2786 |
bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
|
|
2787 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
|
|
2788 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
|
|
2789 |
QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin);
|
|
2790 |
painter->setPen(textColor);
|
|
2791 |
painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
|
|
2792 |
minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
|
|
2793 |
painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
|
|
2794 |
minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
|
|
2795 |
painter->setPen(textAlphaColor);
|
|
2796 |
painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
|
|
2797 |
minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
|
|
2798 |
painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
|
|
2799 |
minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
|
|
2800 |
}
|
|
2801 |
}
|
|
2802 |
// max button
|
|
2803 |
if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
|
|
2804 |
!(titleBar->titleBarState & Qt::WindowMaximized)) {
|
|
2805 |
QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
|
|
2806 |
if (maxButtonRect.isValid()) {
|
|
2807 |
bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
|
|
2808 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
|
|
2809 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
|
|
2810 |
|
|
2811 |
QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
|
2812 |
|
|
2813 |
painter->setPen(textColor);
|
|
2814 |
painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
|
|
2815 |
painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
|
|
2816 |
maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
|
|
2817 |
painter->setPen(textAlphaColor);
|
|
2818 |
const QPoint points[4] = {
|
|
2819 |
maxButtonIconRect.topLeft(),
|
|
2820 |
maxButtonIconRect.topRight(),
|
|
2821 |
maxButtonIconRect.bottomLeft(),
|
|
2822 |
maxButtonIconRect.bottomRight()
|
|
2823 |
};
|
|
2824 |
painter->drawPoints(points, 4);
|
|
2825 |
}
|
|
2826 |
}
|
|
2827 |
|
|
2828 |
// close button
|
|
2829 |
if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
|
|
2830 |
QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
|
|
2831 |
if (closeButtonRect.isValid()) {
|
|
2832 |
bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
|
|
2833 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
|
|
2834 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
|
|
2835 |
QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
|
2836 |
painter->setPen(textAlphaColor);
|
|
2837 |
const QLine lines[4] = {
|
|
2838 |
QLine(closeIconRect.left() + 1, closeIconRect.top(),
|
|
2839 |
closeIconRect.right(), closeIconRect.bottom() - 1),
|
|
2840 |
QLine(closeIconRect.left(), closeIconRect.top() + 1,
|
|
2841 |
closeIconRect.right() - 1, closeIconRect.bottom()),
|
|
2842 |
QLine(closeIconRect.right() - 1, closeIconRect.top(),
|
|
2843 |
closeIconRect.left(), closeIconRect.bottom() - 1),
|
|
2844 |
QLine(closeIconRect.right(), closeIconRect.top() + 1,
|
|
2845 |
closeIconRect.left() + 1, closeIconRect.bottom())
|
|
2846 |
};
|
|
2847 |
painter->drawLines(lines, 4);
|
|
2848 |
const QPoint points[4] = {
|
|
2849 |
closeIconRect.topLeft(),
|
|
2850 |
closeIconRect.topRight(),
|
|
2851 |
closeIconRect.bottomLeft(),
|
|
2852 |
closeIconRect.bottomRight()
|
|
2853 |
};
|
|
2854 |
painter->drawPoints(points, 4);
|
|
2855 |
|
|
2856 |
painter->setPen(textColor);
|
|
2857 |
painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
|
|
2858 |
closeIconRect.right() - 1, closeIconRect.bottom() - 1);
|
|
2859 |
painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
|
|
2860 |
closeIconRect.right() - 1, closeIconRect.top() + 1);
|
|
2861 |
}
|
|
2862 |
}
|
|
2863 |
|
|
2864 |
// normalize button
|
|
2865 |
if ((titleBar->subControls & SC_TitleBarNormalButton) &&
|
|
2866 |
(((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
|
|
2867 |
(titleBar->titleBarState & Qt::WindowMinimized)) ||
|
|
2868 |
((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
|
|
2869 |
(titleBar->titleBarState & Qt::WindowMaximized)))) {
|
|
2870 |
QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
|
|
2871 |
if (normalButtonRect.isValid()) {
|
|
2872 |
|
|
2873 |
bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
|
|
2874 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
|
|
2875 |
QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
|
|
2876 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
|
|
2877 |
|
|
2878 |
QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
|
|
2879 |
painter->setPen(textColor);
|
|
2880 |
painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
|
|
2881 |
painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
|
|
2882 |
frontWindowRect.right() - 1, frontWindowRect.top() + 1);
|
|
2883 |
painter->setPen(textAlphaColor);
|
|
2884 |
const QPoint points[4] = {
|
|
2885 |
frontWindowRect.topLeft(),
|
|
2886 |
frontWindowRect.topRight(),
|
|
2887 |
frontWindowRect.bottomLeft(),
|
|
2888 |
frontWindowRect.bottomRight()
|
|
2889 |
};
|
|
2890 |
painter->drawPoints(points, 4);
|
|
2891 |
|
|
2892 |
QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
|
|
2893 |
QRegion clipRegion = backWindowRect;
|
|
2894 |
clipRegion -= frontWindowRect;
|
|
2895 |
painter->save();
|
|
2896 |
painter->setClipRegion(clipRegion);
|
|
2897 |
painter->setPen(textColor);
|
|
2898 |
painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
|
|
2899 |
painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
|
|
2900 |
backWindowRect.right() - 1, backWindowRect.top() + 1);
|
|
2901 |
painter->setPen(textAlphaColor);
|
|
2902 |
const QPoint points2[4] = {
|
|
2903 |
backWindowRect.topLeft(),
|
|
2904 |
backWindowRect.topRight(),
|
|
2905 |
backWindowRect.bottomLeft(),
|
|
2906 |
backWindowRect.bottomRight()
|
|
2907 |
};
|
|
2908 |
painter->drawPoints(points2, 4);
|
|
2909 |
painter->restore();
|
|
2910 |
}
|
|
2911 |
}
|
|
2912 |
|
|
2913 |
// context help button
|
|
2914 |
if (titleBar->subControls & SC_TitleBarContextHelpButton
|
|
2915 |
&& (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
|
|
2916 |
QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
|
|
2917 |
if (contextHelpButtonRect.isValid()) {
|
|
2918 |
bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
|
|
2919 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
|
|
2920 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
|
|
2921 |
|
|
2922 |
QColor blend;
|
|
2923 |
QImage image(qt_titlebar_context_help);
|
|
2924 |
QColor alpha = textColor;
|
|
2925 |
alpha.setAlpha(128);
|
|
2926 |
image.setColor(1, textColor.rgba());
|
|
2927 |
image.setColor(2, alpha.rgba());
|
|
2928 |
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
|
2929 |
painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image);
|
|
2930 |
}
|
|
2931 |
}
|
|
2932 |
|
|
2933 |
// shade button
|
|
2934 |
if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
|
|
2935 |
QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
|
|
2936 |
if (shadeButtonRect.isValid()) {
|
|
2937 |
bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
|
|
2938 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
|
|
2939 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
|
|
2940 |
QImage image(qt_scrollbar_button_arrow_up);
|
|
2941 |
image.setColor(1, textColor.rgba());
|
|
2942 |
painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image);
|
|
2943 |
}
|
|
2944 |
}
|
|
2945 |
|
|
2946 |
// unshade button
|
|
2947 |
if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
|
|
2948 |
QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
|
|
2949 |
if (unshadeButtonRect.isValid()) {
|
|
2950 |
bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
|
|
2951 |
bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
|
|
2952 |
qt_cleanlooks_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
|
|
2953 |
QImage image(qt_scrollbar_button_arrow_down);
|
|
2954 |
image.setColor(1, textColor.rgba());
|
|
2955 |
painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image);
|
|
2956 |
}
|
|
2957 |
}
|
|
2958 |
|
|
2959 |
if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
|
|
2960 |
QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
|
|
2961 |
if (iconRect.isValid()) {
|
|
2962 |
if (!titleBar->icon.isNull()) {
|
|
2963 |
titleBar->icon.paint(painter, iconRect);
|
|
2964 |
} else {
|
|
2965 |
QStyleOption tool(0);
|
|
2966 |
tool.palette = titleBar->palette;
|
|
2967 |
QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
|
|
2968 |
tool.rect = iconRect;
|
|
2969 |
painter->save();
|
|
2970 |
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
|
|
2971 |
painter->restore();
|
|
2972 |
}
|
|
2973 |
}
|
|
2974 |
}
|
|
2975 |
}
|
|
2976 |
painter->restore();
|
|
2977 |
break;
|
|
2978 |
#ifndef QT_NO_SCROLLBAR
|
|
2979 |
case CC_ScrollBar:
|
|
2980 |
painter->save();
|
|
2981 |
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|
2982 |
bool isEnabled = scrollBar->state & State_Enabled;
|
|
2983 |
bool reverse = scrollBar->direction == Qt::RightToLeft;
|
|
2984 |
bool horizontal = scrollBar->orientation == Qt::Horizontal;
|
|
2985 |
bool sunken = scrollBar->state & State_Sunken;
|
|
2986 |
|
|
2987 |
painter->fillRect(option->rect, option->palette.background());
|
|
2988 |
|
|
2989 |
QRect rect = scrollBar->rect;
|
|
2990 |
QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
|
|
2991 |
QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
|
|
2992 |
QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
|
|
2993 |
QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
|
|
2994 |
|
|
2995 |
// paint groove
|
|
2996 |
if (scrollBar->subControls & SC_ScrollBarGroove) {
|
|
2997 |
painter->setBrush(grooveColor);
|
|
2998 |
painter->setPen(Qt::NoPen);
|
|
2999 |
if (horizontal) {
|
|
3000 |
painter->drawRect(grooveRect);
|
|
3001 |
painter->setPen(darkOutline);
|
|
3002 |
painter->drawLine(grooveRect.topLeft(), grooveRect.topRight());
|
|
3003 |
painter->drawLine(grooveRect.bottomLeft(), grooveRect.bottomRight());
|
|
3004 |
} else {
|
|
3005 |
painter->drawRect(grooveRect);
|
|
3006 |
painter->setPen(darkOutline);
|
|
3007 |
painter->drawLine(grooveRect.topLeft(), grooveRect.bottomLeft());
|
|
3008 |
painter->drawLine(grooveRect.topRight(), grooveRect.bottomRight());
|
|
3009 |
}
|
|
3010 |
}
|
|
3011 |
//paint slider
|
|
3012 |
if (scrollBar->subControls & SC_ScrollBarSlider) {
|
|
3013 |
QRect pixmapRect = scrollBarSlider;
|
|
3014 |
if (horizontal)
|
|
3015 |
pixmapRect.adjust(-1, 0, 0, -1);
|
|
3016 |
else
|
|
3017 |
pixmapRect.adjust(0, -1, -1, 0);
|
|
3018 |
|
|
3019 |
if (isEnabled) {
|
|
3020 |
QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
|
|
3021 |
pixmapRect.center().x(), pixmapRect.bottom());
|
|
3022 |
if (!horizontal)
|
|
3023 |
gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
|
|
3024 |
pixmapRect.right(), pixmapRect.center().y());
|
|
3025 |
|
|
3026 |
if (option->palette.button().gradient()) {
|
|
3027 |
gradient.setStops(option->palette.button().gradient()->stops());
|
|
3028 |
} else {
|
|
3029 |
if (sunken || (option->state & State_MouseOver &&
|
|
3030 |
(scrollBar->activeSubControls & SC_ScrollBarSlider))) {
|
|
3031 |
gradient.setColorAt(0, gradientStartColor.lighter(110));
|
|
3032 |
gradient.setColorAt(1, gradientStopColor.lighter(110));
|
|
3033 |
} else {
|
|
3034 |
gradient.setColorAt(0, gradientStartColor);
|
|
3035 |
gradient.setColorAt(1, gradientStopColor);
|
|
3036 |
}
|
|
3037 |
}
|
|
3038 |
painter->setPen(QPen(darkOutline, 0));
|
|
3039 |
painter->setBrush(gradient);
|
|
3040 |
painter->drawRect(pixmapRect);
|
|
3041 |
|
|
3042 |
|
|
3043 |
//calculate offsets used by highlight and shadow
|
|
3044 |
int yoffset, xoffset;
|
|
3045 |
if (option->state & State_Horizontal) {
|
|
3046 |
xoffset = 0;
|
|
3047 |
yoffset = 1;
|
|
3048 |
} else {
|
|
3049 |
xoffset = 1;
|
|
3050 |
yoffset = 0;
|
|
3051 |
}
|
|
3052 |
//draw slider highlights
|
|
3053 |
painter->setPen(QPen(gradientStopColor, 0));
|
|
3054 |
painter->drawLine(scrollBarSlider.left() + xoffset,
|
|
3055 |
scrollBarSlider.bottom() - yoffset,
|
|
3056 |
scrollBarSlider.right() - xoffset,
|
|
3057 |
scrollBarSlider.bottom() - yoffset);
|
|
3058 |
painter->drawLine(scrollBarSlider.right() - xoffset,
|
|
3059 |
scrollBarSlider.top() + yoffset,
|
|
3060 |
scrollBarSlider.right() - xoffset,
|
|
3061 |
scrollBarSlider.bottom() - yoffset);
|
|
3062 |
|
|
3063 |
//draw slider shadow
|
|
3064 |
painter->setPen(QPen(gradientStartColor, 0));
|
|
3065 |
painter->drawLine(scrollBarSlider.left() + xoffset,
|
|
3066 |
scrollBarSlider.top() + yoffset,
|
|
3067 |
scrollBarSlider.right() - xoffset,
|
|
3068 |
scrollBarSlider.top() + yoffset);
|
|
3069 |
painter->drawLine(scrollBarSlider.left() + xoffset,
|
|
3070 |
scrollBarSlider.top() + yoffset,
|
|
3071 |
scrollBarSlider.left() + xoffset,
|
|
3072 |
scrollBarSlider.bottom() - yoffset);
|
|
3073 |
} else {
|
|
3074 |
QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
|
|
3075 |
pixmapRect.center().x(), pixmapRect.bottom());
|
|
3076 |
if (!horizontal) {
|
|
3077 |
gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
|
|
3078 |
pixmapRect.right(), pixmapRect.center().y());
|
|
3079 |
}
|
|
3080 |
if (sunken) {
|
|
3081 |
gradient.setColorAt(0, gradientStartColor.lighter(110));
|
|
3082 |
gradient.setColorAt(1, gradientStopColor.lighter(110));
|
|
3083 |
} else {
|
|
3084 |
gradient.setColorAt(0, gradientStartColor);
|
|
3085 |
gradient.setColorAt(1, gradientStopColor);
|
|
3086 |
}
|
|
3087 |
painter->setPen(darkOutline);
|
|
3088 |
painter->setBrush(gradient);
|
|
3089 |
painter->drawRect(pixmapRect);
|
|
3090 |
}
|
|
3091 |
int gripMargin = 4;
|
|
3092 |
//draw grips
|
|
3093 |
if (horizontal) {
|
|
3094 |
for (int i = -3; i< 6 ; i += 3) {
|
|
3095 |
painter->setPen(QPen(gripShadow, 1));
|
|
3096 |
painter->drawLine(
|
|
3097 |
QPoint(scrollBarSlider.center().x() + i ,
|
|
3098 |
scrollBarSlider.top() + gripMargin),
|
|
3099 |
QPoint(scrollBarSlider.center().x() + i,
|
|
3100 |
scrollBarSlider.bottom() - gripMargin));
|
|
3101 |
painter->setPen(QPen(palette.light(), 1));
|
|
3102 |
painter->drawLine(
|
|
3103 |
QPoint(scrollBarSlider.center().x() + i + 1,
|
|
3104 |
scrollBarSlider.top() + gripMargin ),
|
|
3105 |
QPoint(scrollBarSlider.center().x() + i + 1,
|
|
3106 |
scrollBarSlider.bottom() - gripMargin));
|
|
3107 |
}
|
|
3108 |
} else {
|
|
3109 |
for (int i = -3; i < 6 ; i += 3) {
|
|
3110 |
painter->setPen(QPen(gripShadow, 1));
|
|
3111 |
painter->drawLine(
|
|
3112 |
QPoint(scrollBarSlider.left() + gripMargin ,
|
|
3113 |
scrollBarSlider.center().y()+ i),
|
|
3114 |
QPoint(scrollBarSlider.right() - gripMargin,
|
|
3115 |
scrollBarSlider.center().y()+ i));
|
|
3116 |
painter->setPen(QPen(palette.light(), 1));
|
|
3117 |
painter->drawLine(
|
|
3118 |
QPoint(scrollBarSlider.left() + gripMargin,
|
|
3119 |
scrollBarSlider.center().y() + 1 + i),
|
|
3120 |
QPoint(scrollBarSlider.right() - gripMargin,
|
|
3121 |
scrollBarSlider.center().y() + 1 + i));
|
|
3122 |
}
|
|
3123 |
}
|
|
3124 |
}
|
|
3125 |
|
|
3126 |
// The SubLine (up/left) buttons
|
|
3127 |
if (scrollBar->subControls & SC_ScrollBarSubLine) {
|
|
3128 |
//int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
|
|
3129 |
QRect pixmapRect = scrollBarSubLine;
|
|
3130 |
if (isEnabled ) {
|
|
3131 |
QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
|
|
3132 |
// Gradients
|
|
3133 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
|
|
3134 |
qt_cleanlooks_draw_gradient(painter,
|
|
3135 |
QRect(fillRect),
|
|
3136 |
gradientStopColor.darker(120),
|
|
3137 |
gradientStopColor.darker(120),
|
|
3138 |
horizontal ? TopDown : FromLeft, option->palette.button());
|
|
3139 |
} else {
|
|
3140 |
qt_cleanlooks_draw_gradient(painter,
|
|
3141 |
QRect(fillRect),
|
|
3142 |
gradientStartColor.lighter(105),
|
|
3143 |
gradientStopColor,
|
|
3144 |
horizontal ? TopDown : FromLeft, option->palette.button());
|
|
3145 |
}
|
|
3146 |
}
|
|
3147 |
// Details
|
|
3148 |
QImage subButton;
|
|
3149 |
if (horizontal) {
|
|
3150 |
subButton = QImage(reverse ? qt_scrollbar_button_right : qt_scrollbar_button_left);
|
|
3151 |
} else {
|
|
3152 |
subButton = QImage(qt_scrollbar_button_up);
|
|
3153 |
}
|
|
3154 |
subButton.setColor(1, alphaCornerColor.rgba());
|
|
3155 |
subButton.setColor(2, darkOutline.rgba());
|
|
3156 |
if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken) {
|
|
3157 |
subButton.setColor(3, gradientStopColor.darker(140).rgba());
|
|
3158 |
subButton.setColor(4, gradientStopColor.darker(120).rgba());
|
|
3159 |
} else {
|
|
3160 |
subButton.setColor(3, gradientStartColor.lighter(105).rgba());
|
|
3161 |
subButton.setColor(4, gradientStopColor.rgba());
|
|
3162 |
}
|
|
3163 |
subButton.setColor(5, scrollBar->palette.text().color().rgba());
|
|
3164 |
painter->drawImage(pixmapRect, subButton);
|
|
3165 |
|
|
3166 |
// Arrows
|
|
3167 |
PrimitiveElement arrow;
|
|
3168 |
if (option->state & State_Horizontal)
|
|
3169 |
arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft: PE_IndicatorArrowRight;
|
|
3170 |
else
|
|
3171 |
arrow = PE_IndicatorArrowUp;
|
|
3172 |
QStyleOption arrowOpt = *option;
|
|
3173 |
arrowOpt.rect = scrollBarSubLine.adjusted(3, 3, -2, -2);
|
|
3174 |
proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
|
|
3175 |
|
|
3176 |
|
|
3177 |
// The AddLine (down/right) button
|
|
3178 |
if (scrollBar->subControls & SC_ScrollBarAddLine) {
|
|
3179 |
QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));
|
|
3180 |
QRect pixmapRect = scrollBarAddLine;
|
|
3181 |
if (isEnabled) {
|
|
3182 |
QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1);
|
|
3183 |
// Gradients
|
|
3184 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
|
|
3185 |
qt_cleanlooks_draw_gradient(painter,
|
|
3186 |
fillRect,
|
|
3187 |
gradientStopColor.darker(120),
|
|
3188 |
gradientStopColor.darker(120),
|
|
3189 |
horizontal ? TopDown: FromLeft, option->palette.button());
|
|
3190 |
} else {
|
|
3191 |
qt_cleanlooks_draw_gradient(painter,
|
|
3192 |
fillRect,
|
|
3193 |
gradientStartColor.lighter(105),
|
|
3194 |
gradientStopColor,
|
|
3195 |
horizontal ? TopDown : FromLeft, option->palette.button());
|
|
3196 |
}
|
|
3197 |
}
|
|
3198 |
// Details
|
|
3199 |
QImage addButton;
|
|
3200 |
if (horizontal) {
|
|
3201 |
addButton = QImage(reverse ? qt_scrollbar_button_left : qt_scrollbar_button_right);
|
|
3202 |
} else {
|
|
3203 |
addButton = QImage(qt_scrollbar_button_down);
|
|
3204 |
}
|
|
3205 |
addButton.setColor(1, alphaCornerColor.rgba());
|
|
3206 |
addButton.setColor(2, darkOutline.rgba());
|
|
3207 |
if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken) {
|
|
3208 |
addButton.setColor(3, gradientStopColor.darker(140).rgba());
|
|
3209 |
addButton.setColor(4, gradientStopColor.darker(120).rgba());
|
|
3210 |
} else {
|
|
3211 |
addButton.setColor(3, gradientStartColor.lighter(105).rgba());
|
|
3212 |
addButton.setColor(4, gradientStopColor.rgba());
|
|
3213 |
}
|
|
3214 |
addButton.setColor(5, scrollBar->palette.text().color().rgba());
|
|
3215 |
painter->drawImage(pixmapRect, addButton);
|
|
3216 |
|
|
3217 |
PrimitiveElement arrow;
|
|
3218 |
if (option->state & State_Horizontal)
|
|
3219 |
arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
|
|
3220 |
else
|
|
3221 |
arrow = PE_IndicatorArrowDown;
|
|
3222 |
|
|
3223 |
QStyleOption arrowOpt = *option;
|
|
3224 |
arrowOpt.rect = scrollBarAddLine.adjusted(3, 3, -2, -2);
|
|
3225 |
proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget);
|
|
3226 |
}
|
|
3227 |
}
|
|
3228 |
}
|
|
3229 |
painter->restore();
|
|
3230 |
break;;
|
|
3231 |
#endif // QT_NO_SCROLLBAR
|
|
3232 |
#ifndef QT_NO_COMBOBOX
|
|
3233 |
case CC_ComboBox:
|
|
3234 |
painter->save();
|
|
3235 |
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
|
3236 |
bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
|
|
3237 |
bool isEnabled = (comboBox->state & State_Enabled);
|
|
3238 |
bool focus = isEnabled && (comboBox->state & State_HasFocus);
|
|
3239 |
QPixmap cache;
|
|
3240 |
QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());
|
|
3241 |
if (sunken)
|
|
3242 |
pixmapName += QLatin1String("-sunken");
|
|
3243 |
if (comboBox->editable)
|
|
3244 |
pixmapName += QLatin1String("-editable");
|
|
3245 |
if (isEnabled)
|
|
3246 |
pixmapName += QLatin1String("-enabled");
|
|
3247 |
|
|
3248 |
if (!QPixmapCache::find(pixmapName, cache)) {
|
|
3249 |
cache = QPixmap(comboBox->rect.size());
|
|
3250 |
cache.fill(Qt::transparent);
|
|
3251 |
QPainter cachePainter(&cache);
|
|
3252 |
QRect pixmapRect(0, 0, comboBox->rect.width(), comboBox->rect.height());
|
|
3253 |
QStyleOptionComboBox comboBoxCopy = *comboBox;
|
|
3254 |
comboBoxCopy.rect = pixmapRect;
|
|
3255 |
|
|
3256 |
QRect rect = pixmapRect;
|
|
3257 |
QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
|
|
3258 |
SC_ComboBoxArrow, widget);
|
|
3259 |
QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
|
|
3260 |
SC_ComboBoxEditField, widget);
|
|
3261 |
// Draw a push button
|
|
3262 |
if (comboBox->editable) {
|
|
3263 |
QStyleOptionFrame buttonOption;
|
|
3264 |
buttonOption.QStyleOption::operator=(*comboBox);
|
|
3265 |
buttonOption.rect = rect;
|
|
3266 |
buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
|
|
3267 |
|
|
3268 |
if (sunken) {
|
|
3269 |
buttonOption.state |= State_Sunken;
|
|
3270 |
buttonOption.state &= ~State_MouseOver;
|
|
3271 |
}
|
|
3272 |
|
|
3273 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
|
|
3274 |
|
|
3275 |
//remove shadow from left side of edit field when pressed:
|
|
3276 |
if (comboBox->direction != Qt::RightToLeft)
|
|
3277 |
cachePainter.fillRect(editRect.left() - 1, editRect.top() + 1, editRect.left(),
|
|
3278 |
editRect.bottom() - 3, option->palette.base());
|
|
3279 |
|
|
3280 |
cachePainter.setPen(dark.lighter(110));
|
|
3281 |
if (!sunken) {
|
|
3282 |
int borderSize = 2;
|
|
3283 |
if (comboBox->direction == Qt::RightToLeft) {
|
|
3284 |
cachePainter.drawLine(QPoint(downArrowRect.right() - 1, downArrowRect.top() + borderSize ),
|
|
3285 |
QPoint(downArrowRect.right() - 1, downArrowRect.bottom() - borderSize));
|
|
3286 |
cachePainter.setPen(option->palette.light().color());
|
|
3287 |
cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
|
|
3288 |
QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
|
|
3289 |
} else {
|
|
3290 |
cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
|
|
3291 |
QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
|
|
3292 |
cachePainter.setPen(option->palette.light().color());
|
|
3293 |
cachePainter.drawLine(QPoint(downArrowRect.left() + 1, downArrowRect.top() + borderSize),
|
|
3294 |
QPoint(downArrowRect.left() + 1, downArrowRect.bottom() - borderSize));
|
|
3295 |
}
|
|
3296 |
} else {
|
|
3297 |
if (comboBox->direction == Qt::RightToLeft) {
|
|
3298 |
cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + 2),
|
|
3299 |
QPoint(downArrowRect.right(), downArrowRect.bottom() - 2));
|
|
3300 |
|
|
3301 |
} else {
|
|
3302 |
cachePainter.drawLine(QPoint(downArrowRect.left(), downArrowRect.top() + 2),
|
|
3303 |
QPoint(downArrowRect.left(), downArrowRect.bottom() - 2));
|
|
3304 |
}
|
|
3305 |
}
|
|
3306 |
} else {
|
|
3307 |
QStyleOptionButton buttonOption;
|
|
3308 |
buttonOption.QStyleOption::operator=(*comboBox);
|
|
3309 |
buttonOption.rect = rect;
|
|
3310 |
buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver);
|
|
3311 |
if (sunken) {
|
|
3312 |
buttonOption.state |= State_Sunken;
|
|
3313 |
buttonOption.state &= ~State_MouseOver;
|
|
3314 |
}
|
|
3315 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
|
|
3316 |
|
|
3317 |
cachePainter.setPen(buttonShadow.darker(102));
|
|
3318 |
int borderSize = 4;
|
|
3319 |
|
|
3320 |
if (!sunken) {
|
|
3321 |
if (comboBox->direction == Qt::RightToLeft) {
|
|
3322 |
cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
|
|
3323 |
QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
|
|
3324 |
cachePainter.setPen(option->palette.light().color());
|
|
3325 |
cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + borderSize),
|
|
3326 |
QPoint(downArrowRect.right(), downArrowRect.bottom() - borderSize));
|
|
3327 |
} else {
|
|
3328 |
cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
|
|
3329 |
QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
|
|
3330 |
cachePainter.setPen(option->palette.light().color());
|
|
3331 |
cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
|
|
3332 |
QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
|
|
3333 |
}
|
|
3334 |
} else {
|
|
3335 |
cachePainter.setPen(dark.lighter(110));
|
|
3336 |
if (comboBox->direction == Qt::RightToLeft) {
|
|
3337 |
cachePainter.drawLine(QPoint(downArrowRect.right() + 1, downArrowRect.top() + borderSize),
|
|
3338 |
QPoint(downArrowRect.right() + 1, downArrowRect.bottom() - borderSize));
|
|
3339 |
|
|
3340 |
} else {
|
|
3341 |
cachePainter.drawLine(QPoint(downArrowRect.left() - 1, downArrowRect.top() + borderSize),
|
|
3342 |
QPoint(downArrowRect.left() - 1, downArrowRect.bottom() - borderSize));
|
|
3343 |
}
|
|
3344 |
}
|
|
3345 |
}
|
|
3346 |
|
|
3347 |
|
|
3348 |
if (comboBox->subControls & SC_ComboBoxArrow) {
|
|
3349 |
if (comboBox->editable) {
|
|
3350 |
// Draw the down arrow
|
|
3351 |
QImage downArrow(qt_cleanlooks_arrow_down_xpm);
|
|
3352 |
downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
|
3353 |
cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
|
3354 |
downArrowRect.center().y() - downArrow.height() / 2 + 1, downArrow);
|
|
3355 |
} else {
|
|
3356 |
// Draw the up/down arrow
|
|
3357 |
QImage upArrow(qt_scrollbar_button_arrow_up);
|
|
3358 |
upArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
|
3359 |
QImage downArrow(qt_scrollbar_button_arrow_down);
|
|
3360 |
downArrow.setColor(1, comboBox->palette.foreground().color().rgba());
|
|
3361 |
cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
|
3362 |
downArrowRect.center().y() - upArrow.height() - 1 , upArrow);
|
|
3363 |
cachePainter.drawImage(downArrowRect.center().x() - downArrow.width() / 2,
|
|
3364 |
downArrowRect.center().y() + 2, downArrow);
|
|
3365 |
}
|
|
3366 |
}
|
|
3367 |
// Draw the focus rect
|
|
3368 |
if (focus && !comboBox->editable
|
|
3369 |
&& ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) {
|
|
3370 |
QStyleOptionFocusRect focus;
|
|
3371 |
focus.rect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget)
|
|
3372 |
.adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2);
|
|
3373 |
proxy()->drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget);
|
|
3374 |
}
|
|
3375 |
cachePainter.end();
|
|
3376 |
QPixmapCache::insert(pixmapName, cache);
|
|
3377 |
}
|
|
3378 |
painter->drawPixmap(comboBox->rect.topLeft(), cache);
|
|
3379 |
}
|
|
3380 |
painter->restore();
|
|
3381 |
break;
|
|
3382 |
#endif // QT_NO_COMBOBOX
|
|
3383 |
#ifndef QT_NO_GROUPBOX
|
|
3384 |
case CC_GroupBox:
|
|
3385 |
painter->save();
|
|
3386 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
|
3387 |
QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
|
|
3388 |
QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
|
|
3389 |
bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
|
|
3390 |
|
|
3391 |
if(!flat) {
|
|
3392 |
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
|
|
3393 |
QStyleOptionFrameV2 frame;
|
|
3394 |
frame.QStyleOption::operator=(*groupBox);
|
|
3395 |
frame.features = groupBox->features;
|
|
3396 |
frame.lineWidth = groupBox->lineWidth;
|
|
3397 |
frame.midLineWidth = groupBox->midLineWidth;
|
|
3398 |
frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
|
|
3399 |
|
|
3400 |
painter->save();
|
|
3401 |
QRegion region(groupBox->rect);
|
|
3402 |
bool ltr = groupBox->direction == Qt::LeftToRight;
|
|
3403 |
region -= checkBoxRect.united(textRect).adjusted(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
|
|
3404 |
if (!groupBox->text.isEmpty() || groupBox->subControls & SC_GroupBoxCheckBox)
|
|
3405 |
painter->setClipRegion(region);
|
|
3406 |
frame.palette.setBrush(QPalette::Dark, option->palette.mid().color().lighter(110));
|
|
3407 |
proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter);
|
|
3408 |
painter->restore();
|
|
3409 |
}
|
|
3410 |
}
|
|
3411 |
// Draw title
|
|
3412 |
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
|
|
3413 |
if (!groupBox->text.isEmpty()) {
|
|
3414 |
QColor textColor = groupBox->textColor;
|
|
3415 |
if (textColor.isValid())
|
|
3416 |
painter->setPen(textColor);
|
|
3417 |
int alignment = int(groupBox->textAlignment);
|
|
3418 |
if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
|
|
3419 |
alignment |= Qt::TextHideMnemonic;
|
|
3420 |
if (flat) {
|
|
3421 |
QFont font = painter->font();
|
|
3422 |
font.setBold(true);
|
|
3423 |
painter->setFont(font);
|
|
3424 |
if (groupBox->subControls & SC_GroupBoxCheckBox) {
|
|
3425 |
textRect.adjust(checkBoxRect.right() + 4, 0, checkBoxRect.right() + 4, 0);
|
|
3426 |
}
|
|
3427 |
}
|
|
3428 |
painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
|
|
3429 |
}
|
|
3430 |
}
|
|
3431 |
if (groupBox->subControls & SC_GroupBoxCheckBox) {
|
|
3432 |
QStyleOptionButton box;
|
|
3433 |
box.QStyleOption::operator=(*groupBox);
|
|
3434 |
box.rect = checkBoxRect;
|
|
3435 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
|
|
3436 |
}
|
|
3437 |
}
|
|
3438 |
painter->restore();
|
|
3439 |
break;
|
|
3440 |
#endif // QT_NO_GROUPBOX
|
|
3441 |
#ifndef QT_NO_SLIDER
|
|
3442 |
case CC_Slider:
|
|
3443 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|
3444 |
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
|
|
3445 |
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
|
|
3446 |
QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);
|
|
3447 |
|
|
3448 |
bool horizontal = slider->orientation == Qt::Horizontal;
|
|
3449 |
bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
|
|
3450 |
bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
|
|
3451 |
QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight);
|
|
3452 |
QPixmap cache;
|
|
3453 |
|
|
3454 |
QBrush oldBrush = painter->brush();
|
|
3455 |
QPen oldPen = painter->pen();
|
|
3456 |
|
|
3457 |
QColor shadowAlpha(Qt::black);
|
|
3458 |
shadowAlpha.setAlpha(10);
|
|
3459 |
QColor highlightAlpha(Qt::white);
|
|
3460 |
highlightAlpha.setAlpha(80);
|
|
3461 |
|
|
3462 |
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
|
|
3463 |
QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size());
|
|
3464 |
QRect pixmapRect(0, 0, groove.width(), groove.height());
|
|
3465 |
|
|
3466 |
// draw background groove
|
|
3467 |
if (!QPixmapCache::find(groovePixmapName, cache)) {
|
|
3468 |
cache = QPixmap(pixmapRect.size());
|
|
3469 |
cache.fill(Qt::transparent);
|
|
3470 |
QPainter groovePainter(&cache);
|
|
3471 |
|
|
3472 |
groovePainter.setPen(shadowAlpha);
|
|
3473 |
groovePainter.drawLine(1, 0, groove.width(), 0);
|
|
3474 |
groovePainter.drawLine(0, 0, 0, groove.height() - 1);
|
|
3475 |
|
|
3476 |
groovePainter.setPen(highlightAlpha);
|
|
3477 |
groovePainter.drawLine(1, groove.height() - 1, groove.width() - 1, groove.height() - 1);
|
|
3478 |
groovePainter.drawLine(groove.width() - 1, 1, groove.width() - 1, groove.height() - 1);
|
|
3479 |
QLinearGradient gradient;
|
|
3480 |
if (horizontal) {
|
|
3481 |
gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
|
|
3482 |
gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
|
|
3483 |
}
|
|
3484 |
else {
|
|
3485 |
gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
|
|
3486 |
gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
|
|
3487 |
}
|
|
3488 |
groovePainter.setPen(QPen(darkOutline.darker(110), 0));
|
|
3489 |
gradient.setColorAt(0, grooveColor.darker(110));//dark.lighter(120));
|
|
3490 |
gradient.setColorAt(1, grooveColor.lighter(110));//palette.button().color().darker(115));
|
|
3491 |
groovePainter.setBrush(gradient);
|
|
3492 |
groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
|
|
3493 |
groovePainter.end();
|
|
3494 |
QPixmapCache::insert(groovePixmapName, cache);
|
|
3495 |
}
|
|
3496 |
painter->drawPixmap(groove.topLeft(), cache);
|
|
3497 |
|
|
3498 |
// draw blue groove highlight
|
|
3499 |
QRect clipRect;
|
|
3500 |
groovePixmapName += QLatin1String("_blue");
|
|
3501 |
if (!QPixmapCache::find(groovePixmapName, cache)) {
|
|
3502 |
cache = QPixmap(pixmapRect.size());
|
|
3503 |
cache.fill(Qt::transparent);
|
|
3504 |
QPainter groovePainter(&cache);
|
|
3505 |
QLinearGradient gradient;
|
|
3506 |
if (horizontal) {
|
|
3507 |
gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
|
|
3508 |
gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
|
|
3509 |
}
|
|
3510 |
else {
|
|
3511 |
gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
|
|
3512 |
gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
|
|
3513 |
}
|
|
3514 |
groovePainter.setPen(QPen(activeHighlight.darker(150), 0));
|
|
3515 |
gradient.setColorAt(0, activeHighlight.darker(120));
|
|
3516 |
gradient.setColorAt(1, activeHighlight.lighter(160));
|
|
3517 |
groovePainter.setBrush(gradient);
|
|
3518 |
groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2));
|
|
3519 |
groovePainter.end();
|
|
3520 |
QPixmapCache::insert(groovePixmapName, cache);
|
|
3521 |
}
|
|
3522 |
if (horizontal) {
|
|
3523 |
if (slider->upsideDown)
|
|
3524 |
clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height());
|
|
3525 |
else
|
|
3526 |
clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height());
|
|
3527 |
} else {
|
|
3528 |
if (slider->upsideDown)
|
|
3529 |
clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom());
|
|
3530 |
else
|
|
3531 |
clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top());
|
|
3532 |
}
|
|
3533 |
painter->save();
|
|
3534 |
painter->setClipRect(clipRect.adjusted(0, 0, 1, 1));
|
|
3535 |
painter->drawPixmap(groove.topLeft(), cache);
|
|
3536 |
painter->restore();
|
|
3537 |
}
|
|
3538 |
|
|
3539 |
// draw handle
|
|
3540 |
if ((option->subControls & SC_SliderHandle) ) {
|
|
3541 |
QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size());
|
|
3542 |
if (!QPixmapCache::find(handlePixmapName, cache)) {
|
|
3543 |
cache = QPixmap(handle.size());
|
|
3544 |
cache.fill(Qt::transparent);
|
|
3545 |
QRect pixmapRect(0, 0, handle.width(), handle.height());
|
|
3546 |
QPainter handlePainter(&cache);
|
|
3547 |
|
|
3548 |
QColor highlightedGradientStartColor = option->palette.button().color();
|
|
3549 |
QColor highlightedGradientStopColor = option->palette.light().color();
|
|
3550 |
QColor gradientStartColor = mergedColors(option->palette.button().color().lighter(155),
|
|
3551 |
dark.lighter(155), 50);
|
|
3552 |
QColor gradientStopColor = gradientStartColor.darker(108);
|
|
3553 |
QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);
|
|
3554 |
|
|
3555 |
QColor gradientBgStartColor = gradientStartColor;
|
|
3556 |
QColor gradientBgStopColor = gradientStopColor;
|
|
3557 |
|
|
3558 |
QColor outline = option->state & State_Enabled ? dark : dark.lighter(130);
|
|
3559 |
if (option->state & State_Enabled && option->activeSubControls & SC_SliderHandle) {
|
|
3560 |
gradientBgStartColor = option->palette.highlight().color().lighter(180);
|
|
3561 |
gradientBgStopColor = option->palette.highlight().color().lighter(110);
|
|
3562 |
outline = option->palette.highlight().color().darker(130);
|
|
3563 |
}
|
|
3564 |
|
|
3565 |
// gradient fill
|
|
3566 |
QRect innerBorder = gradRect;
|
|
3567 |
QRect r = pixmapRect.adjusted(1, 1, -1, -1);
|
|
3568 |
|
|
3569 |
qt_cleanlooks_draw_gradient(&handlePainter, gradRect,
|
|
3570 |
gradientBgStartColor,
|
|
3571 |
gradientBgStopColor,
|
|
3572 |
horizontal ? TopDown : FromLeft, option->palette.button());
|
|
3573 |
|
|
3574 |
handlePainter.setPen(QPen(outline.darker(110), 1));
|
|
3575 |
handlePainter.drawLine(QPoint(r.left(), r.top() + 3), QPoint(r.left(), r.bottom() - 3));
|
|
3576 |
handlePainter.drawLine(QPoint(r.right(), r.top() + 3), QPoint(r.right(), r.bottom() - 3));
|
|
3577 |
handlePainter.drawLine(QPoint(r.left() + 3, r.bottom()), QPoint(r.right() - 3, r.bottom()));
|
|
3578 |
|
|
3579 |
handlePainter.save();
|
|
3580 |
handlePainter.setRenderHint(QPainter::Antialiasing);
|
|
3581 |
handlePainter.translate(0.5, 0.5);
|
|
3582 |
const QLine lines[4] = {
|
|
3583 |
QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())),
|
|
3584 |
QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())),
|
|
3585 |
QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())),
|
|
3586 |
QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top()))
|
|
3587 |
};
|
|
3588 |
handlePainter.drawLines(lines, 4);
|
|
3589 |
handlePainter.restore();;
|
|
3590 |
handlePainter.setPen(QPen(outline.darker(130), 1));
|
|
3591 |
handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top()));
|
|
3592 |
QColor cornerAlpha = outline.darker(120);
|
|
3593 |
cornerAlpha.setAlpha(80);
|
|
3594 |
|
|
3595 |
handlePainter.setPen(cornerAlpha);
|
|
3596 |
if (horizontal) {
|
|
3597 |
handlePainter.drawLine(QPoint(r.left() + 6, r.top()), QPoint(r.left() + 6, r.bottom()));
|
|
3598 |
handlePainter.drawLine(QPoint(r.right() - 6, r.top()), QPoint(r.right() - 6, r.bottom()));
|
|
3599 |
} else {
|
|
3600 |
handlePainter.drawLine(QPoint(r.left(), r.top() + 6), QPoint(r.right(), r.top() + 6));
|
|
3601 |
handlePainter.drawLine(QPoint(r.left(), r.bottom() - 6), QPoint(r.right(), r.bottom() - 6));
|
|
3602 |
}
|
|
3603 |
|
|
3604 |
//handle shadow
|
|
3605 |
handlePainter.setPen(shadowAlpha);
|
|
3606 |
handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
|
|
3607 |
handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
|
|
3608 |
handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));
|
|
3609 |
|
|
3610 |
qt_cleanlooks_draw_gradient(&handlePainter, horizontal ?
|
|
3611 |
gradRect.adjusted(6, 0, -6, 0) : gradRect.adjusted(0, 6, 0, -6),
|
|
3612 |
gradientStartColor,
|
|
3613 |
gradientStopColor.darker(106),
|
|
3614 |
horizontal ? TopDown : FromLeft,
|
|
3615 |
option->palette.button());
|
|
3616 |
|
|
3617 |
//draw grips
|
|
3618 |
for (int i = -3; i< 6 ; i += 3) {
|
|
3619 |
for (int j = -3; j< 6 ; j += 3) {
|
|
3620 |
handlePainter.fillRect(r.center().x() + i, r.center().y() + j, 2, 2, highlightAlpha);
|
|
3621 |
handlePainter.setPen(gripShadow);
|
|
3622 |
handlePainter.drawPoint(r.center().x() + i, r.center().y() + j );
|
|
3623 |
}
|
|
3624 |
}
|
|
3625 |
handlePainter.end();
|
|
3626 |
QPixmapCache::insert(handlePixmapName, cache);
|
|
3627 |
}
|
|
3628 |
|
|
3629 |
painter->drawPixmap(handle.topLeft(), cache);
|
|
3630 |
|
|
3631 |
if (slider->state & State_HasFocus) {
|
|
3632 |
QStyleOptionFocusRect fropt;
|
|
3633 |
fropt.QStyleOption::operator=(*slider);
|
|
3634 |
fropt.rect = slider->rect;
|
|
3635 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
|
|
3636 |
}
|
|
3637 |
}
|
|
3638 |
if (option->subControls & SC_SliderTickmarks) {
|
|
3639 |
painter->setPen(darkOutline);
|
|
3640 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
|
|
3641 |
int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
|
|
3642 |
int interval = slider->tickInterval;
|
|
3643 |
if (interval <= 0) {
|
|
3644 |
interval = slider->singleStep;
|
|
3645 |
if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
|
|
3646 |
available)
|
|
3647 |
- QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
|
|
3648 |
0, available) < 3)
|
|
3649 |
interval = slider->pageStep;
|
|
3650 |
}
|
|
3651 |
if (interval <= 0)
|
|
3652 |
interval = 1;
|
|
3653 |
|
|
3654 |
int v = slider->minimum;
|
|
3655 |
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
|
|
3656 |
while (v <= slider->maximum + 1) {
|
|
3657 |
if (v == slider->maximum + 1 && interval == 1)
|
|
3658 |
break;
|
|
3659 |
const int v_ = qMin(v, slider->maximum);
|
|
3660 |
int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
|
|
3661 |
v_, (horizontal
|
|
3662 |
? slider->rect.width()
|
|
3663 |
: slider->rect.height()) - len,
|
|
3664 |
slider->upsideDown) + len / 2;
|
|
3665 |
int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
|
|
3666 |
|
|
3667 |
if (horizontal) {
|
|
3668 |
if (ticksAbove) {
|
|
3669 |
painter->drawLine(pos, slider->rect.top() + extra,
|
|
3670 |
pos, slider->rect.top() + tickSize);
|
|
3671 |
}
|
|
3672 |
if (ticksBelow) {
|
|
3673 |
painter->drawLine(pos, slider->rect.bottom() - extra,
|
|
3674 |
pos, slider->rect.bottom() - tickSize);
|
|
3675 |
}
|
|
3676 |
} else {
|
|
3677 |
if (ticksAbove) {
|
|
3678 |
painter->drawLine(slider->rect.left() + extra, pos,
|
|
3679 |
slider->rect.left() + tickSize, pos);
|
|
3680 |
}
|
|
3681 |
if (ticksBelow) {
|
|
3682 |
painter->drawLine(slider->rect.right() - extra, pos,
|
|
3683 |
slider->rect.right() - tickSize, pos);
|
|
3684 |
}
|
|
3685 |
}
|
|
3686 |
// in the case where maximum is max int
|
|
3687 |
int nextInterval = v + interval;
|
|
3688 |
if (nextInterval < v)
|
|
3689 |
break;
|
|
3690 |
v = nextInterval;
|
|
3691 |
}
|
|
3692 |
}
|
|
3693 |
painter->setBrush(oldBrush);
|
|
3694 |
painter->setPen(oldPen);
|
|
3695 |
}
|
|
3696 |
break;
|
|
3697 |
#endif // QT_NO_SLIDER
|
|
3698 |
#ifndef QT_NO_DIAL
|
|
3699 |
case CC_Dial:
|
|
3700 |
if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
|
|
3701 |
QStyleHelper::drawDial(dial, painter);
|
|
3702 |
break;
|
|
3703 |
#endif // QT_NO_DIAL
|
|
3704 |
default:
|
|
3705 |
QWindowsStyle::drawComplexControl(control, option, painter, widget);
|
|
3706 |
break;
|
|
3707 |
}
|
|
3708 |
}
|
|
3709 |
|
|
3710 |
/*!
|
|
3711 |
\reimp
|
|
3712 |
*/
|
|
3713 |
int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
|
3714 |
{
|
|
3715 |
int ret = -1;
|
|
3716 |
switch (metric) {
|
|
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 |
}
|
|
3821 |
if (const QPushButton *button = qobject_cast<const QPushButton *>(widget)) {
|
|
3822 |
if (qobject_cast<const QDialogButtonBox *>(button->parentWidget())) {
|
|
3823 |
if (newSize.height() < 32)
|
|
3824 |
newSize.setHeight(32);
|
|
3825 |
}
|
|
3826 |
}
|
|
3827 |
break;
|
|
3828 |
case CT_GroupBox:
|
|
3829 |
// Since we use a bold font we have to recalculate base width
|
|
3830 |
if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) {
|
|
3831 |
QFont font = gb->font();
|
|
3832 |
font.setBold(true);
|
|
3833 |
QFontMetrics metrics(font);
|
|
3834 |
int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' '));
|
|
3835 |
if (gb->isCheckable()) {
|
|
3836 |
baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget);
|
|
3837 |
baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget);
|
|
3838 |
}
|
|
3839 |
newSize.setWidth(qMax(baseWidth, newSize.width()));
|
|
3840 |
}
|
|
3841 |
newSize += QSize(0, 1);
|
|
3842 |
break;
|
|
3843 |
case CT_RadioButton:
|
|
3844 |
case CT_CheckBox:
|
|
3845 |
newSize += QSize(0, 1);
|
|
3846 |
break;
|
|
3847 |
case CT_ToolButton:
|
|
3848 |
#ifndef QT_NO_TOOLBAR
|
|
3849 |
if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
|
|
3850 |
newSize += QSize(4, 6);
|
|
3851 |
#endif // QT_NO_TOOLBAR
|
|
3852 |
break;
|
|
3853 |
case CT_SpinBox:
|
|
3854 |
newSize += QSize(0, -2);
|
|
3855 |
break;
|
|
3856 |
case CT_ComboBox:
|
|
3857 |
newSize += QSize(2, 4);
|
|
3858 |
break;
|
|
3859 |
case CT_LineEdit:
|
|
3860 |
newSize += QSize(0, 4);
|
|
3861 |
break;
|
|
3862 |
case CT_MenuBarItem:
|
|
3863 |
newSize += QSize(0, 2);
|
|
3864 |
break;
|
|
3865 |
case CT_MenuItem:
|
|
3866 |
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
|
3867 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
|
3868 |
if (!menuItem->text.isEmpty()) {
|
|
3869 |
newSize.setHeight(menuItem->fontMetrics.lineSpacing());
|
|
3870 |
}
|
|
3871 |
}
|
|
3872 |
#ifndef QT_NO_COMBOBOX
|
|
3873 |
else if (!menuItem->icon.isNull()) {
|
|
3874 |
if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) {
|
|
3875 |
newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height()));
|
|
3876 |
}
|
|
3877 |
}
|
|
3878 |
#endif // QT_NO_COMBOBOX
|
|
3879 |
}
|
|
3880 |
break;
|
|
3881 |
case CT_SizeGrip:
|
|
3882 |
newSize += QSize(4, 4);
|
|
3883 |
break;
|
|
3884 |
case CT_MdiControls:
|
|
3885 |
if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
|
|
3886 |
int width = 0;
|
|
3887 |
if (styleOpt->subControls & SC_MdiMinButton)
|
|
3888 |
width += 19 + 1;
|
|
3889 |
if (styleOpt->subControls & SC_MdiNormalButton)
|
|
3890 |
width += 19 + 1;
|
|
3891 |
if (styleOpt->subControls & SC_MdiCloseButton)
|
|
3892 |
width += 19 + 1;
|
|
3893 |
newSize = QSize(width, 19);
|
|
3894 |
} else {
|
|
3895 |
newSize = QSize(60, 19);
|
|
3896 |
}
|
|
3897 |
break;
|
|
3898 |
default:
|
|
3899 |
break;
|
|
3900 |
}
|
|
3901 |
return newSize;
|
|
3902 |
}
|
|
3903 |
|
|
3904 |
/*!
|
|
3905 |
\reimp
|
|
3906 |
*/
|
|
3907 |
void QCleanlooksStyle::polish(QApplication *app)
|
|
3908 |
{
|
|
3909 |
QWindowsStyle::polish(app);
|
|
3910 |
}
|
|
3911 |
|
|
3912 |
/*!
|
|
3913 |
\reimp
|
|
3914 |
*/
|
|
3915 |
void QCleanlooksStyle::polish(QWidget *widget)
|
|
3916 |
{
|
|
3917 |
QWindowsStyle::polish(widget);
|
|
3918 |
if (qobject_cast<QAbstractButton*>(widget)
|
|
3919 |
#ifndef QT_NO_COMBOBOX
|
|
3920 |
|| qobject_cast<QComboBox *>(widget)
|
|
3921 |
#endif
|
|
3922 |
#ifndef QT_NO_PROGRESSBAR
|
|
3923 |
|| qobject_cast<QProgressBar *>(widget)
|
|
3924 |
#endif
|
|
3925 |
#ifndef QT_NO_SCROLLBAR
|
|
3926 |
|| qobject_cast<QScrollBar *>(widget)
|
|
3927 |
#endif
|
|
3928 |
#ifndef QT_NO_SPLITTER
|
|
3929 |
|| qobject_cast<QSplitterHandle *>(widget)
|
|
3930 |
#endif
|
|
3931 |
|| qobject_cast<QAbstractSlider *>(widget)
|
|
3932 |
#ifndef QT_NO_SPINBOX
|
|
3933 |
|| qobject_cast<QAbstractSpinBox *>(widget)
|
|
3934 |
#endif
|
|
3935 |
|| (widget->inherits("QWorkspaceChild"))
|
|
3936 |
|| (widget->inherits("QDockSeparator"))
|
|
3937 |
|| (widget->inherits("QDockWidgetSeparator"))
|
|
3938 |
) {
|
|
3939 |
widget->setAttribute(Qt::WA_Hover, true);
|
|
3940 |
}
|
|
3941 |
}
|
|
3942 |
|
|
3943 |
/*!
|
|
3944 |
\reimp
|
|
3945 |
*/
|
|
3946 |
void QCleanlooksStyle::polish(QPalette &pal)
|
|
3947 |
{
|
|
3948 |
QWindowsStyle::polish(pal);
|
|
3949 |
//this is a workaround for some themes such as Human, where the contrast
|
|
3950 |
//between text and background is too low.
|
|
3951 |
QColor highlight = pal.highlight().color();
|
|
3952 |
QColor highlightText = pal.highlightedText().color();
|
|
3953 |
if (qAbs(qGray(highlight.rgb()) - qGray(highlightText.rgb())) < 150) {
|
|
3954 |
if (qGray(highlightText.rgb()) < 128)
|
|
3955 |
pal.setBrush(QPalette::Highlight, highlight.lighter(145));
|
|
3956 |
}
|
|
3957 |
}
|
|
3958 |
|
|
3959 |
/*!
|
|
3960 |
\reimp
|
|
3961 |
*/
|
|
3962 |
void QCleanlooksStyle::unpolish(QWidget *widget)
|
|
3963 |
{
|
|
3964 |
QWindowsStyle::unpolish(widget);
|
|
3965 |
if (qobject_cast<QAbstractButton*>(widget)
|
|
3966 |
#ifndef QT_NO_COMBOBOX
|
|
3967 |
|| qobject_cast<QComboBox *>(widget)
|
|
3968 |
#endif
|
|
3969 |
#ifndef QT_NO_PROGRESSBAR
|
|
3970 |
|| qobject_cast<QProgressBar *>(widget)
|
|
3971 |
#endif
|
|
3972 |
#ifndef QT_NO_SCROLLBAR
|
|
3973 |
|| qobject_cast<QScrollBar *>(widget)
|
|
3974 |
#endif
|
|
3975 |
#ifndef QT_NO_SPLITTER
|
|
3976 |
|| qobject_cast<QSplitterHandle *>(widget)
|
|
3977 |
#endif
|
|
3978 |
|| qobject_cast<QAbstractSlider *>(widget)
|
|
3979 |
#ifndef QT_NO_SPINBOX
|
|
3980 |
|| qobject_cast<QAbstractSpinBox *>(widget)
|
|
3981 |
#endif
|
|
3982 |
|| (widget->inherits("QWorkspaceChild"))
|
|
3983 |
|| (widget->inherits("QDockSeparator"))
|
|
3984 |
|| (widget->inherits("QDockWidgetSeparator"))
|
|
3985 |
) {
|
|
3986 |
widget->setAttribute(Qt::WA_Hover, false);
|
|
3987 |
}
|
|
3988 |
}
|
|
3989 |
|
|
3990 |
/*!
|
|
3991 |
\reimp
|
|
3992 |
*/
|
|
3993 |
void QCleanlooksStyle::unpolish(QApplication *app)
|
|
3994 |
{
|
|
3995 |
QWindowsStyle::unpolish(app);
|
|
3996 |
}
|
|
3997 |
|
|
3998 |
/*!
|
|
3999 |
\reimp
|
|
4000 |
*/
|
|
4001 |
QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
|
4002 |
SubControl subControl, const QWidget *widget) const
|
|
4003 |
{
|
|
4004 |
QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
|
|
4005 |
|
|
4006 |
switch (control) {
|
|
4007 |
#ifndef QT_NO_SLIDER
|
|
4008 |
case CC_Slider:
|
|
4009 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|
4010 |
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
|
|
4011 |
switch (subControl) {
|
|
4012 |
case SC_SliderHandle: {
|
|
4013 |
if (slider->orientation == Qt::Horizontal) {
|
|
4014 |
rect.setHeight(pixelMetric(PM_SliderThickness));
|
|
4015 |
rect.setWidth(pixelMetric(PM_SliderLength));
|
|
4016 |
int centerY = slider->rect.center().y() - rect.height() / 2;
|
|
4017 |
if (slider->tickPosition & QSlider::TicksAbove)
|
|
4018 |
centerY += tickSize;
|
|
4019 |
if (slider->tickPosition & QSlider::TicksBelow)
|
|
4020 |
centerY -= tickSize;
|
|
4021 |
rect.moveTop(centerY);
|
|
4022 |
} else {
|
|
4023 |
rect.setWidth(pixelMetric(PM_SliderThickness));
|
|
4024 |
rect.setHeight(pixelMetric(PM_SliderLength));
|
|
4025 |
int centerX = slider->rect.center().x() - rect.width() / 2;
|
|
4026 |
if (slider->tickPosition & QSlider::TicksAbove)
|
|
4027 |
centerX += tickSize;
|
|
4028 |
if (slider->tickPosition & QSlider::TicksBelow)
|
|
4029 |
centerX -= tickSize;
|
|
4030 |
rect.moveLeft(centerX);
|
|
4031 |
}
|
|
4032 |
}
|
|
4033 |
break;
|
|
4034 |
case SC_SliderGroove: {
|
|
4035 |
QPoint grooveCenter = slider->rect.center();
|
|
4036 |
if (slider->orientation == Qt::Horizontal) {
|
|
4037 |
rect.setHeight(7);
|
|
4038 |
if (slider->tickPosition & QSlider::TicksAbove)
|
|
4039 |
grooveCenter.ry() += tickSize;
|
|
4040 |
if (slider->tickPosition & QSlider::TicksBelow)
|
|
4041 |
grooveCenter.ry() -= tickSize;
|
|
4042 |
} else {
|
|
4043 |
rect.setWidth(7);
|
|
4044 |
if (slider->tickPosition & QSlider::TicksAbove)
|
|
4045 |
grooveCenter.rx() += tickSize;
|
|
4046 |
if (slider->tickPosition & QSlider::TicksBelow)
|
|
4047 |
grooveCenter.rx() -= tickSize;
|
|
4048 |
}
|
|
4049 |
rect.moveCenter(grooveCenter);
|
|
4050 |
break;
|
|
4051 |
}
|
|
4052 |
default:
|
|
4053 |
break;
|
|
4054 |
}
|
|
4055 |
}
|
|
4056 |
break;
|
|
4057 |
#endif // QT_NO_SLIDER
|
|
4058 |
case CC_ScrollBar:
|
|
4059 |
break;
|
|
4060 |
#ifndef QT_NO_SPINBOX
|
|
4061 |
case CC_SpinBox:
|
|
4062 |
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
|
4063 |
QSize bs;
|
|
4064 |
int center = spinbox->rect.height() / 2;
|
|
4065 |
int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
|
|
4066 |
int y = fw;
|
|
4067 |
bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
|
|
4068 |
bs.setWidth(15);
|
|
4069 |
int x, lx, rx;
|
|
4070 |
x = spinbox->rect.width() - y - bs.width() + 2;
|
|
4071 |
lx = fw;
|
|
4072 |
rx = x - fw;
|
|
4073 |
switch (subControl) {
|
|
4074 |
case SC_SpinBoxUp:
|
|
4075 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
|
|
4076 |
return QRect();
|
|
4077 |
rect = QRect(x, fw, bs.width(), center - fw);
|
|
4078 |
break;
|
|
4079 |
case SC_SpinBoxDown:
|
|
4080 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
|
|
4081 |
return QRect();
|
|
4082 |
|
|
4083 |
rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - fw + 1);
|
|
4084 |
break;
|
|
4085 |
case SC_SpinBoxEditField:
|
|
4086 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
|
|
4087 |
rect = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
|
|
4088 |
} else {
|
|
4089 |
rect = QRect(lx, fw, rx - qMax(fw - 1, 0), spinbox->rect.height() - 2*fw);
|
|
4090 |
}
|
|
4091 |
break;
|
|
4092 |
case SC_SpinBoxFrame:
|
|
4093 |
rect = spinbox->rect;
|
|
4094 |
default:
|
|
4095 |
break;
|
|
4096 |
}
|
|
4097 |
rect = visualRect(spinbox->direction, spinbox->rect, rect);
|
|
4098 |
}
|
|
4099 |
break;
|
|
4100 |
#endif // Qt_NO_SPINBOX
|
|
4101 |
#ifndef QT_NO_GROUPBOX
|
|
4102 |
case CC_GroupBox:
|
|
4103 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
|
4104 |
int topMargin = 0;
|
|
4105 |
int topHeight = 0;
|
|
4106 |
int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
|
|
4107 |
bool flat = groupBox->features & QStyleOptionFrameV2::Flat;
|
|
4108 |
if (!groupBox->text.isEmpty()) {
|
|
4109 |
topHeight = groupBox->fontMetrics.height();
|
|
4110 |
if (verticalAlignment & Qt::AlignVCenter)
|
|
4111 |
topMargin = topHeight / 2;
|
|
4112 |
else if (verticalAlignment & Qt::AlignTop)
|
|
4113 |
topMargin = topHeight;
|
|
4114 |
}
|
|
4115 |
QRect frameRect = groupBox->rect;
|
|
4116 |
frameRect.setTop(topMargin);
|
|
4117 |
if (subControl == SC_GroupBoxFrame) {
|
|
4118 |
return rect;
|
|
4119 |
}
|
|
4120 |
else if (subControl == SC_GroupBoxContents) {
|
|
4121 |
if( flat ) {
|
|
4122 |
int margin = 0;
|
|
4123 |
int leftMarginExtension = 16;
|
|
4124 |
rect = frameRect.adjusted(leftMarginExtension + margin, margin + topHeight, -margin, -margin);
|
|
4125 |
}
|
|
4126 |
break;
|
|
4127 |
}
|
|
4128 |
if(flat) {
|
|
4129 |
if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
|
|
4130 |
//Prepare metrics for a bold font
|
|
4131 |
QFont font = widget->font();
|
|
4132 |
font.setBold(true);
|
|
4133 |
QFontMetrics fontMetrics(font);
|
|
4134 |
|
|
4135 |
QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(2, 2);
|
|
4136 |
if (subControl == SC_GroupBoxCheckBox) {
|
|
4137 |
int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
|
|
4138 |
int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
|
|
4139 |
rect.setWidth(indicatorWidth);
|
|
4140 |
rect.setHeight(indicatorHeight);
|
|
4141 |
rect.moveTop((fontMetrics.height() - indicatorHeight) / 2 + 2);
|
|
4142 |
} else if (subControl == SC_GroupBoxLabel) {
|
|
4143 |
rect.setSize(textRect);
|
|
4144 |
}
|
|
4145 |
}
|
|
4146 |
}
|
|
4147 |
}
|
|
4148 |
return rect;
|
|
4149 |
#ifndef QT_NO_COMBOBOX
|
|
4150 |
case CC_ComboBox:
|
|
4151 |
switch (subControl) {
|
|
4152 |
case SC_ComboBoxArrow:
|
|
4153 |
rect = visualRect(option->direction, option->rect, rect);
|
|
4154 |
rect.setRect(rect.right() - 18, rect.top() - 2,
|
|
4155 |
19, rect.height() + 4);
|
|
4156 |
rect = visualRect(option->direction, option->rect, rect);
|
|
4157 |
break;
|
|
4158 |
case SC_ComboBoxEditField: {
|
|
4159 |
int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
|
|
4160 |
rect = visualRect(option->direction, option->rect, rect);
|
|
4161 |
rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
|
|
4162 |
option->rect.width() - 19 - 2 * frameWidth,
|
|
4163 |
option->rect.height() - 2 * frameWidth);
|
|
4164 |
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
|
4165 |
if (!box->editable) {
|
|
4166 |
rect.adjust(2, 0, 0, 0);
|
|
4167 |
if (box->state & (State_Sunken | State_On))
|
|
4168 |
rect.translate(1, 1);
|
|
4169 |
}
|
|
4170 |
}
|
|
4171 |
rect = visualRect(option->direction, option->rect, rect);
|
|
4172 |
break;
|
|
4173 |
}
|
|
4174 |
default:
|
|
4175 |
break;
|
|
4176 |
}
|
|
4177 |
break;
|
|
4178 |
#endif // QT_NO_COMBOBOX
|
|
4179 |
#endif //QT_NO_GROUPBOX
|
|
4180 |
case CC_TitleBar:
|
|
4181 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
|
|
4182 |
SubControl sc = subControl;
|
|
4183 |
QRect &ret = rect;
|
|
4184 |
const int indent = 3;
|
|
4185 |
const int controlTopMargin = 3;
|
|
4186 |
const int controlBottomMargin = 3;
|
|
4187 |
const int controlWidthMargin = 2;
|
|
4188 |
const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ;
|
|
4189 |
const int delta = controlHeight + controlWidthMargin;
|
|
4190 |
int offset = 0;
|
|
4191 |
|
|
4192 |
bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
|
|
4193 |
bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
|
|
4194 |
|
|
4195 |
switch (sc) {
|
|
4196 |
case SC_TitleBarLabel:
|
|
4197 |
if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
|
|
4198 |
ret = tb->rect;
|
|
4199 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
|
|
4200 |
ret.adjust(delta, 0, -delta, 0);
|
|
4201 |
if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
|
|
4202 |
ret.adjust(0, 0, -delta, 0);
|
|
4203 |
if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
|
|
4204 |
ret.adjust(0, 0, -delta, 0);
|
|
4205 |
if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
|
|
4206 |
ret.adjust(0, 0, -delta, 0);
|
|
4207 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
|
|
4208 |
ret.adjust(0, 0, -delta, 0);
|
|
4209 |
}
|
|
4210 |
break;
|
|
4211 |
case SC_TitleBarContextHelpButton:
|
|
4212 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
|
|
4213 |
offset += delta;
|
|
4214 |
case SC_TitleBarMinButton:
|
|
4215 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
|
|
4216 |
offset += delta;
|
|
4217 |
else if (sc == SC_TitleBarMinButton)
|
|
4218 |
break;
|
|
4219 |
case SC_TitleBarNormalButton:
|
|
4220 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
|
|
4221 |
offset += delta;
|
|
4222 |
else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
|
|
4223 |
offset += delta;
|
|
4224 |
else if (sc == SC_TitleBarNormalButton)
|
|
4225 |
break;
|
|
4226 |
case SC_TitleBarMaxButton:
|
|
4227 |
if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
|
|
4228 |
offset += delta;
|
|
4229 |
else if (sc == SC_TitleBarMaxButton)
|
|
4230 |
break;
|
|
4231 |
case SC_TitleBarShadeButton:
|
|
4232 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
|
|
4233 |
offset += delta;
|
|
4234 |
else if (sc == SC_TitleBarShadeButton)
|
|
4235 |
break;
|
|
4236 |
case SC_TitleBarUnshadeButton:
|
|
4237 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
|
|
4238 |
offset += delta;
|
|
4239 |
else if (sc == SC_TitleBarUnshadeButton)
|
|
4240 |
break;
|
|
4241 |
case SC_TitleBarCloseButton:
|
|
4242 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
|
|
4243 |
offset += delta;
|
|
4244 |
else if (sc == SC_TitleBarCloseButton)
|
|
4245 |
break;
|
|
4246 |
ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
|
|
4247 |
controlHeight, controlHeight);
|
|
4248 |
break;
|
|
4249 |
case SC_TitleBarSysMenu:
|
|
4250 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
|
|
4251 |
ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
|
|
4252 |
controlHeight, controlHeight);
|
|
4253 |
}
|
|
4254 |
break;
|
|
4255 |
default:
|
|
4256 |
break;
|
|
4257 |
}
|
|
4258 |
ret = visualRect(tb->direction, tb->rect, ret);
|
|
4259 |
}
|
|
4260 |
break;
|
|
4261 |
default:
|
|
4262 |
break;
|
|
4263 |
}
|
|
4264 |
|
|
4265 |
return rect;
|
|
4266 |
}
|
|
4267 |
|
|
4268 |
|
|
4269 |
/*!
|
|
4270 |
\reimp
|
|
4271 |
*/
|
|
4272 |
QRect QCleanlooksStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
|
|
4273 |
{
|
|
4274 |
return QWindowsStyle::itemPixmapRect(r, flags, pixmap);
|
|
4275 |
}
|
|
4276 |
|
|
4277 |
/*!
|
|
4278 |
\reimp
|
|
4279 |
*/
|
|
4280 |
void QCleanlooksStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
|
|
4281 |
int alignment, const QPixmap &pixmap) const
|
|
4282 |
{
|
|
4283 |
QWindowsStyle::drawItemPixmap(painter, rect, alignment, pixmap);
|
|
4284 |
}
|
|
4285 |
|
|
4286 |
/*!
|
|
4287 |
\reimp
|
|
4288 |
*/
|
|
4289 |
QStyle::SubControl QCleanlooksStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
|
|
4290 |
const QPoint &pt, const QWidget *w) const
|
|
4291 |
{
|
|
4292 |
return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
|
|
4293 |
}
|
|
4294 |
|
|
4295 |
/*!
|
|
4296 |
\reimp
|
|
4297 |
*/
|
|
4298 |
QPixmap QCleanlooksStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
|
4299 |
const QStyleOption *opt) const
|
|
4300 |
{
|
|
4301 |
return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
|
4302 |
}
|
|
4303 |
|
|
4304 |
/*!
|
|
4305 |
\reimp
|
|
4306 |
*/
|
|
4307 |
int QCleanlooksStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
|
4308 |
QStyleHintReturn *returnData) const
|
|
4309 |
{
|
|
4310 |
int ret = 0;
|
|
4311 |
switch (hint) {
|
|
4312 |
case SH_ScrollBar_MiddleClickAbsolutePosition:
|
|
4313 |
ret = true;
|
|
4314 |
break;
|
|
4315 |
case SH_EtchDisabledText:
|
|
4316 |
ret = 1;
|
|
4317 |
break;
|
|
4318 |
case SH_Menu_AllowActiveAndDisabled:
|
|
4319 |
ret = false;
|
|
4320 |
break;
|
|
4321 |
case SH_MainWindow_SpaceBelowMenuBar:
|
|
4322 |
ret = 0;
|
|
4323 |
break;
|
|
4324 |
case SH_MenuBar_MouseTracking:
|
|
4325 |
ret = 1;
|
|
4326 |
break;
|
|
4327 |
case SH_TitleBar_AutoRaise:
|
|
4328 |
ret = 1;
|
|
4329 |
break;
|
|
4330 |
case SH_TitleBar_NoBorder:
|
|
4331 |
ret = 1;
|
|
4332 |
break;
|
|
4333 |
case SH_ItemView_ShowDecorationSelected:
|
|
4334 |
ret = true;
|
|
4335 |
break;
|
|
4336 |
case SH_Table_GridLineColor:
|
|
4337 |
if (option) {
|
|
4338 |
ret = option->palette.background().color().darker(120).rgb();
|
|
4339 |
break;
|
|
4340 |
}
|
|
4341 |
case SH_ComboBox_Popup:
|
|
4342 |
#ifdef QT3_SUPPORT
|
|
4343 |
if (widget && widget->inherits("Q3ComboBox"))
|
|
4344 |
return 0;
|
|
4345 |
#endif
|
|
4346 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
|
|
4347 |
ret = !cmb->editable;
|
|
4348 |
else
|
|
4349 |
ret = 0;
|
|
4350 |
break;
|
|
4351 |
case SH_WindowFrame_Mask:
|
|
4352 |
ret = 1;
|
|
4353 |
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
|
|
4354 |
//left rounded corner
|
|
4355 |
mask->region = option->rect;
|
|
4356 |
mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1);
|
|
4357 |
mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1);
|
|
4358 |
mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1);
|
|
4359 |
mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2);
|
|
4360 |
|
|
4361 |
//right rounded corner
|
|
4362 |
mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1);
|
|
4363 |
mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1);
|
|
4364 |
mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1);
|
|
4365 |
mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2);
|
|
4366 |
}
|
|
4367 |
break;
|
|
4368 |
case SH_MessageBox_TextInteractionFlags:
|
|
4369 |
ret = Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;
|
|
4370 |
break;
|
|
4371 |
case SH_DialogButtonBox_ButtonsHaveIcons:
|
|
4372 |
ret = true;
|
|
4373 |
break;
|
|
4374 |
case SH_MessageBox_CenterButtons:
|
|
4375 |
ret = false;
|
|
4376 |
break;
|
|
4377 |
#ifndef QT_NO_WIZARD
|
|
4378 |
case SH_WizardStyle:
|
|
4379 |
ret = QWizard::ClassicStyle;
|
|
4380 |
break;
|
|
4381 |
#endif
|
|
4382 |
case SH_ItemView_ArrowKeysNavigateIntoChildren:
|
|
4383 |
ret = false;
|
|
4384 |
break;
|
|
4385 |
case SH_Menu_SubMenuPopupDelay:
|
|
4386 |
ret = 225; // default from GtkMenu
|
|
4387 |
break;
|
|
4388 |
default:
|
|
4389 |
ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
|
|
4390 |
break;
|
|
4391 |
}
|
|
4392 |
return ret;
|
|
4393 |
}
|
|
4394 |
|
|
4395 |
/*! \reimp */
|
|
4396 |
QRect QCleanlooksStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
|
|
4397 |
{
|
|
4398 |
QRect r = QWindowsStyle::subElementRect(sr, opt, w);
|
|
4399 |
switch (sr) {
|
|
4400 |
case SE_PushButtonFocusRect:
|
|
4401 |
r.adjust(0, 1, 0, -1);
|
|
4402 |
break;
|
|
4403 |
case SE_DockWidgetTitleBarText: {
|
|
4404 |
const QStyleOptionDockWidgetV2 *v2
|
|
4405 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt);
|
|
4406 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
|
4407 |
if (verticalTitleBar) {
|
|
4408 |
r.adjust(0, 0, 0, -4);
|
|
4409 |
} else {
|
|
4410 |
if (opt->direction == Qt::LeftToRight)
|
|
4411 |
r.adjust(4, 0, 0, 0);
|
|
4412 |
else
|
|
4413 |
r.adjust(0, 0, -4, 0);
|
|
4414 |
}
|
|
4415 |
|
|
4416 |
break;
|
|
4417 |
}
|
|
4418 |
case SE_ProgressBarContents:
|
|
4419 |
r = subElementRect(SE_ProgressBarGroove, opt, w);
|
|
4420 |
break;
|
|
4421 |
default:
|
|
4422 |
break;
|
|
4423 |
}
|
|
4424 |
return r;
|
|
4425 |
}
|
|
4426 |
|
|
4427 |
/*!
|
|
4428 |
\internal
|
|
4429 |
*/
|
|
4430 |
QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon,
|
|
4431 |
const QStyleOption *option,
|
|
4432 |
const QWidget *widget) const
|
|
4433 |
{
|
|
4434 |
return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
|
|
4435 |
}
|
|
4436 |
|
|
4437 |
/*!
|
|
4438 |
\reimp
|
|
4439 |
*/
|
|
4440 |
QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
|
4441 |
const QWidget *widget) const
|
|
4442 |
{
|
|
4443 |
QPixmap pixmap;
|
|
4444 |
|
|
4445 |
#ifndef QT_NO_IMAGEFORMAT_XPM
|
|
4446 |
switch (standardPixmap) {
|
|
4447 |
case SP_TitleBarNormalButton:
|
|
4448 |
return QPixmap((const char **)dock_widget_restore_xpm);
|
|
4449 |
case SP_TitleBarMinButton:
|
|
4450 |
return QPixmap((const char **)workspace_minimize);
|
|
4451 |
case SP_TitleBarCloseButton:
|
|
4452 |
case SP_DockWidgetCloseButton:
|
|
4453 |
return QPixmap((const char **)dock_widget_close_xpm);
|
|
4454 |
|
|
4455 |
default:
|
|
4456 |
break;
|
|
4457 |
}
|
|
4458 |
#endif //QT_NO_IMAGEFORMAT_XPM
|
|
4459 |
|
|
4460 |
return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
|
|
4461 |
}
|
|
4462 |
|
|
4463 |
QT_END_NAMESPACE
|
|
4464 |
|
|
4465 |
#endif // QT_NO_STYLE_CLEANLOOKS || QT_PLUGIN
|