source: trunk/src/gui/styles/qcleanlooksstyle.cpp@ 348

Last change on this file since 348 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

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