Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qfusionstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qfusionstyle_p.h"
5#include "qfusionstyle_p_p.h"
6
7#if QT_CONFIG(style_fusion) || defined(QT_PLUGIN)
8#include "qcommonstyle_p.h"
9#if QT_CONFIG(combobox)
10#include <qcombobox.h>
11#endif
12#if QT_CONFIG(pushbutton)
13#include <qpushbutton.h>
14#endif
15#if QT_CONFIG(abstractbutton)
16#include <qabstractbutton.h>
17#endif
18#include <qpainter.h>
19#include <qpainterpath.h>
20#include <qdir.h>
21#include <qstyleoption.h>
22#include <qapplication.h>
23#if QT_CONFIG(mainwindow)
24#include <qmainwindow.h>
25#endif
26#include <qfont.h>
27#if QT_CONFIG(groupbox)
28#include <qgroupbox.h>
29#endif
30#include <qpixmapcache.h>
31#if QT_CONFIG(scrollbar)
32#include <qscrollbar.h>
33#endif
34#if QT_CONFIG(spinbox)
35#include <qspinbox.h>
36#endif
37#if QT_CONFIG(abstractslider)
38#include <qabstractslider.h>
39#endif
40#if QT_CONFIG(slider)
41#include <qslider.h>
42#endif
43#if QT_CONFIG(splitter)
44#include <qsplitter.h>
45#endif
46#if QT_CONFIG(progressbar)
47#include <qprogressbar.h>
48#endif
49#if QT_CONFIG(wizard)
50#include <qwizard.h>
51#endif
52#include <qdrawutil.h>
53#include <private/qstylehelper_p.h>
54#include <private/qdrawhelper_p.h>
55#include <private/qapplication_p.h>
56#include <private/qwidget_p.h>
57
59
60using namespace Qt::StringLiterals;
61using namespace QStyleHelper;
62
63enum Direction {
64 TopDown,
65 FromLeft,
66 BottomUp,
67 FromRight
68};
69
70// from windows style
71static const int windowsItemFrame = 2; // menu item frame width
72static const int windowsItemVMargin = 8; // menu item ver text margin
73
74static const int groupBoxBottomMargin = 0; // space below the groupbox
75static const int groupBoxTopMargin = 3;
76
77#if QT_CONFIG(imageformat_xpm)
78/* XPM */
79static const char * const fusion_dock_widget_close_xpm[] = {
80 "11 13 7 1",
81 " c None",
82 ". c #D5CFCB",
83 "+ c #8F8B88",
84 "@ c #6C6A67",
85 "# c #ABA6A3",
86 "$ c #B5B0AC",
87 "% c #A4A09D",
88 " ",
89 " +@@@@@@@+ ",
90 "+# #+",
91 "@ $@ @$ @",
92 "@ @@@ @@@ @",
93 "@ @@@@@ @",
94 "@ @@@ @",
95 "@ @@@@@ @",
96 "@ @@@ @@@ @",
97 "@ $@ @$ @",
98 "+% #+",
99 " +@@@@@@@+ ",
100 " "};
101
102static const char * const dock_widget_restore_xpm[] = {
103 "11 13 7 1",
104 " c None",
105 ". c #D5CFCB",
106 "+ c #8F8B88",
107 "@ c #6C6A67",
108 "# c #ABA6A3",
109 "$ c #B5B0AC",
110 "% c #A4A09D",
111 " ",
112 " +@@@@@@@+ ",
113 "+# #+",
114 "@ #@@@# @",
115 "@ @ @ @",
116 "@ #@@@# @ @",
117 "@ @ @ @ @",
118 "@ @ @@@ @",
119 "@ @ @ @",
120 "@ #@@@# @",
121 "+% #+",
122 " +@@@@@@@+ ",
123 " "};
124
125static const char * const workspace_minimize[] = {
126 "11 13 7 1",
127 " c None",
128 ". c #D5CFCB",
129 "+ c #8F8B88",
130 "@ c #6C6A67",
131 "# c #ABA6A3",
132 "$ c #B5B0AC",
133 "% c #A4A09D",
134 " ",
135 " +@@@@@@@+ ",
136 "+# #+",
137 "@ @",
138 "@ @",
139 "@ @",
140 "@ @@@@@@@ @",
141 "@ @@@@@@@ @",
142 "@ @",
143 "@ @",
144 "+% #+",
145 " +@@@@@@@+ ",
146 " "};
147
148
149static const char * const qt_titlebar_context_help[] = {
150 "10 10 3 1",
151 " c None",
152 "# c #000000",
153 "+ c #444444",
154 " +####+ ",
155 " ### ### ",
156 " ## ## ",
157 " +##+ ",
158 " +## ",
159 " ## ",
160 " ## ",
161 " ",
162 " ## ",
163 " ## "};
164#endif // QT_CONFIG(imageformat_xpm)
165
166static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
167{
168 const int maxFactor = 100;
169 QColor tmp = colorA;
170 tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
171 tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
172 tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
173 return tmp;
174}
175
176// The default button and handle gradient
177static QLinearGradient qt_fusion_gradient(const QRect &rect, const QBrush &baseColor, Direction direction = TopDown)
178{
179 int x = rect.center().x();
180 int y = rect.center().y();
181 QLinearGradient gradient;
182 switch (direction) {
183 case FromLeft:
184 gradient = QLinearGradient(rect.left(), y, rect.right(), y);
185 break;
186 case FromRight:
187 gradient = QLinearGradient(rect.right(), y, rect.left(), y);
188 break;
189 case BottomUp:
190 gradient = QLinearGradient(x, rect.bottom(), x, rect.top());
191 break;
192 case TopDown:
193 default:
194 gradient = QLinearGradient(x, rect.top(), x, rect.bottom());
195 break;
196 }
197 if (baseColor.gradient())
198 gradient.setStops(baseColor.gradient()->stops());
199 else {
200 QColor gradientStartColor = baseColor.color().lighter(124);
201 QColor gradientStopColor = baseColor.color().lighter(102);
202 gradient.setColorAt(0, gradientStartColor);
203 gradient.setColorAt(1, gradientStopColor);
204 // Uncomment for adding shiny shading
205 // QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 55);
206 // QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 45);
207 // gradient.setColorAt(0.5, midColor1);
208 // gradient.setColorAt(0.501, midColor2);
209 }
210 return gradient;
211}
212
213static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color)
214{
215 if (rect.isEmpty())
216 return;
217
219 const int arrowWidth = int(QStyleHelper::dpiScaled(14, dpi));
220 const int arrowHeight = int(QStyleHelper::dpiScaled(8, dpi));
221
222 const int arrowMax = qMin(arrowHeight, arrowWidth);
223 const int rectMax = qMin(rect.height(), rect.width());
224 const int size = qMin(arrowMax, rectMax);
225
226 QPixmap cachePixmap;
227 const QString cacheKey = QStyleHelper::uniqueName("fusion-arrow"_L1
229 % HexString<uint>(color.rgba()),
230 option, rect.size());
231 if (!QPixmapCache::find(cacheKey, &cachePixmap)) {
232 cachePixmap = styleCachePixmap(rect.size());
233 cachePixmap.fill(Qt::transparent);
234 QPainter cachePainter(&cachePixmap);
235
236 QRectF arrowRect;
237 arrowRect.setWidth(size);
238 arrowRect.setHeight(arrowHeight * size / arrowWidth);
240 arrowRect = arrowRect.transposed();
241 arrowRect.moveTo((rect.width() - arrowRect.width()) / 2.0,
242 (rect.height() - arrowRect.height()) / 2.0);
243
245 switch (type) {
246 case Qt::DownArrow:
247 triangle << arrowRect.topLeft() << arrowRect.topRight() << QPointF(arrowRect.center().x(), arrowRect.bottom());
248 break;
249 case Qt::RightArrow:
250 triangle << arrowRect.topLeft() << arrowRect.bottomLeft() << QPointF(arrowRect.right(), arrowRect.center().y());
251 break;
252 case Qt::LeftArrow:
253 triangle << arrowRect.topRight() << arrowRect.bottomRight() << QPointF(arrowRect.left(), arrowRect.center().y());
254 break;
255 default:
256 triangle << arrowRect.bottomLeft() << arrowRect.bottomRight() << QPointF(arrowRect.center().x(), arrowRect.top());
257 break;
258 }
259
260 cachePainter.setPen(Qt::NoPen);
261 cachePainter.setBrush(color);
262 cachePainter.setRenderHint(QPainter::Antialiasing);
263 cachePainter.drawPolygon(triangle.data(), int(triangle.size()));
264
265 QPixmapCache::insert(cacheKey, cachePixmap);
266 }
267
268 painter->drawPixmap(rect, cachePixmap);
269}
270
271static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
272{
273 QColor dark;
274 dark.setHsv(option->palette.button().color().hue(),
275 qMin(255, (int)(option->palette.button().color().saturation())),
276 qMin(255, (int)(option->palette.button().color().value()*0.7)));
277
278 QColor highlight = option->palette.highlight().color();
279
280 bool active = (option->titleBarState & QStyle::State_Active);
281 QColor titleBarHighlight(255, 255, 255, 60);
282
283 if (sunken)
284 painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120));
285 else if (hover)
286 painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20));
287
288 QColor mdiButtonGradientStartColor;
289 QColor mdiButtonGradientStopColor;
290
291 mdiButtonGradientStartColor = QColor(0, 0, 0, 40);
292 mdiButtonGradientStopColor = QColor(255, 255, 255, 60);
293
294 if (sunken)
295 titleBarHighlight = highlight.darker(130);
296
297 QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom());
298 gradient.setColorAt(0, mdiButtonGradientStartColor);
299 gradient.setColorAt(1, mdiButtonGradientStopColor);
300 QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110));
301
302 painter->setPen(QPen(mdiButtonBorderColor));
303 const QLine lines[4] = {
304 QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
305 QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
306 QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
307 QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2)
308 };
309 painter->drawLines(lines, 4);
310 const QPoint points[4] = {
311 QPoint(tmp.left() + 1, tmp.top() + 1),
312 QPoint(tmp.right() - 1, tmp.top() + 1),
313 QPoint(tmp.left() + 1, tmp.bottom() - 1),
314 QPoint(tmp.right() - 1, tmp.bottom() - 1)
315 };
317
318 painter->setPen(titleBarHighlight);
319 painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
320 painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2);
321
322 painter->setPen(QPen(gradient, 1));
323 painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2);
324 painter->drawPoint(tmp.right() , tmp.top() + 1);
325
326 painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1);
327 painter->drawPoint(tmp.left() + 1, tmp.bottom());
328 painter->drawPoint(tmp.right() - 1, tmp.bottom());
329 painter->drawPoint(tmp.right() , tmp.bottom() - 1);
330}
331
332/*
333 \internal
334*/
335QFusionStylePrivate::QFusionStylePrivate()
336{
337 animationFps = 60;
338}
339
356QFusionStyle::QFusionStyle() : QCommonStyle(*new QFusionStylePrivate)
357{
358 setObjectName("Fusion"_L1);
359}
360
366QFusionStyle::QFusionStyle(QFusionStylePrivate &dd) : QCommonStyle(dd)
367{
368}
369
373QFusionStyle::~QFusionStyle()
374{
375}
376
395void QFusionStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
396 bool enabled, const QString& text, QPalette::ColorRole textRole) const
397{
398 if (text.isEmpty())
399 return;
400
401 QPen savedPen = painter->pen();
402 if (textRole != QPalette::NoRole) {
403 painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
404 }
405 if (!enabled) {
406 QPen pen = painter->pen();
407 painter->setPen(pen);
408 }
410 painter->setPen(savedPen);
411}
412
413
417void QFusionStyle::drawPrimitive(PrimitiveElement elem,
418 const QStyleOption *option,
419 QPainter *painter, const QWidget *widget) const
420{
422 Q_D (const QFusionStyle);
423
424 QRect rect = option->rect;
425 int state = option->state;
426
427 QColor outline = d->outline(option->palette);
428 QColor highlightedOutline = d->highlightedOutline(option->palette);
429
430 QColor tabFrameColor = d->tabFrameColor(option->palette);
431
432 switch (elem) {
433
434#if QT_CONFIG(groupbox)
435 // No frame drawn
436 case PE_FrameGroupBox:
437 {
438 QPixmap pixmap(":/qt-project.org/styles/commonstyle/images/fusion_groupbox.png"_L1);
439 int topMargin = 0;
440 auto control = qobject_cast<const QGroupBox *>(widget);
441 if (control && !control->isCheckable() && control->title().isEmpty()) {
442 // Shrinking the topMargin if Not checkable AND title is empty
443 topMargin = groupBoxTopMargin;
444 } else {
445 topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
446 }
447 QRect frame = option->rect.adjusted(0, topMargin, 0, 0);
449 break;
450 }
451#endif // QT_CONFIG(groupbox)
452 case PE_IndicatorBranch: {
453 if (!(option->state & State_Children))
454 break;
455 if (option->state & State_Open)
456 drawPrimitive(PE_IndicatorArrowDown, option, painter, widget);
457 else {
458 const bool reverse = (option->direction == Qt::RightToLeft);
459 drawPrimitive(reverse ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight, option, painter, widget);
460 }
461 break;
462 }
463#if QT_CONFIG(tabbar)
464 case PE_FrameTabBarBase:
465 if (const QStyleOptionTabBarBase *tbb
466 = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
467 painter->save();
468 painter->setPen(QPen(outline.lighter(110)));
469 switch (tbb->shape) {
471 QRegion region(tbb->rect);
472 region -= tbb->selectedTabRect;
473 painter->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
474 painter->setClipRegion(region);
475 painter->setPen(option->palette.light().color());
476 painter->drawLine(tbb->rect.topLeft() + QPoint(0, 1), tbb->rect.topRight() + QPoint(0, 1));
477 }
478 break;
480 painter->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
481 break;
483 painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
484 tbb->rect.right(), tbb->rect.bottom());
485 break;
487 painter->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
488 break;
493 painter->restore();
495 return;
496 }
497 painter->restore();
498 }
499 return;
500#endif // QT_CONFIG(tabbar)
501 case PE_PanelScrollAreaCorner: {
502 painter->save();
503 QColor alphaOutline = outline;
504 alphaOutline.setAlpha(180);
505 painter->setPen(alphaOutline);
506 painter->setBrush(option->palette.brush(QPalette::Window));
507 painter->drawRect(option->rect);
508 painter->restore();
509 } break;
510 case PE_IndicatorArrowUp:
511 case PE_IndicatorArrowDown:
512 case PE_IndicatorArrowRight:
513 case PE_IndicatorArrowLeft:
514 {
515 if (option->rect.width() <= 1 || option->rect.height() <= 1)
516 break;
517 QColor arrowColor = option->palette.windowText().color();
518 arrowColor.setAlpha(160);
520 switch (elem) {
521 case PE_IndicatorArrowDown:
522 arrow = Qt::DownArrow;
523 break;
524 case PE_IndicatorArrowRight:
525 arrow = Qt::RightArrow;
526 break;
527 case PE_IndicatorArrowLeft:
528 arrow = Qt::LeftArrow;
529 break;
530 default:
531 break;
532 }
533 qt_fusion_draw_arrow(arrow, painter, option, option->rect, arrowColor);
534 }
535 break;
536 case PE_IndicatorItemViewItemCheck:
537 {
539 button.QStyleOption::operator=(*option);
540 button.state &= ~State_MouseOver;
541 proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);
542 }
543 return;
544 case PE_IndicatorHeaderArrow:
545 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
546 QRect r = header->rect;
547 QColor arrowColor = header->palette.windowText().color();
548 arrowColor.setAlpha(180);
549 QPoint offset = QPoint(0, -2);
550
551#if defined(Q_OS_LINUX)
552 if (header->sortIndicator & QStyleOptionHeader::SortUp) {
553 qt_fusion_draw_arrow(Qt::UpArrow, painter, option, r.translated(offset), arrowColor);
554 } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
555 qt_fusion_draw_arrow(Qt::DownArrow, painter, option, r.translated(offset), arrowColor);
556 }
557#else
558 if (header->sortIndicator & QStyleOptionHeader::SortUp) {
559 qt_fusion_draw_arrow(Qt::DownArrow, painter, option, r.translated(offset), arrowColor);
560 } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
561 qt_fusion_draw_arrow(Qt::UpArrow, painter, option, r.translated(offset), arrowColor);
562 }
563#endif
564 }
565 break;
566 case PE_IndicatorButtonDropDown:
567 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
568 break;
569
570 case PE_IndicatorToolBarSeparator:
571 {
572 QRect rect = option->rect;
573 const int margin = 6;
574 if (option->state & State_Horizontal) {
575 const int offset = rect.width()/2;
576 painter->setPen(QPen(option->palette.window().color().darker(110)));
577 painter->drawLine(rect.bottomLeft().x() + offset,
578 rect.bottomLeft().y() - margin,
579 rect.topLeft().x() + offset,
580 rect.topLeft().y() + margin);
581 painter->setPen(QPen(option->palette.window().color().lighter(110)));
582 painter->drawLine(rect.bottomLeft().x() + offset + 1,
583 rect.bottomLeft().y() - margin,
584 rect.topLeft().x() + offset + 1,
585 rect.topLeft().y() + margin);
586 } else { //Draw vertical separator
587 const int offset = rect.height()/2;
588 painter->setPen(QPen(option->palette.window().color().darker(110)));
589 painter->drawLine(rect.topLeft().x() + margin ,
590 rect.topLeft().y() + offset,
591 rect.topRight().x() - margin,
592 rect.topRight().y() + offset);
593 painter->setPen(QPen(option->palette.window().color().lighter(110)));
594 painter->drawLine(rect.topLeft().x() + margin ,
595 rect.topLeft().y() + offset + 1,
596 rect.topRight().x() - margin,
597 rect.topRight().y() + offset + 1);
598 }
599 }
600 break;
601 case PE_Frame: {
602 if (widget && widget->inherits("QComboBoxPrivateContainer")){
604 copy.state |= State_Raised;
605 proxy()->drawPrimitive(PE_PanelMenu, &copy, painter, widget);
606 break;
607 }
608 painter->save();
609 QPen thePen(outline.lighter(108));
610 thePen.setCosmetic(false);
611 painter->setPen(thePen);
612 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
613 painter->restore(); }
614 break;
615 case PE_FrameMenu:
616 painter->save();
617 {
618 painter->setPen(QPen(outline));
619 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
620 QColor frameLight = option->palette.window().color().lighter(160);
621 QColor frameShadow = option->palette.window().color().darker(110);
622
623 //paint beveleffect
624 QRect frame = option->rect.adjusted(1, 1, -1, -1);
625 painter->setPen(frameLight);
626 painter->drawLine(frame.topLeft(), frame.bottomLeft());
627 painter->drawLine(frame.topLeft(), frame.topRight());
628
629 painter->setPen(frameShadow);
630 painter->drawLine(frame.topRight(), frame.bottomRight());
631 painter->drawLine(frame.bottomLeft(), frame.bottomRight());
632 }
633 painter->restore();
634 break;
635 case PE_FrameDockWidget:
636
637 painter->save();
638 {
639 QColor softshadow = option->palette.window().color().darker(120);
640
641 QRect rect= option->rect;
642 painter->setPen(softshadow);
643 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
644 painter->setPen(QPen(option->palette.light(), 1));
645 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1));
646 painter->setPen(QPen(option->palette.window().color().darker(120)));
647 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1));
648 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1));
649
650 }
651 painter->restore();
652 break;
653 case PE_PanelButtonTool:
654 painter->save();
655 if ((option->state & State_Enabled || option->state & State_On) || !(option->state & State_AutoRaise)) {
656 if (widget && widget->inherits("QDockWidgetTitleButton")) {
657 if (option->state & State_MouseOver)
658 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
659 } else {
660 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
661 }
662 }
663 painter->restore();
664 break;
665 case PE_IndicatorDockWidgetResizeHandle:
666 {
667 QStyleOption dockWidgetHandle = *option;
668 bool horizontal = option->state & State_Horizontal;
669 dockWidgetHandle.state.setFlag(State_Horizontal, !horizontal);
670 proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);
671 }
672 break;
673 case PE_FrameWindow:
674 painter->save();
675 {
676 QRect rect= option->rect;
677 painter->setPen(QPen(outline.darker(150)));
678 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
679 painter->setPen(QPen(option->palette.light(), 1));
680 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
681 QPoint(rect.left() + 1, rect.bottom() - 1));
682 painter->setPen(QPen(option->palette.window().color().darker(120)));
683 painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
684 QPoint(rect.right() - 2, rect.bottom() - 1));
685 painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
686 QPoint(rect.right() - 1, rect.bottom() - 1));
687 }
688 painter->restore();
689 break;
690 case PE_FrameLineEdit:
691 {
692 QRect r = rect;
693 bool hasFocus = option->state & State_HasFocus;
694
695 painter->save();
696
698 // ### highdpi painter bug.
699 painter->translate(0.5, 0.5);
700
701 // Draw Outline
702 painter->setPen( QPen(hasFocus ? highlightedOutline : outline));
703 painter->drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
704
705 if (hasFocus) {
706 QColor softHighlight = highlightedOutline;
707 softHighlight.setAlpha(40);
708 painter->setPen(softHighlight);
709 painter->drawRoundedRect(r.adjusted(1, 1, -2, -2), 1.7, 1.7);
710 }
711 // Draw inner shadow
712 painter->setPen(d->topShadow());
713 painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
714
715 painter->restore();
716
717 }
718 break;
719 case PE_IndicatorCheckBox:
720 painter->save();
721 if (const QStyleOptionButton *checkbox = qstyleoption_cast<const QStyleOptionButton*>(option)) {
723 painter->translate(0.5, 0.5);
724 rect = rect.adjusted(0, 0, -1, -1);
725
726 QColor pressedColor = mergedColors(option->palette.base().color(), option->palette.windowText().color(), 85);
728
729 // Gradient fill
730 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
731 gradient.setColorAt(0, (state & State_Sunken) ? pressedColor : option->palette.base().color().darker(115));
732 gradient.setColorAt(0.15, (state & State_Sunken) ? pressedColor : option->palette.base().color());
733 gradient.setColorAt(1, (state & State_Sunken) ? pressedColor : option->palette.base().color());
734
735 painter->setBrush((state & State_Sunken) ? QBrush(pressedColor) : gradient);
736 painter->setPen(QPen(outline.lighter(110)));
737
738 if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
739 painter->setPen(QPen(highlightedOutline));
741
742 QColor checkMarkColor = option->palette.text().color().darker(120);
743 const qreal checkMarkPadding = 1 + rect.width() * 0.13; // at least one pixel padding
744
745 if (checkbox->state & State_NoChange) {
746 gradient = QLinearGradient(rect.topLeft(), rect.bottomLeft());
747 checkMarkColor.setAlpha(80);
748 gradient.setColorAt(0, checkMarkColor);
749 checkMarkColor.setAlpha(140);
750 gradient.setColorAt(1, checkMarkColor);
751 checkMarkColor.setAlpha(180);
752 painter->setPen(QPen(checkMarkColor, 1));
753 painter->setBrush(gradient);
754 painter->drawRect(rect.adjusted(checkMarkPadding, checkMarkPadding, -checkMarkPadding, -checkMarkPadding));
755
756 } else if (checkbox->state & State_On) {
758 qreal penWidth = QStyleHelper::dpiScaled(1.5, dpi);
759 penWidth = qMax<qreal>(penWidth, 0.13 * rect.height());
760 penWidth = qMin<qreal>(penWidth, 0.20 * rect.height());
761 QPen checkPen = QPen(checkMarkColor, penWidth);
762 checkMarkColor.setAlpha(210);
763 painter->translate(dpiScaled(-0.8, dpi), dpiScaled(0.5, dpi));
764 painter->setPen(checkPen);
766
767 // Draw checkmark
769 const qreal rectHeight = rect.height(); // assuming height equals width
770 path.moveTo(checkMarkPadding + rectHeight * 0.11, rectHeight * 0.47);
771 path.lineTo(rectHeight * 0.5, rectHeight - checkMarkPadding);
772 path.lineTo(rectHeight - checkMarkPadding, checkMarkPadding);
773 painter->drawPath(path.translated(rect.topLeft()));
774 }
775 }
776 painter->restore();
777 break;
778 case PE_IndicatorRadioButton:
779 painter->save();
780 {
781 QColor pressedColor = mergedColors(option->palette.base().color(), option->palette.windowText().color(), 85);
782 painter->setBrush((state & State_Sunken) ? pressedColor : option->palette.base().color());
784 QPainterPath circle;
785 const QPointF circleCenter = rect.center() + QPoint(1, 1);
786 const qreal outlineRadius = (rect.width() + (rect.width() + 1) % 2) / 2.0 - 1;
787 circle.addEllipse(circleCenter, outlineRadius, outlineRadius);
788 painter->setPen(QPen(option->palette.window().color().darker(150)));
789 if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
790 painter->setPen(QPen(highlightedOutline));
791 painter->drawPath(circle);
792
793 if (state & (State_On )) {
794 circle = QPainterPath();
795 const qreal checkmarkRadius = outlineRadius / 2.32;
796 circle.addEllipse(circleCenter, checkmarkRadius, checkmarkRadius);
797 QColor checkMarkColor = option->palette.text().color().darker(120);
798 checkMarkColor.setAlpha(200);
799 painter->setPen(checkMarkColor);
800 checkMarkColor.setAlpha(180);
801 painter->setBrush(checkMarkColor);
802 painter->drawPath(circle);
803 }
804 }
805 painter->restore();
806 break;
807 case PE_IndicatorToolBarHandle:
808 {
809 //draw grips
810 if (option->state & State_Horizontal) {
811 for (int i = -3 ; i < 2 ; i += 3) {
812 for (int j = -8 ; j < 10 ; j += 3) {
813 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade());
814 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade());
815 }
816 }
817 } else { //vertical toolbar
818 for (int i = -6 ; i < 12 ; i += 3) {
819 for (int j = -3 ; j < 2 ; j += 3) {
820 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade());
821 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade());
822 }
823 }
824 }
825 break;
826 }
827 case PE_FrameDefaultButton:
828 break;
829 case PE_FrameFocusRect:
830 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
831 //### check for d->alt_down
832 if (!(fropt->state & State_KeyboardFocusChange))
833 return;
834 QRect rect = option->rect;
835
836 painter->save();
838 painter->translate(0.5, 0.5);
839 QColor fillcolor = highlightedOutline;
840 fillcolor.setAlpha(80);
841 painter->setPen(fillcolor.darker(120));
842 fillcolor.setAlpha(30);
843 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
844 gradient.setColorAt(0, fillcolor.lighter(160));
845 gradient.setColorAt(1, fillcolor);
846 painter->setBrush(gradient);
847 painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 1, 1);
848 painter->restore();
849 }
850 break;
851 case PE_PanelButtonCommand:
852 {
853 bool isDefault = false;
854 bool isFlat = false;
855 bool isDown = (option->state & State_Sunken) || (option->state & State_On);
856 QRect r;
857
858 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option)) {
859 isDefault = (button->features & QStyleOptionButton::DefaultButton) && (button->state & State_Enabled);
860 isFlat = (button->features & QStyleOptionButton::Flat);
861 }
862
863 if (isFlat && !isDown) {
864 if (isDefault) {
865 r = option->rect.adjusted(0, 1, 0, -1);
867 const QLine lines[4] = {
868 QLine(QPoint(r.left() + 2, r.top()),
869 QPoint(r.right() - 2, r.top())),
870 QLine(QPoint(r.left(), r.top() + 2),
871 QPoint(r.left(), r.bottom() - 2)),
872 QLine(QPoint(r.right(), r.top() + 2),
873 QPoint(r.right(), r.bottom() - 2)),
874 QLine(QPoint(r.left() + 2, r.bottom()),
875 QPoint(r.right() - 2, r.bottom()))
876 };
877 painter->drawLines(lines, 4);
878 const QPoint points[4] = {
879 QPoint(r.right() - 1, r.bottom() - 1),
880 QPoint(r.right() - 1, r.top() + 1),
881 QPoint(r.left() + 1, r.bottom() - 1),
882 QPoint(r.left() + 1, r.top() + 1)
883 };
885 }
886 return;
887 }
888
889
890 bool isEnabled = option->state & State_Enabled;
891 bool hasFocus = (option->state & State_HasFocus && option->state & State_KeyboardFocusChange);
892 QColor buttonColor = d->buttonColor(option->palette);
893
894 QColor darkOutline = outline;
895 if (hasFocus | isDefault) {
896 darkOutline = highlightedOutline;
897 }
898
899 if (isDefault)
900 buttonColor = mergedColors(buttonColor, highlightedOutline.lighter(130), 90);
901
902 BEGIN_STYLE_PIXMAPCACHE(QStringLiteral("pushbutton-") + buttonColor.name(QColor::HexArgb))
903 r = rect.adjusted(0, 1, -1, 0);
904
905 p->setRenderHint(QPainter::Antialiasing, true);
906 p->translate(0.5, -0.5);
907
908 QLinearGradient gradient = qt_fusion_gradient(rect, (isEnabled && option->state & State_MouseOver ) ? buttonColor : buttonColor.darker(104));
909 p->setPen(Qt::transparent);
910 p->setBrush(isDown ? QBrush(buttonColor.darker(110)) : gradient);
911 p->drawRoundedRect(r, 2.0, 2.0);
912 p->setBrush(Qt::NoBrush);
913
914 // Outline
915 p->setPen(!isEnabled ? QPen(darkOutline.lighter(115)) : QPen(darkOutline));
916 p->drawRoundedRect(r, 2.0, 2.0);
917
918 p->setPen(d->innerContrastLine());
919 p->drawRoundedRect(r.adjusted(1, 1, -1, -1), 2.0, 2.0);
920
922 }
923 break;
924 case PE_FrameTabWidget:
925 painter->save();
926 painter->fillRect(option->rect.adjusted(0, 0, -1, -1), tabFrameColor);
927#if QT_CONFIG(tabwidget)
928 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
929 QColor borderColor = outline.lighter(110);
930 QRect rect = option->rect.adjusted(0, 0, -1, -1);
931
932 // Shadow outline
933 if (twf->shape != QTabBar::RoundedSouth) {
934 rect.adjust(0, 0, 0, -1);
935 QColor alphaShadow(Qt::black);
936 alphaShadow.setAlpha(15);
937 painter->setPen(alphaShadow);
938 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->setPen(borderColor);
939 }
940
941 // outline
942 painter->setPen(outline);
944
945 // Inner frame highlight
946 painter->setPen(d->innerContrastLine());
947 painter->drawRect(rect.adjusted(1, 1, -1, -1));
948
949 }
950#endif // QT_CONFIG(tabwidget)
951 painter->restore();
952 break ;
953
954 case PE_FrameStatusBarItem:
955 break;
956 case PE_PanelMenu: {
957 painter->save();
958 const QBrush menuBackground = option->palette.base().color().lighter(108);
959 QColor borderColor = option->palette.window().color().darker(160);
960 qDrawPlainRect(painter, option->rect, borderColor, 1, &menuBackground);
961 painter->restore();
962 }
963 break;
964
965 default:
967 break;
968 }
969}
970
974void QFusionStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter,
975 const QWidget *widget) const
976{
977 Q_D (const QFusionStyle);
978 QRect rect = option->rect;
979 QColor outline = d->outline(option->palette);
980 QColor highlightedOutline = d->highlightedOutline(option->palette);
981 QColor shadow = d->darkShade();
982
983 switch (element) {
984 case CE_ComboBoxLabel:
985 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
986 QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
987 painter->save();
988 painter->setClipRect(editRect);
989 if (!cb->currentIcon.isNull()) {
990 QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
992 QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, painter->device()->devicePixelRatio(), mode);
993 QRect iconRect(editRect);
994 iconRect.setWidth(cb->iconSize.width() + 4);
995 iconRect = alignedRect(cb->direction,
997 iconRect.size(), editRect);
998 if (cb->editable)
999 painter->fillRect(iconRect, cb->palette.brush(QPalette::Base));
1000 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
1001
1002 if (cb->direction == Qt::RightToLeft)
1003 editRect.translate(-4 - cb->iconSize.width(), 0);
1004 else
1005 editRect.translate(cb->iconSize.width() + 4, 0);
1006 }
1007 if (!cb->currentText.isEmpty() && !cb->editable) {
1008 proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
1009 visualAlignment(cb->direction, cb->textAlignment),
1010 cb->palette, cb->state & State_Enabled, cb->currentText,
1011 cb->editable ? QPalette::Text : QPalette::ButtonText);
1012 }
1013 painter->restore();
1014 }
1015 break;
1016 case CE_Splitter:
1017 {
1018 // Don't draw handle for single pixel splitters
1019 if (option->rect.width() > 1 && option->rect.height() > 1) {
1020 //draw grips
1021 if (option->state & State_Horizontal) {
1022 for (int j = -6 ; j< 12 ; j += 3) {
1023 painter->fillRect(rect.center().x() + 1, rect.center().y() + j, 2, 2, d->lightShade());
1024 painter->fillRect(rect.center().x() + 1, rect.center().y() + j, 1, 1, d->darkShade());
1025 }
1026 } else {
1027 for (int i = -6; i< 12 ; i += 3) {
1028 painter->fillRect(rect.center().x() + i, rect.center().y(), 2, 2, d->lightShade());
1029 painter->fillRect(rect.center().x() + i, rect.center().y(), 1, 1, d->darkShade());
1030 }
1031 }
1032 }
1033 break;
1034 }
1035#if QT_CONFIG(rubberband)
1036 case CE_RubberBand:
1037 if (qstyleoption_cast<const QStyleOptionRubberBand *>(option)) {
1038 QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
1039 painter->save();
1040 QColor penColor = highlight.darker(120);
1041 penColor.setAlpha(180);
1042 painter->setPen(penColor);
1043 QColor dimHighlight(qMin(highlight.red()/2 + 110, 255),
1044 qMin(highlight.green()/2 + 110, 255),
1045 qMin(highlight.blue()/2 + 110, 255));
1046 dimHighlight.setAlpha(widget && widget->isWindow() ? 255 : 80);
1047 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()));
1048 gradient.setColorAt(0, dimHighlight.lighter(120));
1049 gradient.setColorAt(1, dimHighlight);
1051 painter->translate(0.5, 0.5);
1052 painter->setBrush(dimHighlight);
1053 painter->drawRoundedRect(option->rect.adjusted(0, 0, -1, -1), 1, 1);
1054 //when the rectangle we get is large enough, draw the inner rectangle.
1055 if (option->rect.width() > 2 && option->rect.height() > 2) {
1056 QColor innerLine = Qt::white;
1057 innerLine.setAlpha(40);
1058 painter->setPen(innerLine);
1059 painter->drawRoundedRect(option->rect.adjusted(1, 1, -2, -2), 1, 1);
1060 }
1061 painter->restore();
1062 }
1063 break;
1064#endif //QT_CONFIG(rubberband)
1065 case CE_SizeGrip:
1066 painter->save();
1067 {
1068 //draw grips
1069 for (int i = -6; i< 12 ; i += 3) {
1070 for (int j = -6 ; j< 12 ; j += 3) {
1071 if ((option->direction == Qt::LeftToRight && i > -j) || (option->direction == Qt::RightToLeft && j > i) ) {
1072 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 2, 2, d->lightShade());
1073 painter->fillRect(rect.center().x() + i, rect.center().y() + j, 1, 1, d->darkShade());
1074 }
1075 }
1076 }
1077 }
1078 painter->restore();
1079 break;
1080#if QT_CONFIG(toolbar)
1081 case CE_ToolBar:
1082 if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
1083 // Reserve the beveled appearance only for mainwindow toolbars
1084 if (widget && !(qobject_cast<const QMainWindow*> (widget->parentWidget())))
1085 break;
1086
1087 // Draws the light line above and the dark line below menu bars and
1088 // tool bars.
1089 QLinearGradient gradient(option->rect.topLeft(), option->rect.bottomLeft());
1090 if (!(option->state & State_Horizontal))
1091 gradient = QLinearGradient(rect.left(), rect.center().y(),
1092 rect.right(), rect.center().y());
1093 gradient.setColorAt(0, option->palette.window().color().lighter(104));
1094 gradient.setColorAt(1, option->palette.window().color());
1095 painter->fillRect(option->rect, gradient);
1096
1097 QColor light = d->lightShade();
1098 QColor shadow = d->darkShade();
1099
1100 QPen oldPen = painter->pen();
1101 if (toolBar->toolBarArea == Qt::TopToolBarArea) {
1102 if (toolBar->positionOfLine == QStyleOptionToolBar::End
1103 || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
1104 // The end and onlyone top toolbar lines draw a double
1105 // line at the bottom to blend with the central
1106 // widget.
1107 painter->setPen(light);
1108 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1109 painter->setPen(shadow);
1110 painter->drawLine(option->rect.left(), option->rect.bottom() - 1,
1111 option->rect.right(), option->rect.bottom() - 1);
1112 } else {
1113 // All others draw a single dark line at the bottom.
1114 painter->setPen(shadow);
1115 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1116 }
1117 // All top toolbar lines draw a light line at the top.
1118 painter->setPen(light);
1119 painter->drawLine(option->rect.topLeft(), option->rect.topRight());
1120 } else if (toolBar->toolBarArea == Qt::BottomToolBarArea) {
1121 if (toolBar->positionOfLine == QStyleOptionToolBar::End
1122 || toolBar->positionOfLine == QStyleOptionToolBar::Middle) {
1123 // The end and middle bottom tool bar lines draw a dark
1124 // line at the bottom.
1125 painter->setPen(shadow);
1126 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1127 }
1128 if (toolBar->positionOfLine == QStyleOptionToolBar::Beginning
1129 || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
1130 // The beginning and only one tool bar lines draw a
1131 // double line at the bottom to blend with the
1132 // status bar.
1133 // ### The styleoption could contain whether the
1134 // main window has a menu bar and a status bar, and
1135 // possibly dock widgets.
1136 painter->setPen(shadow);
1137 painter->drawLine(option->rect.left(), option->rect.bottom() - 1,
1138 option->rect.right(), option->rect.bottom() - 1);
1139 painter->setPen(light);
1140 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1141 }
1142 if (toolBar->positionOfLine == QStyleOptionToolBar::End) {
1143 painter->setPen(shadow);
1144 painter->drawLine(option->rect.topLeft(), option->rect.topRight());
1145 painter->setPen(light);
1146 painter->drawLine(option->rect.left(), option->rect.top() + 1,
1147 option->rect.right(), option->rect.top() + 1);
1148
1149 } else {
1150 // All other bottom toolbars draw a light line at the top.
1151 painter->setPen(light);
1152 painter->drawLine(option->rect.topLeft(), option->rect.topRight());
1153 }
1154 }
1155 if (toolBar->toolBarArea == Qt::LeftToolBarArea) {
1156 if (toolBar->positionOfLine == QStyleOptionToolBar::Middle
1157 || toolBar->positionOfLine == QStyleOptionToolBar::End) {
1158 // The middle and left end toolbar lines draw a light
1159 // line to the left.
1160 painter->setPen(light);
1161 painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
1162 }
1163 if (toolBar->positionOfLine == QStyleOptionToolBar::End) {
1164 // All other left toolbar lines draw a dark line to the right
1165 painter->setPen(shadow);
1166 painter->drawLine(option->rect.right() - 1, option->rect.top(),
1167 option->rect.right() - 1, option->rect.bottom());
1168 painter->setPen(light);
1169 painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
1170 } else {
1171 // All other left toolbar lines draw a dark line to the right
1172 painter->setPen(shadow);
1173 painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
1174 }
1175 } else if (toolBar->toolBarArea == Qt::RightToolBarArea) {
1176 if (toolBar->positionOfLine == QStyleOptionToolBar::Middle
1177 || toolBar->positionOfLine == QStyleOptionToolBar::End) {
1178 // Right middle and end toolbar lines draw the dark right line
1179 painter->setPen(shadow);
1180 painter->drawLine(option->rect.topRight(), option->rect.bottomRight());
1181 }
1182 if (toolBar->positionOfLine == QStyleOptionToolBar::End
1183 || toolBar->positionOfLine == QStyleOptionToolBar::OnlyOne) {
1184 // The right end and single toolbar draws the dark
1185 // line on its left edge
1186 painter->setPen(shadow);
1187 painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
1188 // And a light line next to it
1189 painter->setPen(light);
1190 painter->drawLine(option->rect.left() + 1, option->rect.top(),
1191 option->rect.left() + 1, option->rect.bottom());
1192 } else {
1193 // Other right toolbars draw a light line on its left edge
1194 painter->setPen(light);
1195 painter->drawLine(option->rect.topLeft(), option->rect.bottomLeft());
1196 }
1197 }
1198 painter->setPen(oldPen);
1199 }
1200 break;
1201#endif // QT_CONFIG(toolbar)
1202 case CE_DockWidgetTitle:
1203 painter->save();
1204 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
1205 bool verticalTitleBar = dwOpt->verticalTitleBar;
1206
1207 QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
1208 if (verticalTitleBar) {
1209 QRect rect = dwOpt->rect;
1210 QRect r = rect.transposed();
1211 titleRect = QRect(r.left() + rect.bottom()
1212 - titleRect.bottom(),
1213 r.top() + titleRect.left() - rect.left(),
1214 titleRect.height(), titleRect.width());
1215
1216 painter->translate(r.left(), r.top() + r.width());
1217 painter->rotate(-90);
1218 painter->translate(-r.left(), -r.top());
1219 }
1220
1221 if (!dwOpt->title.isEmpty()) {
1222 QString titleText
1223 = painter->fontMetrics().elidedText(dwOpt->title,
1224 Qt::ElideRight, titleRect.width());
1225 proxy()->drawItemText(painter,
1226 titleRect,
1227 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
1228 dwOpt->state & State_Enabled, titleText,
1230 }
1231 }
1232 painter->restore();
1233 break;
1234 case CE_HeaderSection:
1235 painter->save();
1236 // Draws the header in tables.
1237 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
1238 const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(option);
1239 QString pixmapName = QStyleHelper::uniqueName("headersection"_L1, option, option->rect.size());
1240 pixmapName += QString::number(- int(header->position));
1241 pixmapName += QString::number(- int(header->orientation));
1242 if (headerV2)
1243 pixmapName += QString::number(- int(headerV2->isSectionDragTarget));
1244
1245 QPixmap cache;
1246 if (!QPixmapCache::find(pixmapName, &cache)) {
1247 cache = styleCachePixmap(rect.size());
1248 cache.fill(Qt::transparent);
1249 QRect pixmapRect(0, 0, rect.width(), rect.height());
1250 QPainter cachePainter(&cache);
1251 QColor buttonColor = d->buttonColor(option->palette);
1252 QColor gradientStartColor = buttonColor.lighter(104);
1253 QColor gradientStopColor = buttonColor.darker(102);
1254 if (headerV2 && headerV2->isSectionDragTarget) {
1255 gradientStopColor = gradientStartColor.darker(130);
1256 gradientStartColor = gradientStartColor.darker(130);
1257 }
1258 QLinearGradient gradient(pixmapRect.topLeft(), pixmapRect.bottomLeft());
1259
1260 if (option->palette.window().gradient()) {
1261 gradient.setStops(option->palette.window().gradient()->stops());
1262 } else {
1263 QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 60);
1264 QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40);
1265 gradient.setColorAt(0, gradientStartColor);
1266 gradient.setColorAt(0.5, midColor1);
1267 gradient.setColorAt(0.501, midColor2);
1268 gradient.setColorAt(0.92, gradientStopColor);
1269 gradient.setColorAt(1, gradientStopColor.darker(104));
1270 }
1271 cachePainter.fillRect(pixmapRect, gradient);
1272 cachePainter.setPen(d->innerContrastLine());
1273 cachePainter.setBrush(Qt::NoBrush);
1274 cachePainter.drawLine(pixmapRect.topLeft(), pixmapRect.topRight());
1275 cachePainter.setPen(d->outline(option->palette));
1276 cachePainter.drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
1277
1278 if (header->orientation == Qt::Horizontal &&
1279 header->position != QStyleOptionHeader::End &&
1281 cachePainter.setPen(QColor(0, 0, 0, 40));
1282 cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight() + QPoint(0, -1));
1283 cachePainter.setPen(d->innerContrastLine());
1284 cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 0), pixmapRect.bottomRight() + QPoint(-1, -1));
1285 } else if (header->orientation == Qt::Vertical) {
1286 cachePainter.setPen(d->outline(option->palette));
1287 cachePainter.drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
1288 }
1289 cachePainter.end();
1290 QPixmapCache::insert(pixmapName, cache);
1291 }
1292 painter->drawPixmap(rect.topLeft(), cache);
1293 }
1294 painter->restore();
1295 break;
1296 case CE_ProgressBarGroove:
1297 painter->save();
1298 {
1300 painter->translate(0.5, 0.5);
1301
1302 QColor shadowAlpha = Qt::black;
1303 shadowAlpha.setAlpha(16);
1304 painter->setPen(shadowAlpha);
1305 painter->drawLine(rect.topLeft() - QPoint(0, 1), rect.topRight() - QPoint(0, 1));
1306
1307 painter->setBrush(option->palette.base());
1308 painter->setPen(QPen(outline));
1309 painter->drawRoundedRect(rect.adjusted(0, 0, -1, -1), 2, 2);
1310
1311 // Inner shadow
1312 painter->setPen(d->topShadow());
1313 painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
1314 QPoint(rect.right() - 1, rect.top() + 1));
1315 }
1316 painter->restore();
1317 break;
1318 case CE_ProgressBarContents:
1319 painter->save();
1321 painter->translate(0.5, 0.5);
1322 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
1323 bool vertical = false;
1324 bool inverted = false;
1325 bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
1326 bool complete = bar->progress == bar->maximum;
1327
1328 vertical = !(bar->state & QStyle::State_Horizontal);
1329 inverted = bar->invertedAppearance;
1330
1331 // If the orientation is vertical, we use a transform to rotate
1332 // the progress bar 90 degrees clockwise. This way we can use the
1333 // same rendering code for both orientations.
1334 if (vertical) {
1335 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1336 QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0);
1337 m.rotate(90.0);
1338 painter->setTransform(m, true);
1339 }
1340
1341 int maxWidth = rect.width();
1342 const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
1343 const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum);
1344 const auto progressSteps = qint64(progress) - bar->minimum;
1345 const auto progressBarWidth = progressSteps * maxWidth / totalSteps;
1346 int width = indeterminate ? maxWidth : progressBarWidth;
1347
1348 bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
1349 if (inverted)
1350 reverse = !reverse;
1351
1352 int step = 0;
1354 QColor highlight = d->highlight(option->palette);
1355 QColor highlightedoutline = highlight.darker(140);
1356 if (qGray(outline.rgb()) > qGray(highlightedoutline.rgb()))
1357 outline = highlightedoutline;
1358
1359 if (!indeterminate) {
1360 QColor innerShadow(Qt::black);
1361 innerShadow.setAlpha(35);
1362 painter->setPen(innerShadow);
1363 if (!reverse) {
1364 progressBar.setRect(rect.left(), rect.top(), width - 1, rect.height() - 1);
1365 if (!complete) {
1366 painter->drawLine(progressBar.topRight() + QPoint(2, 1), progressBar.bottomRight() + QPoint(2, 0));
1367 painter->setPen(QPen(highlight.darker(140)));
1368 painter->drawLine(progressBar.topRight() + QPoint(1, 1), progressBar.bottomRight() + QPoint(1, 0));
1369 }
1370 } else {
1371 progressBar.setRect(rect.right() - width - 1, rect.top(), width + 2, rect.height() - 1);
1372 if (!complete) {
1373 painter->drawLine(progressBar.topLeft() + QPoint(-2, 1), progressBar.bottomLeft() + QPoint(-2, 0));
1374 painter->setPen(QPen(highlight.darker(140)));
1375 painter->drawLine(progressBar.topLeft() + QPoint(-1, 1), progressBar.bottomLeft() + QPoint(-1, 0));
1376 }
1377 }
1378 } else {
1379 progressBar.setRect(rect.left(), rect.top(), rect.width() - 1, rect.height() - 1);
1380 }
1381
1382 if (indeterminate || bar->progress > bar->minimum) {
1383
1384 painter->setPen(QPen(outline));
1385
1386 QColor highlightedGradientStartColor = highlight.lighter(120);
1387 QColor highlightedGradientStopColor = highlight;
1388 QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y()));
1389 gradient.setColorAt(0, highlightedGradientStartColor);
1390 gradient.setColorAt(1, highlightedGradientStopColor);
1391
1392 painter->setBrush(gradient);
1393
1394 painter->save();
1395 if (!complete && !indeterminate)
1396 painter->setClipRect(progressBar.adjusted(-1, -1, -1, 1));
1397 QRect fillRect = progressBar.adjusted( !indeterminate && !complete && reverse ? -2 : 0, 0,
1398 indeterminate || complete || reverse ? 0 : 2, 0);
1399 painter->drawRoundedRect(fillRect, 2, 2);
1400 painter->restore();
1401
1403 painter->setPen(QColor(255, 255, 255, 50));
1404 painter->drawRoundedRect(progressBar.adjusted(1, 1, -1, -1), 1, 1);
1405
1406 if (!indeterminate) {
1407#if QT_CONFIG(animation)
1408 (const_cast<QFusionStylePrivate*>(d))->stopAnimation(option->styleObject);
1409#endif
1410 } else {
1411 highlightedGradientStartColor.setAlpha(120);
1412 painter->setPen(QPen(highlightedGradientStartColor, 9.0));
1413 painter->setClipRect(progressBar.adjusted(1, 1, -1, -1));
1414#if QT_CONFIG(animation)
1415 if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
1416 step = animation->animationStep() % 22;
1417 else
1418 (const_cast<QFusionStylePrivate*>(d))->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
1419#endif
1420 for (int x = progressBar.left() - rect.height(); x < rect.right() ; x += 22)
1421 painter->drawLine(x + step, progressBar.bottom() + 1,
1422 x + rect.height() + step, progressBar.top() - 2);
1423 }
1424 }
1425 }
1426 painter->restore();
1427 break;
1428 case CE_ProgressBarLabel:
1429 if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
1430 QRect leftRect;
1431 QRect rect = bar->rect;
1432 QColor textColor = option->palette.text().color();
1433 QColor alternateTextColor = d->highlightedText(option->palette);
1434
1435 painter->save();
1436 bool vertical = false, inverted = false;
1437 vertical = !(bar->state & QStyle::State_Horizontal);
1438 inverted = bar->invertedAppearance;
1439 if (vertical)
1440 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
1441 const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum);
1442 const auto progressSteps = qint64(bar->progress) - bar->minimum;
1443 const auto progressIndicatorPos = progressSteps * rect.width() / totalSteps;
1444 if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
1445 leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
1446 if (vertical)
1447 leftRect.translate(rect.width() - progressIndicatorPos, 0);
1448
1449 bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) ||
1450 ((bar->direction == Qt::LeftToRight) && inverted)));
1451
1452 QRegion rightRect = rect;
1453 rightRect = rightRect.subtracted(leftRect);
1454 painter->setClipRegion(rightRect);
1455 painter->setPen(flip ? alternateTextColor : textColor);
1457 if (!leftRect.isNull()) {
1458 painter->setPen(flip ? textColor : alternateTextColor);
1459 painter->setClipRect(leftRect);
1461 }
1462 painter->restore();
1463 }
1464 break;
1465 case CE_MenuBarItem:
1466 painter->save();
1467 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
1468 {
1470 item.rect = mbi->rect.adjusted(0, 1, 0, -3);
1471 QColor highlightOutline = option->palette.highlight().color().darker(125);
1472 painter->fillRect(rect, option->palette.window());
1473
1475
1476 bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
1477 bool dis = !(mbi->state & State_Enabled);
1478
1479 QRect r = option->rect;
1480 if (act) {
1481 painter->setBrush(option->palette.highlight().color());
1482 painter->setPen(QPen(highlightOutline));
1483 painter->drawRect(r.adjusted(0, 0, -1, -1));
1484
1485 // painter->drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2);
1486
1487 //draw text
1490 if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
1492 proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
1493 } else {
1494
1495 QColor shadow = mergedColors(option->palette.window().color().darker(120),
1496 outline.lighter(140), 60);
1497 painter->setPen(QPen(shadow));
1498 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1499 }
1500 }
1501 painter->restore();
1502 break;
1503 case CE_MenuItem:
1504 painter->save();
1505 // Draws one item in a popup menu.
1506 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
1507 QColor highlightOutline = highlightedOutline;
1508 QColor highlight = option->palette.highlight().color();
1509 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
1510 int w = 0;
1511 const int margin = int(QStyleHelper::dpiScaled(5, option));
1512 if (!menuItem->text.isEmpty()) {
1513 painter->setFont(menuItem->font);
1514 proxy()->drawItemText(painter, menuItem->rect.adjusted(margin, 0, -margin, 0),
1516 menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
1518 w = menuItem->fontMetrics.horizontalAdvance(menuItem->text) + margin;
1519 }
1520 painter->setPen(shadow.lighter(106));
1521 const bool reverse = menuItem->direction == Qt::RightToLeft;
1522 qreal y = menuItem->rect.center().y() + 0.5f;
1523 painter->drawLine(QPointF(menuItem->rect.left() + margin + (reverse ? 0 : w), y),
1524 QPointF(menuItem->rect.right() - margin - (reverse ? w : 0), y));
1525 painter->restore();
1526 break;
1527 }
1528 const bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
1529 if (selected) {
1530 QRect r = option->rect;
1531 painter->fillRect(r, highlight);
1532 painter->setPen(QPen(highlightOutline));
1533 painter->drawRect(QRectF(r).adjusted(0.5, 0.5, -0.5, -0.5));
1534 }
1535 const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
1536 const bool checked = menuItem->checked;
1537 const bool sunken = menuItem->state & State_Sunken;
1538 const bool enabled = menuItem->state & State_Enabled;
1539
1540 const int checkColHOffset = QFusionStylePrivate::menuItemHMargin + windowsItemFrame - 1;
1541 // icon checkbox's highlight column width
1542 int checkcol = qMax<int>(menuItem->rect.height() * 0.79,
1543 qMax<int>(menuItem->maxIconWidth, dpiScaled(21, option)));
1544 bool ignoreCheckMark = false;
1545 if (
1546#if QT_CONFIG(combobox)
1547 qobject_cast<const QComboBox*>(widget) ||
1548#endif
1549 (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool()))
1550 ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
1551
1552 if (!ignoreCheckMark || menuItem->state & (State_On | State_Off)) {
1553 // Check, using qreal and QRectF to avoid error accumulation
1554 const qreal boxMargin = dpiScaled(3.5, option);
1555 const qreal boxWidth = checkcol - 2 * boxMargin;
1556 QRect checkRect = QRectF(option->rect.left() + boxMargin + checkColHOffset,
1557 option->rect.center().y() - boxWidth/2 + 1, boxWidth,
1558 boxWidth).toRect();
1559 checkRect.setWidth(checkRect.height()); // avoid .toRect() round error results in non-perfect square
1560 checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
1561 if (checkable) {
1562 if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
1563 // Radio button
1564 if (menuItem->state & State_On || checked || sunken) {
1567
1568 QPalette::ColorRole textRole = !enabled
1569 ? QPalette::Text :
1570 selected ? QPalette::HighlightedText
1572 painter->setBrush(option->palette.brush( option->palette.currentColorGroup(), textRole));
1573 const int adjustment = checkRect.height() * 0.3;
1574 painter->drawEllipse(checkRect.adjusted(adjustment, adjustment, -adjustment, -adjustment));
1575 }
1576 } else {
1577 // Check box
1578 if (menuItem->icon.isNull()) {
1580 box.QStyleOption::operator=(*option);
1581 box.rect = checkRect;
1582 if (checked || menuItem->state & State_On)
1583 box.state |= State_On;
1584 else
1585 box.state |= State_Off;
1586 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
1587 }
1588 }
1589 }
1590 } else { //ignore checkmark
1591 if (menuItem->icon.isNull())
1592 checkcol = 0;
1593 else
1594 checkcol = menuItem->maxIconWidth;
1595 }
1596
1597 // Text and icon, ripped from windows style
1598 const bool dis = !(menuItem->state & State_Enabled);
1599 const bool act = menuItem->state & State_Selected;
1600 const QStyleOption *opt = option;
1601 const QStyleOptionMenuItem *menuitem = menuItem;
1602
1603 QPainter *p = painter;
1604 QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
1605 QRect(menuitem->rect.x() + checkColHOffset, menuitem->rect.y(),
1606 checkcol, menuitem->rect.height()));
1607 if (!menuItem->icon.isNull()) {
1609 if (act && !dis)
1612
1613 int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
1614 QSize iconSize(smallIconSize, smallIconSize);
1615#if QT_CONFIG(combobox)
1616 if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
1617 iconSize = combo->iconSize();
1618#endif
1619 if (checked)
1620 pixmap = menuItem->icon.pixmap(iconSize, painter->device()->devicePixelRatio(), mode, QIcon::On);
1621 else
1622 pixmap = menuItem->icon.pixmap(iconSize, painter->device()->devicePixelRatio(), mode);
1623
1624 QRect pmr(QPoint(0, 0), pixmap.deviceIndependentSize().toSize());
1625 pmr.moveCenter(vCheckRect.center());
1626 painter->setPen(menuItem->palette.text().color());
1627 if (!ignoreCheckMark && checkable && checked) {
1629 if (act) {
1630 QColor activeColor = mergedColors(option->palette.window().color(),
1631 option->palette.highlight().color());
1632 opt.palette.setBrush(QPalette::Button, activeColor);
1633 }
1634 opt.state |= State_Sunken;
1635 opt.rect = vCheckRect;
1636 proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
1637 }
1638 painter->drawPixmap(pmr.topLeft(), pixmap);
1639 }
1640 if (selected) {
1641 painter->setPen(menuItem->palette.highlightedText().color());
1642 } else {
1643 painter->setPen(menuItem->palette.text().color());
1644 }
1645 int x, y, w, h;
1646 menuitem->rect.getRect(&x, &y, &w, &h);
1647 QColor discol;
1648 if (dis) {
1649 discol = menuitem->palette.text().color();
1650 p->setPen(discol);
1651 }
1652 const int xm = checkColHOffset + checkcol + QFusionStylePrivate::menuItemHMargin;
1653 const int xpos = menuitem->rect.x() + xm;
1654
1655 const QRect textRect(xpos, y + windowsItemVMargin,
1656 w - xm - QFusionStylePrivate::menuRightBorder - menuitem->reservedShortcutWidth + 2,
1657 h - 2 * windowsItemVMargin);
1658 const QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
1659 QStringView s(menuitem->text);
1660 if (!s.isEmpty()) { // draw text
1661 p->save();
1662 const qsizetype tabIndex = s.indexOf(u'\t');
1664 if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
1665 text_flags |= Qt::TextHideMnemonic;
1666 text_flags |= Qt::AlignLeft;
1667 if (tabIndex >= 0) {
1668 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
1670 QPoint(menuitem->rect.right(), textRect.bottom())));
1671 const QString textToDraw = s.mid(tabIndex + 1).toString();
1672 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
1673 p->setPen(menuitem->palette.light().color());
1674 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1675 p->setPen(discol);
1676 }
1677 p->drawText(vShortcutRect, text_flags, textToDraw);
1678 s = s.left(tabIndex);
1679 }
1680 QFont font = menuitem->font;
1681 // font may not have any "hard" flags set. We override
1682 // the point size so that when it is resolved against the device, this font will win.
1683 // This is mainly to handle cases where someone sets the font on the window
1684 // and then the combo inherits it and passes it onward. At that point the resolve mask
1685 // is very, very weak. This makes it stonger.
1686 font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF());
1687
1689 font.setBold(true);
1690
1691 p->setFont(font);
1693 const QString textToDraw = fontMetrics.elidedText(s.left(tabIndex).toString(),
1694 Qt::ElideMiddle, vTextRect.width(),
1695 text_flags);
1696 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
1697 p->setPen(menuitem->palette.light().color());
1698 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
1699 p->setPen(discol);
1700 }
1701 p->drawText(vTextRect, text_flags, textToDraw);
1702 p->restore();
1703 }
1704
1705 // Arrow
1706 if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
1707 const int dim = (menuItem->rect.height() - 4) / 2;
1708 PrimitiveElement arrow;
1709 arrow = option->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
1710 const int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
1711 QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
1712 QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
1713 QStyleOptionMenuItem newMI = *menuItem;
1714 newMI.rect = vSubMenuRect;
1715 newMI.state = !enabled ? State_None : State_Enabled;
1716 if (selected)
1718 newMI.palette.highlightedText().color());
1719 proxy()->drawPrimitive(arrow, &newMI, painter, widget);
1720 }
1721 }
1722 painter->restore();
1723 break;
1724 case CE_MenuHMargin:
1725 case CE_MenuVMargin:
1726 break;
1727 case CE_MenuEmptyArea:
1728 break;
1729 case CE_PushButton:
1730 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
1731 proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
1733 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
1734 proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
1735 }
1736 break;
1737 case CE_MenuBarEmptyArea:
1738 painter->save();
1739 {
1740 painter->fillRect(rect, option->palette.window());
1741 QColor shadow = mergedColors(option->palette.window().color().darker(120),
1742 outline.lighter(140), 60);
1743 painter->setPen(QPen(shadow));
1744 painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
1745 }
1746 painter->restore();
1747 break;
1748#if QT_CONFIG(tabbar)
1749 case CE_TabBarTabShape:
1750 painter->save();
1751 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
1752
1753 bool rtlHorTabs = (tab->direction == Qt::RightToLeft
1754 && (tab->shape == QTabBar::RoundedNorth
1755 || tab->shape == QTabBar::RoundedSouth));
1756 bool selected = tab->state & State_Selected;
1757 bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
1758 || (rtlHorTabs
1759 && tab->position == QStyleOptionTab::Beginning));
1760 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1761 int tabOverlap = pixelMetric(PM_TabBarTabOverlap, option, widget);
1762 rect = option->rect.adjusted(0, 0, (onlyOne || lastTab) ? 0 : tabOverlap, 0);
1763
1764 QRect r2(rect);
1765 int x1 = r2.left();
1766 int x2 = r2.right();
1767 int y1 = r2.top();
1768 int y2 = r2.bottom();
1769
1770 painter->setPen(d->innerContrastLine());
1771
1772 QTransform rotMatrix;
1773 bool flip = false;
1774 painter->setPen(shadow);
1775
1776 switch (tab->shape) {
1778 break;
1780 rotMatrix.rotate(180);
1781 rotMatrix.translate(0, -rect.height() + 1);
1782 rotMatrix.scale(-1, 1);
1783 painter->setTransform(rotMatrix, true);
1784 break;
1786 rotMatrix.rotate(180 + 90);
1787 rotMatrix.scale(-1, 1);
1788 flip = true;
1789 painter->setTransform(rotMatrix, true);
1790 break;
1792 rotMatrix.rotate(90);
1793 rotMatrix.translate(0, - rect.width() + 1);
1794 flip = true;
1795 painter->setTransform(rotMatrix, true);
1796 break;
1797 default:
1798 painter->restore();
1800 return;
1801 }
1802
1803 if (flip) {
1804 QRect tmp = rect;
1805 rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
1806 int temp = x1;
1807 x1 = y1;
1808 y1 = temp;
1809 temp = x2;
1810 x2 = y2;
1811 y2 = temp;
1812 }
1813
1815 painter->translate(0.5, 0.5);
1816
1817 QColor tabFrameColor = tab->features & QStyleOptionTab::HasFrame ?
1818 d->tabFrameColor(option->palette) :
1819 option->palette.window().color();
1820
1821 QLinearGradient fillGradient(rect.topLeft(), rect.bottomLeft());
1822 QLinearGradient outlineGradient(rect.topLeft(), rect.bottomLeft());
1823 QPen outlinePen = outline.lighter(110);
1824 if (selected) {
1825 fillGradient.setColorAt(0, tabFrameColor.lighter(104));
1826 // QColor highlight = option->palette.highlight().color();
1827 // if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) {
1828 // fillGradient.setColorAt(0, highlight.lighter(130));
1829 // outlineGradient.setColorAt(0, highlight.darker(130));
1830 // fillGradient.setColorAt(0.14, highlight);
1831 // outlineGradient.setColorAt(0.14, highlight.darker(130));
1832 // fillGradient.setColorAt(0.1401, tabFrameColor);
1833 // outlineGradient.setColorAt(0.1401, highlight.darker(130));
1834 // }
1835 fillGradient.setColorAt(1, tabFrameColor);
1836 outlineGradient.setColorAt(1, outline);
1837 outlinePen = QPen(outlineGradient, 1);
1838 } else {
1839 fillGradient.setColorAt(0, tabFrameColor.darker(108));
1840 fillGradient.setColorAt(0.85, tabFrameColor.darker(108));
1841 fillGradient.setColorAt(1, tabFrameColor.darker(116));
1842 }
1843
1844 QRect drawRect = rect.adjusted(0, selected ? 0 : 2, 0, 3);
1845 painter->setPen(outlinePen);
1846 painter->save();
1847 painter->setClipRect(rect.adjusted(-1, -1, 1, selected ? -2 : -3));
1848 painter->setBrush(fillGradient);
1849 painter->drawRoundedRect(drawRect.adjusted(0, 0, -1, -1), 2.0, 2.0);
1851 painter->setPen(d->innerContrastLine());
1852 painter->drawRoundedRect(drawRect.adjusted(1, 1, -2, -1), 2.0, 2.0);
1853 painter->restore();
1854
1855 if (selected) {
1856 painter->fillRect(rect.left() + 1, rect.bottom() - 1, rect.width() - 2, rect.bottom() - 1, tabFrameColor);
1857 painter->fillRect(QRect(rect.bottomRight() + QPoint(-2, -1), QSize(1, 1)), d->innerContrastLine());
1858 painter->fillRect(QRect(rect.bottomLeft() + QPoint(0, -1), QSize(1, 1)), d->innerContrastLine());
1859 painter->fillRect(QRect(rect.bottomRight() + QPoint(-1, -1), QSize(1, 1)), d->innerContrastLine());
1860 }
1861 }
1862 painter->restore();
1863 break;
1864#endif //QT_CONFIG(tabbar)
1865 default:
1867 break;
1868 }
1869}
1870
1871extern QPalette qt_fusionPalette();
1872
1876QPalette QFusionStyle::standardPalette () const
1877{
1878 return qt_fusionPalette();
1879}
1880
1884void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
1885 QPainter *painter, const QWidget *widget) const
1886{
1887
1888 Q_D (const QFusionStyle);
1889
1890#if QT_CONFIG(spinbox) || QT_CONFIG(slider)
1891 QColor buttonColor = d->buttonColor(option->palette);
1892 QColor gradientStopColor = buttonColor;
1893#endif
1894#if QT_CONFIG(slider)
1895 QColor gradientStartColor = buttonColor.lighter(118);
1896#endif
1897 QColor outline = d->outline(option->palette);
1898
1899 QColor alphaCornerColor;
1900 if (widget) {
1901 // ### backgroundrole/foregroundrole should be part of the style option
1902 alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), outline);
1903 } else {
1904 alphaCornerColor = mergedColors(option->palette.window().color(), outline);
1905 }
1906
1907 switch (control) {
1908 case CC_GroupBox:
1909 painter->save();
1910 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
1911 // Draw frame
1912 QRect textRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget);
1913 QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget);
1914
1915 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
1917 frame.QStyleOption::operator=(*groupBox);
1918 frame.features = groupBox->features;
1919 frame.lineWidth = groupBox->lineWidth;
1920 frame.midLineWidth = groupBox->midLineWidth;
1921 frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
1922 proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget);
1923 }
1924
1925 // Draw title
1926 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
1927 // groupBox->textColor gets the incorrect palette here
1928 painter->setPen(QPen(option->palette.windowText(), 1));
1929 int alignment = int(groupBox->textAlignment);
1930 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
1932
1934 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, QPalette::NoRole);
1935
1936 if (groupBox->state & State_HasFocus) {
1938 fropt.QStyleOption::operator=(*groupBox);
1939 fropt.rect = textRect.adjusted(-2, -1, 2, 1);
1940 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
1941 }
1942 }
1943
1944 // Draw checkbox
1945 if (groupBox->subControls & SC_GroupBoxCheckBox) {
1947 box.QStyleOption::operator=(*groupBox);
1948 box.rect = checkBoxRect;
1949 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
1950 }
1951 }
1952 painter->restore();
1953 break;
1954#if QT_CONFIG(spinbox)
1955 case CC_SpinBox:
1956 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
1957 QPixmap cache;
1958 QString pixmapName = QStyleHelper::uniqueName("spinbox"_L1, spinBox, spinBox->rect.size());
1959 if (!QPixmapCache::find(pixmapName, &cache)) {
1960
1962 cache.fill(Qt::transparent);
1963
1964 QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height());
1965 QRect rect = pixmapRect;
1966 QRect r = rect.adjusted(0, 1, 0, -1);
1967 QPainter cachePainter(&cache);
1968 QColor arrowColor = spinBox->palette.windowText().color();
1969 arrowColor.setAlpha(160);
1970
1971 bool isEnabled = (spinBox->state & State_Enabled);
1972 bool hover = isEnabled && (spinBox->state & State_MouseOver);
1973 bool sunken = (spinBox->state & State_Sunken);
1974 bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
1975 bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
1976 bool hasFocus = (option->state & State_HasFocus);
1977
1978 QStyleOptionSpinBox spinBoxCopy = *spinBox;
1979 spinBoxCopy.rect = pixmapRect;
1980 QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);
1981 QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);
1982
1983 if (spinBox->frame) {
1984 cachePainter.save();
1985 cachePainter.setRenderHint(QPainter::Antialiasing, true);
1986 cachePainter.translate(0.5, 0.5);
1987
1988 // Fill background
1989 cachePainter.setPen(Qt::NoPen);
1990 cachePainter.setBrush(option->palette.base());
1991 cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
1992
1993 // Draw inner shadow
1994 cachePainter.setPen(d->topShadow());
1995 cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
1996
1997 if (!upRect.isNull()) {
1998 // Draw button gradient
1999 const QColor buttonColor = d->buttonColor(option->palette);
2000 const QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2);
2001 const QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver )
2002 ? buttonColor : buttonColor.darker(104));
2003
2004 cachePainter.setPen(Qt::NoPen);
2005 cachePainter.setBrush(gradient);
2006
2007 cachePainter.save();
2008 cachePainter.setClipRect(updownRect);
2009 cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
2010 cachePainter.setPen(QPen(d->innerContrastLine()));
2011 cachePainter.setBrush(Qt::NoBrush);
2012 cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2);
2013 cachePainter.restore();
2014 }
2015
2016 if ((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) && upIsActive) {
2017 if (sunken)
2018 cachePainter.fillRect(upRect.adjusted(0, -1, 0, 0), gradientStopColor.darker(110));
2019 else if (hover)
2020 cachePainter.fillRect(upRect.adjusted(0, -1, 0, 0), d->innerContrastLine());
2021 }
2022
2023 if ((spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) && downIsActive) {
2024 if (sunken)
2025 cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), gradientStopColor.darker(110));
2026 else if (hover)
2027 cachePainter.fillRect(downRect.adjusted(0, 0, 0, 1), d->innerContrastLine());
2028 }
2029
2030 cachePainter.setPen(hasFocus ? d->highlightedOutline(option->palette) : outline);
2031 cachePainter.setBrush(Qt::NoBrush);
2032 cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
2033 if (hasFocus) {
2034 QColor softHighlight = option->palette.highlight().color();
2035 softHighlight.setAlpha(40);
2036 cachePainter.setPen(softHighlight);
2037 cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 1.7, 1.7);
2038 }
2039 cachePainter.restore();
2040 }
2041
2043 // buttonSymbols == NoButtons results in 'null' rects
2044 // and a tiny rect painted in the corner.
2045 cachePainter.setPen(outline);
2046 if (spinBox->direction == Qt::RightToLeft)
2047 cachePainter.drawLine(QLineF(upRect.right(), upRect.top() - 0.5, upRect.right(), downRect.bottom() + 1.5));
2048 else
2049 cachePainter.drawLine(QLineF(upRect.left(), upRect.top() - 0.5, upRect.left(), downRect.bottom() + 1.5));
2050 }
2051
2052 if (upIsActive && sunken) {
2053 cachePainter.setPen(gradientStopColor.darker(130));
2054 cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.right(), downRect.top());
2055 cachePainter.drawLine(upRect.left() + 1, upRect.top(), upRect.left() + 1, upRect.bottom());
2056 cachePainter.drawLine(upRect.left() + 1, upRect.top() - 1, upRect.right(), upRect.top() - 1);
2057 }
2058
2059 if (downIsActive && sunken) {
2060 cachePainter.setPen(gradientStopColor.darker(130));
2061 cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.left() + 1, downRect.bottom() + 1);
2062 cachePainter.drawLine(downRect.left() + 1, downRect.top(), downRect.right(), downRect.top());
2063 cachePainter.setPen(gradientStopColor.darker(110));
2064 cachePainter.drawLine(downRect.left() + 1, downRect.bottom() + 1, downRect.right(), downRect.bottom() + 1);
2065 }
2066
2067 QColor disabledColor = mergedColors(arrowColor, option->palette.button().color());
2069 int centerX = upRect.center().x();
2070 int centerY = upRect.center().y();
2071
2072 // plus/minus
2073 cachePainter.setPen((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor);
2074 cachePainter.drawLine(centerX - 1, centerY, centerX + 3, centerY);
2075 cachePainter.drawLine(centerX + 1, centerY - 2, centerX + 1, centerY + 2);
2076
2077 centerX = downRect.center().x();
2078 centerY = downRect.center().y();
2079 cachePainter.setPen((spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor);
2080 cachePainter.drawLine(centerX - 1, centerY, centerX + 3, centerY);
2081
2083 // arrows
2084 qt_fusion_draw_arrow(Qt::UpArrow, &cachePainter, option, upRect.adjusted(0, 0, 0, 1),
2085 (spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor);
2086 qt_fusion_draw_arrow(Qt::DownArrow, &cachePainter, option, downRect,
2087 (spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor);
2088 }
2089
2090 cachePainter.end();
2091 QPixmapCache::insert(pixmapName, cache);
2092 }
2094 }
2095 break;
2096#endif // QT_CONFIG(spinbox)
2097 case CC_TitleBar:
2098 painter->save();
2099 if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
2100 const int buttonMargin = 5;
2101 bool active = (titleBar->titleBarState & State_Active);
2102 QRect fullRect = titleBar->rect;
2103 QPalette palette = option->palette;
2104 QColor highlight = option->palette.highlight().color();
2105
2106 QColor titleBarFrameBorder(active ? highlight.darker(180): outline.darker(110));
2107 QColor titleBarHighlight(active ? highlight.lighter(120): palette.window().color().lighter(120));
2108 QColor textColor(active ? 0xffffff : 0xff000000);
2109 QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
2110
2111 {
2112 // Fill title bar gradient
2113 QColor titlebarColor = QColor(active ? highlight: palette.window().color());
2114 QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
2115 option->rect.center().x(), option->rect.bottom());
2116
2117 gradient.setColorAt(0, titlebarColor.lighter(114));
2118 gradient.setColorAt(0.5, titlebarColor.lighter(102));
2119 gradient.setColorAt(0.51, titlebarColor.darker(104));
2120 gradient.setColorAt(1, titlebarColor);
2121 painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient);
2122
2123 // Frame and rounded corners
2124 painter->setPen(titleBarFrameBorder);
2125
2126 // top outline
2127 painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
2128 painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
2129 const QPoint points[5] = {
2130 QPoint(fullRect.left() + 4, fullRect.top() + 1),
2131 QPoint(fullRect.left() + 3, fullRect.top() + 1),
2132 QPoint(fullRect.left() + 2, fullRect.top() + 2),
2133 QPoint(fullRect.left() + 1, fullRect.top() + 3),
2134 QPoint(fullRect.left() + 1, fullRect.top() + 4)
2135 };
2137
2138 painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
2139 const QPoint points2[5] = {
2140 QPoint(fullRect.right() - 3, fullRect.top() + 1),
2141 QPoint(fullRect.right() - 4, fullRect.top() + 1),
2142 QPoint(fullRect.right() - 2, fullRect.top() + 2),
2143 QPoint(fullRect.right() - 1, fullRect.top() + 3),
2144 QPoint(fullRect.right() - 1, fullRect.top() + 4)
2145 };
2146 painter->drawPoints(points2, 5);
2147
2148 // draw bottomline
2149 painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
2150
2151 // top highlight
2152 painter->setPen(titleBarHighlight);
2153 painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
2154 }
2155 // draw title
2156 QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
2157 painter->setPen(active? (titleBar->palette.text().color().lighter(120)) :
2158 titleBar->palette.text().color() );
2159 // Note workspace also does elliding but it does not use the correct font
2163 if (active)
2165 // min button
2166 if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
2167 !(titleBar->titleBarState& Qt::WindowMinimized)) {
2168 QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
2169 if (minButtonRect.isValid()) {
2170 bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
2171 bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
2172 qt_fusion_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
2173 QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin);
2174 painter->setPen(textColor);
2175 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
2176 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
2177 painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
2178 minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
2179 painter->setPen(textAlphaColor);
2180 painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
2181 minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
2182 painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
2183 minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
2184 }
2185 }
2186 // max button
2187 if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
2188 !(titleBar->titleBarState & Qt::WindowMaximized)) {
2189 QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
2190 if (maxButtonRect.isValid()) {
2191 bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
2192 bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
2193 qt_fusion_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
2194
2195 QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2196
2197 painter->setPen(textColor);
2198 painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
2199 painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
2200 maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
2201 painter->setPen(textAlphaColor);
2202 const QPoint points[4] = {
2203 maxButtonIconRect.topLeft(),
2204 maxButtonIconRect.topRight(),
2205 maxButtonIconRect.bottomLeft(),
2206 maxButtonIconRect.bottomRight()
2207 };
2209 }
2210 }
2211
2212 // close button
2213 if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
2214 QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
2215 if (closeButtonRect.isValid()) {
2216 bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
2217 bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
2218 qt_fusion_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
2219 QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2220 painter->setPen(textAlphaColor);
2221 const QLine lines[4] = {
2222 QLine(closeIconRect.left() + 1, closeIconRect.top(),
2223 closeIconRect.right(), closeIconRect.bottom() - 1),
2224 QLine(closeIconRect.left(), closeIconRect.top() + 1,
2225 closeIconRect.right() - 1, closeIconRect.bottom()),
2226 QLine(closeIconRect.right() - 1, closeIconRect.top(),
2227 closeIconRect.left(), closeIconRect.bottom() - 1),
2228 QLine(closeIconRect.right(), closeIconRect.top() + 1,
2229 closeIconRect.left() + 1, closeIconRect.bottom())
2230 };
2231 painter->drawLines(lines, 4);
2232 const QPoint points[4] = {
2233 closeIconRect.topLeft(),
2234 closeIconRect.topRight(),
2235 closeIconRect.bottomLeft(),
2236 closeIconRect.bottomRight()
2237 };
2239
2240 painter->setPen(textColor);
2241 painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
2242 closeIconRect.right() - 1, closeIconRect.bottom() - 1);
2243 painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
2244 closeIconRect.right() - 1, closeIconRect.top() + 1);
2245 }
2246 }
2247
2248 // normalize button
2249 if ((titleBar->subControls & SC_TitleBarNormalButton) &&
2250 (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
2251 (titleBar->titleBarState & Qt::WindowMinimized)) ||
2252 ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
2253 (titleBar->titleBarState & Qt::WindowMaximized)))) {
2254 QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
2255 if (normalButtonRect.isValid()) {
2256
2257 bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
2258 bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
2259 QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
2260 qt_fusion_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
2261
2262 QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
2263 painter->setPen(textColor);
2264 painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
2265 painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
2266 frontWindowRect.right() - 1, frontWindowRect.top() + 1);
2267 painter->setPen(textAlphaColor);
2268 const QPoint points[4] = {
2269 frontWindowRect.topLeft(),
2270 frontWindowRect.topRight(),
2271 frontWindowRect.bottomLeft(),
2272 frontWindowRect.bottomRight()
2273 };
2275
2276 QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
2277 QRegion clipRegion = backWindowRect;
2278 clipRegion -= frontWindowRect;
2279 painter->save();
2280 painter->setClipRegion(clipRegion);
2281 painter->setPen(textColor);
2282 painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
2283 painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
2284 backWindowRect.right() - 1, backWindowRect.top() + 1);
2285 painter->setPen(textAlphaColor);
2286 const QPoint points2[4] = {
2287 backWindowRect.topLeft(),
2288 backWindowRect.topRight(),
2289 backWindowRect.bottomLeft(),
2290 backWindowRect.bottomRight()
2291 };
2292 painter->drawPoints(points2, 4);
2293 painter->restore();
2294 }
2295 }
2296
2297 // context help button
2298 if (titleBar->subControls & SC_TitleBarContextHelpButton
2299 && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
2300 QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
2301 if (contextHelpButtonRect.isValid()) {
2302 bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
2303 bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
2304 qt_fusion_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
2305#if QT_CONFIG(imageformat_xpm)
2306 QImage image(qt_titlebar_context_help);
2307 QColor alpha = textColor;
2308 alpha.setAlpha(128);
2309 image.setColor(1, textColor.rgba());
2310 image.setColor(2, alpha.rgba());
2312 painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image);
2313#endif
2314 }
2315 }
2316
2317 // shade button
2318 if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
2319 QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
2320 if (shadeButtonRect.isValid()) {
2321 bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
2322 bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
2323 qt_fusion_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
2324 qt_fusion_draw_arrow(Qt::UpArrow, painter, option, shadeButtonRect.adjusted(5, 7, -5, -7), textColor);
2325 }
2326 }
2327
2328 // unshade button
2329 if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
2330 QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
2331 if (unshadeButtonRect.isValid()) {
2332 bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
2333 bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
2334 qt_fusion_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
2335 qt_fusion_draw_arrow(Qt::DownArrow, painter, option, unshadeButtonRect.adjusted(5, 7, -5, -7), textColor);
2336 }
2337 }
2338
2339 if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
2340 QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
2341 if (iconRect.isValid()) {
2342 if (!titleBar->icon.isNull()) {
2343 titleBar->icon.paint(painter, iconRect);
2344 } else {
2345 QStyleOption tool = *titleBar;
2346 QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
2347 tool.rect = iconRect;
2348 painter->save();
2349 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
2350 painter->restore();
2351 }
2352 }
2353 }
2354 }
2355 painter->restore();
2356 break;
2357#if QT_CONFIG(slider)
2358 case CC_ScrollBar:
2359 painter->save();
2360 if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
2361 bool wasActive = false;
2362 qreal expandScale = 1.0;
2363 qreal expandOffset = -1.0;
2364 QObject *styleObject = option->styleObject;
2365 if (styleObject && proxy()->styleHint(SH_ScrollBar_Transient, option, widget)) {
2366#if QT_CONFIG(animation)
2367 qreal opacity = 0.0;
2368 bool shouldExpand = false;
2369 const qreal maxExpandScale = 13.0 / 9.0;
2370#endif
2371
2372 int oldPos = styleObject->property("_q_stylepos").toInt();
2373 int oldMin = styleObject->property("_q_stylemin").toInt();
2374 int oldMax = styleObject->property("_q_stylemax").toInt();
2375 QRect oldRect = styleObject->property("_q_stylerect").toRect();
2376 QStyle::State oldState = static_cast<QStyle::State>(qvariant_cast<QStyle::State::Int>(styleObject->property("_q_stylestate")));
2377 uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt();
2378
2379 // a scrollbar is transient when the scrollbar itself and
2380 // its sibling are both inactive (ie. not pressed/hovered/moved)
2381 bool transient = !option->activeSubControls && !(option->state & State_On);
2382
2383 if (!transient ||
2384 oldPos != scrollBar->sliderPosition ||
2385 oldMin != scrollBar->minimum ||
2386 oldMax != scrollBar->maximum ||
2387 oldRect != scrollBar->rect ||
2388 oldState != scrollBar->state ||
2389 oldActiveControls != scrollBar->activeSubControls) {
2390
2392 styleObject->setProperty("_q_stylemin", scrollBar->minimum);
2393 styleObject->setProperty("_q_stylemax", scrollBar->maximum);
2394 styleObject->setProperty("_q_stylerect", scrollBar->rect);
2395 styleObject->setProperty("_q_stylestate", static_cast<QStyle::State::Int>(scrollBar->state));
2396 styleObject->setProperty("_q_stylecontrols", static_cast<uint>(scrollBar->activeSubControls));
2397
2398#if QT_CONFIG(animation)
2399 // if the scrollbar is transient or its attributes, geometry or
2400 // state has changed, the opacity is reset back to 100% opaque
2401 opacity = 1.0;
2402
2403 QScrollbarStyleAnimation *anim = qobject_cast<QScrollbarStyleAnimation *>(d->animation(styleObject));
2404 if (transient) {
2405 if (!anim) {
2407 d->startAnimation(anim);
2408 } else if (anim->mode() == QScrollbarStyleAnimation::Deactivating) {
2409 // the scrollbar was already fading out while the
2410 // state changed -> restart the fade out animation
2411 anim->setCurrentTime(0);
2412 }
2413 } else if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
2414 d->stopAnimation(styleObject);
2415 }
2416#endif // animation
2417 }
2418
2419#if QT_CONFIG(animation)
2420 QScrollbarStyleAnimation *anim = qobject_cast<QScrollbarStyleAnimation *>(d->animation(styleObject));
2421 if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
2422 // once a scrollbar was active (hovered/pressed), it retains
2423 // the active look even if it's no longer active while fading out
2424 if (oldActiveControls)
2425 anim->setActive(true);
2426
2427 wasActive = anim->wasActive();
2428 opacity = anim->currentValue();
2429 }
2430
2431 shouldExpand = (option->activeSubControls || wasActive);
2432 if (shouldExpand) {
2433 if (!anim && !oldActiveControls) {
2434 // Start expand animation only once and when entering
2436 d->startAnimation(anim);
2437 }
2438 if (anim && anim->mode() == QScrollbarStyleAnimation::Activating) {
2439 expandScale = 1.0 + (maxExpandScale - 1.0) * anim->currentValue();
2440 expandOffset = 5.5 * anim->currentValue() - 1;
2441 } else {
2442 // Keep expanded state after the animation ends, and when fading out
2443 expandScale = maxExpandScale;
2444 expandOffset = 4.5;
2445 }
2446 }
2447 painter->setOpacity(opacity);
2448#endif // animation
2449 }
2450
2451 bool transient = proxy()->styleHint(SH_ScrollBar_Transient, option, widget);
2452 bool horizontal = scrollBar->orientation == Qt::Horizontal;
2453 bool sunken = scrollBar->state & State_Sunken;
2454
2455 QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
2456 QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
2457 QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
2458 QRect scrollBarGroove = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
2459
2460 QRect rect = option->rect;
2461 QColor alphaOutline = outline;
2462 alphaOutline.setAlpha(180);
2463
2464 QColor arrowColor = option->palette.windowText().color();
2465 arrowColor.setAlpha(160);
2466
2467 const QColor bgColor = QStyleHelper::backgroundColor(option->palette, widget);
2468 const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128;
2469
2470 if (transient) {
2471 if (horizontal) {
2472 rect.setY(rect.y() + 4.5 - expandOffset);
2473 scrollBarSlider.setY(scrollBarSlider.y() + 4.5 - expandOffset);
2474 scrollBarGroove.setY(scrollBarGroove.y() + 4.5 - expandOffset);
2475
2476 rect.setHeight(rect.height() * expandScale);
2477 scrollBarGroove.setHeight(scrollBarGroove.height() * expandScale);
2478 } else {
2479 rect.setX(rect.x() + 4.5 - expandOffset);
2480 scrollBarSlider.setX(scrollBarSlider.x() + 4.5 - expandOffset);
2481 scrollBarGroove.setX(scrollBarGroove.x() + 4.5 - expandOffset);
2482
2483 rect.setWidth(rect.width() * expandScale);
2484 scrollBarGroove.setWidth(scrollBarGroove.width() * expandScale);
2485 }
2486 }
2487
2488 // Paint groove
2489 if ((!transient || scrollBar->activeSubControls || wasActive) && scrollBar->subControls & SC_ScrollBarGroove) {
2490 QLinearGradient gradient(rect.center().x(), rect.top(),
2491 rect.center().x(), rect.bottom());
2492 if (!horizontal)
2493 gradient = QLinearGradient(rect.left(), rect.center().y(),
2494 rect.right(), rect.center().y());
2495 if (!transient || !isDarkBg) {
2496 gradient.setColorAt(0, buttonColor.darker(107));
2497 gradient.setColorAt(0.1, buttonColor.darker(105));
2498 gradient.setColorAt(0.9, buttonColor.darker(105));
2499 gradient.setColorAt(1, buttonColor.darker(107));
2500 } else {
2501 gradient.setColorAt(0, bgColor.lighter(157));
2502 gradient.setColorAt(0.1, bgColor.lighter(155));
2503 gradient.setColorAt(0.9, bgColor.lighter(155));
2504 gradient.setColorAt(1, bgColor.lighter(157));
2505 }
2506
2507 painter->save();
2508 if (transient)
2509 painter->setOpacity(0.8);
2510 painter->fillRect(rect, gradient);
2512 if (transient)
2513 painter->setOpacity(0.4);
2514 painter->setPen(alphaOutline);
2515 if (horizontal)
2516 painter->drawLine(rect.topLeft(), rect.topRight());
2517 else
2518 painter->drawLine(rect.topLeft(), rect.bottomLeft());
2519
2520 QColor subtleEdge = alphaOutline;
2521 subtleEdge.setAlpha(40);
2522 painter->setPen(subtleEdge);
2524 painter->setClipRect(scrollBarGroove.adjusted(1, 0, -1, -3));
2525 painter->drawRect(scrollBarGroove.adjusted(1, 0, -1, -1));
2526 painter->restore();
2527 }
2528
2529 QRect pixmapRect = scrollBarSlider;
2530 QLinearGradient gradient(pixmapRect.center().x(), pixmapRect.top(),
2531 pixmapRect.center().x(), pixmapRect.bottom());
2532 if (!horizontal)
2533 gradient = QLinearGradient(pixmapRect.left(), pixmapRect.center().y(),
2534 pixmapRect.right(), pixmapRect.center().y());
2535
2536 QLinearGradient highlightedGradient = gradient;
2537
2538 QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40);
2539 gradient.setColorAt(0, d->buttonColor(option->palette).lighter(108));
2540 gradient.setColorAt(1, d->buttonColor(option->palette));
2541
2542 highlightedGradient.setColorAt(0, gradientStartColor.darker(102));
2543 highlightedGradient.setColorAt(1, gradientStopColor.lighter(102));
2544
2545 // Paint slider
2546 if (scrollBar->subControls & SC_ScrollBarSlider) {
2547 if (transient) {
2548 QRect rect = scrollBarSlider.adjusted(horizontal ? 1 : 2, horizontal ? 2 : 1, -1, -1);
2550 painter->setBrush(isDarkBg ? d->lightShade() : d->darkShade());
2551 int r = qMin(rect.width(), rect.height()) / 2;
2552
2553 painter->save();
2556 painter->restore();
2557 } else {
2558 QRect pixmapRect = scrollBarSlider;
2559 painter->setPen(QPen(alphaOutline));
2560 if (option->state & State_Sunken && scrollBar->activeSubControls & SC_ScrollBarSlider)
2561 painter->setBrush(midColor2);
2562 else if (option->state & State_MouseOver && scrollBar->activeSubControls & SC_ScrollBarSlider)
2563 painter->setBrush(highlightedGradient);
2564 else
2565 painter->setBrush(gradient);
2566
2567 painter->drawRect(pixmapRect.adjusted(horizontal ? -1 : 0, horizontal ? 0 : -1, horizontal ? 0 : 1, horizontal ? 1 : 0));
2568
2569 painter->setPen(d->innerContrastLine());
2570 painter->drawRect(scrollBarSlider.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, -1, -1));
2571
2572 // Outer shadow
2573 // painter->setPen(subtleEdge);
2574 // if (horizontal) {
2577 // } else {
2580 // }
2581 }
2582 }
2583
2584 // The SubLine (up/left) buttons
2585 if (!transient && scrollBar->subControls & SC_ScrollBarSubLine) {
2586 if ((scrollBar->activeSubControls & SC_ScrollBarSubLine) && sunken)
2587 painter->setBrush(gradientStopColor);
2588 else if ((scrollBar->activeSubControls & SC_ScrollBarSubLine))
2589 painter->setBrush(highlightedGradient);
2590 else
2591 painter->setBrush(gradient);
2592
2594 painter->drawRect(scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, 0, 0));
2595 painter->setPen(QPen(alphaOutline));
2596 if (option->state & State_Horizontal) {
2597 if (option->direction == Qt::RightToLeft) {
2598 pixmapRect.setLeft(scrollBarSubLine.left());
2599 painter->drawLine(pixmapRect.topLeft(), pixmapRect.bottomLeft());
2600 } else {
2601 pixmapRect.setRight(scrollBarSubLine.right());
2602 painter->drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
2603 }
2604 } else {
2605 pixmapRect.setBottom(scrollBarSubLine.bottom());
2606 painter->drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
2607 }
2608
2609 QRect upRect = scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, horizontal ? -2 : -1, horizontal ? -1 : -2);
2611 painter->setPen(d->innerContrastLine());
2612 painter->drawRect(upRect);
2613
2614 // Arrows
2615 Qt::ArrowType arrowType = Qt::UpArrow;
2616 if (option->state & State_Horizontal)
2617 arrowType = option->direction == Qt::LeftToRight ? Qt::LeftArrow : Qt::RightArrow;
2618 qt_fusion_draw_arrow(arrowType, painter, option, upRect, arrowColor);
2619 }
2620
2621 // The AddLine (down/right) button
2622 if (!transient && scrollBar->subControls & SC_ScrollBarAddLine) {
2623 if ((scrollBar->activeSubControls & SC_ScrollBarAddLine) && sunken)
2624 painter->setBrush(gradientStopColor);
2625 else if ((scrollBar->activeSubControls & SC_ScrollBarAddLine))
2626 painter->setBrush(midColor2);
2627 else
2628 painter->setBrush(gradient);
2629
2631 painter->drawRect(scrollBarAddLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, 0, 0));
2632 painter->setPen(QPen(alphaOutline, 1));
2633 if (option->state & State_Horizontal) {
2634 if (option->direction == Qt::LeftToRight) {
2635 pixmapRect.setLeft(scrollBarAddLine.left());
2636 painter->drawLine(pixmapRect.topLeft(), pixmapRect.bottomLeft());
2637 } else {
2638 pixmapRect.setRight(scrollBarAddLine.right());
2639 painter->drawLine(pixmapRect.topRight(), pixmapRect.bottomRight());
2640 }
2641 } else {
2642 pixmapRect.setTop(scrollBarAddLine.top());
2643 painter->drawLine(pixmapRect.topLeft(), pixmapRect.topRight());
2644 }
2645
2646 QRect downRect = scrollBarAddLine.adjusted(1, 1, -1, -1);
2647 painter->setPen(d->innerContrastLine());
2649 painter->drawRect(downRect);
2650
2651 Qt::ArrowType arrowType = Qt::DownArrow;
2652 if (option->state & State_Horizontal)
2653 arrowType = option->direction == Qt::LeftToRight ? Qt::RightArrow : Qt::LeftArrow;
2654 qt_fusion_draw_arrow(arrowType, painter, option, downRect, arrowColor);
2655 }
2656
2657 }
2658 painter->restore();
2659 break;;
2660#endif // QT_CONFIG(slider)
2661 case CC_ComboBox:
2662 painter->save();
2663 if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
2664 bool hasFocus = option->state & State_HasFocus && option->state & State_KeyboardFocusChange;
2665 bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
2666 bool isEnabled = (comboBox->state & State_Enabled);
2667 QPixmap cache;
2668 QString pixmapName = QStyleHelper::uniqueName("combobox"_L1, option, comboBox->rect.size());
2669 if (sunken)
2670 pixmapName += "-sunken"_L1;
2671 if (comboBox->editable)
2672 pixmapName += "-editable"_L1;
2673 if (isEnabled)
2674 pixmapName += "-enabled"_L1;
2675 if (!comboBox->frame)
2676 pixmapName += "-frameless"_L1;
2677
2678 if (!QPixmapCache::find(pixmapName, &cache)) {
2679 cache = styleCachePixmap(comboBox->rect.size());
2680 cache.fill(Qt::transparent);
2681 QPainter cachePainter(&cache);
2682 QRect pixmapRect(0, 0, comboBox->rect.width(), comboBox->rect.height());
2683 QStyleOptionComboBox comboBoxCopy = *comboBox;
2684 comboBoxCopy.rect = pixmapRect;
2685
2686 QRect rect = pixmapRect;
2687 QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
2688 SC_ComboBoxArrow, widget);
2689 // Draw a line edit
2690 if (comboBox->editable) {
2691 QStyleOptionFrame buttonOption;
2692 buttonOption.QStyleOption::operator=(*comboBox);
2693 buttonOption.rect = rect;
2694 buttonOption.state = (comboBox->state & (State_Enabled | State_MouseOver | State_HasFocus))
2695 | State_KeyboardFocusChange; // Always show hig
2696
2697 if (sunken) {
2698 buttonOption.state |= State_Sunken;
2699 buttonOption.state &= ~State_MouseOver;
2700 }
2701
2702 if (comboBox->frame) {
2703 cachePainter.save();
2704 cachePainter.setRenderHint(QPainter::Antialiasing, true);
2705 cachePainter.translate(0.5, 0.5);
2706 cachePainter.setPen(Qt::NoPen);
2707 cachePainter.setBrush(buttonOption.palette.base());
2708 cachePainter.drawRoundedRect(rect.adjusted(0, 0, -1, -1), 2, 2);
2709 cachePainter.restore();
2710 proxy()->drawPrimitive(PE_FrameLineEdit, &buttonOption, &cachePainter, widget);
2711 }
2712
2713 // Draw button clipped
2714 cachePainter.save();
2715 cachePainter.setClipRect(downArrowRect.adjusted(0, 0, 1, 0));
2716 buttonOption.rect.setLeft(comboBox->direction == Qt::LeftToRight ?
2717 downArrowRect.left() - 6: downArrowRect.right() + 6);
2718 proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
2719 cachePainter.restore();
2720 cachePainter.setPen( QPen(hasFocus ? option->palette.highlight() : outline.lighter(110), 1));
2721
2722 if (!sunken) {
2723 int borderSize = 1;
2724 if (comboBox->direction == Qt::RightToLeft) {
2725 cachePainter.drawLine(QPoint(downArrowRect.right() - 1, downArrowRect.top() + borderSize ),
2726 QPoint(downArrowRect.right() - 1, downArrowRect.bottom() - borderSize));
2727 } else {
2728 cachePainter.drawLine(QPoint(downArrowRect.left() , downArrowRect.top() + borderSize),
2729 QPoint(downArrowRect.left() , downArrowRect.bottom() - borderSize));
2730 }
2731 } else {
2732 if (comboBox->direction == Qt::RightToLeft) {
2733 cachePainter.drawLine(QPoint(downArrowRect.right(), downArrowRect.top() + 2),
2734 QPoint(downArrowRect.right(), downArrowRect.bottom() - 2));
2735
2736 } else {
2737 cachePainter.drawLine(QPoint(downArrowRect.left(), downArrowRect.top() + 2),
2738 QPoint(downArrowRect.left(), downArrowRect.bottom() - 2));
2739 }
2740 }
2741 } else {
2742 QStyleOptionButton buttonOption;
2743 buttonOption.QStyleOption::operator=(*comboBox);
2744 buttonOption.rect = rect;
2745 buttonOption.state = comboBox->state & (State_Enabled | State_MouseOver | State_HasFocus | State_KeyboardFocusChange);
2746 if (sunken) {
2747 buttonOption.state |= State_Sunken;
2748 buttonOption.state &= ~State_MouseOver;
2749 }
2750 proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);
2751 }
2752 if (comboBox->subControls & SC_ComboBoxArrow) {
2753 // Draw the up/down arrow
2754 QColor arrowColor = option->palette.buttonText().color();
2755 arrowColor.setAlpha(160);
2756 qt_fusion_draw_arrow(Qt::DownArrow, &cachePainter, option, downArrowRect, arrowColor);
2757 }
2758 cachePainter.end();
2759 QPixmapCache::insert(pixmapName, cache);
2760 }
2761 painter->drawPixmap(comboBox->rect.topLeft(), cache);
2762 }
2763 painter->restore();
2764 break;
2765#if QT_CONFIG(slider)
2766 case CC_Slider:
2767 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
2768 QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
2769 QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
2770
2771 bool horizontal = slider->orientation == Qt::Horizontal;
2772 bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
2773 bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
2774 QColor activeHighlight = d->highlight(option->palette);
2775 QPixmap cache;
2776 QBrush oldBrush = painter->brush();
2777 QPen oldPen = painter->pen();
2778 QColor shadowAlpha(Qt::black);
2779 shadowAlpha.setAlpha(10);
2780 if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
2781 outline = d->highlightedOutline(option->palette);
2782
2783
2784 if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
2785 QColor grooveColor;
2786 grooveColor.setHsv(buttonColor.hue(),
2787 qMin(255, (int)(buttonColor.saturation())),
2788 qMin(255, (int)(buttonColor.value()*0.9)));
2789 QString groovePixmapName = QStyleHelper::uniqueName("slider_groove"_L1, option, groove.size());
2790 QRect pixmapRect(0, 0, groove.width(), groove.height());
2791
2792 // draw background groove
2793 if (!QPixmapCache::find(groovePixmapName, &cache)) {
2794 cache = styleCachePixmap(pixmapRect.size());
2795 cache.fill(Qt::transparent);
2796 QPainter groovePainter(&cache);
2797 groovePainter.setRenderHint(QPainter::Antialiasing, true);
2798 groovePainter.translate(0.5, 0.5);
2799 QLinearGradient gradient;
2800 if (horizontal) {
2801 gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
2802 gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
2803 }
2804 else {
2805 gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
2806 gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
2807 }
2808 groovePainter.setPen(QPen(outline));
2809 gradient.setColorAt(0, grooveColor.darker(110));
2810 gradient.setColorAt(1, grooveColor.lighter(110));//palette.button().color().darker(115));
2811 groovePainter.setBrush(gradient);
2812 groovePainter.drawRoundedRect(pixmapRect.adjusted(1, 1, -2, -2), 1, 1);
2813 groovePainter.end();
2814 QPixmapCache::insert(groovePixmapName, cache);
2815 }
2816 painter->drawPixmap(groove.topLeft(), cache);
2817
2818 // draw blue groove highlight
2819 QRect clipRect;
2820 groovePixmapName += "_blue"_L1;
2821 if (!QPixmapCache::find(groovePixmapName, &cache)) {
2822 cache = styleCachePixmap(pixmapRect.size());
2823 cache.fill(Qt::transparent);
2824 QPainter groovePainter(&cache);
2825 QLinearGradient gradient;
2826 if (horizontal) {
2827 gradient.setStart(pixmapRect.center().x(), pixmapRect.top());
2828 gradient.setFinalStop(pixmapRect.center().x(), pixmapRect.bottom());
2829 }
2830 else {
2831 gradient.setStart(pixmapRect.left(), pixmapRect.center().y());
2832 gradient.setFinalStop(pixmapRect.right(), pixmapRect.center().y());
2833 }
2834 QColor highlight = d->highlight(option->palette);
2835 QColor highlightedoutline = highlight.darker(140);
2836 if (qGray(outline.rgb()) > qGray(highlightedoutline.rgb()))
2837 outline = highlightedoutline;
2838
2839
2840 groovePainter.setRenderHint(QPainter::Antialiasing, true);
2841 groovePainter.translate(0.5, 0.5);
2842 groovePainter.setPen(QPen(outline));
2843 gradient.setColorAt(0, activeHighlight);
2844 gradient.setColorAt(1, activeHighlight.lighter(130));
2845 groovePainter.setBrush(gradient);
2846 groovePainter.drawRoundedRect(pixmapRect.adjusted(1, 1, -2, -2), 1, 1);
2847 groovePainter.setPen(d->innerContrastLine());
2848 groovePainter.setBrush(Qt::NoBrush);
2849 groovePainter.drawRoundedRect(pixmapRect.adjusted(2, 2, -3, -3), 1, 1);
2850 groovePainter.end();
2851 QPixmapCache::insert(groovePixmapName, cache);
2852 }
2853 if (horizontal) {
2854 if (slider->upsideDown)
2855 clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height());
2856 else
2857 clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height());
2858 } else {
2859 if (slider->upsideDown)
2860 clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom());
2861 else
2862 clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top());
2863 }
2864 painter->save();
2865 painter->setClipRect(clipRect.adjusted(0, 0, 1, 1), Qt::IntersectClip);
2866 painter->drawPixmap(groove.topLeft(), cache);
2867 painter->restore();
2868 }
2869
2870 if (option->subControls & SC_SliderTickmarks) {
2871 painter->setPen(outline);
2872 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
2873 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
2874 int interval = slider->tickInterval;
2875 if (interval <= 0) {
2876 interval = slider->singleStep;
2877 if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
2878 available)
2879 - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
2880 0, available) < 3)
2881 interval = slider->pageStep;
2882 }
2883 if (interval <= 0)
2884 interval = 1;
2885
2886 int v = slider->minimum;
2887 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
2888 while (v <= slider->maximum + 1) {
2889 if (v == slider->maximum + 1 && interval == 1)
2890 break;
2891 const int v_ = qMin(v, slider->maximum);
2892 int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
2893 v_, (horizontal
2894 ? slider->rect.width()
2895 : slider->rect.height()) - len,
2896 slider->upsideDown) + len / 2;
2897 int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
2898
2899 if (horizontal) {
2900 if (ticksAbove) {
2901 painter->drawLine(pos, slider->rect.top() + extra,
2902 pos, slider->rect.top() + tickSize);
2903 }
2904 if (ticksBelow) {
2905 painter->drawLine(pos, slider->rect.bottom() - extra,
2906 pos, slider->rect.bottom() - tickSize);
2907 }
2908 } else {
2909 if (ticksAbove) {
2910 painter->drawLine(slider->rect.left() + extra, pos,
2911 slider->rect.left() + tickSize, pos);
2912 }
2913 if (ticksBelow) {
2914 painter->drawLine(slider->rect.right() - extra, pos,
2915 slider->rect.right() - tickSize, pos);
2916 }
2917 }
2918 // in the case where maximum is max int
2919 int nextInterval = v + interval;
2920 if (nextInterval < v)
2921 break;
2922 v = nextInterval;
2923 }
2924 }
2925 // draw handle
2926 if ((option->subControls & SC_SliderHandle) ) {
2927 QString handlePixmapName = QStyleHelper::uniqueName("slider_handle"_L1, option, handle.size());
2928 if (!QPixmapCache::find(handlePixmapName, &cache)) {
2929 cache = styleCachePixmap(handle.size());
2930 cache.fill(Qt::transparent);
2931 QRect pixmapRect(0, 0, handle.width(), handle.height());
2932 QPainter handlePainter(&cache);
2933 QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2);
2934
2935 // gradient fill
2936 QRect r = pixmapRect.adjusted(1, 1, -2, -2);
2937 QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft);
2938
2939 handlePainter.setRenderHint(QPainter::Antialiasing, true);
2940 handlePainter.translate(0.5, 0.5);
2941
2942 handlePainter.setPen(Qt::NoPen);
2943 handlePainter.setBrush(QColor(0, 0, 0, 40));
2944 handlePainter.drawRect(r.adjusted(-1, 2, 1, -2));
2945
2946 handlePainter.setPen(QPen(d->outline(option->palette)));
2947 if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
2948 handlePainter.setPen(QPen(d->highlightedOutline(option->palette)));
2949
2950 handlePainter.setBrush(gradient);
2951 handlePainter.drawRoundedRect(r, 2, 2);
2952 handlePainter.setBrush(Qt::NoBrush);
2953 handlePainter.setPen(d->innerContrastLine());
2954 handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2);
2955
2956 QColor cornerAlpha = outline.darker(120);
2957 cornerAlpha.setAlpha(80);
2958
2959 //handle shadow
2960 handlePainter.setPen(shadowAlpha);
2961 handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1));
2962 handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4));
2963 handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2));
2964
2965 handlePainter.end();
2966 QPixmapCache::insert(handlePixmapName, cache);
2967 }
2968
2969 painter->drawPixmap(handle.topLeft(), cache);
2970
2971 }
2972 painter->setBrush(oldBrush);
2973 painter->setPen(oldPen);
2974 }
2975 break;
2976#endif // QT_CONFIG(slider)
2977#if QT_CONFIG(dial)
2978 case CC_Dial:
2979 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
2980 QStyleHelper::drawDial(dial, painter);
2981 break;
2982#endif
2983 default:
2985 break;
2986 }
2987}
2988
2992int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
2993{
2994 int val = -1;
2995 switch (metric) {
2996 case PM_SliderTickmarkOffset:
2997 val = 4;
2998 break;
2999 case PM_HeaderMargin:
3000 case PM_ToolTipLabelFrameWidth:
3001 val = 2;
3002 break;
3003 case PM_ButtonDefaultIndicator:
3004 case PM_ButtonShiftHorizontal:
3005 case PM_ButtonShiftVertical:
3006 val = 0;
3007 break;
3008 case PM_MessageBoxIconSize:
3009 val = 48;
3010 break;
3011 case PM_ListViewIconSize:
3012 val = 24;
3013 break;
3014 case PM_DialogButtonsSeparator:
3015 case PM_ScrollBarSliderMin:
3016 val = 26;
3017 break;
3018 case PM_TitleBarHeight:
3019 val = 24;
3020 break;
3021 case PM_ScrollBarExtent:
3022 val = 14;
3023 break;
3024 case PM_SliderThickness:
3025 case PM_SliderLength:
3026 val = 15;
3027 break;
3028 case PM_DockWidgetTitleMargin:
3029 val = 1;
3030 break;
3031 case PM_SpinBoxFrameWidth:
3032 val = 3;
3033 break;
3034 case PM_MenuVMargin:
3035 case PM_MenuHMargin:
3036 case PM_MenuPanelWidth:
3037 val = 0;
3038 break;
3039 case PM_MenuBarItemSpacing:
3040 val = 6;
3041 break;
3042 case PM_MenuBarVMargin:
3043 case PM_MenuBarHMargin:
3044 case PM_MenuBarPanelWidth:
3045 val = 0;
3046 break;
3047 case PM_ToolBarHandleExtent:
3048 val = 9;
3049 break;
3050 case PM_ToolBarItemSpacing:
3051 val = 1;
3052 break;
3053 case PM_ToolBarFrameWidth:
3054 case PM_ToolBarItemMargin:
3055 val = 2;
3056 break;
3057 case PM_SmallIconSize:
3058 case PM_ButtonIconSize:
3059 val = 16;
3060 break;
3061 case PM_DockWidgetTitleBarButtonMargin:
3062 val = 2;
3063 break;
3064 case PM_TitleBarButtonSize:
3065 val = 19;
3066 break;
3067 case PM_MaximumDragDistance:
3068 return -1; // Do not dpi-scale because the value is magic
3069 case PM_TabCloseIndicatorWidth:
3070 case PM_TabCloseIndicatorHeight:
3071 val = 20;
3072 break;
3073 case PM_TabBarTabVSpace:
3074 val = 12;
3075 break;
3076 case PM_TabBarTabOverlap:
3077 val = 1;
3078 break;
3079 case PM_TabBarBaseOverlap:
3080 val = 2;
3081 break;
3082 case PM_SubMenuOverlap:
3083 val = -1;
3084 break;
3085 case PM_DockWidgetHandleExtent:
3086 case PM_SplitterWidth:
3087 val = 4;
3088 break;
3089 case PM_IndicatorHeight:
3090 case PM_IndicatorWidth:
3091 case PM_ExclusiveIndicatorHeight:
3092 case PM_ExclusiveIndicatorWidth:
3093 val = 14;
3094 break;
3095 case PM_ScrollView_ScrollBarSpacing:
3096 val = 0;
3097 break;
3098 case PM_ScrollView_ScrollBarOverlap:
3099 if (proxy()->styleHint(SH_ScrollBar_Transient, option, widget))
3100 return proxy()->pixelMetric(PM_ScrollBarExtent, option, widget);
3101 val = 0;
3102 break;
3103 case PM_DefaultFrameWidth:
3104 return 1; // Do not dpi-scale because the drawn frame is always exactly 1 pixel thick
3105 default:
3106 return QCommonStyle::pixelMetric(metric, option, widget);
3107 }
3109}
3110
3114QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
3115 const QSize &size, const QWidget *widget) const
3116{
3118 switch (type) {
3119 case CT_PushButton:
3120 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
3121 if (!btn->text.isEmpty() && newSize.width() < 80)
3122 newSize.setWidth(80);
3123 if (!btn->icon.isNull() && btn->iconSize.height() > 16)
3124 newSize -= QSize(0, 2);
3125 }
3126 break;
3127 case CT_GroupBox:
3128 if (option) {
3129 int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
3130 newSize += QSize(10, topMargin); // Add some space below the groupbox
3131 }
3132 break;
3133 case CT_RadioButton:
3134 case CT_CheckBox:
3135 newSize += QSize(0, 1);
3136 break;
3137 case CT_ToolButton:
3138 newSize += QSize(2, 2);
3139 break;
3140 case CT_SpinBox:
3141 newSize += QSize(0, -3);
3142 break;
3143 case CT_ComboBox:
3144 newSize += QSize(2, 4);
3145 break;
3146 case CT_LineEdit:
3147 newSize += QSize(0, 4);
3148 break;
3149 case CT_MenuBarItem:
3150 newSize += QSize(8, 5);
3151 break;
3152 case CT_MenuItem:
3153 if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
3154 int w = size.width(); // Don't rely of QCommonStyle's width calculation here
3155 if (menuItem->text.contains(u'\t'))
3156 w += menuItem->reservedShortcutWidth;
3157 else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu)
3158 w += 2 * QStyleHelper::dpiScaled(QFusionStylePrivate::menuArrowHMargin, option);
3159 else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) {
3160 const QFontMetrics fm(menuItem->font);
3161 QFont fontBold = menuItem->font;
3162 fontBold.setBold(true);
3163 const QFontMetrics fmBold(fontBold);
3164 w += fmBold.horizontalAdvance(menuItem->text) - fm.horizontalAdvance(menuItem->text);
3165 }
3167 // Windows always shows a check column
3168 const int checkcol = qMax<int>(menuItem->maxIconWidth,
3169 QStyleHelper::dpiScaled(QFusionStylePrivate::menuCheckMarkWidth, dpi));
3170 w += checkcol + windowsItemFrame;
3171 w += QStyleHelper::dpiScaled(int(QFusionStylePrivate::menuRightBorder) + 10, dpi);
3172 newSize.setWidth(w);
3173 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
3174 if (!menuItem->text.isEmpty()) {
3175 newSize.setHeight(menuItem->fontMetrics.height());
3176 }
3177 }
3178 else if (!menuItem->icon.isNull()) {
3179#if QT_CONFIG(combobox)
3180 if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) {
3181 newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height()));
3182 }
3183#endif
3184 }
3185 newSize.setWidth(newSize.width() + int(QStyleHelper::dpiScaled(12, dpi)));
3186 newSize.setWidth(qMax<int>(newSize.width(), int(QStyleHelper::dpiScaled(120, dpi))));
3187 }
3188 break;
3189 case CT_SizeGrip:
3190 newSize += QSize(4, 4);
3191 break;
3192 case CT_MdiControls:
3193 newSize -= QSize(1, 0);
3194 break;
3195 default:
3196 break;
3197 }
3198 return newSize;
3199}
3200
3204void QFusionStyle::polish(QApplication *app)
3205{
3207}
3208
3212void QFusionStyle::polish(QWidget *widget)
3213{
3215 if (false
3216#if QT_CONFIG(abstractbutton)
3217 || qobject_cast<QAbstractButton*>(widget)
3218#endif
3219#if QT_CONFIG(combobox)
3220 || qobject_cast<QComboBox *>(widget)
3221#endif
3222#if QT_CONFIG(progressbar)
3223 || qobject_cast<QProgressBar *>(widget)
3224#endif
3225#if QT_CONFIG(scrollbar)
3226 || qobject_cast<QScrollBar *>(widget)
3227#endif
3228#if QT_CONFIG(splitter)
3229 || qobject_cast<QSplitterHandle *>(widget)
3230#endif
3231#if QT_CONFIG(abstractslider)
3232 || qobject_cast<QAbstractSlider *>(widget)
3233#endif
3234#if QT_CONFIG(spinbox)
3235 || qobject_cast<QAbstractSpinBox *>(widget)
3236#endif
3237 || (widget->inherits("QDockSeparator"))
3238 || (widget->inherits("QDockWidgetSeparator"))
3239 ) {
3242 }
3243}
3244
3248void QFusionStyle::polish(QPalette &pal)
3249{
3251}
3252
3256void QFusionStyle::unpolish(QWidget *widget)
3257{
3259 if (false
3260#if QT_CONFIG(abstractbutton)
3261 || qobject_cast<QAbstractButton*>(widget)
3262#endif
3263#if QT_CONFIG(combobox)
3264 || qobject_cast<QComboBox *>(widget)
3265#endif
3266#if QT_CONFIG(progressbar)
3267 || qobject_cast<QProgressBar *>(widget)
3268#endif
3269#if QT_CONFIG(scrollbar)
3270 || qobject_cast<QScrollBar *>(widget)
3271#endif
3272#if QT_CONFIG(splitter)
3273 || qobject_cast<QSplitterHandle *>(widget)
3274#endif
3275#if QT_CONFIG(abstractslider)
3276 || qobject_cast<QAbstractSlider *>(widget)
3277#endif
3278#if QT_CONFIG(spinbox)
3279 || qobject_cast<QAbstractSpinBox *>(widget)
3280#endif
3281 || (widget->inherits("QDockSeparator"))
3282 || (widget->inherits("QDockWidgetSeparator"))
3283 ) {
3285 }
3286}
3287
3291void QFusionStyle::unpolish(QApplication *app)
3292{
3294}
3295
3299QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
3300 SubControl subControl, const QWidget *widget) const
3301{
3302 QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget);
3303
3304 switch (control) {
3305#if QT_CONFIG(slider)
3306 case CC_Slider:
3307 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
3308 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
3309 switch (subControl) {
3310 case SC_SliderHandle: {
3311 if (slider->orientation == Qt::Horizontal) {
3312 rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option));
3313 rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option));
3314 int centerY = slider->rect.center().y() - rect.height() / 2;
3315 if (slider->tickPosition & QSlider::TicksAbove)
3316 centerY += tickSize;
3317 if (slider->tickPosition & QSlider::TicksBelow)
3318 centerY -= tickSize;
3319 rect.moveTop(centerY);
3320 } else {
3321 rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option));
3322 rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option));
3323 int centerX = slider->rect.center().x() - rect.width() / 2;
3324 if (slider->tickPosition & QSlider::TicksAbove)
3325 centerX += tickSize;
3326 if (slider->tickPosition & QSlider::TicksBelow)
3327 centerX -= tickSize;
3328 rect.moveLeft(centerX);
3329 }
3330 }
3331 break;
3332 case SC_SliderGroove: {
3333 QPoint grooveCenter = slider->rect.center();
3334 const int grooveThickness = QStyleHelper::dpiScaled(7, option);
3335 if (slider->orientation == Qt::Horizontal) {
3336 rect.setHeight(grooveThickness);
3337 if (slider->tickPosition & QSlider::TicksAbove)
3338 grooveCenter.ry() += tickSize;
3339 if (slider->tickPosition & QSlider::TicksBelow)
3340 grooveCenter.ry() -= tickSize;
3341 } else {
3342 rect.setWidth(grooveThickness);
3343 if (slider->tickPosition & QSlider::TicksAbove)
3344 grooveCenter.rx() += tickSize;
3345 if (slider->tickPosition & QSlider::TicksBelow)
3346 grooveCenter.rx() -= tickSize;
3347 }
3348 rect.moveCenter(grooveCenter);
3349 break;
3350 }
3351 default:
3352 break;
3353 }
3354 }
3355 break;
3356#endif // QT_CONFIG(slider)
3357#if QT_CONFIG(spinbox)
3358 case CC_SpinBox:
3359 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
3360 int center = spinbox->rect.height() / 2;
3361 int fw = spinbox->frame ? 3 : 0; // Is drawn with 3 pixels width in drawComplexControl, independently from PM_SpinBoxFrameWidth
3362 int y = fw;
3363 const int buttonWidth = QStyleHelper::dpiScaled(14, option);
3364 int x, lx, rx;
3365 x = spinbox->rect.width() - y - buttonWidth + 2;
3366 lx = fw;
3367 rx = x - fw;
3368 switch (subControl) {
3369 case SC_SpinBoxUp:
3370 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
3371 return QRect();
3372 rect = QRect(x, fw, buttonWidth, center - fw);
3373 break;
3374 case SC_SpinBoxDown:
3375 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
3376 return QRect();
3377
3378 rect = QRect(x, center, buttonWidth, spinbox->rect.bottom() - center - fw + 1);
3379 break;
3380 case SC_SpinBoxEditField:
3381 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
3382 rect = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
3383 } else {
3384 rect = QRect(lx, fw, rx - qMax(fw - 1, 0), spinbox->rect.height() - 2*fw);
3385 }
3386 break;
3387 case SC_SpinBoxFrame:
3388 rect = spinbox->rect;
3389 default:
3390 break;
3391 }
3392 rect = visualRect(spinbox->direction, spinbox->rect, rect);
3393 }
3394 break;
3395#endif // QT_CONFIG(spinbox)
3396 case CC_GroupBox:
3397 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
3398 rect = option->rect;
3399 if (subControl == SC_GroupBoxFrame)
3400 return rect.adjusted(0, 0, 0, 0);
3401 else if (subControl == SC_GroupBoxContents) {
3402 QRect frameRect = option->rect.adjusted(0, 0, 0, -groupBoxBottomMargin);
3403 int margin = 3;
3404 int leftMarginExtension = 0;
3405 const int exclusiveIndicatorHeight = option->subControls.testFlag(SC_GroupBoxCheckBox) ?
3406 pixelMetric(PM_ExclusiveIndicatorHeight) : 0;
3407 const int fontMetricsHeight = groupBox->text.isEmpty() ? 0 :
3409 const int topMargin = qMax(exclusiveIndicatorHeight, fontMetricsHeight) +
3410 groupBoxTopMargin;
3411 return frameRect.adjusted(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBoxBottomMargin);
3412 }
3413
3414 QSize textSize = option->fontMetrics.boundingRect(groupBox->text).size() + QSize(2, 2);
3415 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
3416 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
3417
3418 const int width = textSize.width()
3419 + (option->subControls & QStyle::SC_GroupBoxCheckBox ? indicatorWidth + 5 : 0);
3420
3421 rect = QRect();
3422
3423 if (option->rect.width() > width) {
3424 switch (groupBox->textAlignment & Qt::AlignHorizontal_Mask) {
3425 case Qt::AlignHCenter:
3426 rect.moveLeft((option->rect.width() - width) / 2);
3427 break;
3428 case Qt::AlignRight:
3429 rect.moveLeft(option->rect.width() - width);
3430 break;
3431 }
3432 }
3433
3434 if (subControl == SC_GroupBoxCheckBox) {
3435 rect.setWidth(indicatorWidth);
3436 rect.setHeight(indicatorHeight);
3437 rect.moveTop(textSize.height() > indicatorHeight ? (textSize.height() - indicatorHeight) / 2 : 0);
3438 rect.translate(1, 0);
3439 } else if (subControl == SC_GroupBoxLabel) {
3440 rect.setSize(textSize);
3441 rect.moveTop(1);
3442 if (option->subControls & QStyle::SC_GroupBoxCheckBox)
3443 rect.translate(indicatorWidth + 5, 0);
3444 }
3445 return visualRect(option->direction, option->rect, rect);
3446 }
3447
3448 return rect;
3449
3450 case CC_ComboBox:
3451 switch (subControl) {
3452 case SC_ComboBoxArrow: {
3454 rect = visualRect(option->direction, option->rect, rect);
3455 rect.setRect(rect.right() - int(QStyleHelper::dpiScaled(18, dpi)), rect.top() - 2,
3456 int(QStyleHelper::dpiScaled(19, dpi)), rect.height() + 4);
3457 rect = visualRect(option->direction, option->rect, rect);
3458 }
3459 break;
3460 case SC_ComboBoxEditField: {
3461 int frameWidth = 2;
3462 rect = visualRect(option->direction, option->rect, rect);
3463 rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
3464 option->rect.width() - int(QStyleHelper::dpiScaled(19, option)) - 2 * frameWidth,
3465 option->rect.height() - 2 * frameWidth);
3466 if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3467 if (!box->editable) {
3468 rect.adjust(2, 0, 0, 0);
3469 if (box->state & (State_Sunken | State_On))
3470 rect.translate(1, 1);
3471 }
3472 }
3473 rect = visualRect(option->direction, option->rect, rect);
3474 break;
3475 }
3476 default:
3477 break;
3478 }
3479 break;
3480 case CC_TitleBar:
3481 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
3482 SubControl sc = subControl;
3483 QRect &ret = rect;
3484 const int indent = 3;
3485 const int controlTopMargin = 3;
3486 const int controlBottomMargin = 3;
3487 const int controlWidthMargin = 2;
3488 const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ;
3489 const int delta = controlHeight + controlWidthMargin;
3490 int offset = 0;
3491
3492 bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
3493 bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
3494
3495 switch (sc) {
3496 case SC_TitleBarLabel:
3497 if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
3498 ret = tb->rect;
3499 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
3500 ret.adjust(delta, 0, -delta, 0);
3501 if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3502 ret.adjust(0, 0, -delta, 0);
3503 if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3504 ret.adjust(0, 0, -delta, 0);
3505 if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
3506 ret.adjust(0, 0, -delta, 0);
3507 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
3508 ret.adjust(0, 0, -delta, 0);
3509 }
3510 break;
3511 case SC_TitleBarContextHelpButton:
3512 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
3513 offset += delta;
3514 Q_FALLTHROUGH();
3515 case SC_TitleBarMinButton:
3516 if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
3517 offset += delta;
3518 else if (sc == SC_TitleBarMinButton)
3519 break;
3520 Q_FALLTHROUGH();
3521 case SC_TitleBarNormalButton:
3522 if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
3523 offset += delta;
3524 else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
3525 offset += delta;
3526 else if (sc == SC_TitleBarNormalButton)
3527 break;
3528 Q_FALLTHROUGH();
3529 case SC_TitleBarMaxButton:
3530 if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
3531 offset += delta;
3532 else if (sc == SC_TitleBarMaxButton)
3533 break;
3534 Q_FALLTHROUGH();
3535 case SC_TitleBarShadeButton:
3536 if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
3537 offset += delta;
3538 else if (sc == SC_TitleBarShadeButton)
3539 break;
3540 Q_FALLTHROUGH();
3541 case SC_TitleBarUnshadeButton:
3542 if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
3543 offset += delta;
3544 else if (sc == SC_TitleBarUnshadeButton)
3545 break;
3546 Q_FALLTHROUGH();
3547 case SC_TitleBarCloseButton:
3548 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
3549 offset += delta;
3550 else if (sc == SC_TitleBarCloseButton)
3551 break;
3552 ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
3553 controlHeight, controlHeight);
3554 break;
3555 case SC_TitleBarSysMenu:
3556 if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3557 ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
3558 controlHeight, controlHeight);
3559 }
3560 break;
3561 default:
3562 break;
3563 }
3564 ret = visualRect(tb->direction, tb->rect, ret);
3565 }
3566 break;
3567 default:
3568 break;
3569 }
3570
3571 return rect;
3572}
3573
3574
3578QRect QFusionStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
3579{
3581}
3582
3586void QFusionStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
3587 int alignment, const QPixmap &pixmap) const
3588{
3590}
3591
3595QStyle::SubControl QFusionStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
3596 const QPoint &pt, const QWidget *w) const
3597{
3598 return QCommonStyle::hitTestComplexControl(cc, opt, pt, w);
3599}
3600
3604QPixmap QFusionStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
3605 const QStyleOption *opt) const
3606{
3607 return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt);
3608}
3609
3613int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
3614 QStyleHintReturn *returnData) const
3615{
3616 switch (hint) {
3617 case SH_Slider_SnapToValue:
3618 case SH_PrintDialog_RightAlignButtons:
3619 case SH_FontDialog_SelectAssociatedText:
3620 case SH_MenuBar_AltKeyNavigation:
3621 case SH_ComboBox_ListMouseTracking:
3622 case SH_Slider_StopMouseOverSlider:
3623 case SH_ScrollBar_MiddleClickAbsolutePosition:
3624 case SH_EtchDisabledText:
3625 case SH_TitleBar_AutoRaise:
3626 case SH_TitleBar_NoBorder:
3627 case SH_ItemView_ShowDecorationSelected:
3628 case SH_ItemView_ArrowKeysNavigateIntoChildren:
3629 case SH_ItemView_ChangeHighlightOnFocus:
3630 case SH_MenuBar_MouseTracking:
3631 case SH_Menu_MouseTracking:
3632 case SH_Menu_SupportsSections:
3633 return 1;
3634
3635#if defined(QT_PLATFORM_UIKIT)
3636 case SH_ComboBox_UseNativePopup:
3637 return 1;
3638#endif
3639
3640 case SH_ToolBox_SelectedPageTitleBold:
3641 case SH_ScrollView_FrameOnlyAroundContents:
3642 case SH_Menu_AllowActiveAndDisabled:
3643 case SH_MainWindow_SpaceBelowMenuBar:
3644 case SH_MessageBox_CenterButtons:
3645 case SH_RubberBand_Mask:
3646 return 0;
3647
3648 case SH_ComboBox_Popup:
3649 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
3650 return !cmb->editable;
3651 return 0;
3652
3653 case SH_Table_GridLineColor:
3654 return option ? option->palette.window().color().darker(120).rgba() : 0;
3655
3656 case SH_MessageBox_TextInteractionFlags:
3658#if QT_CONFIG(wizard)
3659 case SH_WizardStyle:
3660 return QWizard::ClassicStyle;
3661#endif
3662 case SH_Menu_SubMenuPopupDelay:
3663 return 225; // default from GtkMenu
3664
3665 case SH_WindowFrame_Mask:
3666 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
3667 //left rounded corner
3668 mask->region = option->rect;
3669 mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1);
3670 mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1);
3671 mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1);
3672 mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2);
3673
3674 //right rounded corner
3675 mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1);
3676 mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1);
3677 mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1);
3678 mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2);
3679 return 1;
3680 }
3681 default:
3682 break;
3683 }
3684 return QCommonStyle::styleHint(hint, option, widget, returnData);
3685}
3686
3688QRect QFusionStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const
3689{
3691 switch (sr) {
3692 case SE_ProgressBarLabel:
3693 case SE_ProgressBarContents:
3694 case SE_ProgressBarGroove:
3695 return opt->rect;
3696 case SE_PushButtonFocusRect:
3697 r.adjust(0, 1, 0, -1);
3698 break;
3699 case SE_DockWidgetTitleBarText: {
3700 if (const QStyleOptionDockWidget *titlebar = qstyleoption_cast<const QStyleOptionDockWidget*>(opt)) {
3701 bool verticalTitleBar = titlebar->verticalTitleBar;
3702 if (verticalTitleBar) {
3703 r.adjust(0, 0, 0, -4);
3704 } else {
3706 r.adjust(4, 0, 0, 0);
3707 else
3708 r.adjust(0, 0, -4, 0);
3709 }
3710 }
3711
3712 break;
3713 }
3714 default:
3715 break;
3716 }
3717 return r;
3718}
3719
3723QIcon QFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
3724 const QWidget *widget) const
3725{
3726#if QT_CONFIG(imageformat_xpm)
3727 switch (standardIcon) {
3728 case SP_TitleBarNormalButton:
3729 return QIcon(QPixmap(dock_widget_restore_xpm));
3730 case SP_TitleBarMinButton:
3731 return QIcon(QPixmap(workspace_minimize));
3732 case SP_TitleBarCloseButton:
3733 case SP_DockWidgetCloseButton:
3734 return QIcon(QPixmap(fusion_dock_widget_close_xpm));
3735 default:
3736 break;
3737 }
3738#endif // imageformat_xpm
3739 return QCommonStyle::standardIcon(standardIcon, option, widget);
3740}
3741
3745QPixmap QFusionStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
3746 const QWidget *widget) const
3747{
3748#ifndef QT_NO_IMAGEFORMAT_XPM
3749 switch (standardPixmap) {
3750 case SP_TitleBarNormalButton:
3751 return QPixmap(dock_widget_restore_xpm);
3752 case SP_TitleBarMinButton:
3753 return QPixmap(workspace_minimize);
3754 case SP_TitleBarCloseButton:
3755 case SP_DockWidgetCloseButton:
3756 return QPixmap(fusion_dock_widget_close_xpm);
3757
3758 default:
3759 break;
3760 }
3761#endif //QT_NO_IMAGEFORMAT_XPM
3762
3763 return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
3764}
3765
3767
3768#include "moc_qfusionstyle_p.cpp"
3769
3770#endif // style_fusion|| QT_PLUGIN
void setCurrentTime(int msecs)
Qt::Orientation orientation
the orientation of the slider
int sliderPosition
the current slider position
int minimum
the sliders's minimum value
int maximum
the slider's maximum value
bool frame
whether the spin box draws itself with a frame
ButtonSymbols buttonSymbols
the current button symbol mode
virtual StepEnabled stepEnabled() const
Virtual function that determines whether stepping up and down is legal at any given time.
The QApplication class manages the GUI application's control flow and main settings.
\inmodule QtGui
Definition qbrush.h:30
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition qbrush.cpp:791
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
int saturation() const noexcept
Returns the HSV saturation color component of this color.
Definition qcolor.cpp:1734
QColor darker(int f=200) const noexcept
Definition qcolor.cpp:2857
QRgb rgb() const noexcept
Returns the RGB value of the color.
Definition qcolor.cpp:1439
void setGreen(int green)
Sets the green color component of this color to green.
Definition qcolor.cpp:1568
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
Definition qcolor.cpp:1376
void setBlue(int blue)
Sets the blue color component of this color to blue.
Definition qcolor.cpp:1597
int red() const noexcept
Returns the red color component of this color.
Definition qcolor.cpp:1528
int hue() const noexcept
Returns the HSV hue color component of this color.
Definition qcolor.cpp:1708
int blue() const noexcept
Returns the blue color component of this color.
Definition qcolor.cpp:1583
int green() const noexcept
Returns the green color component of this color.
Definition qcolor.cpp:1555
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1481
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition qcolor.cpp:1099
int value() const noexcept
Returns the value color component of this color.
Definition qcolor.cpp:1756
QColor lighter(int f=150) const noexcept
Definition qcolor.cpp:2812
QString name(NameFormat format=HexRgb) const
Definition qcolor.cpp:834
@ HexArgb
Definition qcolor.h:36
void setRed(int red)
Sets the red color component of this color to red.
Definition qcolor.cpp:1541
The QComboBox widget is a combined button and popup list.
Definition qcombobox.h:24
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
int pixelMetric(PixelMetric m, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
\reimp
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=nullptr) const override
\reimp
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
\reimp
void unpolish(QWidget *widget) override
\reimp
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
\reimp
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=nullptr) const override
\reimp
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
\reimp
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override
\reimp
void polish(QPalette &) override
\reimp
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=nullptr) const override
\reimp
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
\reentrant
Definition qfontinfo.h:14
qreal pointSizeF() const
Returns the point size of the matched window system font.
Definition qfont.cpp:2847
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags=0) const
\reentrant
Definition qfont.h:20
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
Definition qfont.h:312
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition qfont.cpp:995
int midLineWidth
the width of the mid-line
Definition qframe.h:23
int lineWidth
the line width
Definition qframe.h:22
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition qbrush.cpp:1608
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition qbrush.cpp:1563
QGradientStops stops() const
Returns the stop points for this gradient.
Definition qbrush.cpp:1631
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:973
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
@ Disabled
Definition qicon.h:22
@ Normal
Definition qicon.h:22
@ Active
Definition qicon.h:22
@ On
Definition qicon.h:23
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qline.h:182
\inmodule QtCore
Definition qline.h:18
\inmodule QtGui
Definition qbrush.h:394
void setFinalStop(const QPointF &stop)
Definition qbrush.cpp:1943
void setStart(const QPointF &start)
Definition qbrush.cpp:1902
\inmodule QtCore
Definition qmargins.h:23
\inmodule QtCore
Definition qobject.h:90
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4187
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition qobject.h:313
qreal devicePixelRatio() const
\inmodule QtGui
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
Definition qpainter.h:545
const QPen & pen() const
Returns the painter's current pen.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition qpainter.h:519
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition qpainter.h:442
void restore()
Restores the current painter state (pops a saved state off the stack).
void rotate(qreal a)
Rotates the coordinate system clockwise.
const QBrush & brush() const
Returns the painter's current brush.
void setOpacity(qreal opacity)
QFontMetrics fontMetrics() const
Returns the font metrics for the painter if the painter is active.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
void save()
Saves the current painter state (pushes the state onto a stack).
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
@ SmoothPixmapTransform
Definition qpainter.h:54
@ Antialiasing
Definition qpainter.h:52
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen's color.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:87
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition qpalette.h:82
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition qpalette.cpp:794
const QBrush & light() const
Returns the light brush of the current color group.
Definition qpalette.h:84
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
Definition qpalette.h:150
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition qpalette.h:145
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:88
@ HighlightedText
Definition qpalette.h:52
@ ButtonText
Definition qpalette.h:51
@ WindowText
Definition qpalette.h:50
@ Highlight
Definition qpalette.h:52
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition qpalette.h:98
\inmodule QtGui
Definition qpen.h:25
qreal widthF() const
Returns the pen width with floating point precision.
Definition qpen.cpp:598
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition qpixmap.cpp:854
\inmodule QtCore\reentrant
Definition qpoint.h:214
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:333
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:338
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr int & ry() noexcept
Returns a reference to the y coordinate of this point.
Definition qpoint.h:157
constexpr int & rx() noexcept
Returns a reference to the x coordinate of this point.
Definition qpoint.h:152
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:127
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:132
\inmodule QtCore\reentrant
Definition qrect.h:483
constexpr void moveTo(qreal x, qreal y) noexcept
Moves the rectangle, leaving the top-left corner at the given position (x, y).
Definition qrect.h:736
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:499
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:718
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:715
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
Definition qrect.h:513
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:496
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
Definition qrect.h:804
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:510
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:685
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Definition qrect.h:511
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
Definition qrect.h:845
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:497
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
Definition qrect.h:807
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
Definition qrect.h:512
constexpr QRectF transposed() const noexcept
Definition qrect.h:756
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:498
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr QPoint bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
Definition qrect.h:229
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:372
constexpr void getRect(int *x, int *y, int *w, int *h) const
Extracts the position of the rectangle's top-left corner to *x and *y, and its dimensions to *width a...
Definition qrect.h:337
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
Definition qrect.h:169
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition qrect.h:163
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:181
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
Definition qrect.h:196
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:220
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition qrect.h:369
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:175
constexpr QPoint topRight() const noexcept
Returns the position of the rectangle's top-right corner.
Definition qrect.h:226
constexpr void setBottom(int pos) noexcept
Sets the bottom edge of the rectangle to the given y coordinate.
Definition qrect.h:199
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
Definition qrect.h:190
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:172
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
Definition qrect.h:380
constexpr void setX(int x) noexcept
Sets the left edge of the rectangle to the given x coordinate.
Definition qrect.h:214
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
Definition qrect.h:244
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Definition qrect.h:223
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:187
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
Definition qrect.h:383
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:232
constexpr void setY(int y) noexcept
Sets the top edge of the rectangle to the given y coordinate.
Definition qrect.h:217
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:178
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
Definition qrect.h:193
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
QRegion subtracted(const QRegion &r) const
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
Definition qsize.h:135
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
Definition qsize.h:138
@ TicksAbove
Definition qslider.h:27
@ TicksBelow
Definition qslider.h:29
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
Definition qstring.cpp:5204
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
Definition qstring.cpp:5161
The QStyleHintReturnMask class provides style hints that return a QRegion.
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionHeaderV2::textElideMode
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
\variable QStyleOptionComplex::subControls
\variable QStyleOption::palette
\variable QStyleOptionFocusRect::backgroundColor
\variable QStyleOptionFrame::features
The QStyleOptionHeaderV2 class is used to describe the parameters for drawing a header.
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
\variable QStyleOptionProgressBar::minimum
MenuItemType menuItemType
\variable QStyleOptionButton::features
\variable QStyleOptionToolBox::selectedPosition
The QStyleOption class stores the parameters used by QStyle functions.
QStyle::State state
QPalette palette
Qt::LayoutDirection direction
@ State_Active
Definition qstyle.h:83
@ State_Horizontal
Definition qstyle.h:74
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Returns the area within the given rectangle in which to draw the specified pixmap according to the de...
Definition qstyle.cpp:534
@ SH_UnderlineShortcut
Definition qstyle.h:624
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment,...
Definition qstyle.cpp:612
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition qstyle.cpp:2223
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
@ SC_GroupBoxCheckBox
Definition qstyle.h:390
@ SC_GroupBoxLabel
Definition qstyle.h:391
@ SC_GroupBoxFrame
Definition qstyle.h:393
@ RoundedSouth
Definition qtabbar.h:42
@ RoundedNorth
Definition qtabbar.h:42
@ TriangularEast
Definition qtabbar.h:43
@ RoundedWest
Definition qtabbar.h:42
@ TriangularSouth
Definition qtabbar.h:43
@ RoundedEast
Definition qtabbar.h:42
@ TriangularWest
Definition qtabbar.h:43
@ TriangularNorth
Definition qtabbar.h:43
\reentrant
Definition qtextoption.h:18
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis, qreal distanceToPlane=1024.0f)
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis.
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
constexpr size_type size() const noexcept
T * data() noexcept
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
uint toUInt(bool *ok=nullptr) const
Returns the variant as an unsigned int if the variant has userType() \l QMetaType::UInt,...
QRect toRect() const
Returns the variant as a QRect if the variant has userType() \l QMetaType::QRect; otherwise returns a...
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
QPalette palette
the widget's palette
Definition qwidget.h:132
QFontMetrics fontMetrics() const
Returns the font metrics for the widget's current font.
Definition qwidget.h:847
QRect rect
the internal geometry of the widget excluding any window frame
Definition qwidget.h:116
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition qwidget.h:811
QPalette::ColorRole backgroundRole() const
Returns the background role of the widget.
Definition qwidget.cpp:4367
@ ClassicStyle
Definition qwizard.h:55
QOpenGLWidget * widget
[1]
QString text
QPushButton * button
[2]
QCache< int, Employee > cache
[0]
object setObjectName("A new object name")
opt iconSize
drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget)
rect
[4]
QStyleOptionButton subopt
[2]
uint alignment
direction
QStyleOptionButton opt
fontMetrics
else opt state
[0]
QRect textRect
const QStyleOptionButton * btn
[3]
Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi)
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)
Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option)
QColor backgroundColor(const QPalette &pal, const QWidget *widget)
Combined button and popup list for selecting options.
bool isEnabled()
@ WindowMinimized
Definition qnamespace.h:252
@ WindowMaximized
Definition qnamespace.h:253
@ AlignRight
Definition qnamespace.h:145
@ AlignVCenter
Definition qnamespace.h:154
@ AlignHCenter
Definition qnamespace.h:147
@ AlignHorizontal_Mask
Definition qnamespace.h:150
@ AlignCenter
Definition qnamespace.h:162
@ AlignAbsolute
Definition qnamespace.h:149
@ AlignLeft
Definition qnamespace.h:143
@ TextSelectableByMouse
@ LinksAccessibleByMouse
@ WA_Hover
Definition qnamespace.h:339
@ WA_OpaquePaintEvent
Definition qnamespace.h:286
@ IntersectClip
@ LeftToolBarArea
@ BottomToolBarArea
@ TopToolBarArea
@ RightToolBarArea
@ LeftToRight
@ RightToLeft
@ Horizontal
Definition qnamespace.h:98
@ Vertical
Definition qnamespace.h:99
ArrowType
@ UpArrow
@ RightArrow
@ LeftArrow
@ DownArrow
@ TextSingleLine
Definition qnamespace.h:169
@ TextDontClip
Definition qnamespace.h:170
@ TextHideMnemonic
Definition qnamespace.h:177
@ TextShowMnemonic
Definition qnamespace.h:172
@ white
Definition qnamespace.h:30
@ transparent
Definition qnamespace.h:46
@ black
Definition qnamespace.h:29
@ NoPen
@ NoBrush
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
@ WindowContextHelpButtonHint
Definition qnamespace.h:230
@ WindowMaximizeButtonHint
Definition qnamespace.h:228
@ WindowMinimizeButtonHint
Definition qnamespace.h:227
@ WindowShadeButtonHint
Definition qnamespace.h:231
@ WindowTitleHint
Definition qnamespace.h:225
@ WindowSystemMenuHint
Definition qnamespace.h:226
@ ElideMiddle
Definition qnamespace.h:190
@ ElideRight
Definition qnamespace.h:189
Definition image.cpp:4
void flip(QMatrix4x4 &matrix)
Definition qssgutils_p.h:74
QRectF fillRect(QRect rect, int background)
static jboolean copy(JNIEnv *, jobject)
#define Q_FALLTHROUGH()
static QString header(const QString &name)
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules(), QDrawBorderPixmap::DrawingHints hints=QDrawBorderPixmap::DrawingHints())
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
return ret
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLenum mode
const GLfloat * m
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble right
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei width
GLenum type
GLbitfield flags
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei const GLint * box
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLfloat * val
GLfixed GLfixed GLfixed y2
GLenum GLsizei len
GLfixed GLfixed x2
GLsizei const GLchar *const * path
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint GLenum option
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
Q_GUI_EXPORT QPalette qt_fusionPalette()
static QRectF alignedRect(bool mirrored, Qt::Alignment alignment, const QSizeF &size, const QRectF &rectangle)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
constexpr int qGray(int r, int g, int b)
Definition qrgb.h:36
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define QStringLiteral(str)
#define BEGIN_STYLE_PIXMAPCACHE(a)
Definition qstyle_p.h:58
#define END_STYLE_PIXMAPCACHE
Definition qstyle_p.h:79
QPixmap styleCachePixmap(const QSize &size)
Definition qstyle_p.h:50
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
#define Q_INT64_C(c)
Definition qtypes.h:52
static const int windowsItemFrame
static const int windowsItemVMargin
QObject * styleObject(const QStyleOption *option)
QString title
[35]
QScrollBar * scrollBar
QPropertyAnimation animation
[0]
p rx()++
QRect r2(QPoint(100, 200), QSize(11, 16))
QGraphicsItem * item
QApplication app(argc, argv)
[0]
widget render & pixmap
QPainter painter(this)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QFrame frame
[0]
QSpinBox * spinBox
[0]
QCheckBox * checkbox
[0]
QNetworkProxy proxy
[0]