Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcommonstyle.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 "qcommonstyle.h"
5#include "qcommonstyle_p.h"
6
7#include <qfile.h>
8#if QT_CONFIG(itemviews)
9#include <qabstractitemview.h>
10#endif
11#include <qapplication.h>
12#include <private/qguiapplication_p.h>
13#include <qpa/qplatformtheme.h>
14#include <qbitmap.h>
15#include <qcache.h>
16#if QT_CONFIG(dockwidget)
17#include <qdockwidget.h>
18#endif
19#include <qdrawutil.h>
20#if QT_CONFIG(dialogbuttonbox)
21#include <qdialogbuttonbox.h>
22#endif
23#if QT_CONFIG(formlayout)
24#include <qformlayout.h>
25#else
26#include <qlayout.h>
27#endif
28#if QT_CONFIG(groupbox)
29#include <qgroupbox.h>
30#endif
31#include <qmath.h>
32#if QT_CONFIG(menu)
33#include <qmenu.h>
34#endif
35#include <qpainter.h>
36#include <qpaintengine.h>
37#include <qpainterpath.h>
38#if QT_CONFIG(slider)
39#include <qslider.h>
40#endif
41#include <qstyleoption.h>
42#if QT_CONFIG(tabbar)
43#include <qtabbar.h>
44#endif
45#if QT_CONFIG(tabwidget)
46#include <qtabwidget.h>
47#endif
48#if QT_CONFIG(toolbar)
49#include <qtoolbar.h>
50#endif
51#if QT_CONFIG(toolbutton)
52#include <qtoolbutton.h>
53#endif
54#if QT_CONFIG(rubberband)
55#include <qrubberband.h>
56#endif
57#if QT_CONFIG(treeview)
58#include "qtreeview.h"
59#endif
60#include <private/qcommonstylepixmaps_p.h>
61#include <private/qmath_p.h>
62#include <qdebug.h>
63#include <qtextformat.h>
64#if QT_CONFIG(wizard)
65#include <qwizard.h>
66#endif
67#if QT_CONFIG(filedialog)
68#include <qsidebar_p.h>
69#endif
70#include <qfileinfo.h>
71#include <qdir.h>
72#if QT_CONFIG(settings)
73#include <qsettings.h>
74#endif
75#include <qvariant.h>
76#include <qpixmapcache.h>
77#if QT_CONFIG(animation)
78#include <private/qstyleanimation_p.h>
79#endif
80
81#include <qloggingcategory.h>
82
83#include <limits.h>
84
85#include <private/qtextengine_p.h>
86#include <private/qstylehelper_p.h>
87
89
90Q_LOGGING_CATEGORY(lcCommonStyle, "qt.widgets.commonstyle");
91
92using namespace Qt::StringLiterals;
93
95{
96 return widget ? widget->devicePixelRatio() : qApp->devicePixelRatio();
97}
98
128{ }
129
133 : QStyle(dd)
134{ }
135
140{ }
141
142
147 const QWidget *widget) const
148{
149 Q_D(const QCommonStyle);
150 switch (pe) {
154 opt->state & (State_Sunken | State_On), 1, 0);
155 break;
161 opt->state & (State_Sunken | State_On), 1,
163 break;
166 break;
168 if (opt->state & State_NoChange) {
169 p->setPen(opt->palette.windowText().color());
170 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
171 p->drawRect(opt->rect);
172 p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight());
173 } else {
177 }
178 break;
180 QRect ir = opt->rect;
181 p->setPen(opt->palette.dark().color());
182 p->drawArc(opt->rect, 0, 5760);
183 if (opt->state & (State_Sunken | State_On)) {
184 ir.adjust(2, 2, -2, -2);
185 p->setBrush(opt->palette.windowText());
186 p->drawEllipse(ir);
187 }
188 break; }
190 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
191 QColor bg = fropt->backgroundColor;
192 QPen oldPen = p->pen();
193 if (bg.isValid()) {
194 int h, s, v;
195 bg.getHsv(&h, &s, &v);
196 if (v >= 128)
197 p->setPen(Qt::black);
198 else
199 p->setPen(Qt::white);
200 } else {
201 p->setPen(opt->palette.windowText().color());
202 }
203 QRect focusRect = opt->rect.adjusted(1, 1, -1, -1);
204 p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive
205 p->setPen(oldPen);
206 }
207 break;
209 const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width();
210 const int markH = markW;
211 int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1;
212 int posY = opt->rect.y() + (opt->rect.height() - markH)/2;
213
215 a.reserve(markH);
216
217 int i, xx, yy;
218 xx = posX;
219 yy = 3 + posY;
220 for (i = 0; i < markW/2; ++i) {
221 a << QLineF(xx, yy, xx, yy + 2);
222 ++xx;
223 ++yy;
224 }
225 yy -= 2;
226 for (; i < markH; ++i) {
227 a << QLineF(xx, yy, xx, yy + 2);
228 ++xx;
229 --yy;
230 }
231 if (!(opt->state & State_Enabled) && !(opt->state & State_On)) {
232 p->save();
233 p->translate(1, 1);
234 p->setPen(opt->palette.light().color());
235 p->drawLines(a);
236 p->restore();
237 }
238 p->setPen((opt->state & State_On) ? opt->palette.highlightedText().color() : opt->palette.text().color());
239 p->drawLines(a);
240 break; }
241 case PE_Frame:
242 case PE_FrameMenu:
243 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
244 if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) {
247 } else {
249 }
250 }
251 break;
252#if QT_CONFIG(toolbar)
253 case PE_PanelMenuBar:
254 if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
255 break;
256 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)){
259
260 }
261 else if (const QStyleOptionToolBar *frame = qstyleoption_cast<const QStyleOptionToolBar *>(opt)){
264 }
265
266 break;
267 case PE_PanelMenu:
268 break;
269 case PE_PanelToolBar:
270 break;
271#endif // QT_CONFIG(toolbar)
272#if QT_CONFIG(progressbar)
274 {
275 bool vertical = false;
276 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt))
277 vertical = !(pb->state & QStyle::State_Horizontal);
278 if (!vertical) {
279 p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
281 } else {
282 p->fillRect(opt->rect.x() + 2, opt->rect.y(), opt->rect.width() -6, opt->rect.height() - 2,
284 }
285 }
286 break;
287#endif // QT_CONFIG(progressbar)
288 case PE_IndicatorBranch: {
289 static const int decoration_size = 9;
290 int mid_h = opt->rect.x() + opt->rect.width() / 2;
291 int mid_v = opt->rect.y() + opt->rect.height() / 2;
292 int bef_h = mid_h;
293 int bef_v = mid_v;
294 int aft_h = mid_h;
295 int aft_v = mid_v;
296 if (opt->state & State_Children) {
297 int delta = decoration_size / 2;
298 bef_h -= delta;
299 bef_v -= delta;
300 aft_h += delta;
301 aft_v += delta;
302 p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
303 if (!(opt->state & State_Open))
304 p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
305 QPen oldPen = p->pen();
306 p->setPen(opt->palette.dark().color());
307 p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
308 p->setPen(oldPen);
309 }
311 if (opt->state & State_Item) {
313 p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
314 else
315 p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
316 }
317 if (opt->state & State_Sibling)
318 p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
320 p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
321 break; }
323 qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, nullptr);
324 break;
326 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
327 QPen oldPen = p->pen();
328 if (header->sortIndicator & QStyleOptionHeader::SortUp) {
329 p->setPen(QPen(opt->palette.light(), 0));
330 p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),
331 opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
332 p->setPen(QPen(opt->palette.dark(), 0));
333 const QPoint points[] = {
334 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()),
335 QPoint(opt->rect.x(), opt->rect.y()),
336 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y()),
337 };
338 p->drawPolyline(points, sizeof points / sizeof *points);
339 } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
340 p->setPen(QPen(opt->palette.light(), 0));
341 const QPoint points[] = {
342 QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height()),
343 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()),
344 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y()),
345 };
346 p->drawPolyline(points, sizeof points / sizeof *points);
347 p->setPen(QPen(opt->palette.dark(), 0));
348 p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),
349 opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
350 }
351 p->setPen(oldPen);
352 }
353 break;
354#if QT_CONFIG(tabbar)
356 if (const QStyleOptionTabBarBase *tbb
357 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
358 p->save();
359 switch (tbb->shape) {
362 p->setPen(QPen(tbb->palette.light(), 0));
363 p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
364 break;
367 p->setPen(QPen(tbb->palette.light(), 0));
368 p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
369 break;
372 p->setPen(QPen(tbb->palette.shadow(), 0));
373 p->drawLine(tbb->rect.left(), tbb->rect.bottom(),
374 tbb->rect.right(), tbb->rect.bottom());
375 p->setPen(QPen(tbb->palette.dark(), 0));
376 p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1,
377 tbb->rect.right() - 1, tbb->rect.bottom() - 1);
378 break;
381 p->setPen(QPen(tbb->palette.dark(), 0));
382 p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
383 break;
384 }
385 p->restore();
386 }
387 break;
389 if (d->tabBarcloseButtonIcon.isNull())
390 d->tabBarcloseButtonIcon = proxy()->standardIcon(QStyle::SP_TabCloseButton, opt, widget);
391
396 if (!(opt->state & State_Raised)
397 && !(opt->state & State_Sunken)
400
402 QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(size, size), p->device()->devicePixelRatio(), mode, state);
404 break;
405 }
406#else
407 Q_UNUSED(d);
408#endif // QT_CONFIG(tabbar)
410 case PE_FrameWindow:
411 qDrawWinPanel(p, opt->rect, opt->palette, false, nullptr);
412 break;
413 case PE_FrameLineEdit:
415 break;
416#if QT_CONFIG(groupbox)
417 case PE_FrameGroupBox:
418 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
419 if (frame->features & QStyleOptionFrame::Flat) {
420 QRect fr = frame->rect;
421 QPoint p1(fr.x(), fr.y() + 1);
422 QPoint p2(fr.x() + fr.width(), p1.y());
423 qDrawShadeLine(p, p1, p2, frame->palette, true,
425 } else {
427 frame->rect.height(), frame->palette, true,
429 }
430 }
431 break;
432#endif // QT_CONFIG(groupbox)
433#if QT_CONFIG(dockwidget)
435 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
436 int lw = frame->lineWidth;
437 if (lw <= 0)
439
440 qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
441 }
442 break;
443#endif // QT_CONFIG(dockwidget)
444#if QT_CONFIG(toolbar)
446 p->save();
447 p->translate(opt->rect.x(), opt->rect.y());
448 if (opt->state & State_Horizontal) {
449 int x = opt->rect.width() / 3;
451 x -= 2;
452 if (opt->rect.height() > 4) {
453 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
454 opt->palette, false, 1, nullptr);
455 qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,
456 opt->palette, false, 1, nullptr);
457 }
458 } else {
459 if (opt->rect.width() > 4) {
460 int y = opt->rect.height() / 3;
461 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
462 opt->palette, false, 1, nullptr);
463 qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,
464 opt->palette, false, 1, nullptr);
465 }
466 }
467 p->restore();
468 break;
470 {
471 QPoint p1, p2;
472 if (opt->state & State_Horizontal) {
473 p1 = QPoint(opt->rect.width()/2, 0);
474 p2 = QPoint(p1.x(), opt->rect.height());
475 } else {
476 p1 = QPoint(0, opt->rect.height()/2);
477 p2 = QPoint(opt->rect.width(), p1.y());
478 }
479 qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
480 break;
481 }
482#endif // QT_CONFIG(toolbar)
483#if QT_CONFIG(spinbox)
486 QRect r = opt->rect;
488 QRect br = r.adjusted(fw, fw, -fw, -fw);
489 int x = br.x();
490 int y = br.y();
491 int w = br.width();
492 int h = br.height();
493 p->save();
494 const qreal devicePixelRatio = p->device()->devicePixelRatio();
495 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
496 const qreal inverseScale = qreal(1) / devicePixelRatio;
497 p->scale(inverseScale, inverseScale);
498 x = qRound(devicePixelRatio * x);
499 y = qRound(devicePixelRatio * y);
500 w = qRound(devicePixelRatio * w);
501 h = qRound(devicePixelRatio * h);
502 p->translate(0.5, 0.5);
503 }
504 int len = std::min(w, h);
505 if (len & 1)
506 ++len;
507 int step = (len + 4) / 5;
508 if (step & 1)
509 ++step;
510 const int step2 = step / 2;
511 QPoint center(x + w / 2, y + h / 2);
512 if (opt->state & State_Sunken) {
515 }
516 p->translate(center);
517 p->fillRect(-len / 2, -step2, len, step, opt->palette.buttonText());
518 if (pe == PE_IndicatorSpinPlus)
519 p->fillRect(-step2, -len / 2, step, len, opt->palette.buttonText());
520 p->restore();
521 break; }
524 QRect r = opt->rect;
526 // QRect br = r.adjusted(fw, fw, -fw, -fw);
527 int x = r.x();
528 int y = r.y();
529 int w = r.width();
530 int h = r.height();
531 p->save();
532 const qreal devicePixelRatio = p->device()->devicePixelRatio();
533 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
534 const qreal inverseScale = qreal(1) / devicePixelRatio;
535 p->scale(inverseScale, inverseScale);
536 x = qRound(devicePixelRatio * x);
537 y = qRound(devicePixelRatio * y);
538 w = qRound(devicePixelRatio * w);
539 h = qRound(devicePixelRatio * h);
540 p->translate(0.5, 0.5);
541 }
542 int sw = w-4;
543 if (sw < 3)
544 break;
545 else if (!(sw & 1))
546 sw--;
547 sw -= (sw / 7) * 2; // Empty border
548 int sh = sw/2 + 2; // Must have empty row at foot of arrow
549
550 int sx = x + w / 2 - sw / 2;
551 int sy = y + h / 2 - sh / 2;
552
553 if (pe == PE_IndicatorSpinUp && fw)
554 --sy;
555
556 int bsx = 0;
557 int bsy = 0;
558 if (opt->state & State_Sunken) {
561 }
562 p->translate(sx + bsx, sy + bsy);
563 p->setPen(opt->palette.buttonText().color());
564 p->setBrush(opt->palette.buttonText());
565 if (pe == PE_IndicatorSpinDown) {
566 const QPoint points[] = { QPoint(0, 1), QPoint(sw-1, 1), QPoint(sh-2, sh-1) };
567 p->drawPolygon(points, sizeof points / sizeof *points);
568 } else {
569 const QPoint points[] = { QPoint(0, sh-1), QPoint(sw-1, sh-1), QPoint(sh-2, 1) };
570 p->drawPolygon(points, sizeof points / sizeof *points);
571 }
572 p->restore();
573 break; }
574#endif // QT_CONFIG(spinbox)
575 case PE_PanelTipLabel: {
578 break;
579 }
580#if QT_CONFIG(tabbar)
582 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
583 bool rtl = tab->direction == Qt::RightToLeft;
584 const bool horizontal = tab->rect.height() > tab->rect.width();
585 const int margin = 4;
587
588 if (horizontal) {
589 QRect rect = tab->rect.adjusted(rtl ? margin : 0, 0, rtl ? 1 : -margin, 0);
590 rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
591 rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
592
593 path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
594 int count = 4;
595 for (int jags = 1; jags <= count; ++jags, rtl = !rtl)
596 path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
597 } else {
598 QRect rect = tab->rect.adjusted(0, 0, 0, -margin);
599 rect.setLeft(rect.left() + ((tab->state & State_Selected) ? 1 : 3));
600 rect.setRight(rect.right() - ((tab->state & State_Selected) ? 0 : 2));
601
602 path.moveTo(QPoint(rect.left(), rect.top()));
603 int count = 4;
604 for (int jags = 1; jags <= count; ++jags, rtl = !rtl)
605 path.lineTo(QPoint(rect.left() + jags * rect.width()/count, rtl ? rect.top() : rect.bottom()));
606 }
607
608 p->setPen(QPen(tab->palette.dark(), qreal(.8)));
609 p->setBrush(tab->palette.window());
610 p->setRenderHint(QPainter::Antialiasing);
611 p->drawPath(path);
612 }
613 break;
614#endif // QT_CONFIG(tabbar)
615#if QT_CONFIG(lineedit)
616 case PE_PanelLineEdit:
617 if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
618 p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth),
620
621 if (panel->lineWidth > 0)
623 }
624 break;
625#endif // QT_CONFIG(lineedit)
626#if QT_CONFIG(columnview)
628 if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
629 bool reverse = (viewOpt->direction == Qt::RightToLeft);
630 p->save();
632 int x = viewOpt->rect.x() + 1;
633 int offset = (viewOpt->rect.height() / 3);
634 int height = (viewOpt->rect.height()) - offset * 2;
635 if (height % 2 == 1)
636 --height;
637 int x2 = x + height - 1;
638 if (reverse) {
639 x = viewOpt->rect.x() + viewOpt->rect.width() - 1;
640 x2 = x - height + 1;
641 }
642 path.moveTo(x, viewOpt->rect.y() + offset);
643 path.lineTo(x, viewOpt->rect.y() + offset + height);
644 path.lineTo(x2, viewOpt->rect.y() + offset+height/2);
645 path.closeSubpath();
646 if (viewOpt->state & QStyle::State_Selected ) {
647 if (viewOpt->showDecorationSelected) {
648 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::HighlightedText);
649 p->setPen(color);
650 p->setBrush(color);
651 } else {
652 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::WindowText);
653 p->setPen(color);
654 p->setBrush(color);
655 }
656
657 } else {
658 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Mid);
659 p->setPen(color);
660 p->setBrush(color);
661 }
662 p->drawPath(path);
663
664 // draw the vertical and top triangle line
665 if (!(viewOpt->state & QStyle::State_Selected)) {
666 QPainterPath lines;
667 lines.moveTo(x, viewOpt->rect.y() + offset);
668 lines.lineTo(x, viewOpt->rect.y() + offset + height);
669 lines.moveTo(x, viewOpt->rect.y() + offset);
670 lines.lineTo(x2, viewOpt->rect.y() + offset+height/2);
671 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Dark);
672 p->setPen(color);
673 p->drawPath(lines);
674 }
675 p->restore();
676 }
677 break; }
678#endif //QT_CONFIG(columnview)
680 QRect rect = opt->rect;
681 if (opt->rect.height() == 0)
682 p->drawLine(rect.topLeft(), rect.topRight());
683 else
684 p->drawRect(rect);
685 break; }
686#if QT_CONFIG(itemviews)
688 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
691 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
693
694 if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected)
695 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
696 else if (vopt->features & QStyleOptionViewItem::Alternate)
697 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
698 }
699 break;
701 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
704 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
706
707 if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) {
708 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
709 } else {
710 if (vopt->backgroundBrush.style() != Qt::NoBrush) {
711 QPointF oldBO = p->brushOrigin();
712 p->setBrushOrigin(vopt->rect.topLeft());
713 p->fillRect(vopt->rect, vopt->backgroundBrush);
714 p->setBrushOrigin(oldBO);
715 }
716
717 if (vopt->state & QStyle::State_Selected) {
719 p->fillRect(textRect, vopt->palette.brush(cg, QPalette::Highlight));
720 }
721 }
722 }
723 break;
724#endif // QT_CONFIG(itemviews)
727 p->fillRect(opt->rect, brush);
728 } break;
733 {
734 if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
735 break;
736 QRect r = opt->rect;
737 int size = qMin(r.height(), r.width());
739 QString pixmapName =
740 QStyleHelper::uniqueName("$qt_ia-"_L1
742 opt, QSize(size, size))
743 % HexString<uint>(pe);
744 if (!QPixmapCache::find(pixmapName, &pixmap)) {
745 qreal pixelRatio = p->device()->devicePixelRatio();
746 int border = qRound(pixelRatio*(size/5));
747 int sqsize = qRound(pixelRatio*(2*(size/2)));
749 image.fill(0);
750 QPainter imagePainter(&image);
751
752 QPolygon a;
753 switch (pe) {
755 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
756 break;
758 a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
759 break;
761 a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
762 break;
764 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
765 break;
766 default:
767 break;
768 }
769
770 int bsx = 0;
771 int bsy = 0;
772
773 if (opt->state & State_Sunken) {
776 }
777
778 QRect bounds = a.boundingRect();
779 int sx = sqsize / 2 - bounds.center().x() - 1;
780 int sy = sqsize / 2 - bounds.center().y() - 1;
781 imagePainter.translate(sx + bsx, sy + bsy);
782 imagePainter.setPen(opt->palette.buttonText().color());
783 imagePainter.setBrush(opt->palette.buttonText());
784
785 if (!(opt->state & State_Enabled)) {
786 imagePainter.translate(1, 1);
787 imagePainter.setBrush(opt->palette.light().color());
788 imagePainter.setPen(opt->palette.light().color());
789 imagePainter.drawPolygon(a);
790 imagePainter.translate(-1, -1);
791 imagePainter.setBrush(opt->palette.mid().color());
792 imagePainter.setPen(opt->palette.mid().color());
793 }
794
795 imagePainter.drawPolygon(a);
796 imagePainter.end();
798 pixmap.setDevicePixelRatio(pixelRatio);
799 QPixmapCache::insert(pixmapName, pixmap);
800 }
801 int xOffset = r.x() + (r.width() - size)/2;
802 int yOffset = r.y() + (r.height() - size)/2;
803 p->drawPixmap(xOffset, yOffset, pixmap);
804 }
805 break;
806 default:
807 break;
808 }
809}
810
811#if QT_CONFIG(toolbutton)
812static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton,
813 const QRect &rect, QPainter *painter, const QWidget *widget = nullptr)
814{
816 switch (toolbutton->arrowType) {
817 case Qt::LeftArrow:
819 break;
820 case Qt::RightArrow:
822 break;
823 case Qt::UpArrow:
825 break;
826 case Qt::DownArrow:
828 break;
829 default:
830 return;
831 }
832 QStyleOption arrowOpt = *toolbutton;
833 arrowOpt.rect = rect;
834 style->drawPrimitive(pe, &arrowOpt, painter, widget);
835}
836#endif // QT_CONFIG(toolbutton)
837
838static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr)
839{
840 if (lastVisibleLine)
841 *lastVisibleLine = -1;
842 qreal height = 0;
843 qreal widthUsed = 0;
844 textLayout.beginLayout();
845 int i = 0;
846 while (true) {
847 QTextLine line = textLayout.createLine();
848 if (!line.isValid())
849 break;
850 line.setLineWidth(lineWidth);
851 line.setPosition(QPointF(0, height));
852 height += line.height();
853 widthUsed = qMax(widthUsed, line.naturalTextWidth());
854 // we assume that the height of the next line is the same as the current one
855 if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) {
856 const QTextLine nextLine = textLayout.createLine();
857 *lastVisibleLine = nextLine.isValid() ? i : -1;
858 break;
859 }
860 ++i;
861 }
862 textLayout.endLayout();
863 return QSizeF(widthUsed, height);
864}
865
867 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
868 Qt::TextElideMode textElideMode, int flags,
869 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const
870{
871 QTextLayout textLayout(text, font);
872 textLayout.setTextOption(textOption);
873
874 // In AlignVCenter mode when more than one line is displayed and the height only allows
875 // some of the lines it makes no sense to display those. From a users perspective it makes
876 // more sense to see the start of the text instead something inbetween.
877 const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter);
878
879 int lastVisibleLine = -1;
880 viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine);
881
882 const QRectF boundingRect = textLayout.boundingRect();
883 // don't care about LTR/RTL here, only need the height
884 const QRect layoutRect = QStyle::alignedRect(Qt::LayoutDirectionAuto, valign,
886
887 if (paintStartPosition)
888 *paintStartPosition = QPointF(textRect.x(), layoutRect.top());
889
890 QString ret;
891 qreal height = 0;
892 const int lineCount = textLayout.lineCount();
893 for (int i = 0; i < lineCount; ++i) {
894 const QTextLine line = textLayout.lineAt(i);
895 height += line.height();
896
897 // above visible rect
898 if (height + layoutRect.top() <= textRect.top()) {
899 if (paintStartPosition)
900 paintStartPosition->ry() += line.height();
901 continue;
902 }
903
904 const int start = line.textStart();
905 const int length = line.textLength();
906 const bool drawElided = line.naturalTextWidth() > textRect.width();
907 bool elideLastVisibleLine = lastVisibleLine == i;
908 if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) {
909 const QTextLine nextLine = textLayout.lineAt(i + 1);
910 const int nextHeight = height + nextLine.height() / 2;
911 // elide when less than the next half line is visible
912 if (nextHeight + layoutRect.top() > textRect.height() + textRect.top())
913 elideLastVisibleLine = true;
914 }
915
916 QString text = textLayout.text().mid(start, length);
917 if (drawElided || elideLastVisibleLine) {
918 if (elideLastVisibleLine) {
920 text.chop(1);
921 text += QChar(0x2026);
922 }
924 ret += engine.elidedText(textElideMode, textRect.width(), flags);
925
926 // no newline for the last line (last visible or real)
927 // sometimes drawElided is true but no eliding is done so the text ends
928 // with QChar::LineSeparator - don't add another one. This happened with
929 // arabic text in the testcase for QTBUG-72805
930 if (i < lineCount - 1 &&
931 !ret.endsWith(QChar::LineSeparator))
933 } else {
934 ret += text;
935 }
936
937 // below visible text, can stop
938 if ((height + layoutRect.top() >= textRect.bottom()) ||
939 (lastVisibleLine >= 0 && lastVisibleLine == i))
940 break;
941 }
942 return ret;
943}
944
945#if QT_CONFIG(itemviews)
946
947QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int role) const
948{
949 const QWidget *widget = option->widget;
950 switch (role) {
952 if (option->features & QStyleOptionViewItem::HasCheckIndicator)
955 break;
956 case Qt::DisplayRole:
957 if (option->features & QStyleOptionViewItem::HasDisplay) {
958 QTextOption textOption;
960 QTextLayout textLayout(option->text, option->font);
961 textLayout.setTextOption(textOption);
962 const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
963 const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, option, widget) + 1;
964 QRect bounds = option->rect;
965 switch (option->decorationPosition) {
966 case QStyleOptionViewItem::Left:
967 case QStyleOptionViewItem::Right: {
968 if (wrapText && bounds.isValid()) {
969 int width = bounds.width() - 2 * textMargin;
970 if (option->features & QStyleOptionViewItem::HasDecoration)
971 width -= option->decorationSize.width() + 2 * textMargin;
972 bounds.setWidth(width);
973 } else
974 bounds.setWidth(QFIXED_MAX);
975 break;
976 }
977 case QStyleOptionViewItem::Top:
978 case QStyleOptionViewItem::Bottom: {
979 int width;
980 if (wrapText) {
981 if (bounds.isValid())
982 width = bounds.width() - 2 * textMargin;
983 else if (option->features & QStyleOptionViewItem::HasDecoration)
984 width = option->decorationSize.width();
985 else
986 width = 0;
987 } else {
989 }
990 bounds.setWidth(width);
991 break;
992 }
993 default:
994 break;
995 }
996
997 if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
998 bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option) - 2 * textMargin);
999
1000 const int lineWidth = bounds.width();
1001 const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
1002 return QSize(qCeil(size.width()) + 2 * textMargin, qCeil(size.height()));
1003 }
1004 break;
1005 case Qt::DecorationRole:
1006 if (option->features & QStyleOptionViewItem::HasDecoration) {
1007 return option->decorationSize;
1008 }
1009 break;
1010 default:
1011 break;
1012 }
1013
1014 return QSize(0, 0);
1015}
1016
1017void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const
1018{
1019 const QWidget *widget = option->widget;
1020 const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
1021
1022 QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
1023 const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
1024 QTextOption textOption;
1025 textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
1026 textOption.setTextDirection(option->direction);
1027 textOption.setAlignment(QStyle::visualAlignment(option->direction, option->displayAlignment));
1028
1029 QPointF paintPosition;
1030 const QString newText = calculateElidedText(option->text, textOption,
1031 option->font, textRect, option->displayAlignment,
1032 option->textElideMode, 0,
1033 true, &paintPosition);
1034
1035 QTextLayout textLayout(newText, option->font);
1036 textLayout.setTextOption(textOption);
1037 viewItemTextLayout(textLayout, textRect.width());
1038 textLayout.draw(p, paintPosition);
1039}
1040
1049void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
1050 QRect *pixmapRect, QRect *textRect, bool sizehint) const
1051{
1052 Q_ASSERT(checkRect && pixmapRect && textRect);
1053 *pixmapRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DecorationRole));
1054 *textRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DisplayRole));
1055 *checkRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::CheckStateRole));
1056
1057 const QWidget *widget = opt->widget;
1058 const bool hasCheck = checkRect->isValid();
1059 const bool hasPixmap = pixmapRect->isValid();
1060 const bool hasText = textRect->isValid();
1061 const bool hasMargin = (hasText | hasPixmap | hasCheck);
1062 const int frameHMargin = hasMargin ?
1064 const int textMargin = hasText ? frameHMargin : 0;
1065 const int pixmapMargin = hasPixmap ? frameHMargin : 0;
1066 const int checkMargin = hasCheck ? frameHMargin : 0;
1067 const int x = opt->rect.left();
1068 const int y = opt->rect.top();
1069 int w, h;
1070
1071 if (textRect->height() == 0 && (!hasPixmap || !sizehint)) {
1072 //if there is no text, we still want to have a decent height for the item sizeHint and the editor size
1074 }
1075
1076 QSize pm(0, 0);
1077 if (hasPixmap) {
1078 pm = pixmapRect->size();
1079 pm.rwidth() += 2 * pixmapMargin;
1080 }
1081 if (sizehint) {
1082 h = qMax(checkRect->height(), qMax(textRect->height(), pm.height()));
1083 if (opt->decorationPosition == QStyleOptionViewItem::Left
1084 || opt->decorationPosition == QStyleOptionViewItem::Right) {
1085 w = textRect->width() + pm.width();
1086 } else {
1087 w = qMax(textRect->width(), pm.width());
1088 }
1089 } else {
1090 w = opt->rect.width();
1091 h = opt->rect.height();
1092 }
1093
1094 int cw = 0;
1095 QRect check;
1096 if (hasCheck) {
1097 cw = checkRect->width() + 2 * checkMargin;
1098 if (sizehint) w += cw;
1099 if (opt->direction == Qt::RightToLeft) {
1100 check.setRect(x + w - cw, y, cw, h);
1101 } else {
1102 check.setRect(x, y, cw, h);
1103 }
1104 }
1105
1106 QRect display;
1108 switch (opt->decorationPosition) {
1109 case QStyleOptionViewItem::Top: {
1110 if (hasPixmap)
1111 pm.setHeight(pm.height() + pixmapMargin); // add space
1112 h = sizehint ? textRect->height() : h - pm.height();
1113
1114 if (opt->direction == Qt::RightToLeft) {
1115 decoration.setRect(x, y, w - cw, pm.height());
1116 display.setRect(x, y + pm.height(), w - cw, h);
1117 } else {
1118 decoration.setRect(x + cw, y, w - cw, pm.height());
1119 display.setRect(x + cw, y + pm.height(), w - cw, h);
1120 }
1121 break; }
1122 case QStyleOptionViewItem::Bottom: {
1123 if (hasText)
1124 textRect->setHeight(textRect->height() + textMargin); // add space
1125 h = sizehint ? textRect->height() + pm.height() : h;
1126
1127 if (opt->direction == Qt::RightToLeft) {
1128 display.setRect(x, y, w - cw, textRect->height());
1129 decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height());
1130 } else {
1131 display.setRect(x + cw, y, w - cw, textRect->height());
1132 decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height());
1133 }
1134 break; }
1135 case QStyleOptionViewItem::Left: {
1136 if (opt->direction == Qt::LeftToRight) {
1137 decoration.setRect(x + cw, y, pm.width(), h);
1138 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
1139 } else {
1140 display.setRect(x, y, w - pm.width() - cw, h);
1141 decoration.setRect(display.right() + 1, y, pm.width(), h);
1142 }
1143 break; }
1144 case QStyleOptionViewItem::Right: {
1145 if (opt->direction == Qt::LeftToRight) {
1146 display.setRect(x + cw, y, w - pm.width() - cw, h);
1147 decoration.setRect(display.right() + 1, y, pm.width(), h);
1148 } else {
1149 decoration.setRect(x, y, pm.width(), h);
1150 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
1151 }
1152 break; }
1153 default:
1154 qCWarning(lcCommonStyle, "doLayout: decoration position is invalid");
1155 decoration = *pixmapRect;
1156 break;
1157 }
1158
1159 if (!sizehint) { // we only need to do the internal layout if we are going to paint
1161 checkRect->size(), check);
1162 *pixmapRect = QStyle::alignedRect(opt->direction, opt->decorationAlignment,
1163 pixmapRect->size(), decoration);
1164 // the text takes up all available space, unless the decoration is not shown as selected
1165 if (opt->showDecorationSelected)
1166 *textRect = display;
1167 else
1168 *textRect = QStyle::alignedRect(opt->direction, opt->displayAlignment,
1169 textRect->size().boundedTo(display.size()), display);
1170 } else {
1171 *checkRect = check;
1172 *pixmapRect = decoration;
1173 *textRect = display;
1174 }
1175}
1176#endif // QT_CONFIG(itemviews)
1177
1178#if QT_CONFIG(toolbutton)
1179QString QCommonStylePrivate::toolButtonElideText(const QStyleOptionToolButton *option,
1180 const QRect &textRect, int flags) const
1181{
1182 if (option->fontMetrics.horizontalAdvance(option->text) <= textRect.width())
1183 return option->text;
1184
1185 QString text = option->text;
1187 QTextOption textOption;
1189 textOption.setTextDirection(option->direction);
1190
1191 return calculateElidedText(text, textOption,
1194 false, nullptr);
1195}
1196#endif // QT_CONFIG(toolbutton)
1197
1198#if QT_CONFIG(tabbar)
1204void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const
1205{
1207 Q_ASSERT(iconRect);
1208 QRect tr = opt->rect;
1209 bool verticalTabs = opt->shape == QTabBar::RoundedEast
1210 || opt->shape == QTabBar::RoundedWest
1211 || opt->shape == QTabBar::TriangularEast
1212 || opt->shape == QTabBar::TriangularWest;
1213 if (verticalTabs)
1214 tr.setRect(0, 0, tr.height(), tr.width()); // 0, 0 as we will have a translate transform
1215
1220 if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth)
1221 verticalShift = -verticalShift;
1222 tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding);
1223 bool selected = opt->state & QStyle::State_Selected;
1224 if (selected) {
1225 tr.setTop(tr.top() - verticalShift);
1226 tr.setRight(tr.right() - horizontalShift);
1227 }
1228
1229 // left widget
1230 if (!opt->leftButtonSize.isEmpty()) {
1231 tr.setLeft(tr.left() + 4 +
1232 (verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width()));
1233 }
1234 // right widget
1235 if (!opt->rightButtonSize.isEmpty()) {
1236 tr.setRight(tr.right() - 4 -
1237 (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width()));
1238 }
1239
1240 // icon
1241 if (!opt->icon.isNull()) {
1243 if (!iconSize.isValid()) {
1245 iconSize = QSize(iconExtent, iconExtent);
1246 }
1247 QSize tabIconSize = opt->icon.actualSize(iconSize,
1249 (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off);
1250 // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize
1251 tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height()));
1252
1253 const int offsetX = (iconSize.width() - tabIconSize.width()) / 2;
1254 *iconRect = QRect(tr.left() + offsetX, tr.center().y() - tabIconSize.height() / 2,
1255 tabIconSize.width(), tabIconSize.height());
1256 if (!verticalTabs)
1257 *iconRect = QStyle::visualRect(opt->direction, opt->rect, *iconRect);
1258 tr.setLeft(tr.left() + tabIconSize.width() + 4);
1259 }
1260
1261 if (!verticalTabs)
1263
1264 *textRect = tr;
1265}
1266#endif // QT_CONFIG(tabbar)
1267
1268#if QT_CONFIG(animation)
1270QList<const QObject*> QCommonStylePrivate::animationTargets() const
1271{
1272 return animations.keys();
1273}
1274
1276QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const
1277{
1278 return animations.value(target);
1279}
1280
1282void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const
1283{
1284 Q_Q(const QCommonStyle);
1285 stopAnimation(animation->target());
1286 q->connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection);
1287 animations.insert(animation->target(), animation);
1288 animation->start();
1289}
1290
1292void QCommonStylePrivate::stopAnimation(const QObject *target) const
1293{
1294 QStyleAnimation *animation = animations.take(target);
1295 if (animation) {
1296 animation->stop();
1297 delete animation;
1298 }
1299}
1300
1302void QCommonStylePrivate::_q_removeAnimation()
1303{
1304 Q_Q(QCommonStyle);
1305 QObject *animation = q->sender();
1306 if (animation)
1307 animations.remove(animation->parent());
1308}
1309#endif
1310
1315 QPainter *p, const QWidget *widget) const
1316{
1317 Q_D(const QCommonStyle);
1318 switch (element) {
1319
1320 case CE_PushButton:
1321 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1326 if (btn->state & State_HasFocus) {
1328 fropt.QStyleOption::operator=(*btn);
1331 }
1332 }
1333 break;
1334 case CE_PushButtonBevel:
1335 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1336 QRect br = btn->rect;
1341 br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
1343 || btn->state & (State_Sunken | State_On)
1345 QStyleOptionButton tmpBtn = *btn;
1346 tmpBtn.rect = br;
1348 }
1351 QRect ir = btn->rect;
1352 QStyleOptionButton newBtn = *btn;
1353 newBtn.rect = QRect(ir.right() - mbi - 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6);
1354 newBtn.rect = visualRect(btn->direction, br, newBtn.rect);
1356 }
1357 }
1358 break;
1359 case CE_PushButtonLabel:
1360 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1365
1366 if (button->features & QStyleOptionButton::HasMenu) {
1367 int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget);
1368 if (button->direction == Qt::LeftToRight)
1369 textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
1370 else
1371 textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
1372 }
1373
1374 if (!button->icon.isNull()) {
1375 //Center both icon and text
1377 if (mode == QIcon::Normal && button->state & State_HasFocus)
1380 if (button->state & State_On)
1381 state = QIcon::On;
1382
1383 QPixmap pixmap = button->icon.pixmap(button->iconSize, p->device()->devicePixelRatio(), mode, state);
1384 int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
1385 int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
1386 int labelWidth = pixmapWidth;
1387 int labelHeight = pixmapHeight;
1388 int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
1389 if (!button->text.isEmpty()) {
1390 int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
1391 labelWidth += (textWidth + iconSpacing);
1392 }
1393
1394 QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
1395 textRect.y() + (textRect.height() - labelHeight) / 2,
1396 pixmapWidth, pixmapHeight);
1397
1398 iconRect = visualRect(button->direction, textRect, iconRect);
1399
1400 if (button->direction == Qt::RightToLeft) {
1401 tf |= Qt::AlignRight;
1402 textRect.setRight(iconRect.left() - iconSpacing / 2);
1403 } else {
1404 tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
1405 textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing / 2);
1406 }
1407
1408 if (button->state & (State_On | State_Sunken))
1411 p->drawPixmap(iconRect, pixmap);
1412 } else {
1413 tf |= Qt::AlignHCenter;
1414 }
1415 if (button->state & (State_On | State_Sunken))
1418
1421 }
1422 break;
1423 case CE_RadioButton:
1424 case CE_CheckBox:
1425 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1426 bool isRadio = (element == CE_RadioButton);
1431 &subopt, p, widget);
1435 if (btn->state & State_HasFocus) {
1437 fropt.QStyleOption::operator=(*btn);
1441 }
1442 }
1443 break;
1445 case CE_CheckBoxLabel:
1446 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1448
1451 QPixmap pix;
1453 if (!btn->icon.isNull()) {
1454 pix = btn->icon.pixmap(btn->iconSize, p->device()->devicePixelRatio(), btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
1458 else
1460 }
1461 if (!btn->text.isEmpty()){
1464 }
1465 }
1466 break;
1467#if QT_CONFIG(menu)
1468 case CE_MenuScroller: {
1469 QStyleOption arrowOpt = *opt;
1470 arrowOpt.state |= State_Enabled;
1472 &arrowOpt, p, widget);
1473 break; }
1474 case CE_MenuTearoff:
1475 if (opt->state & State_Selected)
1476 p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight));
1477 else
1478 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1479 p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1480 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1,
1481 opt->rect.x() + opt->rect.width() - 4,
1482 opt->rect.y() + opt->rect.height() / 2 - 1);
1483 p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1484 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2,
1485 opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
1486 break;
1487#endif // QT_CONFIG(menu)
1488#if QT_CONFIG(menubar)
1489 case CE_MenuBarItem:
1490 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1495 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
1496 QPixmap pix = mbi->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1497 if (!pix.isNull())
1498 proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
1499 else
1500 proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
1501 mbi->text, QPalette::ButtonText);
1502 }
1503 break;
1506 p->eraseRect(opt->rect);
1507 break;
1508#endif // QT_CONFIG(menubar)
1509#if QT_CONFIG(progressbar)
1510 case CE_ProgressBar:
1511 if (const QStyleOptionProgressBar *pb
1512 = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1518 if (pb->textVisible) {
1521 }
1522 }
1523 break;
1525 if (opt->rect.isValid())
1526 qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
1528 break;
1530 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1531 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1532 if (!vertical) {
1534 if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
1535 && ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) {
1536 textRole = QPalette::HighlightedText;
1537 //Draw text shadow, This will increase readability when the background of same color
1538 QRect shadowRect(pb->rect);
1539 shadowRect.translate(1,1);
1540 QColor shadowColor = (pb->palette.color(textRole).value() <= 128)
1541 ? QColor(255,255,255,160) : QColor(0,0,0,160);
1542 QPalette shadowPalette = pb->palette;
1543 shadowPalette.setColor(textRole, shadowColor);
1544 proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette,
1545 pb->state & State_Enabled, pb->text, textRole);
1546 }
1547 proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette,
1548 pb->state & State_Enabled, pb->text, textRole);
1549 }
1550 }
1551 break;
1553 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1554
1555 QRect rect = pb->rect;
1556 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1557 const bool inverted = pb->invertedAppearance;
1558 qint64 minimum = qint64(pb->minimum);
1559 qint64 maximum = qint64(pb->maximum);
1560 qint64 progress = qint64(pb->progress);
1561
1562 QTransform m;
1563
1564 if (vertical) {
1565 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
1566 m.rotate(90);
1567 m.translate(0, -(rect.height() + rect.y()*2));
1568 }
1569
1570 QPalette pal2 = pb->palette;
1571 // Correct the highlight color if it is the same as the background
1572 if (pal2.highlight() == pal2.window())
1573 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1575 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1576 if (inverted)
1577 reverse = !reverse;
1578 int w = rect.width();
1579 if (pb->minimum == 0 && pb->maximum == 0) {
1580 // draw busy indicator
1581 int x = (progress - minimum) % (w * 2);
1582 if (x > w)
1583 x = 2 * w - x;
1584 x = reverse ? rect.right() - x : x + rect.x();
1585 p->setPen(QPen(pal2.highlight().color(), 4));
1586 p->drawLine(x, rect.y(), x, rect.height());
1587 } else {
1588 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
1589 if (!unit_width)
1590 return;
1591
1592 int u;
1593 if (unit_width > 1)
1594 u = ((rect.width() + unit_width) / unit_width);
1595 else
1596 u = w / unit_width;
1597 qint64 p_v = progress - minimum;
1598 qint64 t_s = (maximum - minimum) ? (maximum - minimum) : qint64(1);
1599
1600 if (u > 0 && p_v >= INT_MAX / u && t_s >= u) {
1601 // scale down to something usable.
1602 p_v /= u;
1603 t_s /= u;
1604 }
1605
1606 // nu < tnu, if last chunk is only a partial chunk
1607 int tnu, nu;
1608 tnu = nu = p_v * u / t_s;
1609
1610 if (nu * unit_width > w)
1611 --nu;
1612
1613 // Draw nu units out of a possible u of unit_width
1614 // width, each a rectangle bordered by background
1615 // color, all in a sunken panel with a percentage text
1616 // display at the end.
1617 int x = 0;
1618 int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0)
1619 : rect.x();
1620
1621 QStyleOptionProgressBar pbBits = *pb;
1622 pbBits.rect = rect;
1623 pbBits.palette = pal2;
1624 int myY = pbBits.rect.y();
1625 int myHeight = pbBits.rect.height();
1626 pbBits.state = State_None;
1627 for (int i = 0; i < nu; ++i) {
1628 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1629 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1631 x += reverse ? -unit_width : unit_width;
1632 }
1633
1634 // Draw the last partial chunk to fill up the
1635 // progress bar entirely
1636 if (nu < tnu) {
1637 int pixels_left = w - (nu * unit_width);
1638 int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x;
1639 pbBits.rect.setRect(offset, myY, pixels_left, myHeight);
1640 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1642 }
1643 }
1644 }
1645 break;
1646#endif // QT_CONFIG(progressbar)
1647 case CE_HeaderLabel:
1648 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
1649 QRect rect = header->rect;
1650 if (!header->icon.isNull()) {
1651 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
1653 = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1654 int pixw = pixmap.width() / pixmap.devicePixelRatio();
1655
1656 QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect);
1657 QRect inter = aligned.intersected(rect);
1658 p->drawPixmap(inter.x(), inter.y(), pixmap,
1659 inter.x() - aligned.x(), inter.y() - aligned.y(),
1660 aligned.width() * pixmap.devicePixelRatio(),
1661 pixmap.height() * pixmap.devicePixelRatio());
1662
1663 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
1664 if (header->direction == Qt::LeftToRight)
1665 rect.setLeft(rect.left() + pixw + margin);
1666 else
1667 rect.setRight(rect.right() - pixw - margin);
1668 }
1669 QFontMetrics fm(header->fontMetrics);
1670 if (header->state & QStyle::State_On) {
1671 QFont fnt = p->font();
1672 fnt.setBold(true);
1673 p->setFont(fnt);
1674 fm = QFontMetrics((p->font()));
1675 }
1676 QString text = header->text;
1677 if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
1678 if (headerV2->textElideMode != Qt::ElideNone)
1679 text = fm.elidedText(header->text, headerV2->textElideMode, rect.width());
1680 }
1681 proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
1682 header->state.testFlag(State_Enabled), text, QPalette::ButtonText);
1683 }
1684 break;
1685#if QT_CONFIG(toolbutton)
1686 case CE_ToolButtonLabel:
1687 if (const QStyleOptionToolButton *toolbutton
1688 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1689 QRect rect = toolbutton->rect;
1690 int shiftX = 0;
1691 int shiftY = 0;
1692 if (toolbutton->state & (State_Sunken | State_On)) {
1693 shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget);
1694 shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget);
1695 }
1696 // Arrow type always overrules and is always shown
1697 bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow;
1698 if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty())
1699 || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) {
1703 rect.translate(shiftX, shiftY);
1704 p->setFont(toolbutton->font);
1705 const QString text = d->toolButtonElideText(toolbutton, rect, alignment);
1706 proxy()->drawItemText(p, rect, alignment, toolbutton->palette,
1709 } else {
1710 QPixmap pm;
1711 QSize pmSize = toolbutton->iconSize;
1712 if (!toolbutton->icon.isNull()) {
1715 if (!(toolbutton->state & State_Enabled))
1717 else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise))
1719 else
1721 pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), p->device()->devicePixelRatio(),
1722 mode, state);
1723 pmSize = pm.size() / pm.devicePixelRatio();
1724 }
1725
1726 if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) {
1727 p->setFont(toolbutton->font);
1728 QRect pr = rect,
1729 tr = rect;
1733
1734 if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
1735 pr.setHeight(pmSize.height() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint()
1736 tr.adjust(0, pr.height() - 1, 0, -1);
1737 pr.translate(shiftX, shiftY);
1738 if (!hasArrow) {
1740 } else {
1741 drawArrow(proxy(), toolbutton, pr, p, widget);
1742 }
1744 } else {
1745 pr.setWidth(pmSize.width() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint()
1746 tr.adjust(pr.width(), 0, 0, 0);
1747 pr.translate(shiftX, shiftY);
1748 if (!hasArrow) {
1750 } else {
1751 drawArrow(proxy(), toolbutton, pr, p, widget);
1752 }
1754 }
1755 tr.translate(shiftX, shiftY);
1756 const QString text = d->toolButtonElideText(toolbutton, tr, alignment);
1758 toolbutton->state & State_Enabled, text,
1760 } else {
1761 rect.translate(shiftX, shiftY);
1762 if (hasArrow) {
1763 drawArrow(proxy(), toolbutton, rect, p, widget);
1764 } else {
1766 }
1767 }
1768 }
1769 }
1770 break;
1771#endif // QT_CONFIG(toolbutton)
1772#if QT_CONFIG(toolbox)
1773 case CE_ToolBoxTab:
1774 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1777 }
1778 break;
1779 case CE_ToolBoxTabShape:
1780 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1781 p->setPen(tb->palette.mid().color().darker(150));
1782 int d = 20 + tb->rect.height() - 3;
1783 if (tb->direction != Qt::RightToLeft) {
1784 const QPoint points[] = {
1785 QPoint(-1, tb->rect.height() + 1),
1786 QPoint(-1, 1),
1787 QPoint(tb->rect.width() - d, 1),
1788 QPoint(tb->rect.width() - 20, tb->rect.height() - 2),
1789 QPoint(tb->rect.width() - 1, tb->rect.height() - 2),
1790 QPoint(tb->rect.width() - 1, tb->rect.height() + 1),
1791 QPoint(-1, tb->rect.height() + 1),
1792 };
1793 p->drawPolygon(points, sizeof points / sizeof *points);
1794 } else {
1795 const QPoint points[] = {
1796 QPoint(tb->rect.width(), tb->rect.height() + 1),
1797 QPoint(tb->rect.width(), 1),
1798 QPoint(d - 1, 1),
1799 QPoint(20 - 1, tb->rect.height() - 2),
1800 QPoint(0, tb->rect.height() - 2),
1801 QPoint(0, tb->rect.height() + 1),
1802 QPoint(tb->rect.width(), tb->rect.height() + 1),
1803 };
1804 p->drawPolygon(points, sizeof points / sizeof *points);
1805 }
1806 p->setPen(tb->palette.light().color());
1807 if (tb->direction != Qt::RightToLeft) {
1808 p->drawLine(0, 2, tb->rect.width() - d, 2);
1809 p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1);
1810 p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1,
1811 tb->rect.width(), tb->rect.height() - 1);
1812 } else {
1813 p->drawLine(tb->rect.width() - 1, 2, d - 1, 2);
1814 p->drawLine(d, 2, 20, tb->rect.height() - 1);
1815 p->drawLine(19, tb->rect.height() - 1,
1816 -1, tb->rect.height() - 1);
1817 }
1818 p->setBrush(Qt::NoBrush);
1819 }
1820 break;
1821#endif // QT_CONFIG(toolbox)
1822#if QT_CONFIG(tabbar)
1823 case CE_TabBarTab:
1824 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1827 }
1828 break;
1829 case CE_TabBarTabShape:
1830 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1831 p->save();
1832
1833 QRect rect(tab->rect);
1834 bool selected = tab->state & State_Selected;
1835 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1836 int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget);
1837
1838 if (!selected) {
1839 switch (tab->shape) {
1841 rect.adjust(0, 0, 0, -tabOverlap);
1842 if (!selected)
1843 rect.adjust(1, 1, -1, 0);
1844 break;
1846 rect.adjust(0, tabOverlap, 0, 0);
1847 if (!selected)
1848 rect.adjust(1, 0, -1, -1);
1849 break;
1851 rect.adjust(tabOverlap, 0, 0, 0);
1852 if (!selected)
1853 rect.adjust(0, 1, -1, -1);
1854 break;
1856 rect.adjust(0, 0, -tabOverlap, 0);
1857 if (!selected)
1858 rect.adjust(1, 1, 0, -1);
1859 break;
1860 default:
1861 break;
1862 }
1863 }
1864
1865 p->setPen(QPen(tab->palette.windowText(), 0));
1866 if (selected) {
1867 p->setBrush(tab->palette.base());
1868 } else {
1869 if (widget && widget->parentWidget())
1870 p->setBrush(widget->parentWidget()->palette().window());
1871 else
1872 p->setBrush(tab->palette.window());
1873 }
1874
1875 int y;
1876 int x;
1877 QPolygon a(10);
1878 switch (tab->shape) {
1881 a.setPoint(0, 0, -1);
1882 a.setPoint(1, 0, 0);
1883 y = rect.height() - 2;
1884 x = y / 3;
1885 a.setPoint(2, x++, y - 1);
1886 ++x;
1887 a.setPoint(3, x++, y++);
1888 a.setPoint(4, x, y);
1889
1890 int i;
1891 int right = rect.width() - 1;
1892 for (i = 0; i < 5; ++i)
1893 a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y());
1894 if (tab->shape == QTabBar::TriangularNorth)
1895 for (i = 0; i < 10; ++i)
1896 a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y());
1897
1898 a.translate(rect.left(), rect.top());
1899 p->setRenderHint(QPainter::Antialiasing);
1900 p->translate(0, 0.5);
1901
1903 path.addPolygon(a);
1904 p->drawPath(path);
1905 break; }
1908 a.setPoint(0, -1, 0);
1909 a.setPoint(1, 0, 0);
1910 x = rect.width() - 2;
1911 y = x / 3;
1912 a.setPoint(2, x - 1, y++);
1913 ++y;
1914 a.setPoint(3, x++, y++);
1915 a.setPoint(4, x, y);
1916 int i;
1917 int bottom = rect.height() - 1;
1918 for (i = 0; i < 5; ++i)
1919 a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y());
1920 if (tab->shape == QTabBar::TriangularWest)
1921 for (i = 0; i < 10; ++i)
1922 a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y());
1923 a.translate(rect.left(), rect.top());
1924 p->setRenderHint(QPainter::Antialiasing);
1925 p->translate(0.5, 0);
1927 path.addPolygon(a);
1928 p->drawPath(path);
1929 break; }
1930 default:
1931 break;
1932 }
1933 p->restore();
1934 }
1935 break;
1936 case CE_ToolBoxTabLabel:
1937 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1938 bool enabled = tb->state & State_Enabled;
1939 bool selected = tb->state & State_Selected;
1940 int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget);
1941 QPixmap pm = tb->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(),
1943
1945 QRect tr, ir;
1946 int ih = 0;
1947 if (pm.isNull()) {
1948 tr = cr;
1949 tr.adjust(4, 0, -8, 0);
1950 } else {
1951 int iw = pm.width() / pm.devicePixelRatio() + 4;
1952 ih = pm.height()/ pm.devicePixelRatio();
1953 ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih);
1954 tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height());
1955 }
1956
1958 QFont f(p->font());
1959 f.setBold(true);
1960 p->setFont(f);
1961 }
1962
1963 QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width());
1964
1965 if (ih)
1966 p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm);
1967
1972
1973 if (!txt.isEmpty() && opt->state & State_HasFocus) {
1975 opt.rect = tr;
1976 opt.palette = tb->palette;
1979 }
1980 }
1981 break;
1982 case CE_TabBarTabLabel:
1983 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1984 QRect tr = tab->rect;
1985 bool verticalTabs = tab->shape == QTabBar::RoundedEast
1986 || tab->shape == QTabBar::RoundedWest
1987 || tab->shape == QTabBar::TriangularEast
1988 || tab->shape == QTabBar::TriangularWest;
1989
1993
1994 if (verticalTabs) {
1995 p->save();
1996 int newX, newY, newRot;
1997 if (tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) {
1998 newX = tr.width() + tr.x();
1999 newY = tr.y();
2000 newRot = 90;
2001 } else {
2002 newX = tr.x();
2003 newY = tr.y() + tr.height();
2004 newRot = -90;
2005 }
2007 m.rotate(newRot);
2008 p->setTransform(m, true);
2009 }
2010 QRect iconRect;
2011 d->tabLayout(tab, widget, &tr, &iconRect);
2012
2013 // compute tr again, unless tab is moving, because the style may override subElementRect
2014 if (tab->position != QStyleOptionTab::TabPosition::Moving)
2016
2017 if (!tab->icon.isNull()) {
2018 QPixmap tabIcon = tab->icon.pixmap(tab->iconSize, p->device()->devicePixelRatio(),
2019 (tab->state & State_Enabled) ? QIcon::Normal
2021 (tab->state & State_Selected) ? QIcon::On
2022 : QIcon::Off);
2023 p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
2024 }
2025
2026 proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text,
2028 if (verticalTabs)
2029 p->restore();
2030
2031 if (tab->state & State_HasFocus) {
2032 const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
2033
2034 int x1, x2;
2035 x1 = tab->rect.left();
2036 x2 = tab->rect.right() - 1;
2037
2039 fropt.QStyleOption::operator=(*tab);
2040 fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET,
2041 x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET);
2043 }
2044 }
2045 break;
2046#endif // QT_CONFIG(tabbar)
2047#if QT_CONFIG(sizegrip)
2048 case CE_SizeGrip: {
2049 p->save();
2050 int x, y, w, h;
2051 opt->rect.getRect(&x, &y, &w, &h);
2052
2053 int sw = qMin(h, w);
2054 if (h > w)
2055 p->translate(0, h - w);
2056 else
2057 p->translate(w - h, 0);
2058
2059 int sx = x;
2060 int sy = y;
2061 int s = sw / 3;
2062
2063 Qt::Corner corner;
2064 if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt))
2065 corner = sgOpt->corner;
2066 else if (opt->direction == Qt::RightToLeft)
2067 corner = Qt::BottomLeftCorner;
2068 else
2069 corner = Qt::BottomRightCorner;
2070
2071 if (corner == Qt::BottomLeftCorner) {
2072 sx = x + sw;
2073 for (int i = 0; i < 4; ++i) {
2074 p->setPen(QPen(opt->palette.light().color(), 1));
2075 p->drawLine(x, sy - 1 , sx + 1, sw);
2076 p->setPen(QPen(opt->palette.dark().color(), 1));
2077 p->drawLine(x, sy, sx, sw);
2078 p->setPen(QPen(opt->palette.dark().color(), 1));
2079 p->drawLine(x, sy + 1, sx - 1, sw);
2080 sx -= s;
2081 sy += s;
2082 }
2083 } else if (corner == Qt::BottomRightCorner) {
2084 for (int i = 0; i < 4; ++i) {
2085 p->setPen(QPen(opt->palette.light().color(), 1));
2086 p->drawLine(sx - 1, sw, sw, sy - 1);
2087 p->setPen(QPen(opt->palette.dark().color(), 1));
2088 p->drawLine(sx, sw, sw, sy);
2089 p->setPen(QPen(opt->palette.dark().color(), 1));
2090 p->drawLine(sx + 1, sw, sw, sy + 1);
2091 sx += s;
2092 sy += s;
2093 }
2094 } else if (corner == Qt::TopRightCorner) {
2095 sy = y + sw;
2096 for (int i = 0; i < 4; ++i) {
2097 p->setPen(QPen(opt->palette.light().color(), 1));
2098 p->drawLine(sx - 1, y, sw, sy + 1);
2099 p->setPen(QPen(opt->palette.dark().color(), 1));
2100 p->drawLine(sx, y, sw, sy);
2101 p->setPen(QPen(opt->palette.dark().color(), 1));
2102 p->drawLine(sx + 1, y, sw, sy - 1);
2103 sx += s;
2104 sy -= s;
2105 }
2106 } else if (corner == Qt::TopLeftCorner) {
2107 for (int i = 0; i < 4; ++i) {
2108 p->setPen(QPen(opt->palette.light().color(), 1));
2109 p->drawLine(x, sy - 1, sx - 1, y);
2110 p->setPen(QPen(opt->palette.dark().color(), 1));
2111 p->drawLine(x, sy, sx, y);
2112 p->setPen(QPen(opt->palette.dark().color(), 1));
2113 p->drawLine(x, sy + 1, sx + 1, y);
2114 sx += s;
2115 sy += s;
2116 }
2117 }
2118 p->restore();
2119 break; }
2120#endif // QT_CONFIG(sizegrip)
2121#if QT_CONFIG(rubberband)
2122 case CE_RubberBand: {
2123 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
2124 QPixmap tiledPixmap(16, 16);
2125 QPainter pixmapPainter(&tiledPixmap);
2126 pixmapPainter.setPen(Qt::NoPen);
2127 pixmapPainter.setBrush(Qt::Dense4Pattern);
2128 pixmapPainter.setBackground(QBrush(opt->palette.base()));
2129 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
2130 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
2131 pixmapPainter.end();
2132 // ### workaround for borked XRENDER
2133 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
2134
2135 p->save();
2136 QRect r = opt->rect;
2139 p->setClipRegion(mask.region);
2140 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
2142 p->setBrush(Qt::NoBrush);
2143 p->drawRect(r.adjusted(0, 0, -1, -1));
2144 if (rbOpt->shape == QRubberBand::Rectangle)
2145 p->drawRect(r.adjusted(3, 3, -4, -4));
2146 p->restore();
2147 }
2148 break; }
2149#endif // QT_CONFIG(rubberband)
2150#if QT_CONFIG(dockwidget)
2151 case CE_DockWidgetTitle:
2152 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2153 QRect r = dwOpt->rect.adjusted(0, 0, -1, -1);
2154 if (dwOpt->movable) {
2155 p->setPen(dwOpt->palette.color(QPalette::Dark));
2156 p->drawRect(r);
2157 }
2158
2159 if (!dwOpt->title.isEmpty()) {
2160 const bool verticalTitleBar = dwOpt->verticalTitleBar;
2161
2162 if (verticalTitleBar) {
2163 r = r.transposed();
2164
2165 p->save();
2166 p->translate(r.left(), r.top() + r.width());
2167 p->rotate(-90);
2168 p->translate(-r.left(), -r.top());
2169 }
2170
2171 const int indent = p->fontMetrics().descent();
2172 proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),
2173 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
2174 dwOpt->state & State_Enabled, dwOpt->title,
2176
2177 if (verticalTitleBar)
2178 p->restore();
2179 }
2180 }
2181 break;
2182#endif // QT_CONFIG(dockwidget)
2183 case CE_Header:
2184 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2185 QRegion clipRegion = p->clipRegion();
2186 p->setClipRect(opt->rect);
2188 // opt can be a QStyleOptionHeaderV2 and we must pass it to the subcontrol drawings
2190 QStyleOptionHeader &v1Copy = subopt;
2191 if (auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(opt))
2192 subopt = *v2;
2193 else
2194 v1Copy = *header;
2196 if (subopt.rect.isValid())
2198 if (header->sortIndicator != QStyleOptionHeader::None) {
2201 }
2202 p->setClipRegion(clipRegion);
2203 }
2204 break;
2205 case CE_FocusFrame:
2206 p->fillRect(opt->rect, opt->palette.windowText());
2207 break;
2208 case CE_HeaderSection:
2210 opt->state & State_Sunken, 1,
2212 break;
2213 case CE_HeaderEmptyArea:
2214 p->fillRect(opt->rect, opt->palette.window());
2215 break;
2216#if QT_CONFIG(combobox)
2217 case CE_ComboBoxLabel:
2218 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2220 p->save();
2221 p->setClipRect(editRect);
2222 if (!cb->currentIcon.isNull()) {
2225 QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, p->device()->devicePixelRatio(), mode);
2226 QRect iconRect(editRect);
2227 iconRect.setWidth(cb->iconSize.width() + 4);
2228 iconRect = alignedRect(cb->direction,
2230 iconRect.size(), editRect);
2231 if (cb->editable)
2232 p->fillRect(iconRect, opt->palette.brush(QPalette::Base));
2234
2235 if (cb->direction == Qt::RightToLeft)
2236 editRect.translate(-4 - cb->iconSize.width(), 0);
2237 else
2238 editRect.translate(cb->iconSize.width() + 4, 0);
2239 }
2240 if (!cb->currentText.isEmpty() && !cb->editable) {
2241 proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0),
2242 visualAlignment(cb->direction, cb->textAlignment),
2243 cb->palette, cb->state & State_Enabled, cb->currentText);
2244 }
2245 p->restore();
2246 }
2247 break;
2248#endif // QT_CONFIG(combobox)
2249#if QT_CONFIG(toolbar)
2250 case CE_ToolBar:
2251 if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2252 // Compatibility with styles that use PE_PanelToolBar
2254 frame.QStyleOption::operator=(*toolBar);
2255 frame.lineWidth = toolBar->lineWidth;
2256 frame.midLineWidth = toolBar->midLineWidth;
2258
2259 if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
2260 break;
2261 qDrawShadePanel(p, toolBar->rect, toolBar->palette, false, toolBar->lineWidth,
2262 &toolBar->palette.brush(QPalette::Button));
2263 }
2264 break;
2265#endif // QT_CONFIG(toolbar)
2266 case CE_ColumnViewGrip: {
2267 // draw background gradients
2268 QLinearGradient g(0, 0, opt->rect.width(), 0);
2269 g.setColorAt(0, opt->palette.color(QPalette::Active, QPalette::Mid));
2270 g.setColorAt(0.5, Qt::white);
2271 p->fillRect(QRect(0, 0, opt->rect.width(), opt->rect.height()), g);
2272
2273 // draw the two lines
2274 QPen pen(p->pen());
2275 pen.setWidth(opt->rect.width()/20);
2277 p->setPen(pen);
2278
2279 int line1starting = opt->rect.width()*8 / 20;
2280 int line2starting = opt->rect.width()*13 / 20;
2281 int top = opt->rect.height()*20/75;
2282 int bottom = opt->rect.height() - 1 - top;
2283 p->drawLine(line1starting, top, line1starting, bottom);
2284 p->drawLine(line2starting, top, line2starting, bottom);
2285 }
2286 break;
2287
2288#if QT_CONFIG(itemviews)
2289 case CE_ItemViewItem:
2290 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
2291 p->save();
2292 // the style calling this might want to clip, so respect any region already set
2293 const QRegion clipRegion = p->hasClipping() ? (p->clipRegion() & opt->rect) : opt->rect;
2294 p->setClipRegion(clipRegion);
2295
2299
2300 // draw the background
2302
2303 // draw the check mark
2304 if (vopt->features & QStyleOptionViewItem::HasCheckIndicator) {
2305 QStyleOptionViewItem option(*vopt);
2306 option.rect = checkRect;
2307 option.state = option.state & ~QStyle::State_HasFocus;
2308
2309 switch (vopt->checkState) {
2310 case Qt::Unchecked:
2311 option.state |= QStyle::State_Off;
2312 break;
2315 break;
2316 case Qt::Checked:
2317 option.state |= QStyle::State_On;
2318 break;
2319 }
2321 }
2322
2323 // draw the icon
2325 if (!(vopt->state & QStyle::State_Enabled))
2327 else if (vopt->state & QStyle::State_Selected)
2330 vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state);
2331
2332 // draw the text
2333 if (!vopt->text.isEmpty()) {
2336 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
2337 cg = QPalette::Inactive;
2338
2339 if (vopt->state & QStyle::State_Selected) {
2340 p->setPen(vopt->palette.color(cg, QPalette::HighlightedText));
2341 } else {
2342 p->setPen(vopt->palette.color(cg, QPalette::Text));
2343 }
2344 if (vopt->state & QStyle::State_Editing) {
2345 p->setPen(vopt->palette.color(cg, QPalette::Text));
2346 p->drawRect(textRect.adjusted(0, 0, -1, -1));
2347 }
2348
2349 d->viewItemDrawText(p, vopt, textRect);
2350 }
2351
2352 // draw the focus rect
2353 if (vopt->state & QStyle::State_HasFocus) {
2355 o.QStyleOption::operator=(*vopt);
2358 o.state |= QStyle::State_Item;
2359 QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled)
2361 o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected)
2364 }
2365
2366 p->restore();
2367 }
2368 break;
2369
2370#endif // QT_CONFIG(itemviews)
2371#ifndef QT_NO_FRAME
2372 case CE_ShapedFrame:
2373 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2374 int frameShape = f->frameShape;
2375 int frameShadow = QFrame::Plain;
2376 if (f->state & QStyle::State_Sunken) {
2377 frameShadow = QFrame::Sunken;
2378 } else if (f->state & QStyle::State_Raised) {
2379 frameShadow = QFrame::Raised;
2380 }
2381
2382 int lw = f->lineWidth;
2383 int mlw = f->midLineWidth;
2385 if (widget)
2386 foregroundRole = widget->foregroundRole();
2387
2388 switch (frameShape) {
2389 case QFrame::Box:
2390 if (frameShadow == QFrame::Plain) {
2391 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2392 } else {
2393 qDrawShadeRect(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2394 }
2395 break;
2397 //keep the compatibility with Qt 4.4 if there is a proxy style.
2398 //be sure to call drawPrimitive(QStyle::PE_Frame) on the proxy style
2399 if (widget) {
2401 } else {
2403 }
2404 break;
2405 case QFrame::Panel:
2406 if (frameShadow == QFrame::Plain) {
2407 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2408 } else {
2409 qDrawShadePanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw);
2410 }
2411 break;
2412 case QFrame::WinPanel:
2413 if (frameShadow == QFrame::Plain) {
2414 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2415 } else {
2416 qDrawWinPanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken);
2417 }
2418 break;
2419 case QFrame::HLine:
2420 case QFrame::VLine: {
2421 QPoint p1, p2;
2422 if (frameShape == QFrame::HLine) {
2423 p1 = QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height() / 2);
2424 p2 = QPoint(opt->rect.x() + opt->rect.width(), p1.y());
2425 } else {
2426 p1 = QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
2427 p2 = QPoint(p1.x(), p1.y() + opt->rect.height());
2428 }
2429 if (frameShadow == QFrame::Plain) {
2430 QPen oldPen = p->pen();
2431 p->setPen(QPen(opt->palette.brush(foregroundRole), lw));
2432 p->drawLine(p1, p2);
2433 p->setPen(oldPen);
2434 } else {
2435 qDrawShadeLine(p, p1, p2, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2436 }
2437 break;
2438 }
2439 }
2440 }
2441 break;
2442#endif
2443 default:
2444 break;
2445 }
2446#if !QT_CONFIG(tabbar) && !QT_CONFIG(itemviews)
2447 Q_UNUSED(d);
2448#endif
2449}
2450
2455 const QWidget *widget) const
2456{
2457 Q_D(const QCommonStyle);
2458 QRect r;
2459 switch (sr) {
2461 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2462 int dx1, dx2;
2466 dx2 = dx1 * 2;
2467 r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2,
2468 opt->rect.height() - dx2);
2470 }
2471 break;
2473 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2474 int dbw1 = 0, dbw2 = 0;
2477 dbw2 = dbw1 * 2;
2478 }
2479
2480 int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1,
2481 dfw2 = dfw1 * 2;
2482
2483 r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1,
2484 btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2);
2486 }
2487 break;
2488 case SE_PushButtonBevel:
2489 {
2490 r = opt->rect;
2492 }
2493 break;
2495 {
2497 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2500 }
2501 break;
2502
2504 {
2505 // Deal with the logical first, then convert it back to screen coords.
2509 r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2510 opt->rect.height());
2512 }
2513 break;
2514
2516 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2517 if (btn->icon.isNull() && btn->text.isEmpty()) {
2519 r.adjust(1, 1, -1, -1);
2520 break;
2521 }
2522 // As above, deal with the logical first, then convert it back to screen coords.
2525
2526 QRect iconRect, textRect;
2527 if (!btn->text.isEmpty()) {
2531 }
2532 if (!btn->icon.isNull()) {
2536 if (!textRect.isEmpty())
2537 textRect.translate(iconRect.right() + 4, 0);
2538 }
2539 r = iconRect | textRect;
2540 r.adjust(-3, -2, 3, 2);
2541 r = r.intersected(btn->rect);
2543 }
2544 break;
2545
2547 {
2549 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2552 }
2553 break;
2554
2556 {
2560 r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2561 opt->rect.height());
2563 break;
2564 }
2565
2567 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2568 if (btn->icon.isNull() && btn->text.isEmpty()) {
2570 r.adjust(1, 1, -1, -1);
2571 break;
2572 }
2575
2576 QRect iconRect, textRect;
2577 if (!btn->text.isEmpty()){
2580 }
2581 if (!btn->icon.isNull()) {
2584 if (!textRect.isEmpty())
2585 textRect.translate(iconRect.right() + 4, 0);
2586 }
2587 r = iconRect | textRect;
2588 r.adjust(-3, -2, 3, 2);
2589 r = r.intersected(btn->rect);
2591 }
2592 break;
2593#if QT_CONFIG(slider)
2594 case SE_SliderFocusRect:
2595 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2596 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
2597 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2598 if (slider->orientation == Qt::Horizontal)
2599 r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2);
2600 else
2601 r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height());
2602 r = r.intersected(slider->rect);
2604 }
2605 break;
2606#endif // QT_CONFIG(slider)
2607#if QT_CONFIG(progressbar)
2611 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2612 int textw = 0;
2613 const bool vertical = !(pb->state & QStyle::State_Horizontal);
2614 if (!vertical) {
2615 if (pb->textVisible)
2616 textw = qMax(pb->fontMetrics.horizontalAdvance(pb->text), pb->fontMetrics.horizontalAdvance("100%"_L1)) + 6;
2617 }
2618
2619 if ((pb->textAlignment & Qt::AlignCenter) == 0) {
2620 if (sr != SE_ProgressBarLabel)
2621 r.setCoords(pb->rect.left(), pb->rect.top(),
2622 pb->rect.right() - textw, pb->rect.bottom());
2623 else
2624 r.setCoords(pb->rect.right() - textw, pb->rect.top(),
2625 pb->rect.right(), pb->rect.bottom());
2626 } else {
2627 r = pb->rect;
2628 }
2629 r = visualRect(pb->direction, pb->rect, r);
2630 }
2631 break;
2632#endif // QT_CONFIG(progressbar)
2633#if QT_CONFIG(combobox)
2635 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2636 int margin = cb->frame ? 3 : 0;
2637 r.setRect(opt->rect.left() + margin, opt->rect.top() + margin,
2638 opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin);
2640 }
2641 break;
2642#endif // QT_CONFIG(combobox)
2643#if QT_CONFIG(toolbox)
2645 r = opt->rect;
2646 r.adjust(0, 0, -30, 0);
2647 break;
2648#endif // QT_CONFIG(toolbox)
2649 case SE_HeaderLabel: {
2651 r.setRect(opt->rect.x() + margin, opt->rect.y() + margin,
2652 opt->rect.width() - margin * 2, opt->rect.height() - margin * 2);
2653
2654 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2655 // Subtract width needed for arrow, if there is one
2656 if (header->sortIndicator != QStyleOptionHeader::None) {
2657 if (opt->state & State_Horizontal)
2658 r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
2659 else
2660 r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2));
2661 }
2662 }
2664 break; }
2665 case SE_HeaderArrow: {
2666 int h = opt->rect.height();
2667 int w = opt->rect.width();
2668 int x = opt->rect.x();
2669 int y = opt->rect.y();
2671
2672 if (opt->state & State_Horizontal) {
2673 int horiz_size = h / 2;
2674 r.setRect(x + w - margin * 2 - horiz_size, y + 5,
2675 horiz_size, h - margin * 2 - 5);
2676 } else {
2677 int vert_size = w / 2;
2678 r.setRect(x + 5, y + h - margin * 2 - vert_size,
2679 w - margin * 2 - 5, vert_size);
2680 }
2682 break; }
2683
2687 break;
2691 break;
2692#if QT_CONFIG(tabwidget)
2693 case SE_TabWidgetTabBar:
2694 if (const QStyleOptionTabWidgetFrame *twf
2695 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2696 r.setSize(twf->tabBarSize);
2697 const uint alingMask = Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter;
2698 switch (twf->shape) {
2701 // Constrain the size now, otherwise, center could get off the page
2702 // This of course repeated for all the other directions
2703 r.setWidth(qMin(r.width(), twf->rect.width()
2704 - twf->leftCornerWidgetSize.width()
2705 - twf->rightCornerWidgetSize.width()));
2706 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2707 default:
2708 case Qt::AlignLeft:
2709 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0));
2710 break;
2711 case Qt::AlignHCenter:
2712 r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2713 + (twf->leftCornerWidgetSize.width() / 2)
2714 - (twf->rightCornerWidgetSize.width() / 2), 0));
2715 break;
2716 case Qt::AlignRight:
2717 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2718 - twf->rightCornerWidgetSize.width(), 0));
2719 break;
2720 }
2721 r = visualRect(twf->direction, twf->rect, r);
2722 break;
2725 r.setWidth(qMin(r.width(), twf->rect.width()
2726 - twf->leftCornerWidgetSize.width()
2727 - twf->rightCornerWidgetSize.width()));
2728 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2729 default:
2730 case Qt::AlignLeft:
2731 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(),
2732 twf->rect.height() - twf->tabBarSize.height()));
2733 break;
2734 case Qt::AlignHCenter:
2735 r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2736 + (twf->leftCornerWidgetSize.width() / 2)
2737 - (twf->rightCornerWidgetSize.width() / 2),
2738 twf->rect.height() - twf->tabBarSize.height()));
2739 break;
2740 case Qt::AlignRight:
2741 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2742 - twf->rightCornerWidgetSize.width(),
2743 twf->rect.height() - twf->tabBarSize.height()));
2744 break;
2745 }
2746 r = visualRect(twf->direction, twf->rect, r);
2747 break;
2750 r.setHeight(qMin(r.height(), twf->rect.height()
2751 - twf->leftCornerWidgetSize.height()
2752 - twf->rightCornerWidgetSize.height()));
2753 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2754 default:
2755 case Qt::AlignLeft:
2756 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2757 twf->leftCornerWidgetSize.height()));
2758 break;
2759 case Qt::AlignHCenter:
2760 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2761 twf->rect.center().y() - r.height() / 2));
2762 break;
2763 case Qt::AlignRight:
2764 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2765 twf->rect.height() - twf->tabBarSize.height()
2766 - twf->rightCornerWidgetSize.height()));
2767 break;
2768 }
2769 break;
2772 r.setHeight(qMin(r.height(), twf->rect.height()
2773 - twf->leftCornerWidgetSize.height()
2774 - twf->rightCornerWidgetSize.height()));
2775 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2776 default:
2777 case Qt::AlignLeft:
2778 r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height()));
2779 break;
2780 case Qt::AlignHCenter:
2781 r.moveTopLeft(QPoint(0, twf->rect.center().y() - r.height() / 2));
2782 break;
2783 case Qt::AlignRight:
2784 r.moveTopLeft(QPoint(0, twf->rect.height() - twf->tabBarSize.height()
2785 - twf->rightCornerWidgetSize.height()));
2786 break;
2787 }
2788 break;
2789 }
2790 }
2791 break;
2794 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2795 QStyleOptionTab tabopt;
2796 tabopt.shape = twf->shape;
2797 int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget);
2798 if (twf->lineWidth == 0)
2799 overlap = 0;
2800 switch (twf->shape) {
2803 r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)),
2804 QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2805 break;
2808 r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2809 break;
2812 r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2813 break;
2816 r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0),
2817 QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2818 break;
2819 }
2820 if (sr == SE_TabWidgetTabContents && twf->lineWidth > 0)
2821 r.adjust(2, 2, -2, -2);
2822 }
2823 break;
2825 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2827 switch (twf->shape) {
2830 r = QRect(QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()),
2831 twf->leftCornerWidgetSize);
2832 break;
2835 r = QRect(QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize);
2836 break;
2837 default:
2838 break;
2839 }
2840 r = visualRect(twf->direction, twf->rect, r);
2841 }
2842 break;
2844 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2846 switch (twf->shape) {
2849 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2850 paneRect.y() - twf->rightCornerWidgetSize.height()),
2851 twf->rightCornerWidgetSize);
2852 break;
2855 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2856 paneRect.height()), twf->rightCornerWidgetSize);
2857 break;
2858 default:
2859 break;
2860 }
2861 r = visualRect(twf->direction, twf->rect, r);
2862 }
2863 break;
2864 case SE_TabBarTabText:
2865 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2866 QRect dummyIconRect;
2867 d->tabLayout(tab, widget, &r, &dummyIconRect);
2868 }
2869 break;
2872 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2873 bool selected = tab->state & State_Selected;
2874 int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
2875 int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
2876 int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
2877 hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt
2878
2879 bool verticalTabs = tab->shape == QTabBar::RoundedEast
2880 || tab->shape == QTabBar::RoundedWest
2881 || tab->shape == QTabBar::TriangularEast
2882 || tab->shape == QTabBar::TriangularWest;
2883
2884 QRect tr = tab->rect;
2885 if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth)
2886 verticalShift = -verticalShift;
2887 if (verticalTabs) {
2888 qSwap(horizontalShift, verticalShift);
2889 horizontalShift *= -1;
2890 verticalShift *= -1;
2891 }
2892 if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest)
2893 horizontalShift = -horizontalShift;
2894
2895 tr.adjust(0, 0, horizontalShift, verticalShift);
2896 if (selected)
2897 {
2898 tr.setBottom(tr.bottom() - verticalShift);
2899 tr.setRight(tr.right() - horizontalShift);
2900 }
2901
2902 QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize;
2903 int w = size.width();
2904 int h = size.height();
2905 int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2));
2906 int midWidth = ((tr.width() - w) / 2);
2907
2908 bool atTheTop = true;
2909 switch (tab->shape) {
2912 atTheTop = (sr == SE_TabBarTabLeftButton);
2913 break;
2916 atTheTop = (sr == SE_TabBarTabRightButton);
2917 break;
2918 default:
2919 if (sr == SE_TabBarTabLeftButton)
2920 r = QRect(tab->rect.x() + hpadding, midHeight, w, h);
2921 else
2922 r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h);
2923 r = visualRect(tab->direction, tab->rect, r);
2924 }
2925 if (verticalTabs) {
2926 if (atTheTop)
2927 r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h);
2928 else
2929 r = QRect(midWidth, tr.y() + hpadding, w, h);
2930 }
2931 }
2932
2933 break;
2934#endif // QT_CONFIG(tabwidget)
2935#if QT_CONFIG(tabbar)
2937 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2938 switch (tab->shape) {
2943 r.setRect(tab->rect.left(), tab->rect.top(), 8, opt->rect.height());
2944 break;
2949 r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 8);
2950 break;
2951 default:
2952 break;
2953 }
2955 }
2956 break;
2958 const bool vertical = opt->rect.width() < opt->rect.height();
2960 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget);
2961 const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, nullptr, widget);
2962
2963 r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth)
2964 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height()));
2965 break; }
2967 const bool vertical = opt->rect.width() < opt->rect.height();
2969 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget);
2970
2971 r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth)
2972 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height()));
2973 break; }
2974#endif
2976 r = opt->rect;
2977 break;
2979 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2980 r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth);
2982 }
2983 break;
2984 case SE_FrameContents:
2985 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2987 r = opt->rect.adjusted(fw, fw, -fw, -fw);
2989 }
2990 break;
2992 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2993 int frameShape = f->frameShape;
2994 int frameShadow = QFrame::Plain;
2995 if (f->state & QStyle::State_Sunken) {
2996 frameShadow = QFrame::Sunken;
2997 } else if (f->state & QStyle::State_Raised) {
2998 frameShadow = QFrame::Raised;
2999 }
3000
3001 int frameWidth = 0;
3002
3003 switch (frameShape) {
3004 case QFrame::NoFrame:
3005 frameWidth = 0;
3006 break;
3007
3008 case QFrame::Box:
3009 case QFrame::HLine:
3010 case QFrame::VLine:
3011 switch (frameShadow) {
3012 case QFrame::Plain:
3013 frameWidth = f->lineWidth;
3014 break;
3015 case QFrame::Raised:
3016 case QFrame::Sunken:
3017 frameWidth = (short)(f->lineWidth*2 + f->midLineWidth);
3018 break;
3019 }
3020 break;
3021
3023 //keep the compatibility with Qt 4.4 if there is a proxy style.
3024 //be sure to call drawPrimitive(QStyle::SE_FrameContents) on the proxy style
3025 if (widget)
3027 else
3029
3030 case QFrame::WinPanel:
3031 frameWidth = 2;
3032 break;
3033
3034 case QFrame::Panel:
3035 switch (frameShadow) {
3036 case QFrame::Plain:
3037 case QFrame::Raised:
3038 case QFrame::Sunken:
3039 frameWidth = f->lineWidth;
3040 break;
3041 }
3042 break;
3043 }
3044 r = f->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
3045 }
3046 break;
3047#if QT_CONFIG(dockwidget)
3051 case SE_DockWidgetIcon: {
3055 QRect rect = opt->rect;
3056
3057 const QStyleOptionDockWidget *dwOpt
3058 = qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
3059 bool canClose = dwOpt == nullptr ? true : dwOpt->closable;
3060 bool canFloat = dwOpt == nullptr ? false : dwOpt->floatable;
3061
3062 const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
3063
3064 // If this is a vertical titlebar, we transpose and work as if it was
3065 // horizontal, then transpose again.
3066
3067 if (verticalTitleBar)
3068 rect = rect.transposed();
3069
3070 do {
3071
3072 int right = rect.right();
3073 int left = rect.left();
3074
3075 QRect closeRect;
3076 if (canClose) {
3079 sz += QSize(buttonMargin, buttonMargin);
3080 if (verticalTitleBar)
3081 sz = sz.transposed();
3082 closeRect = QRect(right - sz.width(),
3083 rect.center().y() - sz.height()/2,
3084 sz.width(), sz.height());
3085 right = closeRect.left() - 1;
3086 }
3087 if (sr == SE_DockWidgetCloseButton) {
3088 r = closeRect;
3089 break;
3090 }
3091
3092 QRect floatRect;
3093 if (canFloat) {
3096 sz += QSize(buttonMargin, buttonMargin);
3097 if (verticalTitleBar)
3098 sz = sz.transposed();
3099 floatRect = QRect(right - sz.width(),
3100 rect.center().y() - sz.height()/2,
3101 sz.width(), sz.height());
3102 right = floatRect.left() - 1;
3103 }
3104 if (sr == SE_DockWidgetFloatButton) {
3105 r = floatRect;
3106 break;
3107 }
3108
3109 QRect iconRect;
3110 if (const QDockWidget *dw = qobject_cast<const QDockWidget*>(widget)) {
3111 QIcon icon;
3112 if (dw->isFloating())
3113 icon = dw->windowIcon();
3114 if (!icon.isNull()
3116 QSize sz = icon.actualSize(QSize(r.height(), r.height()));
3117 if (verticalTitleBar)
3118 sz = sz.transposed();
3119 iconRect = QRect(left, rect.center().y() - sz.height()/2,
3120 sz.width(), sz.height());
3121 left = iconRect.right() + margin;
3122 }
3123 }
3124 if (sr == SE_DockWidgetIcon) {
3125 r = iconRect;
3126 break;
3127 }
3128
3129 QRect textRect = QRect(left, rect.top(),
3130 right - left, rect.height());
3131 if (sr == SE_DockWidgetTitleBarText) {
3132 r = textRect;
3133 break;
3134 }
3135
3136 } while (false);
3137
3138 if (verticalTitleBar) {
3139 r = QRect(rect.left() + r.top() - rect.top(),
3140 rect.top() + rect.right() - r.right(),
3141 r.height(), r.width());
3142 } else {
3144 }
3145 break;
3146 }
3147#endif
3148#if QT_CONFIG(itemviews)
3150 if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
3152 break;
3153 }
3154 Q_FALLTHROUGH();
3158 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
3159 if (!d->isViewItemCached(*vopt)) {
3160 d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false);
3161 if (d->cachedOption) {
3162 delete d->cachedOption;
3163 d->cachedOption = nullptr;
3164 }
3165 d->cachedOption = new QStyleOptionViewItem(*vopt);
3166 }
3168 r = d->checkRect;
3169 else if (sr == SE_ItemViewItemDecoration)
3170 r = d->decorationRect;
3171 else if (sr == SE_ItemViewItemText || sr == SE_ItemViewItemFocusRect)
3172 r = d->displayRect;
3173 }
3174 break;
3175#endif // QT_CONFIG(itemviews)
3176#if QT_CONFIG(toolbar)
3177 case SE_ToolBarHandle:
3178 if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
3179 if (tbopt->features & QStyleOptionToolBar::Movable) {
3181 //have all the information we need (ie. the layout's margin)
3182 const QToolBar *tb = qobject_cast<const QToolBar*>(widget);
3183 const QMargins margins = tb && tb->layout() ? tb->layout()->contentsMargins() : QMargins(2, 2, 2, 2);
3184 const int handleExtent = proxy()->pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb);
3185 if (tbopt->state & QStyle::State_Horizontal) {
3186 r = QRect(margins.left(), margins.top(),
3187 handleExtent,
3188 tbopt->rect.height() - (margins.top() + margins.bottom()));
3189 r = QStyle::visualRect(tbopt->direction, tbopt->rect, r);
3190 } else {
3191 r = QRect(margins.left(), margins.top(),
3192 tbopt->rect.width() - (margins.left() + margins.right()),
3193 handleExtent);
3194 }
3195 }
3196 }
3197 break;
3198#endif // QT_CONFIG(toolbar)
3199 default:
3200 break;
3201 }
3202 return r;
3203#if !QT_CONFIG(tabwidget) && !QT_CONFIG(itemviews)
3204 Q_UNUSED(d);
3205#endif
3206}
3207
3208#if QT_CONFIG(dial)
3209
3210// in lieu of std::array, minimal API
3211template <int N>
3212struct StaticPolygonF
3213{
3214 QPointF data[N];
3215
3216 constexpr int size() const { return N; }
3217 constexpr const QPointF *cbegin() const { return data; }
3218 constexpr const QPointF &operator[](int idx) const { return data[idx]; }
3219};
3220
3221static StaticPolygonF<3> calcArrow(const QStyleOptionSlider *dial, qreal &a)
3222{
3223 int width = dial->rect.width();
3224 int height = dial->rect.height();
3225 int r = qMin(width, height) / 2;
3226 int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
3227
3228 if (dial->maximum == dial->minimum)
3229 a = Q_PI / 2;
3230 else if (dial->dialWrapping)
3231 a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
3232 / (dial->maximum - dial->minimum);
3233 else
3234 a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
3235 / (dial->maximum - dial->minimum)) / 6;
3236
3237 int xc = width / 2 + dial->rect.left();
3238 int yc = height / 2 + dial->rect.top();
3239
3240 int len = r - QStyleHelper::calcBigLineSize(r) - 5;
3241 if (len < 5)
3242 len = 5;
3243 int back = len / 2;
3244
3245 StaticPolygonF<3> arrow = {{
3246 QPointF(0.5 + xc + len * qCos(a),
3247 0.5 + yc - len * qSin(a)),
3248 QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6),
3249 0.5 + yc - back * qSin(a + Q_PI * 5 / 6)),
3250 QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6),
3251 0.5 + yc - back * qSin(a - Q_PI * 5 / 6)),
3252 }};
3253 return arrow;
3254}
3255
3256#endif // QT_CONFIG(dial)
3257
3262 QPainter *p, const QWidget *widget) const
3263{
3264 switch (cc) {
3265#if QT_CONFIG(slider)
3266 case CC_Slider:
3267 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3268 if (slider->subControls == SC_SliderTickmarks) {
3269 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
3270 int ticks = slider->tickPosition;
3271 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
3272 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3273 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
3274 int interval = slider->tickInterval;
3275 if (interval <= 0) {
3276 interval = slider->singleStep;
3277 if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
3278 available)
3279 - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3280 0, available) < 3)
3281 interval = slider->pageStep;
3282 }
3283 if (!interval)
3284 interval = 1;
3285 int fudge = len / 2;
3286 int pos;
3287 // Since there is no subrect for tickmarks do a translation here.
3288 p->save();
3289 p->translate(slider->rect.x(), slider->rect.y());
3290 p->setPen(slider->palette.windowText().color());
3291 int v = slider->minimum;
3292 while (v <= slider->maximum + 1) {
3293 if (v == slider->maximum + 1 && interval == 1)
3294 break;
3295 const int v_ = qMin(v, slider->maximum);
3296 pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3297 v_, available) + fudge;
3298 if (slider->orientation == Qt::Horizontal) {
3299 if (ticks & QSlider::TicksAbove)
3300 p->drawLine(pos, 0, pos, tickOffset - 2);
3301 if (ticks & QSlider::TicksBelow)
3302 p->drawLine(pos, tickOffset + thickness + 1, pos,
3303 slider->rect.height()-1);
3304 } else {
3305 if (ticks & QSlider::TicksAbove)
3306 p->drawLine(0, pos, tickOffset - 2, pos);
3307 if (ticks & QSlider::TicksBelow)
3308 p->drawLine(tickOffset + thickness + 1, pos,
3309 slider->rect.width()-1, pos);
3310 }
3311 // in the case where maximum is max int
3312 int nextInterval = v + interval;
3313 if (nextInterval < v)
3314 break;
3315 v = nextInterval;
3316 }
3317 p->restore();
3318 }
3319 }
3320 break;
3321#endif // QT_CONFIG(slider)
3322#if QT_CONFIG(scrollbar)
3323 case CC_ScrollBar:
3324 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3325 // Make a copy here and reset it for each primitive.
3326 QStyleOptionSlider newScrollbar = *scrollbar;
3327 State saveFlags = scrollbar->state;
3328
3329 if (scrollbar->subControls & SC_ScrollBarSubLine) {
3330 newScrollbar.state = saveFlags;
3331 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget);
3332 if (newScrollbar.rect.isValid()) {
3333 if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
3334 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3335 proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget);
3336 }
3337 }
3338 if (scrollbar->subControls & SC_ScrollBarAddLine) {
3339 newScrollbar.rect = scrollbar->rect;
3340 newScrollbar.state = saveFlags;
3341 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget);
3342 if (newScrollbar.rect.isValid()) {
3343 if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
3344 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3345 proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget);
3346 }
3347 }
3348 if (scrollbar->subControls & SC_ScrollBarSubPage) {
3349 newScrollbar.rect = scrollbar->rect;
3350 newScrollbar.state = saveFlags;
3351 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget);
3352 if (newScrollbar.rect.isValid()) {
3353 if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage))
3354 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3355 proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget);
3356 }
3357 }
3358 if (scrollbar->subControls & SC_ScrollBarAddPage) {
3359 newScrollbar.rect = scrollbar->rect;
3360 newScrollbar.state = saveFlags;
3361 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget);
3362 if (newScrollbar.rect.isValid()) {
3363 if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage))
3364 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3365 proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget);
3366 }
3367 }
3368 if (scrollbar->subControls & SC_ScrollBarFirst) {
3369 newScrollbar.rect = scrollbar->rect;
3370 newScrollbar.state = saveFlags;
3371 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget);
3372 if (newScrollbar.rect.isValid()) {
3373 if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
3374 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3375 proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget);
3376 }
3377 }
3378 if (scrollbar->subControls & SC_ScrollBarLast) {
3379 newScrollbar.rect = scrollbar->rect;
3380 newScrollbar.state = saveFlags;
3381 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget);
3382 if (newScrollbar.rect.isValid()) {
3383 if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
3384 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3385 proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget);
3386 }
3387 }
3388 if (scrollbar->subControls & SC_ScrollBarSlider) {
3389 newScrollbar.rect = scrollbar->rect;
3390 newScrollbar.state = saveFlags;
3391 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget);
3392 if (newScrollbar.rect.isValid()) {
3393 if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
3394 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3395 proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget);
3396
3397 if (scrollbar->state & State_HasFocus) {
3399 fropt.QStyleOption::operator=(newScrollbar);
3400 fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2,
3401 newScrollbar.rect.width() - 5,
3402 newScrollbar.rect.height() - 5);
3404 }
3405 }
3406 }
3407 }
3408 break;
3409#endif // QT_CONFIG(scrollbar)
3410#if QT_CONFIG(spinbox)
3411 case CC_SpinBox:
3412 if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3413 QStyleOptionSpinBox copy = *sb;
3415
3416 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3418 qDrawWinPanel(p, r, sb->palette, true);
3419 }
3420
3421 if (sb->subControls & SC_SpinBoxUp) {
3422 copy.subControls = SC_SpinBoxUp;
3423 QPalette pal2 = sb->palette;
3424 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
3426 copy.state &= ~State_Enabled;
3427 }
3428
3429 copy.palette = pal2;
3430
3431 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3432 copy.state |= State_On;
3433 copy.state |= State_Sunken;
3434 } else {
3435 copy.state |= State_Raised;
3436 copy.state &= ~State_Sunken;
3437 }
3438 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3440
3443 copy.rect.adjust(3, 0, -4, 0);
3444 proxy()->drawPrimitive(pe, &copy, p, widget);
3445 }
3446
3447 if (sb->subControls & SC_SpinBoxDown) {
3448 copy.subControls = SC_SpinBoxDown;
3449 copy.state = sb->state;
3450 QPalette pal2 = sb->palette;
3451 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
3453 copy.state &= ~State_Enabled;
3454 }
3455 copy.palette = pal2;
3456
3457 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3458 copy.state |= State_On;
3459 copy.state |= State_Sunken;
3460 } else {
3461 copy.state |= State_Raised;
3462 copy.state &= ~State_Sunken;
3463 }
3464 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3466
3469 copy.rect.adjust(3, 0, -4, 0);
3470 proxy()->drawPrimitive(pe, &copy, p, widget);
3471 }
3472 }
3473 break;
3474#endif // QT_CONFIG(spinbox)
3475#if QT_CONFIG(toolbutton)
3476 case CC_ToolButton:
3477 if (const QStyleOptionToolButton *toolbutton
3478 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3479 QRect button, menuarea;
3480 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
3481 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
3482
3483 State bflags = toolbutton->state & ~State_Sunken;
3484
3485 if (bflags & State_AutoRaise) {
3486 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
3487 bflags &= ~State_Raised;
3488 }
3489 }
3490 State mflags = bflags;
3491 if (toolbutton->state & State_Sunken) {
3492 if (toolbutton->activeSubControls & SC_ToolButton)
3493 bflags |= State_Sunken;
3494 mflags |= State_Sunken;
3495 }
3496
3497 QStyleOption tool = *toolbutton;
3498 if (toolbutton->subControls & SC_ToolButton) {
3499 if (bflags & (State_Sunken | State_On | State_Raised)) {
3500 tool.rect = button;
3501 tool.state = bflags;
3503 }
3504 }
3505
3506 if (toolbutton->state & State_HasFocus) {
3508 fr.QStyleOption::operator=(*toolbutton);
3509 fr.rect.adjust(3, 3, -3, -3);
3512 toolbutton, widget), 0);
3514 }
3515 QStyleOptionToolButton label = *toolbutton;
3516 label.state = bflags;
3518 label.rect = button.adjusted(fw, fw, -fw, -fw);
3520
3521 if (toolbutton->subControls & SC_ToolButtonMenu) {
3522 tool.rect = menuarea;
3523 tool.state = mflags;
3524 if (mflags & (State_Sunken | State_On | State_Raised))
3527 } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
3528 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
3529 QRect ir = toolbutton->rect;
3530 QStyleOptionToolButton newBtn = *toolbutton;
3531 newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6);
3532 newBtn.rect = visualRect(toolbutton->direction, button, newBtn.rect);
3534 }
3535 }
3536 break;
3537#endif // QT_CONFIG(toolbutton)
3538 case CC_TitleBar:
3539 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
3540 QRect ir;
3541 if (opt->subControls & SC_TitleBarLabel) {
3542 QColor left = tb->palette.highlight().color();
3543 QColor right = tb->palette.base().color();
3544
3545 QBrush fillBrush(left);
3546 if (left != right) {
3547 QPoint p1(tb->rect.x(), tb->rect.top() + tb->rect.height()/2);
3548 QPoint p2(tb->rect.right(), tb->rect.top() + tb->rect.height()/2);
3549 QLinearGradient lg(p1, p2);
3550 lg.setColorAt(0, left);
3551 lg.setColorAt(1, right);
3552 fillBrush = lg;
3553 }
3554
3555 p->fillRect(opt->rect, fillBrush);
3556
3558
3559 p->setPen(tb->palette.highlightedText().color());
3560 p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(),
3562 }
3563
3564 bool down = false;
3565 QPixmap pm;
3566
3567 QStyleOption tool = *tb;
3568 if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3570 down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken);
3571 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool
3572#if QT_CONFIG(dockwidget)
3573 || qobject_cast<const QDockWidget *>(widget)
3574#endif
3575 )
3576 pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3577 else
3578 pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3579 tool.rect = ir;
3580 tool.state = down ? State_Sunken : State_Raised;
3582
3583 p->save();
3584 if (down)
3588 p->restore();
3589 }
3590
3591 if (tb->subControls & SC_TitleBarMaxButton
3592 && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
3593 && !(tb->titleBarState & Qt::WindowMaximized)) {
3595
3596 down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
3597 pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3598 tool.rect = ir;
3599 tool.state = down ? State_Sunken : State_Raised;
3601
3602 p->save();
3603 if (down)
3607 p->restore();
3608 }
3609
3610 if (tb->subControls & SC_TitleBarMinButton
3611 && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
3612 && !(tb->titleBarState & Qt::WindowMinimized)) {
3614 down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
3615 pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3616 tool.rect = ir;
3617 tool.state = down ? State_Sunken : State_Raised;
3619
3620 p->save();
3621 if (down)
3625 p->restore();
3626 }
3627
3628 bool drawNormalButton = (tb->subControls & SC_TitleBarNormalButton)
3629 && (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3630 && (tb->titleBarState & Qt::WindowMinimized))
3631 || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3632 && (tb->titleBarState & Qt::WindowMaximized)));
3633
3634 if (drawNormalButton) {
3636 down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
3637 pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3638 tool.rect = ir;
3639 tool.state = down ? State_Sunken : State_Raised;
3641
3642 p->save();
3643 if (down)
3647 p->restore();
3648 }
3649
3650 if (tb->subControls & SC_TitleBarShadeButton
3651 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3652 && !(tb->titleBarState & Qt::WindowMinimized)) {
3654 down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
3655 pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3656 tool.rect = ir;
3657 tool.state = down ? State_Sunken : State_Raised;
3659 p->save();
3660 if (down)
3664 p->restore();
3665 }
3666
3667 if (tb->subControls & SC_TitleBarUnshadeButton
3668 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3669 && tb->titleBarState & Qt::WindowMinimized) {
3671
3672 down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
3673 pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3674 tool.rect = ir;
3675 tool.state = down ? State_Sunken : State_Raised;
3677 p->save();
3678 if (down)
3682 p->restore();
3683 }
3684 if (tb->subControls & SC_TitleBarContextHelpButton
3685 && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) {
3687
3688 down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken);
3689 pm = proxy()->standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3690 tool.rect = ir;
3691 tool.state = down ? State_Sunken : State_Raised;
3693 p->save();
3694 if (down)
3698 p->restore();
3699 }
3700 if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3702 if (!tb->icon.isNull()) {
3703 tb->icon.paint(p, ir);
3704 } else {
3706 pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(QSize(iconSize, iconSize), p->device()->devicePixelRatio());
3707 tool.rect = ir;
3708 p->save();
3710 p->restore();
3711 }
3712 }
3713 }
3714 break;
3715#if QT_CONFIG(dial)
3716 case CC_Dial:
3717 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3718 // OK, this is more a port of things over
3719 p->save();
3720
3721 // avoid dithering
3722 if (p->paintEngine()->hasFeature(QPaintEngine::Antialiasing))
3723 p->setRenderHint(QPainter::Antialiasing);
3724
3725 int width = dial->rect.width();
3726 int height = dial->rect.height();
3727 qreal r = qMin(width, height) / 2;
3728 qreal d_ = r / 6;
3729 qreal dx = dial->rect.x() + d_ + (width - 2 * r) / 2 + 1;
3730 qreal dy = dial->rect.y() + d_ + (height - 2 * r) / 2 + 1;
3731 QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2), int(r * 2 - 2 * d_ - 2));
3732
3733 QPalette pal = opt->palette;
3734 // draw notches
3735 if (dial->subControls & QStyle::SC_DialTickmarks) {
3736 p->setPen(pal.windowText().color());
3737 p->drawLines(QStyleHelper::calcLines(dial));
3738 }
3739
3740 if (dial->state & State_Enabled) {
3742 dial, widget))));
3743 p->setPen(Qt::NoPen);
3744 p->drawEllipse(br);
3745 p->setBrush(Qt::NoBrush);
3746 }
3747 p->setPen(QPen(pal.dark().color()));
3748 p->drawArc(br, 60 * 16, 180 * 16);
3749 p->setPen(QPen(pal.light().color()));
3750 p->drawArc(br, 240 * 16, 180 * 16);
3751
3752 qreal a;
3753 const StaticPolygonF<3> arrow = calcArrow(dial, a);
3754
3755 p->setPen(Qt::NoPen);
3756 p->setBrush(pal.button());
3757 p->drawPolygon(arrow.cbegin(), arrow.size());
3758
3759 a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]);
3760 p->setBrush(Qt::NoBrush);
3761
3762 if (a <= 0 || a > 200) {
3763 p->setPen(pal.light().color());
3764 p->drawLine(arrow[2], arrow[0]);
3765 p->drawLine(arrow[1], arrow[2]);
3766 p->setPen(pal.dark().color());
3767 p->drawLine(arrow[0], arrow[1]);
3768 } else if (a > 0 && a < 45) {
3769 p->setPen(pal.light().color());
3770 p->drawLine(arrow[2], arrow[0]);
3771 p->setPen(pal.dark().color());
3772 p->drawLine(arrow[1], arrow[2]);
3773 p->drawLine(arrow[0], arrow[1]);
3774 } else if (a >= 45 && a < 135) {
3775 p->setPen(pal.dark().color());
3776 p->drawLine(arrow[2], arrow[0]);
3777 p->drawLine(arrow[1], arrow[2]);
3778 p->setPen(pal.light().color());
3779 p->drawLine(arrow[0], arrow[1]);
3780 } else if (a >= 135 && a < 200) {
3781 p->setPen(pal.dark().color());
3782 p->drawLine(arrow[2], arrow[0]);
3783 p->setPen(pal.light().color());
3784 p->drawLine(arrow[0], arrow[1]);
3785 p->drawLine(arrow[1], arrow[2]);
3786 }
3787
3788 // draw focus rect around the dial
3790 fropt.rect = dial->rect;
3791 fropt.state = dial->state;
3792 fropt.palette = dial->palette;
3793 if (fropt.state & QStyle::State_HasFocus) {
3794 br.adjust(0, 0, 2, 2);
3795 if (dial->subControls & SC_DialTickmarks) {
3796 int r = qMin(width, height) / 2;
3797 br.translate(-r / 6, - r / 6);
3798 br.setWidth(br.width() + r / 3);
3799 br.setHeight(br.height() + r / 3);
3800 }
3801 fropt.rect = br.adjusted(-2, -2, 2, 2);
3803 }
3804 p->restore();
3805 }
3806 break;
3807#endif // QT_CONFIG(dial)
3808#if QT_CONFIG(groupbox)
3809 case CC_GroupBox:
3810 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
3811 // Draw frame
3814 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
3816 frame.QStyleOption::operator=(*groupBox);
3817 frame.features = groupBox->features;
3818 frame.lineWidth = groupBox->lineWidth;
3819 frame.midLineWidth = groupBox->midLineWidth;
3821 p->save();
3822 QRegion region(groupBox->rect);
3823 if (!groupBox->text.isEmpty()) {
3824 bool ltr = groupBox->direction == Qt::LeftToRight;
3825 QRect finalRect;
3826 if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
3827 finalRect = checkBoxRect.united(textRect);
3828 finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
3829 } else {
3830 finalRect = textRect;
3831 }
3832 region -= finalRect;
3833 }
3834 p->setClipRegion(region);
3836 p->restore();
3837 }
3838
3839 // Draw title
3840 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
3841 QColor textColor = groupBox->textColor;
3842 if (textColor.isValid())
3843 p->setPen(textColor);
3844 int alignment = int(groupBox->textAlignment);
3847
3851
3852 if (groupBox->state & State_HasFocus) {
3854 fropt.QStyleOption::operator=(*groupBox);
3855 fropt.rect = textRect;
3857 }
3858 }
3859
3860 // Draw checkbox
3861 if (groupBox->subControls & SC_GroupBoxCheckBox) {
3863 box.QStyleOption::operator=(*groupBox);
3864 box.rect = checkBoxRect;
3866 }
3867 }
3868 break;
3869#endif // QT_CONFIG(groupbox)
3870#if QT_CONFIG(mdiarea)
3871 case CC_MdiControls:
3872 {
3873 QStyleOptionButton btnOpt;
3874 btnOpt.QStyleOption::operator=(*opt);
3875 btnOpt.state &= ~State_MouseOver;
3876 int bsx = 0;
3877 int bsy = 0;
3878 const int buttonIconMetric = proxy()->pixelMetric(PM_TitleBarButtonIconSize, &btnOpt, widget);
3879 const QSize buttonIconSize(buttonIconMetric, buttonIconMetric);
3880 if (opt->subControls & QStyle::SC_MdiCloseButton) {
3881 if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
3882 btnOpt.state |= State_Sunken;
3883 btnOpt.state &= ~State_Raised;
3886 } else {
3887 btnOpt.state |= State_Raised;
3888 btnOpt.state &= ~State_Sunken;
3889 bsx = 0;
3890 bsy = 0;
3891 }
3894 QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3895 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3896 }
3897 if (opt->subControls & QStyle::SC_MdiNormalButton) {
3898 if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
3899 btnOpt.state |= State_Sunken;
3900 btnOpt.state &= ~State_Raised;
3903 } else {
3904 btnOpt.state |= State_Raised;
3905 btnOpt.state &= ~State_Sunken;
3906 bsx = 0;
3907 bsy = 0;
3908 }
3911 QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3912 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3913 }
3914 if (opt->subControls & QStyle::SC_MdiMinButton) {
3915 if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
3916 btnOpt.state |= State_Sunken;
3917 btnOpt.state &= ~State_Raised;
3920 } else {
3921 btnOpt.state |= State_Raised;
3922 btnOpt.state &= ~State_Sunken;
3923 bsx = 0;
3924 bsy = 0;
3925 }
3928 QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3929 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3930 }
3931 }
3932 break;
3933#endif // QT_CONFIG(mdiarea)
3934 default:
3935 qCWarning(lcCommonStyle, "QCommonStyle::drawComplexControl: Control %d not handled", cc);
3936 }
3937}
3938
3943 const QPoint &pt, const QWidget *widget) const
3944{
3945 SubControl sc = SC_None;
3946 switch (cc) {
3947#if QT_CONFIG(slider)
3948 case CC_Slider:
3949 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3950 QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget);
3951 if (r.isValid() && r.contains(pt)) {
3952 sc = SC_SliderHandle;
3953 } else {
3954 r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget);
3955 if (r.isValid() && r.contains(pt))
3956 sc = SC_SliderGroove;
3957 }
3958 }
3959 break;
3960#endif // QT_CONFIG(slider)
3961#if QT_CONFIG(scrollbar)
3962 case CC_ScrollBar:
3963 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3964 QRect r;
3966 while (ctrl <= SC_ScrollBarGroove) {
3967 r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget);
3968 if (r.isValid() && r.contains(pt)) {
3969 sc = QStyle::SubControl(ctrl);
3970 break;
3971 }
3972 ctrl <<= 1;
3973 }
3974 }
3975 break;
3976#endif // QT_CONFIG(scrollbar)
3977#if QT_CONFIG(toolbutton)
3978 case CC_ToolButton:
3979 if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3980 QRect r;
3981 uint ctrl = SC_ToolButton;
3982 while (ctrl <= SC_ToolButtonMenu) {
3983 r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget);
3984 if (r.isValid() && r.contains(pt)) {
3985 sc = QStyle::SubControl(ctrl);
3986 break;
3987 }
3988 ctrl <<= 1;
3989 }
3990 }
3991 break;
3992#endif // QT_CONFIG(toolbutton)
3993#if QT_CONFIG(spinbox)
3994 case CC_SpinBox:
3995 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3996 QRect r;
3997 uint ctrl = SC_SpinBoxUp;
3998 while (ctrl <= SC_SpinBoxEditField) {
3999 r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget);
4000 if (r.isValid() && r.contains(pt)) {
4001 sc = QStyle::SubControl(ctrl);
4002 break;
4003 }
4004 ctrl <<= 1;
4005 }
4006 }
4007 break;
4008#endif // QT_CONFIG(spinbox)
4009 case CC_TitleBar:
4010 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4011 QRect r;
4012 uint ctrl = SC_TitleBarSysMenu;
4013
4014 while (ctrl <= SC_TitleBarLabel) {
4015 r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget);
4016 if (r.isValid() && r.contains(pt)) {
4017 sc = QStyle::SubControl(ctrl);
4018 break;
4019 }
4020 ctrl <<= 1;
4021 }
4022 }
4023 break;
4024#if QT_CONFIG(combobox)
4025 case CC_ComboBox:
4026 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4027 QRect r;
4028 uint ctrl = SC_ComboBoxArrow; // Start here and go down.
4029 while (ctrl > 0) {
4031 if (r.isValid() && r.contains(pt)) {
4032 sc = QStyle::SubControl(ctrl);
4033 break;
4034 }
4035 ctrl >>= 1;
4036 }
4037 }
4038 break;
4039#endif // QT_CONFIG(combobox)
4040#if QT_CONFIG(groupbox)
4041 case CC_GroupBox:
4042 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4043 QRect r;
4045 while (ctrl <= SC_GroupBoxFrame) {
4047 if (r.isValid() && r.contains(pt)) {
4048 sc = QStyle::SubControl(ctrl);
4049 break;
4050 }
4051 ctrl <<= 1;
4052 }
4053 }
4054 break;
4055#endif // QT_CONFIG(groupbox)
4056 case CC_MdiControls:
4057 {
4058 QRect r;
4059 uint ctrl = SC_MdiMinButton;
4060 while (ctrl <= SC_MdiCloseButton) {
4062 if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) {
4063 sc = QStyle::SubControl(ctrl);
4064 return sc;
4065 }
4066 ctrl <<= 1;
4067 }
4068 }
4069 break;
4070 default:
4071 qCWarning(lcCommonStyle, "QCommonStyle::hitTestComplexControl: Case %d not handled", cc);
4072 }
4073 return sc;
4074}
4075
4080 SubControl sc, const QWidget *widget) const
4081{
4082 QRect ret;
4083 switch (cc) {
4084#if QT_CONFIG(slider)
4085 case CC_Slider:
4086 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4087 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
4088 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
4089
4090 switch (sc) {
4091 case SC_SliderHandle: {
4092 int sliderPos = 0;
4093 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
4094 bool horizontal = slider->orientation == Qt::Horizontal;
4095 sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
4096 slider->sliderPosition,
4097 (horizontal ? slider->rect.width()
4098 : slider->rect.height()) - len,
4099 slider->upsideDown);
4100 if (horizontal)
4101 ret.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
4102 else
4103 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
4104 break; }
4105 case SC_SliderGroove:
4106 if (slider->orientation == Qt::Horizontal)
4107 ret.setRect(slider->rect.x(), slider->rect.y() + tickOffset,
4108 slider->rect.width(), thickness);
4109 else
4110 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y(),
4111 thickness, slider->rect.height());
4112 break;
4113 default:
4114 break;
4115 }
4116 ret = visualRect(slider->direction, slider->rect, ret);
4117 }
4118 break;
4119#endif // QT_CONFIG(slider)
4120#if QT_CONFIG(scrollbar)
4121 case CC_ScrollBar:
4122 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4123 const QRect scrollBarRect = scrollbar->rect;
4124 int sbextent = 0;
4125 if (!proxy()->styleHint(SH_ScrollBar_Transient, scrollbar, widget))
4126 sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget);
4127 int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
4128 scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2);
4129 int sliderlen;
4130
4131 // calculate slider length
4132 if (scrollbar->maximum != scrollbar->minimum) {
4133 uint range = scrollbar->maximum - scrollbar->minimum;
4134 sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep);
4135
4136 int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);
4137 if (sliderlen < slidermin || range > INT_MAX / 2)
4138 sliderlen = slidermin;
4139 if (sliderlen > maxlen)
4140 sliderlen = maxlen;
4141 } else {
4142 sliderlen = maxlen;
4143 }
4144
4145 int sliderstart = sbextent + sliderPositionFromValue(scrollbar->minimum,
4146 scrollbar->maximum,
4147 scrollbar->sliderPosition,
4148 maxlen - sliderlen,
4149 scrollbar->upsideDown);
4150
4151 switch (sc) {
4152 case SC_ScrollBarSubLine: // top/left button
4153 if (scrollbar->orientation == Qt::Horizontal) {
4154 int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent);
4155 ret.setRect(0, 0, buttonWidth, scrollBarRect.height());
4156 } else {
4157 int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent);
4158 ret.setRect(0, 0, scrollBarRect.width(), buttonHeight);
4159 }
4160 break;
4161 case SC_ScrollBarAddLine: // bottom/right button
4162 if (scrollbar->orientation == Qt::Horizontal) {
4163 int buttonWidth = qMin(scrollBarRect.width()/2, sbextent);
4164 ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height());
4165 } else {
4166 int buttonHeight = qMin(scrollBarRect.height()/2, sbextent);
4167 ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight);
4168 }
4169 break;
4170 case SC_ScrollBarSubPage: // between top/left button and slider
4171 if (scrollbar->orientation == Qt::Horizontal)
4172 ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height());
4173 else
4174 ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent);
4175 break;
4176 case SC_ScrollBarAddPage: // between bottom/right button and slider
4177 if (scrollbar->orientation == Qt::Horizontal)
4178 ret.setRect(sliderstart + sliderlen, 0,
4179 maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height());
4180 else
4181 ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(),
4182 maxlen - sliderstart - sliderlen + sbextent);
4183 break;
4184 case SC_ScrollBarGroove:
4185 if (scrollbar->orientation == Qt::Horizontal)
4186 ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2,
4187 scrollBarRect.height());
4188 else
4189 ret.setRect(0, sbextent, scrollBarRect.width(),
4190 scrollBarRect.height() - sbextent * 2);
4191 break;
4192 case SC_ScrollBarSlider:
4193 if (scrollbar->orientation == Qt::Horizontal)
4194 ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
4195 else
4196 ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
4197 break;
4198 default:
4199 break;
4200 }
4201 ret = visualRect(scrollbar->direction, scrollBarRect, ret);
4202 }
4203 break;
4204#endif // QT_CONFIG(scrollbar)
4205#if QT_CONFIG(spinbox)
4206 case CC_SpinBox:
4207 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
4208 QSize bs;
4209 int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
4210 bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw));
4211 // 1.6 -approximate golden mean
4212 bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4)));
4213 int y = fw + spinbox->rect.y();
4214 int x, lx, rx;
4215 x = spinbox->rect.x() + spinbox->rect.width() - fw - bs.width();
4216 lx = fw;
4217 rx = x - fw;
4218 switch (sc) {
4219 case SC_SpinBoxUp:
4220 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4221 return QRect();
4222 ret = QRect(x, y, bs.width(), bs.height());
4223 break;
4224 case SC_SpinBoxDown:
4225 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4226 return QRect();
4227
4228 ret = QRect(x, y + bs.height(), bs.width(), bs.height());
4229 break;
4231 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4232 ret = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
4233 } else {
4234 ret = QRect(lx, fw, rx, spinbox->rect.height() - 2*fw);
4235 }
4236 break;
4237 case SC_SpinBoxFrame:
4238 ret = spinbox->rect;
4239 default:
4240 break;
4241 }
4242 ret = visualRect(spinbox->direction, spinbox->rect, ret);
4243 }
4244 break;
4245#endif // Qt_NO_SPINBOX
4246#if QT_CONFIG(toolbutton)
4247 case CC_ToolButton:
4248 if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
4250 ret = tb->rect;
4251 switch (sc) {
4252 case SC_ToolButton:
4253 if ((tb->features
4256 ret.adjust(0, 0, -mbi, 0);
4257 break;
4258 case SC_ToolButtonMenu:
4259 if ((tb->features
4262 ret.adjust(ret.width() - mbi, 0, 0, 0);
4263 break;
4264 default:
4265 break;
4266 }
4267 ret = visualRect(tb->direction, tb->rect, ret);
4268 }
4269 break;
4270#endif // QT_CONFIG(toolbutton)
4271#if QT_CONFIG(combobox)
4272 case CC_ComboBox:
4273 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4274 const qreal dpi = QStyleHelper::dpi(opt);
4275 const int x = cb->rect.x(), y = cb->rect.y(), wi = cb->rect.width(), he = cb->rect.height();
4276 const int margin = cb->frame ? qRound(QStyleHelper::dpiScaled(3, dpi)) : 0;
4277 const int bmarg = cb->frame ? qRound(QStyleHelper::dpiScaled(2, dpi)) : 0;
4278 const int xpos = x + wi - bmarg - qRound(QStyleHelper::dpiScaled(16, dpi));
4279
4280
4281 switch (sc) {
4282 case SC_ComboBoxFrame:
4283 ret = cb->rect;
4284 break;
4285 case SC_ComboBoxArrow:
4286 ret.setRect(xpos, y + bmarg, qRound(QStyleHelper::dpiScaled(16, opt)), he - 2*bmarg);
4287 break;
4289 ret.setRect(x + margin, y + margin, wi - 2 * margin - qRound(QStyleHelper::dpiScaled(16, dpi)), he - 2 * margin);
4290 break;
4292 ret = cb->rect;
4293 break;
4294 default:
4295 break;
4296 }
4297 ret = visualRect(cb->direction, cb->rect, ret);
4298 }
4299 break;
4300#endif // QT_CONFIG(combobox)
4301 case CC_TitleBar:
4302 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4303 const int controlMargin = 2;
4304 const int controlHeight = tb->rect.height() - controlMargin *2;
4305 const int delta = controlHeight + controlMargin;
4306 int offset = 0;
4307
4308 bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
4309 bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
4310
4311 switch (sc) {
4312 case SC_TitleBarLabel:
4313 if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
4314 ret = tb->rect;
4315 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4316 ret.adjust(delta, 0, -delta, 0);
4317 if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
4318 ret.adjust(0, 0, -delta, 0);
4319 if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
4320 ret.adjust(0, 0, -delta, 0);
4321 if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
4322 ret.adjust(0, 0, -delta, 0);
4323 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4324 ret.adjust(0, 0, -delta, 0);
4325 }
4326 break;
4328 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4329 offset += delta;
4330 Q_FALLTHROUGH();
4332 if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4333 offset += delta;
4334 else if (sc == SC_TitleBarMinButton)
4335 break;
4336 Q_FALLTHROUGH();
4338 if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4339 offset += delta;
4340 else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4341 offset += delta;
4342 else if (sc == SC_TitleBarNormalButton)
4343 break;
4344 Q_FALLTHROUGH();
4346 if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4347 offset += delta;
4348 else if (sc == SC_TitleBarMaxButton)
4349 break;
4350 Q_FALLTHROUGH();
4352 if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4353 offset += delta;
4354 else if (sc == SC_TitleBarShadeButton)
4355 break;
4356 Q_FALLTHROUGH();
4358 if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4359 offset += delta;
4360 else if (sc == SC_TitleBarUnshadeButton)
4361 break;
4362 Q_FALLTHROUGH();
4364 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4365 offset += delta;
4366 else if (sc == SC_TitleBarCloseButton)
4367 break;
4368 ret.setRect(tb->rect.right() - offset, tb->rect.top() + controlMargin,
4369 controlHeight, controlHeight);
4370 break;
4371 case SC_TitleBarSysMenu:
4372 if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
4373 ret.setRect(tb->rect.left() + controlMargin, tb->rect.top() + controlMargin,
4374 controlHeight, controlHeight);
4375 }
4376 break;
4377 default:
4378 break;
4379 }
4380 ret = visualRect(tb->direction, tb->rect, ret);
4381 }
4382 break;
4383#if QT_CONFIG(groupbox)
4384 case CC_GroupBox: {
4385 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4386 switch (sc) {
4387 case SC_GroupBoxFrame:
4388 case SC_GroupBoxContents: {
4389 int topMargin = 0;
4390 int topHeight = 0;
4392 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4393 if (groupBox->text.size() || hasCheckBox) {
4394 int checkBoxHeight = hasCheckBox ? proxy()->pixelMetric(PM_IndicatorHeight, groupBox, widget) : 0;
4395 topHeight = qMax(groupBox->fontMetrics.height(), checkBoxHeight);
4396 if (verticalAlignment & Qt::AlignVCenter)
4397 topMargin = topHeight / 2;
4398 else if (verticalAlignment & Qt::AlignTop)
4399 topMargin = topHeight;
4400 }
4401
4402 QRect frameRect = groupBox->rect;
4403 frameRect.setTop(topMargin);
4404
4405 if (sc == SC_GroupBoxFrame) {
4406 ret = frameRect;
4407 break;
4408 }
4409
4410 int frameWidth = 0;
4411 if ((groupBox->features & QStyleOptionFrame::Flat) == 0)
4413 ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin,
4414 -frameWidth, -frameWidth);
4415 break;
4416 }
4418 case SC_GroupBoxLabel: {
4420 int th = fontMetrics.height();
4421 int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + u' ').width();
4422 int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
4423 ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
4424
4425 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget);
4426 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
4427 int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;
4428 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4429 int checkBoxWidth = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
4430 int checkBoxHeight = hasCheckBox ? indicatorHeight : 0;
4431
4432 int h = qMax(th, checkBoxHeight);
4433 ret.setHeight(h);
4434
4435 // Adjusted rect for label + indicatorWidth + indicatorSpace
4436 QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
4437 QSize(tw + checkBoxWidth, h), ret);
4438
4439 // Adjust totalRect if checkbox is set
4440 if (hasCheckBox) {
4441 bool ltr = groupBox->direction == Qt::LeftToRight;
4442 int left = 0;
4443 // Adjust for check box
4444 if (sc == SC_GroupBoxCheckBox) {
4445 left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
4446 int top = totalRect.top() + (h - checkBoxHeight) / 2;
4447 totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
4448 // Adjust for label
4449 } else {
4450 left = ltr ? (totalRect.left() + checkBoxWidth - 2) : totalRect.left();
4451 int top = totalRect.top() + (h - th) / 2;
4452 totalRect.setRect(left, top, totalRect.width() - checkBoxWidth, th);
4453 }
4454 }
4455 ret = totalRect;
4456 break;
4457 }
4458 default:
4459 break;
4460 }
4461 }
4462 break;
4463 }
4464#endif // QT_CONFIG(groupbox)
4465#if QT_CONFIG(mdiarea)
4466 case CC_MdiControls:
4467 {
4468 int numSubControls = 0;
4469 if (opt->subControls & SC_MdiCloseButton)
4470 ++numSubControls;
4471 if (opt->subControls & SC_MdiMinButton)
4472 ++numSubControls;
4473 if (opt->subControls & SC_MdiNormalButton)
4474 ++numSubControls;
4475 if (numSubControls == 0)
4476 break;
4477
4478 int buttonWidth = opt->rect.width() / numSubControls - 1;
4479 int offset = 0;
4480 switch (sc) {
4481 case SC_MdiCloseButton:
4482 // Only one sub control, no offset needed.
4483 if (numSubControls == 1)
4484 break;
4485 offset += buttonWidth + 2;
4486 Q_FALLTHROUGH();
4487 case SC_MdiNormalButton:
4488 // No offset needed if
4489 // 1) There's only one sub control
4490 // 2) We have a close button and a normal button (offset already added in SC_MdiClose)
4491 if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton)))
4492 break;
4493 if (opt->subControls & SC_MdiNormalButton)
4494 offset += buttonWidth;
4495 break;
4496 default:
4497 break;
4498 }
4499
4500 // Subtract one pixel if we only have one sub control. At this point
4501 // buttonWidth is the actual width + 1 pixel margin, but we don't want the
4502 // margin when there are no other controllers.
4503 if (numSubControls == 1)
4504 --buttonWidth;
4505 ret = QRect(offset, 0, buttonWidth, opt->rect.height());
4506 break;
4507 }
4508#endif // QT_CONFIG(mdiarea)
4509 default:
4510 qCWarning(lcCommonStyle, "QCommonStyle::subControlRect: Case %d not handled", cc);
4511 }
4512#if !QT_CONFIG(slider) && !QT_CONFIG(spinbox) && !QT_CONFIG(toolbutton) && !QT_CONFIG(groupbox)
4514#endif
4515 return ret;
4516}
4517
4520{
4521 int ret;
4522
4523 switch (m) {
4526 ret = 2;
4527 break;
4528 case PM_MenuBarVMargin:
4529 case PM_MenuBarHMargin:
4530 ret = 0;
4531 break;
4533 ret = int(QStyleHelper::dpiScaled(5, opt));
4534 break;
4536 ret = int(QStyleHelper::dpiScaled(70, opt));
4537 break;
4539 ret = int(QStyleHelper::dpiScaled(30, opt));
4540 break;
4541 case PM_TitleBarHeight:
4542 {
4543 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4544 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) {
4546#if QT_CONFIG(dockwidget)
4547 } else if (qobject_cast<const QDockWidget*>(widget)) {
4549#endif
4550 } else {
4552 }
4553 } else {
4554 ret = int(QStyleHelper::dpiScaled(18., opt));
4555 }
4556 break;
4557 }
4559 ret = int(QStyleHelper::dpiScaled(16., opt));
4560 break;
4562 ret = int(QStyleHelper::dpiScaled(16., opt));
4563 break;
4564
4566 ret = int(QStyleHelper::dpiScaled(9., opt));
4567 break;
4568
4569 case PM_ButtonMargin:
4570 ret = int(QStyleHelper::dpiScaled(6., opt));
4571 break;
4572
4574 ret = int(QStyleHelper::dpiScaled(2., opt));
4575 break;
4576
4578 ret = 0;
4579 break;
4580
4582 ret = int(QStyleHelper::dpiScaled(12, opt));
4583 break;
4584
4587
4589 ret = 2;
4590 break;
4591
4594 case PM_MenuPanelWidth:
4598 break;
4599
4601 ret = int(QStyleHelper::dpiScaled(4, opt));
4602 break;
4603
4605 ret = int(QStyleHelper::dpiScaled(196, opt));
4606 break;
4607
4608#if QT_CONFIG(scrollbar)
4609 case PM_ScrollBarExtent:
4610 if (qstyleoption_cast<const QStyleOptionSlider *>(opt))
4611 ret = 16;
4612 else
4613 ret = int(QStyleHelper::dpiScaled(16, opt));
4614 break;
4615#endif
4618 break;
4619
4620#if QT_CONFIG(slider)
4621 case PM_SliderThickness:
4622 ret = int(QStyleHelper::dpiScaled(16, opt));
4623 break;
4624
4626 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4627 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height()
4628 : sl->rect.width();
4629 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget);
4630 int ticks = sl->tickPosition;
4631
4632 if (ticks == QSlider::TicksBothSides)
4633 ret = (space - thickness) / 2;
4634 else if (ticks == QSlider::TicksAbove)
4635 ret = space - thickness;
4636 else
4637 ret = 0;
4638 } else {
4639 ret = 0;
4640 }
4641 break;
4642
4644 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4645 if (sl->orientation == Qt::Horizontal)
4646 ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4647 else
4648 ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4649 } else {
4650 ret = 0;
4651 }
4652 break;
4653#endif // QT_CONFIG(slider)
4654#if QT_CONFIG(dockwidget)
4656 ret = int(QStyleHelper::dpiScaled(6, opt));
4657 break;
4658
4660 ret = int(QStyleHelper::dpiScaled(8, opt));
4661 break;
4663 ret = 0;
4664 break;
4666 ret = 1;
4667 break;
4668#endif // QT_CONFIG(dockwidget)
4669
4672 ret = 2;
4673 break;
4674
4676 ret = 0;
4677 break;
4678
4679#if QT_CONFIG(toolbar)
4681 ret = 1;
4682 break;
4683
4685 ret = 0;
4686 break;
4687
4689 ret = int(QStyleHelper::dpiScaled(4, opt));
4690 break;
4691
4693 ret = int(QStyleHelper::dpiScaled(8, opt));
4694 break;
4695
4697 ret = int(QStyleHelper::dpiScaled(6, opt));
4698 break;
4699
4701 ret = int(QStyleHelper::dpiScaled(12, opt));
4702 break;
4703#endif // QT_CONFIG(toolbar)
4704
4705#if QT_CONFIG(tabbar)
4707 ret = 3;
4708 break;
4709
4710 case PM_TabBarTabHSpace:
4711 ret = int(QStyleHelper::dpiScaled(24, opt));
4712 break;
4713
4715 ret = 0;
4716 break;
4717
4719 ret = 2;
4720 break;
4721
4722 case PM_TabBarTabVSpace:
4723 {
4724 const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt);
4725 if (tb && (tb->shape == QTabBar::RoundedNorth || tb->shape == QTabBar::RoundedSouth
4726 || tb->shape == QTabBar::RoundedWest || tb->shape == QTabBar::RoundedEast))
4727 ret = 8;
4728 else
4729 if (tb && (tb->shape == QTabBar::TriangularWest || tb->shape == QTabBar::TriangularEast))
4730 ret = 3;
4731 else
4732 ret = 2;
4733 break;
4734 }
4735#endif
4736
4738 ret = 9;
4739 break;
4740
4741 case PM_IndicatorWidth:
4742 ret = int(QStyleHelper::dpiScaled(13, opt));
4743 break;
4744
4745 case PM_IndicatorHeight:
4746 ret = int(QStyleHelper::dpiScaled(13, opt));
4747 break;
4748
4750 ret = int(QStyleHelper::dpiScaled(12, opt));
4751 break;
4752
4754 ret = int(QStyleHelper::dpiScaled(12, opt));
4755 break;
4756
4758 ret = int(QStyleHelper::dpiScaled(10, opt));
4759 break;
4760
4762 ret = int(QStyleHelper::dpiScaled(10, opt));
4763 break;
4764
4766 case PM_MenuHMargin:
4767 case PM_MenuVMargin:
4768 ret = 0;
4769 break;
4770
4771 case PM_HeaderMargin:
4772 ret = int(QStyleHelper::dpiScaled(4, opt));
4773 break;
4774 case PM_HeaderMarkSize:
4775 ret = int(QStyleHelper::dpiScaled(16, opt));
4776 break;
4778 ret = int(QStyleHelper::dpiScaled(4, opt));
4779 break;
4781 ret = int(QStyleHelper::dpiScaled(100, opt));
4782 break;
4784 ret = int(QStyleHelper::dpiScaled(30, opt));
4785 break;
4787 ret = int(QStyleHelper::dpiScaled(16, opt));
4788 break;
4790 case PM_LayoutTopMargin:
4793 {
4794 bool isWindow = false;
4795 if (opt) {
4797 } else if (widget) {
4799 }
4800 ret = int(QStyleHelper::dpiScaled(isWindow ? 11 : 9, opt));
4801 break;
4802 }
4805 ret = int(QStyleHelper::dpiScaled(6, opt));
4806 break;
4807
4808 case PM_ToolBarIconSize:
4809 ret = 0;
4811 ret = theme->themeHint(QPlatformTheme::ToolBarIconSize).toInt();
4812 if (ret <= 0)
4813 ret = int(QStyleHelper::dpiScaled(24, opt));
4814 break;
4815
4816 case PM_TabBarIconSize:
4818 break;
4820#if QT_CONFIG(filedialog)
4821 if (qobject_cast<const QSidebar *>(widget))
4822 ret = int(QStyleHelper::dpiScaled(24., opt));
4823 else
4824#endif
4826 break;
4827
4828 case PM_ButtonIconSize:
4829 case PM_SmallIconSize:
4830 ret = int(QStyleHelper::dpiScaled(16, opt));
4831 break;
4834 break;
4837 break;
4840 break;
4841
4842 case PM_LargeIconSize:
4843 ret = int(QStyleHelper::dpiScaled(32, opt));
4844 break;
4845
4847 ret = 1;
4848 break;
4851 ret = int(QStyleHelper::dpiScaled(6, opt));
4852 break;
4853 case PM_SizeGripSize:
4854 ret = int(QStyleHelper::dpiScaled(13, opt));
4855 break;
4857#ifdef Q_OS_MAC
4859 ret = 64; // No DPI scaling, it's handled elsewhere.
4860 } else
4861#endif
4862 {
4863 ret = int(QStyleHelper::dpiScaled(32, opt));
4864 }
4865 break;
4866 case PM_TextCursorWidth:
4868 break;
4870 ret = 1;
4871 break;
4874 ret = int(QStyleHelper::dpiScaled(16, opt));
4875 break;
4878 break;
4880 ret = 0;
4881 break;
4882 case PM_SubMenuOverlap:
4884 break;
4886 ret = int(QStyleHelper::dpiScaled(20, opt));
4887 break;
4888 default:
4889 ret = 0;
4890 break;
4891 }
4892
4893 return ret;
4894}
4895
4900 const QSize &contentsSize, const QWidget *widget) const
4901{
4902 Q_D(const QCommonStyle);
4903 QSize size(contentsSize);
4904 switch (contentsType) {
4905 case CT_PushButton:
4906 if (const auto *buttonOpt = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4907 int width = contentsSize.width();
4908 int height = contentsSize.height();
4909 const int buttonMargin = proxy()->pixelMetric(PM_ButtonMargin, buttonOpt, widget);
4910 const int defaultFrameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, buttonOpt, widget) * 2;
4911 width += buttonMargin + defaultFrameWidth;
4912 height += buttonMargin + defaultFrameWidth;
4913 if (buttonOpt->features.testFlag(QStyleOptionButton::AutoDefaultButton)) {
4914 const int buttonIndicator = proxy()->pixelMetric(PM_ButtonDefaultIndicator,
4915 buttonOpt,
4916 widget) * 2;
4917 width += buttonIndicator;
4918 height += buttonIndicator;
4919 }
4920 size = QSize(width, height);
4921 }
4922 break;
4923 case CT_RadioButton:
4924 case CT_CheckBox:
4925 if (const auto *buttonOpt = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4926 const bool isRadio = (contentsType == CT_RadioButton);
4927
4928 const int width = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
4929 : PM_IndicatorWidth, buttonOpt, widget);
4930 const int height = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
4931 : PM_IndicatorHeight, buttonOpt, widget);
4932
4933 int margins = 0;
4934
4935 // we add 4 pixels for label margins
4936 if (!buttonOpt->icon.isNull() || !buttonOpt->text.isEmpty()) {
4937 margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
4939 }
4940
4941 size += QSize(width + margins, 4);
4942 size.setHeight(qMax(size.height(), height));
4943 }
4944 break;
4945#if QT_CONFIG(menu)
4946 case CT_MenuItem:
4947 if (const auto *menuItemOpt = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4948 const bool checkable = menuItemOpt->menuHasCheckableItems;
4949 const int maxpmw = menuItemOpt->maxIconWidth;
4950 int width = size.width();
4951 int height;
4952 if (menuItemOpt->menuItemType == QStyleOptionMenuItem::Separator) {
4953 width = 10;
4954 height = 2;
4955 } else {
4956 height = menuItemOpt->fontMetrics.height() + 8;
4957 if (!menuItemOpt->icon.isNull()) {
4958 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
4959 height = qMax(height,
4960 menuItemOpt->icon.actualSize(QSize(iconExtent,
4961 iconExtent)).height() + 4);
4962 }
4963 }
4964 if (menuItemOpt->text.contains(u'\t'))
4965 width += 12;
4966 if (maxpmw > 0)
4967 width += maxpmw + 6;
4968 if (checkable && maxpmw < 20)
4969 width += 20 - maxpmw;
4970 if (checkable || maxpmw > 0)
4971 width += 2;
4972 width += 12;
4973 size = QSize(width, height);
4974 }
4975 break;
4976#endif // QT_CONFIG(menu)
4977#if QT_CONFIG(toolbutton)
4978 case CT_ToolButton:
4979 size = QSize(size.width() + 6, size.height() + 5);
4980 break;
4981#endif // QT_CONFIG(toolbutton)
4982#if QT_CONFIG(combobox)
4983 case CT_ComboBox:
4984 if (const auto *comboBoxOpt = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4985 const int frameWidth = comboBoxOpt->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth,
4986 opt,
4987 widget) * 2 : 0;
4988 const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin, opt) + 1);
4989
4990 // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
4991 const int other = qMax(23, 2 * textMargins
4993 opt, widget));
4994
4995 size = QSize(size.width() + frameWidth + other, size.height() + frameWidth);
4996 }
4997 break;
4998#endif // QT_CONFIG(combobox)
4999 case CT_HeaderSection:
5000 if (const auto *headerOpt = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
5001 const bool nullIcon = headerOpt->icon.isNull();
5002 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, headerOpt, widget);
5003 const int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize,
5004 headerOpt,
5005 widget);
5006 const QSize textSize = headerOpt->fontMetrics.size(0, headerOpt->text);
5007 size.setHeight(margin + qMax(iconSize, textSize.height()) + margin);
5008 size.setWidth((nullIcon ? 0 : margin) + iconSize
5009 + (headerOpt->text.isNull() ? 0 : margin) + textSize.width() + margin);
5010 if (headerOpt->sortIndicator != QStyleOptionHeader::None) {
5011 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, headerOpt, widget);
5012 if (headerOpt->orientation == Qt::Horizontal)
5013 size.rwidth() += size.height() + margin;
5014 else
5015 size.rheight() += size.width() + margin;
5016 }
5017 }
5018 break;
5019 case CT_TabWidget:
5020 size += QSize(4, 4);
5021 break;
5022 case CT_LineEdit:
5023 if (const auto *frameOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt))
5024 size += QSize(2 * frameOpt->lineWidth, 2 * frameOpt->lineWidth);
5025 break;
5026#if QT_CONFIG(groupbox)
5027 case CT_GroupBox:
5028 if (const auto *groupBoxOpt = qstyleoption_cast<const QStyleOptionGroupBox *>(opt))
5029 size += QSize(groupBoxOpt->features.testFlag(QStyleOptionFrame::Flat) ? 0 : 16, 0);
5030 break;
5031#endif // QT_CONFIG(groupbox)
5032 case CT_MdiControls:
5033 if (const auto *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
5034 const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, styleOpt, widget);
5035 int width = 1;
5036 if (styleOpt->subControls & SC_MdiMinButton)
5037 width += buttonSize + 1;
5038 if (styleOpt->subControls & SC_MdiNormalButton)
5039 width += buttonSize + 1;
5040 if (styleOpt->subControls & SC_MdiCloseButton)
5041 width += buttonSize + 1;
5042 size = QSize(width, buttonSize);
5043 } else {
5044 const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, opt, widget);
5045 size = QSize(1 + 3 * (buttonSize + 1), buttonSize);
5046 }
5047 break;
5048#if QT_CONFIG(itemviews)
5049 case CT_ItemViewItem:
5050 if (const auto *viewItemOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
5051 QRect decorationRect, displayRect, checkRect;
5052 d->viewItemLayout(viewItemOpt, &checkRect, &decorationRect, &displayRect, true);
5053 size = (decorationRect|displayRect|checkRect).size();
5054 if (decorationRect.isValid() && size.height() == decorationRect.height())
5055 size.rheight() += 2; // Prevent icons from overlapping.
5056 }
5057 break;
5058#else
5059 Q_UNUSED(d);
5060#endif // QT_CONFIG(itemviews)
5061#if QT_CONFIG(spinbox)
5062 case CT_SpinBox:
5063 if (const auto *spinBoxOpt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
5064 // Add button + frame widths
5065 const qreal dpi = QStyleHelper::dpi(opt);
5066 const bool hasButtons = (spinBoxOpt->buttonSymbols != QAbstractSpinBox::NoButtons);
5067 const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0;
5068 const int frameWidth = spinBoxOpt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth,
5069 spinBoxOpt, widget) : 0;
5070
5071 size += QSize(buttonWidth + 2 * frameWidth, 2 * frameWidth);
5072 }
5073 break;
5074#endif
5075 case CT_ScrollBar:
5076 case CT_MenuBar:
5077 case CT_Menu:
5078 case CT_MenuBarItem:
5079 case CT_Slider:
5080 case CT_ProgressBar:
5081 case CT_TabBarTab:
5082 // just return the contentsSize for now
5083 Q_FALLTHROUGH();
5084 default:
5085 break;
5086 }
5087 return size;
5088}
5089
5090
5093 QStyleHintReturn *hret) const
5094{
5095 int ret = 0;
5096
5097 switch (sh) {
5099 ret = false;
5100 break;
5103 break;
5106 break;
5108 ret = true;
5109 break;
5110#if QT_CONFIG(dialogbuttonbox)
5111 case SH_DialogButtons_DefaultButton: // This value not used anywhere.
5113 break;
5114#endif
5115#if QT_CONFIG(groupbox)
5118 break;
5119
5121 ret = opt ? int(opt->palette.color(QPalette::Text).rgba()) : 0;
5122 break;
5123#endif // QT_CONFIG(groupbox)
5124
5128 break;
5129
5130
5133 break;
5134
5137 break;
5138
5140 ret = false;
5141 break;
5142
5144 ret = 256;
5145 break;
5146
5148 ret = true;
5149 break;
5150
5152 ret = false;
5153 break;
5155 ret = 1;
5156 break;
5158 ret = true;
5159 break;
5161 ret = 1000;
5162 break;
5164 ret = false;
5165 break;
5167 ret = false;
5168 break;
5169
5172 break;
5173
5175#if defined(Q_OS_DARWIN)
5176 ret = 0;
5177#else
5178 ret = 1;
5179#endif
5180 break;
5181
5183 if (opt)
5185 else
5186 ret = -1;
5187 break;
5191 const QVariant hint = theme ? theme->themeHint(hintType) : QPlatformTheme::defaultThemeHint(hintType);
5192 ret = hint.toChar().unicode();
5193 break;
5194 }
5197 break;
5199 ret = 1;
5200 break;
5201
5202 case SH_UnderlineShortcut: {
5206 break;
5207 }
5208
5210 ret = 150;
5211 break;
5212
5214 ret = 500;
5215 break;
5216
5218 ret = 75;
5219 break;
5220
5222 ret = true;
5223 break;
5224
5226 ret = true;
5227 break;
5228
5230 ret = 255;
5231 break;
5232
5235 break;
5236
5238 ret = 0;
5239 break;
5240
5242 ret = 600;
5243 break;
5244
5245 case SH_FocusFrame_Mask:
5246 ret = 1;
5247 if (widget) {
5248 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5249 mask->region = widget->rect();
5250 const int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt);
5251 const int hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt);
5252 mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
5253 }
5254 }
5255 break;
5256#if QT_CONFIG(rubberband)
5257 case SH_RubberBand_Mask:
5258 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
5259 ret = 0;
5260 if (rbOpt->shape == QRubberBand::Rectangle) {
5261 ret = true;
5262 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5263 mask->region = opt->rect;
5264 const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, opt) * 2;
5265 mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
5266 }
5267 }
5268 }
5269 break;
5270#endif // QT_CONFIG(rubberband)
5272 ret = 1;
5273 break;
5274
5277 break;
5278
5281 break;
5282
5285 break;
5286
5288 ret = false;
5289 break;
5290
5292 ret = 0;
5294 ret = theme->themeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick).toBool() ? 1 : 0;
5295 break;
5297 ret = true;
5298 break;
5300 ret = false;
5301 break;
5304 break;
5305#if QT_CONFIG(dialogbuttonbox)
5309 ret = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt();
5310 break;
5311#endif
5314 break;
5317 break;
5319 ret = 0;
5321 ret = theme->themeHint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool() ? 1 : 0;
5322 break;
5324 ret = true;
5325 break;
5327 ret = true;
5328 break;
5330 ret = false;
5331 break;
5332#if QT_CONFIG(tabwidget)
5335 break;
5336#endif
5337 case SH_ToolBar_Movable:
5338 ret = true;
5339 break;
5341 ret = true;
5342 if (QStyleHintReturnVariant *vret = qstyleoption_cast<QStyleHintReturnVariant*>(hret)) {
5345 fmt.setProperty(QTextFormat::OutlinePen, outline);
5346 vret->variant = fmt;
5347 }
5348 break;
5349#if QT_CONFIG(wizard)
5350 case SH_WizardStyle:
5352 break;
5353#endif
5354#if QT_CONFIG(formlayout)
5357 break;
5360 break;
5361#endif
5364 break;
5367 break;
5369 ret = false;
5370 break;
5372 ret = 0;
5373 break;
5374#if QT_CONFIG(tabbar)
5377 break;
5379 ret = 500;
5380 break;
5381#endif
5383 ret = true;
5384 break;
5385 case SH_ToolButtonStyle:
5386 ret = 0;
5388 ret = theme->themeHint(QPlatformTheme::ToolButtonStyle).toInt();
5389 break;
5392 break;
5394 ret = false;
5395 break;
5397 ret = false;
5398 break;
5399#if QT_CONFIG(tooltip)
5401 ret = 700;
5402 break;
5404 ret = 2000;
5405 break;
5406#endif
5407 case SH_Widget_Animate:
5408 // TODO Qt6: move this code in the SH_Widget_Animation_Duration case
5409 // and replace false with 0 and true with 200.
5410#if QT_CONFIG(treeview)
5411 if (qobject_cast<const QTreeView*>(widget)) {
5412 ret = false;
5413 } else
5414#endif
5415 {
5416 ret = true;
5417 }
5418 break;
5420 ret = true;
5421 break;
5422#if QT_CONFIG(itemviews)
5425 break;
5426#endif
5428 ret = true;
5429 break;
5431 ret = styleHint(SH_Widget_Animate, opt, widget, hret) ? 200 : 0;
5432 break;
5434 ret = true;
5435 break;
5437 ret = true;
5438 break;
5441 break;
5443 ret = true;
5444 break;
5446 ret = true;
5447 break;
5467 case SH_ComboBox_Popup:
5471 case SH_Menu_Scrollable:
5477 case SH_ToolTip_Mask:
5478 case SH_Menu_Mask:
5484 ret = false;
5485 break;
5488 ret = theme->themeHint(QPlatformTheme::MenuBarFocusOnAltPressRelease).toBool();
5489 break;
5490 case SH_CustomBase:
5491 // Added to get compiler errors when a style hint is missing
5492 ret = false;
5493 break;
5494 }
5495
5496 return ret;
5497}
5498
5499#if QT_CONFIG(imageformat_xpm)
5500static QPixmap cachedPixmapFromXPM(const char * const *xpm)
5501{
5503 const QString tag = QString::asprintf("xpm:0x%p", static_cast<const void*>(xpm));
5504 if (!QPixmapCache::find(tag, &result)) {
5505 result = QPixmap(xpm);
5507 }
5508 return result;
5509}
5510
5511static inline QPixmap titleBarMenuCachedPixmapFromXPM() { return cachedPixmapFromXPM(qt_menu_xpm); }
5512#endif // QT_CONFIG(imageformat_xpm)
5513
5514#ifndef QT_NO_IMAGEFORMAT_PNG
5516{
5517 return QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png");
5518}
5519#endif // !QT_NO_IMAGEFORMAT_PNG
5520
5521#if defined(Q_OS_WIN) || QT_CONFIG(imageformat_png)
5522static QIcon clearTextIcon(bool rtl)
5523{
5524 const QString directionalThemeName = rtl
5525 ? QStringLiteral("edit-clear-locationbar-ltr") : QStringLiteral("edit-clear-locationbar-rtl");
5526 if (QIcon::hasThemeIcon(directionalThemeName))
5527 return QIcon::fromTheme(directionalThemeName);
5528 const QString themeName = QStringLiteral("edit-clear");
5531
5532 QIcon icon;
5533#ifndef QT_NO_IMAGEFORMAT_PNG
5534 QPixmap clearText16(clearText16IconPath());
5535 Q_ASSERT(!clearText16.size().isEmpty());
5536 icon.addPixmap(clearText16);
5537 QPixmap clearText32(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-32.png"));
5538 Q_ASSERT(!clearText32.size().isEmpty());
5539 icon.addPixmap(clearText32);
5540 clearText32.setDevicePixelRatio(2); // The 32x32 pixmap can also be used for 16x16/devicePixelRatio=2
5541 icon.addPixmap(clearText32);
5542#endif // !QT_NO_IMAGEFORMAT_PNG
5543 return icon;
5544}
5545#endif
5546
5549 const QWidget *widget) const
5550{
5551 const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft());
5552#ifdef QT_NO_IMAGEFORMAT_PNG
5554 Q_UNUSED(sp);
5555#else
5557
5559 switch (sp) {
5560 case SP_DialogYesButton:
5561 case SP_DialogOkButton:
5562 pixmap = QIcon::fromTheme("dialog-ok"_L1).pixmap(16);
5563 break;
5565 pixmap = QIcon::fromTheme("dialog-ok-apply"_L1).pixmap(16);
5566 break;
5568 pixmap = QIcon::fromTheme("edit-delete"_L1).pixmap(16);
5569 break;
5571 pixmap = QIcon::fromTheme("dialog-close"_L1).pixmap(16);
5572 break;
5573 case SP_DirHomeIcon:
5574 pixmap = QIcon::fromTheme("user-home"_L1).pixmap(16);
5575 break;
5577 pixmap = QIcon::fromTheme("messagebox_info"_L1).pixmap(16);
5578 break;
5580 pixmap = QIcon::fromTheme("messagebox_warning"_L1).pixmap(16);
5581 break;
5583 pixmap = QIcon::fromTheme("messagebox_critical"_L1).pixmap(16);
5584 break;
5586 pixmap = QIcon::fromTheme("help"_L1).pixmap(16);
5587 break;
5589 case SP_DirOpenIcon:
5590 pixmap = QIcon::fromTheme("folder-open"_L1).pixmap(16);
5591 break;
5592 case SP_FileIcon:
5593 pixmap = QIcon::fromTheme("text-x-generic"_L1, QIcon::fromTheme("empty"_L1)).pixmap(16);
5594 break;
5595 case SP_DirClosedIcon:
5596 case SP_DirIcon:
5597 pixmap = QIcon::fromTheme("folder"_L1).pixmap(16);
5598 break;
5599 case SP_DriveFDIcon:
5600 pixmap = QIcon::fromTheme("media-floppy"_L1,
5601 QIcon::fromTheme("3floppy_unmount"_L1)).pixmap(16);
5602 break;
5603 case SP_ComputerIcon:
5604 pixmap = QIcon::fromTheme("computer"_L1, QIcon::fromTheme("system"_L1)).pixmap(16);
5605 break;
5606 case SP_DesktopIcon:
5607 pixmap = QIcon::fromTheme("user-desktop"_L1,
5608 QIcon::fromTheme("desktop"_L1)).pixmap(16);
5609 break;
5610 case SP_TrashIcon:
5611 pixmap = QIcon::fromTheme("user-trash"_L1,
5612 QIcon::fromTheme("trashcan_empty"_L1)).pixmap(16);
5613 break;
5614 case SP_DriveCDIcon:
5615 case SP_DriveDVDIcon:
5616 pixmap = QIcon::fromTheme("media-optical"_L1,
5617 QIcon::fromTheme("cdrom_unmount"_L1)).pixmap(16);
5618 break;
5619 case SP_DriveHDIcon:
5620 pixmap = QIcon::fromTheme("drive-harddisk"_L1,
5621 QIcon::fromTheme("hdd_unmount"_L1)).pixmap(16);
5622 break;
5624 pixmap = QIcon::fromTheme("go-up"_L1, QIcon::fromTheme("up"_L1)).pixmap(16);
5625 break;
5627 pixmap = QIcon::fromTheme("folder_new"_L1).pixmap(16);
5628 break;
5629 case SP_ArrowUp:
5630 pixmap = QIcon::fromTheme("go-up"_L1,
5631 QIcon::fromTheme("up"_L1)).pixmap(16);
5632 break;
5633 case SP_ArrowDown:
5634 pixmap = QIcon::fromTheme("go-down"_L1, QIcon::fromTheme("down"_L1)).pixmap(16);
5635 break;
5636 case SP_ArrowRight:
5637 pixmap = QIcon::fromTheme("go-next"_L1, QIcon::fromTheme("forward"_L1)).pixmap(16);
5638 break;
5639 case SP_ArrowLeft:
5640 pixmap = QIcon::fromTheme("go-previous"_L1, QIcon::fromTheme("back"_L1)).pixmap(16);
5641 break;
5643 pixmap = QIcon::fromTheme("view_detailed"_L1).pixmap(16);
5644 break;
5646 pixmap = QIcon::fromTheme("view_icon"_L1).pixmap(16);
5647 break;
5648 case SP_BrowserReload:
5649 pixmap = QIcon::fromTheme("reload"_L1).pixmap(16);
5650 break;
5651 case SP_BrowserStop:
5652 pixmap = QIcon::fromTheme("process-stop"_L1).pixmap(16);
5653 break;
5654 case SP_MediaPlay:
5655 pixmap = QIcon::fromTheme("media-playback-start"_L1).pixmap(16);
5656 break;
5657 case SP_MediaPause:
5658 pixmap = QIcon::fromTheme("media-playback-pause"_L1).pixmap(16);
5659 break;
5660 case SP_MediaStop:
5661 pixmap = QIcon::fromTheme("media-playback-stop"_L1).pixmap(16);
5662 break;
5664 pixmap = QIcon::fromTheme("media-seek-forward"_L1).pixmap(16);
5665 break;
5667 pixmap = QIcon::fromTheme("media-seek-backward"_L1).pixmap(16);
5668 break;
5670 pixmap = QIcon::fromTheme("media-skip-forward"_L1).pixmap(16);
5671 break;
5673 pixmap = QIcon::fromTheme("media-skip-backward"_L1).pixmap(16);
5674 break;
5676 pixmap = QIcon::fromTheme("edit-clear"_L1).pixmap(24);
5677 break;
5679 pixmap = QIcon::fromTheme("help-contents"_L1).pixmap(24);
5680 break;
5681 case SP_DialogNoButton:
5683 pixmap = QIcon::fromTheme("dialog-cancel"_L1,
5684 QIcon::fromTheme("process-stop"_L1)).pixmap(24);
5685 break;
5687 pixmap = QIcon::fromTheme("document-save"_L1).pixmap(24);
5688 break;
5689 case SP_FileLinkIcon:
5690 pixmap = QIcon::fromTheme("emblem-symbolic-link"_L1).pixmap(16);
5691 if (!pixmap.isNull()) {
5692 QPixmap fileIcon = QIcon::fromTheme("text-x-generic"_L1).pixmap(16);
5693 if (fileIcon.isNull())
5694 fileIcon = QIcon::fromTheme("empty"_L1).pixmap(16);
5695 if (!fileIcon.isNull()) {
5696 QPainter painter(&fileIcon);
5697 painter.drawPixmap(0, 0, 16, 16, pixmap);
5698 return fileIcon;
5699 }
5700 }
5701 break;
5702 case SP_DirLinkIcon:
5703 pixmap = QIcon::fromTheme("emblem-symbolic-link"_L1).pixmap(16);
5704 if (!pixmap.isNull()) {
5705 QPixmap dirIcon = QIcon::fromTheme("folder"_L1).pixmap(16);
5706 if (!dirIcon.isNull()) {
5707 QPainter painter(&dirIcon);
5708 painter.drawPixmap(0, 0, 16, 16, pixmap);
5709 return dirIcon;
5710 }
5711 }
5712 break;
5714 pixmap = clearTextIcon(rtl).pixmap(16);
5715 break;
5716 default:
5717 break;
5718 }
5719 }
5720
5721 if (!pixmap.isNull())
5722 return pixmap;
5723#endif //QT_NO_IMAGEFORMAT_PNG
5724 switch (sp) {
5725#ifndef QT_NO_IMAGEFORMAT_XPM
5727 if (rtl) {
5729 im = im.convertToFormat(QImage::Format_ARGB32).mirrored(true, false);
5730 return QPixmap::fromImage(im);
5731 }
5732 return cachedPixmapFromXPM(tb_extension_arrow_h_xpm);
5734 return cachedPixmapFromXPM(tb_extension_arrow_v_xpm);
5735 case SP_FileDialogStart:
5736 return cachedPixmapFromXPM(filedialog_start_xpm);
5737 case SP_FileDialogEnd:
5738 return cachedPixmapFromXPM(filedialog_end_xpm);
5739#endif
5740#ifndef QT_NO_IMAGEFORMAT_PNG
5741 case SP_CommandLink:
5742 case SP_ArrowForward:
5743 if (rtl)
5746 case SP_ArrowBack:
5747 if (rtl)
5750 case SP_ArrowLeft:
5751 return QPixmap(":/qt-project.org/styles/commonstyle/images/left-16.png"_L1);
5752 case SP_ArrowRight:
5753 return QPixmap(":/qt-project.org/styles/commonstyle/images/right-16.png"_L1);
5754 case SP_ArrowUp:
5755 return QPixmap(":/qt-project.org/styles/commonstyle/images/up-16.png"_L1);
5756 case SP_ArrowDown:
5757 return QPixmap(":/qt-project.org/styles/commonstyle/images/down-16.png"_L1);
5761 return QPixmap(":/qt-project.org/styles/commonstyle/images/newdirectory-16.png"_L1);
5763 return QPixmap(":/qt-project.org/styles/commonstyle/images/viewdetailed-16.png"_L1);
5765 return QPixmap(":/qt-project.org/styles/commonstyle/images/fileinfo-16.png"_L1);
5767 return QPixmap(":/qt-project.org/styles/commonstyle/images/filecontents-16.png"_L1);
5769 return QPixmap(":/qt-project.org/styles/commonstyle/images/viewlist-16.png"_L1);
5770 case SP_FileDialogBack:
5772 case SP_DriveHDIcon:
5773 return QPixmap(":/qt-project.org/styles/commonstyle/images/harddrive-16.png"_L1);
5774 case SP_TrashIcon:
5775 return QPixmap(":/qt-project.org/styles/commonstyle/images/trash-16.png"_L1);
5776 case SP_DriveFDIcon:
5777 return QPixmap(":/qt-project.org/styles/commonstyle/images/floppy-16.png"_L1);
5778 case SP_DriveNetIcon:
5779 return QPixmap(":/qt-project.org/styles/commonstyle/images/networkdrive-16.png"_L1);
5780 case SP_DesktopIcon:
5781 return QPixmap(":/qt-project.org/styles/commonstyle/images/desktop-16.png"_L1);
5782 case SP_ComputerIcon:
5783 return QPixmap(":/qt-project.org/styles/commonstyle/images/computer-16.png"_L1);
5784 case SP_DriveCDIcon:
5785 return QPixmap(":/qt-project.org/styles/commonstyle/images/cdr-16.png"_L1);
5786 case SP_DriveDVDIcon:
5787 return QPixmap(":/qt-project.org/styles/commonstyle/images/dvd-16.png"_L1);
5788 case SP_DirHomeIcon:
5789 case SP_DirOpenIcon:
5790 return QPixmap(":/qt-project.org/styles/commonstyle/images/diropen-16.png"_L1);
5791 case SP_DirIcon:
5792 case SP_DirClosedIcon:
5793 return QPixmap(":/qt-project.org/styles/commonstyle/images/dirclosed-16.png"_L1);
5794 case SP_DirLinkIcon:
5795 return QPixmap(":/qt-project.org/styles/commonstyle/images/dirlink-16.png"_L1);
5796 case SP_FileIcon:
5797 return QPixmap(":/qt-project.org/styles/commonstyle/images/file-16.png"_L1);
5798 case SP_FileLinkIcon:
5799 return QPixmap(":/qt-project.org/styles/commonstyle/images/filelink-16.png"_L1);
5800 case SP_DialogOkButton:
5801 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-ok-16.png"_L1);
5803 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-16.png"_L1);
5805 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-help-16.png"_L1);
5807 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png"_L1);
5809 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"_L1);
5811 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-close-16.png"_L1);
5813 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-apply-16.png"_L1);
5815 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-clear-16.png"_L1);
5817 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-delete-16.png"_L1);
5818 case SP_DialogYesButton:
5819 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-yes-16.png"_L1);
5820 case SP_DialogNoButton:
5821 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-no-16.png"_L1);
5822 case SP_BrowserReload:
5823 return QPixmap(":/qt-project.org/styles/commonstyle/images/refresh-24.png"_L1);
5824 case SP_BrowserStop:
5825 return QPixmap(":/qt-project.org/styles/commonstyle/images/stop-24.png"_L1);
5826 case SP_MediaPlay:
5827 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-play-32.png"_L1);
5828 case SP_MediaPause:
5829 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-pause-32.png"_L1);
5830 case SP_MediaStop:
5831 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-stop-32.png"_L1);
5833 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-seek-forward-32.png"_L1);
5835 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-seek-backward-32.png"_L1);
5837 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-skip-forward-32.png"_L1);
5839 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-skip-backward-32.png"_L1);
5840 case SP_MediaVolume:
5841 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-volume-16.png"_L1);
5843 return QPixmap(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"_L1);
5845 return QPixmap(clearText16IconPath());
5846 case SP_TabCloseButton:
5847 return QPixmap(":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-16.png"_L1);
5848#endif // QT_NO_IMAGEFORMAT_PNG
5849 default:
5850 break;
5851 }
5852
5853#ifndef QT_NO_IMAGEFORMAT_XPM
5854 switch (sp) {
5856 return titleBarMenuCachedPixmapFromXPM();
5858 return cachedPixmapFromXPM(qt_shade_xpm);
5860 return cachedPixmapFromXPM(qt_unshade_xpm);
5862 return cachedPixmapFromXPM(qt_normalizeup_xpm);
5864 return cachedPixmapFromXPM(qt_minimize_xpm);
5866 return cachedPixmapFromXPM(qt_maximize_xpm);
5868 return cachedPixmapFromXPM(qt_close_xpm);
5870 return cachedPixmapFromXPM(qt_help_xpm);
5872 return cachedPixmapFromXPM(dock_widget_close_xpm);
5874 return cachedPixmapFromXPM(information_xpm);
5876 return cachedPixmapFromXPM(warning_xpm);
5878 return cachedPixmapFromXPM(critical_xpm);
5880 return cachedPixmapFromXPM(question_xpm);
5881 default:
5882 break;
5883 }
5884#endif //QT_NO_IMAGEFORMAT_XPM
5885
5886#if !QT_CONFIG(imageformat_png) && !QT_CONFIG(imageformat_xpm) && !QT_CONFIG(imageformat_png)
5887 Q_UNUSED(rtl);
5888#endif
5889
5890 return QPixmap();
5891}
5892
5893#if QT_CONFIG(imageformat_png)
5894static inline QString iconResourcePrefix() { return QStringLiteral(":/qt-project.org/styles/commonstyle/images/"); }
5895static inline QString iconPngSuffix() { return QStringLiteral(".png"); }
5896
5897static void addIconFiles(const QString &prefix, const int sizes[], size_t count, QIcon &icon)
5898{
5899 for (size_t i = 0; i < count; ++i)
5900 icon.addFile(prefix + QString::number(sizes[i]) + iconPngSuffix());
5901}
5902
5903static const int dockTitleIconSizes[] = {10, 16, 20, 32, 48, 64};
5904static const int titleBarSizes[] = {16, 32, 48};
5905static const int toolBarExtHSizes[] = {8, 16, 32};
5906static const int toolBarExtVSizes[] = {5, 10, 20};
5907#endif // imageformat_png
5908
5913 const QWidget *widget) const
5914{
5915 QIcon icon;
5916 const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft());
5917
5918#ifdef Q_OS_WIN
5919 switch (standardIcon) {
5920 case SP_DriveCDIcon:
5921 case SP_DriveDVDIcon:
5922 case SP_DriveNetIcon:
5923 case SP_DriveHDIcon:
5924 case SP_DriveFDIcon:
5925 case SP_FileIcon:
5926 case SP_FileLinkIcon:
5927 case SP_DesktopIcon:
5928 case SP_ComputerIcon:
5929 case SP_VistaShield:
5936 for (int size = 16 ; size <= 32 ; size += 16) {
5937 QPixmap pixmap = theme->standardPixmap(sp, QSizeF(size, size));
5939 }
5940 }
5941 break;
5942 case SP_DirIcon:
5943 case SP_DirLinkIcon:
5948 for (int size = 16 ; size <= 32 ; size += 16) {
5949 QSizeF pixSize(size, size);
5950 QPixmap pixmap = theme->standardPixmap(spOff, pixSize);
5952 pixmap = theme->standardPixmap(spOn, pixSize);
5954 }
5955 }
5956 break;
5958 icon = clearTextIcon(rtl);
5959 break;
5960 default:
5961 break;
5962 }
5963 if (!icon.isNull())
5964 return icon;
5965
5966#endif
5967
5969 switch (standardIcon) {
5970 case SP_DirHomeIcon:
5971 icon = QIcon::fromTheme("user-home"_L1);
5972 break;
5974 icon = QIcon::fromTheme("dialog-information"_L1);
5975 break;
5977 icon = QIcon::fromTheme("dialog-warning"_L1);
5978 break;
5980 icon = QIcon::fromTheme("dialog-error"_L1);
5981 break;
5983 icon = QIcon::fromTheme("dialog-question"_L1);
5984 break;
5986 case SP_DirOpenIcon:
5987 icon = QIcon::fromTheme("folder-open"_L1);
5988 break;
5990 icon = QIcon::fromTheme("document-save"_L1);
5991 break;
5993 icon = QIcon::fromTheme("dialog-ok-apply"_L1);
5994 break;
5995 case SP_DialogYesButton:
5996 case SP_DialogOkButton:
5997 icon = QIcon::fromTheme("dialog-ok"_L1);
5998 break;
6000 icon = QIcon::fromTheme("edit-delete"_L1);
6001 break;
6003 icon = QIcon::fromTheme("edit-clear"_L1);
6004 break;
6006 icon = QIcon::fromTheme("help-contents"_L1);
6007 break;
6008 case SP_FileIcon:
6009 icon = QIcon::fromTheme("text-x-generic"_L1);
6010 break;
6011 case SP_DirClosedIcon:
6012 case SP_DirIcon:
6013 icon = QIcon::fromTheme("folder"_L1);
6014 break;
6015 case SP_DriveFDIcon:
6016 icon = QIcon::fromTheme("floppy_unmount"_L1);
6017 break;
6018 case SP_ComputerIcon:
6019 icon = QIcon::fromTheme("computer"_L1, QIcon::fromTheme("system"_L1));
6020 break;
6021 case SP_DesktopIcon:
6022 icon = QIcon::fromTheme("user-desktop"_L1);
6023 break;
6024 case SP_TrashIcon:
6025 icon = QIcon::fromTheme("user-trash"_L1);
6026 break;
6027 case SP_DriveCDIcon:
6028 case SP_DriveDVDIcon:
6029 icon = QIcon::fromTheme("media-optical"_L1);
6030 break;
6031 case SP_DriveHDIcon:
6032 icon = QIcon::fromTheme("drive-harddisk"_L1);
6033 break;
6035 icon = QIcon::fromTheme("go-up"_L1);
6036 break;
6038 icon = QIcon::fromTheme("folder-new"_L1);
6039 break;
6040 case SP_ArrowUp:
6041 icon = QIcon::fromTheme("go-up"_L1);
6042 break;
6043 case SP_ArrowDown:
6044 icon = QIcon::fromTheme("go-down"_L1);
6045 break;
6046 case SP_ArrowRight:
6047 icon = QIcon::fromTheme("go-next"_L1);
6048 break;
6049 case SP_ArrowLeft:
6050 icon = QIcon::fromTheme("go-previous"_L1);
6051 break;
6052 case SP_DialogNoButton:
6054 icon = QIcon::fromTheme("dialog-cancel"_L1, QIcon::fromTheme("process-stop"_L1));
6055 break;
6057 icon = QIcon::fromTheme("window-close"_L1);
6058 break;
6060 icon = QIcon::fromTheme("view-list-details"_L1);
6061 break;
6063 icon = QIcon::fromTheme("view-list-icons"_L1);
6064 break;
6065 case SP_BrowserReload:
6066 icon = QIcon::fromTheme("view-refresh"_L1);
6067 break;
6068 case SP_BrowserStop:
6069 icon = QIcon::fromTheme("process-stop"_L1);
6070 break;
6071 case SP_MediaPlay:
6072 icon = QIcon::fromTheme("media-playback-start"_L1);
6073 break;
6074 case SP_MediaPause:
6075 icon = QIcon::fromTheme("media-playback-pause"_L1);
6076 break;
6077 case SP_MediaStop:
6078 icon = QIcon::fromTheme("media-playback-stop"_L1);
6079 break;
6081 icon = QIcon::fromTheme("media-seek-forward"_L1);
6082 break;
6084 icon = QIcon::fromTheme("media-seek-backward"_L1);
6085 break;
6087 icon = QIcon::fromTheme("media-skip-forward"_L1);
6088 break;
6090 icon = QIcon::fromTheme("media-skip-backward"_L1);
6091 break;
6092 case SP_MediaVolume:
6093 icon = QIcon::fromTheme("audio-volume-medium"_L1);
6094 break;
6096 icon = QIcon::fromTheme("audio-volume-muted"_L1);
6097 break;
6098 case SP_ArrowForward:
6099 if (rtl)
6102 case SP_ArrowBack:
6103 if (rtl)
6106 case SP_FileLinkIcon:
6107 {
6108 QIcon linkIcon = QIcon::fromTheme("emblem-symbolic-link"_L1);
6109 if (!linkIcon.isNull()) {
6112 for (int i = 0 ; i < sizes.size() ; ++i) {
6113 int size = sizes[i].width();
6114 QPixmap basePixmap = baseIcon.pixmap(QSize(size, size), qt_getDevicePixelRatio(widget));
6115 QPixmap linkPixmap = linkIcon.pixmap(QSize(size / 2, size / 2), qt_getDevicePixelRatio(widget));
6116 QPainter painter(&basePixmap);
6117 painter.drawPixmap(size/2, size/2, linkPixmap);
6118 icon.addPixmap(basePixmap);
6119 }
6120 }
6121 }
6122 break;
6123 case SP_DirLinkIcon:
6124 {
6125 QIcon linkIcon = QIcon::fromTheme("emblem-symbolic-link"_L1);
6126 if (!linkIcon.isNull()) {
6129 for (int i = 0 ; i < sizes.size() ; ++i) {
6130 int size = sizes[i].width();
6131 QPixmap basePixmap = baseIcon.pixmap(QSize(size, size), qt_getDevicePixelRatio(widget));
6132 QPixmap linkPixmap = linkIcon.pixmap(QSize(size / 2, size / 2), qt_getDevicePixelRatio(widget));
6133 QPainter painter(&basePixmap);
6134 painter.drawPixmap(size/2, size/2, linkPixmap);
6135 icon.addPixmap(basePixmap);
6136 }
6137 }
6138 }
6139 break;
6140 default:
6141 break;
6142 }
6143 } // if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty())
6144
6145 if (!icon.isNull())
6146 return icon;
6147
6148#if defined(Q_OS_MAC)
6150 switch (standardIcon) {
6151 case SP_DirIcon: {
6152 // A rather special case
6155 closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On);
6156 closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On);
6157 closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On);
6158 closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On);
6159 return closeIcon;
6160 }
6161
6164 QIcon titleBarIcon;
6166 ? QStringLiteral(":/qt-project.org/styles/macstyle/images/closedock-")
6167 : QStringLiteral(":/qt-project.org/styles/macstyle/images/dockdock-");
6168 for (const auto size : dockTitleIconSizes) {
6169 titleBarIcon.addFile(prefix + QStringLiteral("macstyle-") + QString::number(size) + iconPngSuffix(),
6171 titleBarIcon.addFile(prefix + QStringLiteral("down-macstyle-") + QString::number(size) + iconPngSuffix(),
6173 }
6174 return titleBarIcon;
6175 }
6176
6181 case SP_DesktopIcon:
6182 case SP_TrashIcon:
6183 case SP_ComputerIcon:
6184 case SP_DriveFDIcon:
6185 case SP_DriveHDIcon:
6186 case SP_DriveCDIcon:
6187 case SP_DriveDVDIcon:
6188 case SP_DriveNetIcon:
6189 case SP_DirOpenIcon:
6190 case SP_DirClosedIcon:
6191 case SP_DirLinkIcon:
6192 case SP_FileLinkIcon:
6193 case SP_FileIcon:
6196 QIcon retIcon;
6198 for (const QSize &size : sizes) {
6199 QPixmap mainIcon;
6200 const QString cacheKey = "qt_mac_constructQIconFromIconRef"_L1 + QString::number(standardIcon) + QString::number(size.width());
6202 mainIcon = theme->standardPixmap(sp, QSizeF(size));
6203 } else if (QPixmapCache::find(cacheKey, &mainIcon) == false) {
6204 mainIcon = theme->standardPixmap(sp, QSizeF(size));
6205 QPixmapCache::insert(cacheKey, mainIcon);
6206 }
6207
6208 retIcon.addPixmap(mainIcon);
6209 }
6210 if (!retIcon.isNull())
6211 return retIcon;
6212 }
6213
6214 default:
6215 break;
6216 }
6217 } // if (QGuiApplication::desktopSettingsAware())
6218#endif // Q_OS_MAC
6219
6220 switch (standardIcon) {
6221#ifndef QT_NO_IMAGEFORMAT_PNG
6223 addIconFiles(iconResourcePrefix() + QStringLiteral("titlebar-min-"),
6224 titleBarSizes, sizeof(titleBarSizes)/sizeof(titleBarSizes[0]), icon);
6225 break;
6227 addIconFiles(iconResourcePrefix() + QStringLiteral("titlebar-max-"),
6228 titleBarSizes, sizeof(titleBarSizes)/sizeof(titleBarSizes[0]), icon);
6229 break;
6231 addIconFiles(iconResourcePrefix() + QStringLiteral("titlebar-shade-"),
6232 titleBarSizes, sizeof(titleBarSizes)/sizeof(titleBarSizes[0]), icon);
6233
6234 break;
6236 addIconFiles(iconResourcePrefix() + QStringLiteral("titlebar-unshade-"),
6237 titleBarSizes, sizeof(titleBarSizes)/sizeof(titleBarSizes[0]), icon);
6238 break;
6240 addIconFiles(iconResourcePrefix() + QStringLiteral("titlebar-contexthelp-"),
6241 titleBarSizes, sizeof(titleBarSizes)/sizeof(titleBarSizes[0]), icon);
6242 break;
6244 icon.addFile(":/qt-project.org/styles/commonstyle/images/newdirectory-16.png"_L1, QSize(16, 16));
6245 icon.addFile(":/qt-project.org/styles/commonstyle/images/newdirectory-32.png"_L1, QSize(32, 32));
6246 icon.addFile(":/qt-project.org/styles/commonstyle/images/newdirectory-128.png"_L1, QSize(128, 128));
6247 break;
6248 case SP_FileDialogBack:
6253 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewdetailed-16.png"_L1, QSize(16, 16));
6254 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewdetailed-32.png"_L1, QSize(32, 32));
6255 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewdetailed-128.png"_L1, QSize(128, 128));
6256 break;
6258 icon.addFile(":/qt-project.org/styles/commonstyle/images/fileinfo-16.png"_L1, QSize(16, 16));
6259 icon.addFile(":/qt-project.org/styles/commonstyle/images/fileinfo-32.png"_L1, QSize(32, 32));
6260 icon.addFile(":/qt-project.org/styles/commonstyle/images/fileinfo-128.png"_L1, QSize(128, 128));
6261 break;
6263 icon.addFile(":/qt-project.org/styles/commonstyle/images/filecontents-16.png"_L1, QSize(16, 16));
6264 icon.addFile(":/qt-project.org/styles/commonstyle/images/filecontents-32.png"_L1, QSize(32, 32));
6265 icon.addFile(":/qt-project.org/styles/commonstyle/images/filecontents-128.png"_L1, QSize(128, 128));
6266 break;
6268 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewlist-16.png"_L1, QSize(16, 16));
6269 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewlist-32.png"_L1, QSize(32, 32));
6270 icon.addFile(":/qt-project.org/styles/commonstyle/images/viewlist-128.png"_L1, QSize(128, 128));
6271 break;
6272 case SP_DialogOkButton:
6273 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-ok-16.png"_L1, QSize(16, 16));
6274 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-ok-32.png"_L1, QSize(32, 32));
6275 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-ok-128.png"_L1, QSize(128, 128));
6276 break;
6278 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-16.png"_L1, QSize(16, 16));
6279 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-32.png"_L1, QSize(32, 32));
6280 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-128.png"_L1, QSize(128, 128));
6281 break;
6283 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-help-16.png"_L1, QSize(16, 16));
6284 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-help-32.png"_L1, QSize(32, 32));
6285 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-help-128.png"_L1, QSize(128, 128));
6286 break;
6288 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png"_L1, QSize(16, 16));
6289 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png"_L1, QSize(32, 32));
6290 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png"_L1, QSize(128, 128));
6291 break;
6293 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"_L1, QSize(16, 16));
6294 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"_L1, QSize(32, 32));
6295 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"_L1, QSize(128, 128));
6296 break;
6298 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-close-16.png"_L1, QSize(16, 16));
6299 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-close-32.png"_L1, QSize(32, 32));
6300 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-close-128.png"_L1, QSize(128, 128));
6301 break;
6303 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-apply-16.png"_L1, QSize(16, 16));
6304 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-apply-32.png"_L1, QSize(32, 32));
6305 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-apply-128.png"_L1, QSize(128, 128));
6306 break;
6308 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-clear-16.png"_L1, QSize(16, 16));
6309 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-clear-32.png"_L1, QSize(32, 32));
6310 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-clear-128.png"_L1, QSize(128, 128));
6311 break;
6313 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-delete-16.png"_L1, QSize(16, 16));
6314 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-delete-32.png"_L1, QSize(32, 32));
6315 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-delete-128.png"_L1, QSize(128, 128));
6316 break;
6317 case SP_DialogYesButton:
6318 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-yes-16.png"_L1, QSize(16, 16));
6319 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-yes-32.png"_L1, QSize(32, 32));
6320 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-yes-128.png"_L1, QSize(128, 128));
6321 break;
6322 case SP_DialogNoButton:
6323 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-no-16.png"_L1, QSize(16, 16));
6324 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-no-32.png"_L1, QSize(32, 32));
6325 icon.addFile(":/qt-project.org/styles/commonstyle/images/standardbutton-no-128.png"_L1, QSize(128, 128));
6326 break;
6327 case SP_ArrowForward:
6328 if (rtl)
6331 case SP_ArrowBack:
6332 if (rtl)
6335 case SP_ArrowLeft:
6336 icon.addFile(":/qt-project.org/styles/commonstyle/images/left-16.png"_L1, QSize(16, 16));
6337 icon.addFile(":/qt-project.org/styles/commonstyle/images/left-32.png"_L1, QSize(32, 32));
6338 icon.addFile(":/qt-project.org/styles/commonstyle/images/left-128.png"_L1, QSize(128, 128));
6339 break;
6340 case SP_ArrowRight:
6341 icon.addFile(":/qt-project.org/styles/commonstyle/images/right-16.png"_L1, QSize(16, 16));
6342 icon.addFile(":/qt-project.org/styles/commonstyle/images/right-32.png"_L1, QSize(32, 32));
6343 icon.addFile(":/qt-project.org/styles/commonstyle/images/right-128.png"_L1, QSize(128, 128));
6344 break;
6345 case SP_ArrowUp:
6346 icon.addFile(":/qt-project.org/styles/commonstyle/images/up-16.png"_L1, QSize(16, 16));
6347 icon.addFile(":/qt-project.org/styles/commonstyle/images/up-32.png"_L1, QSize(32, 32));
6348 icon.addFile(":/qt-project.org/styles/commonstyle/images/up-128.png"_L1, QSize(128, 128));
6349 break;
6350 case SP_ArrowDown:
6351 icon.addFile(":/qt-project.org/styles/commonstyle/images/down-16.png"_L1, QSize(16, 16));
6352 icon.addFile(":/qt-project.org/styles/commonstyle/images/down-32.png"_L1, QSize(32, 32));
6353 icon.addFile(":/qt-project.org/styles/commonstyle/images/down-128.png"_L1, QSize(128, 128));
6354 break;
6355 case SP_DirHomeIcon:
6356 case SP_DirIcon:
6357 icon.addFile(":/qt-project.org/styles/commonstyle/images/dirclosed-16.png"_L1,
6359 icon.addFile(":/qt-project.org/styles/commonstyle/images/diropen-16.png"_L1,
6361 icon.addFile(":/qt-project.org/styles/commonstyle/images/dirclosed-32.png"_L1,
6362 QSize(32, 32), QIcon::Normal, QIcon::Off);
6363 icon.addFile(":/qt-project.org/styles/commonstyle/images/diropen-32.png"_L1,
6364 QSize(32, 32), QIcon::Normal, QIcon::On);
6365 icon.addFile(":/qt-project.org/styles/commonstyle/images/dirclosed-128.png"_L1,
6366 QSize(128, 128), QIcon::Normal, QIcon::Off);
6367 icon.addFile(":/qt-project.org/styles/commonstyle/images/diropen-128.png"_L1,
6368 QSize(128, 128), QIcon::Normal, QIcon::On);
6369 break;
6370 case SP_DriveCDIcon:
6371 icon.addFile(":/qt-project.org/styles/commonstyle/images/cdr-16.png"_L1, QSize(16, 16));
6372 icon.addFile(":/qt-project.org/styles/commonstyle/images/cdr-32.png"_L1, QSize(32, 32));
6373 icon.addFile(":/qt-project.org/styles/commonstyle/images/cdr-128.png"_L1, QSize(128, 128));
6374 break;
6375 case SP_DriveDVDIcon:
6376 icon.addFile(":/qt-project.org/styles/commonstyle/images/dvd-16.png"_L1, QSize(16, 16));
6377 icon.addFile(":/qt-project.org/styles/commonstyle/images/dvd-32.png"_L1, QSize(32, 32));
6378 icon.addFile(":/qt-project.org/styles/commonstyle/images/dvd-128.png"_L1, QSize(128, 128));
6379 break;
6380 case SP_FileIcon:
6381 icon.addFile(":/qt-project.org/styles/commonstyle/images/file-16.png"_L1, QSize(16, 16));
6382 icon.addFile(":/qt-project.org/styles/commonstyle/images/file-32.png"_L1, QSize(32, 32));
6383 icon.addFile(":/qt-project.org/styles/commonstyle/images/file-128.png"_L1, QSize(128, 128));
6384 break;
6385 case SP_FileLinkIcon:
6386 icon.addFile(":/qt-project.org/styles/commonstyle/images/filelink-16.png"_L1, QSize(16, 16));
6387 icon.addFile(":/qt-project.org/styles/commonstyle/images/filelink-32.png"_L1, QSize(32, 32));
6388 icon.addFile(":/qt-project.org/styles/commonstyle/images/filelink-128.png"_L1, QSize(128, 128));
6389 break;
6390 case SP_TrashIcon:
6391 icon.addFile(":/qt-project.org/styles/commonstyle/images/trash-16.png"_L1, QSize(16, 16));
6392 icon.addFile(":/qt-project.org/styles/commonstyle/images/trash-32.png"_L1, QSize(32, 32));
6393 icon.addFile(":/qt-project.org/styles/commonstyle/images/trash-128.png"_L1, QSize(128, 128));
6394 break;
6395 case SP_BrowserReload:
6396 icon.addFile(":/qt-project.org/styles/commonstyle/images/refresh-24.png"_L1, QSize(24, 24));
6397 icon.addFile(":/qt-project.org/styles/commonstyle/images/refresh-32.png"_L1, QSize(32, 32));
6398 break;
6399 case SP_BrowserStop:
6400 icon.addFile(":/qt-project.org/styles/commonstyle/images/stop-24.png"_L1, QSize(24, 24));
6401 icon.addFile(":/qt-project.org/styles/commonstyle/images/stop-32.png"_L1, QSize(32, 32));
6402 break;
6403 case SP_MediaPlay:
6404 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-play-16.png"_L1, QSize(16, 16));
6405 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-play-32.png"_L1, QSize(32, 32));
6406 break;
6407 case SP_MediaPause:
6408 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-pause-16.png"_L1, QSize(16, 16));
6409 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-pause-32.png"_L1, QSize(32, 32));
6410 break;
6411 case SP_MediaStop:
6412 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-stop-16.png"_L1, QSize(16, 16));
6413 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-stop-32.png"_L1, QSize(32, 32));
6414 break;
6416 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-seek-forward-16.png"_L1, QSize(16, 16));
6417 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-seek-forward-32.png"_L1, QSize(32, 32));
6418 break;
6420 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-seek-backward-16.png"_L1, QSize(16, 16));
6421 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-seek-backward-32.png"_L1, QSize(32, 32));
6422 break;
6424 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-skip-forward-16.png"_L1, QSize(16, 16));
6425 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-skip-forward-32.png"_L1, QSize(32, 32));
6426 break;
6428 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-skip-backward-16.png"_L1, QSize(16, 16));
6429 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-skip-backward-32.png"_L1, QSize(32, 32));
6430 break;
6431 case SP_MediaVolume:
6432 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-volume-16.png"_L1, QSize(16, 16));
6433 break;
6435 icon.addFile(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"_L1, QSize(16, 16));
6436 break;
6438 addIconFiles(iconResourcePrefix() + QStringLiteral("closedock-"),
6439 dockTitleIconSizes, sizeof(dockTitleIconSizes)/sizeof(dockTitleIconSizes[0]), icon);
6440 break;
6442# ifndef QT_NO_IMAGEFORMAT_XPM
6443 icon.addPixmap(titleBarMenuCachedPixmapFromXPM());
6444# endif
6445 icon.addFile(":/qt-project.org/qmessagebox/images/qtlogo-64.png"_L1);
6446 break;
6448 addIconFiles(iconResourcePrefix() + QStringLiteral("normalizedockup-"),
6449 dockTitleIconSizes, sizeof(dockTitleIconSizes)/sizeof(dockTitleIconSizes[0]), icon);
6450 break;
6452 QString prefix = iconResourcePrefix() + QStringLiteral("toolbar-ext-h-");
6453 if (rtl)
6454 prefix += QStringLiteral("rtl-");
6455 addIconFiles(prefix, toolBarExtHSizes, sizeof(toolBarExtHSizes)/sizeof(toolBarExtHSizes[0]), icon);
6456 }
6457 break;
6459 addIconFiles(iconResourcePrefix() + QStringLiteral("toolbar-ext-v-"),
6460 toolBarExtVSizes, sizeof(toolBarExtVSizes)/sizeof(toolBarExtVSizes[0]), icon);
6461 break;
6462 case SP_TabCloseButton:
6463 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-16.png", QSize(16, 16),
6465 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-32.png", QSize(32, 32),
6467 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-down-16.png", QSize(16, 16),
6469 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-down-32.png", QSize(32, 32),
6471 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-hover-16.png", QSize(16, 16),
6473 icon.addFile(iconResourcePrefix() + u"standardbutton-closetab-hover-32.png", QSize(32, 32),
6475 break;
6476#endif // QT_NO_IMAGEFORMAT_PNG
6477 default:
6479 break;
6480 }
6481 return icon;
6482}
6483
6484static inline uint qt_intensity(uint r, uint g, uint b)
6485{
6486 // 30% red, 59% green, 11% blue
6487 return (77 * r + 150 * g + 28 * b) / 255;
6488}
6489
6492 const QStyleOption *opt) const
6493{
6494 switch (iconMode) {
6495 case QIcon::Disabled: {
6496 QImage im = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
6497
6498 // Create a colortable based on the background (black -> bg -> white)
6500 int red = bg.red();
6501 int green = bg.green();
6502 int blue = bg.blue();
6503 uchar reds[256], greens[256], blues[256];
6504 for (int i=0; i<128; ++i) {
6505 reds[i] = uchar((red * (i<<1)) >> 8);
6506 greens[i] = uchar((green * (i<<1)) >> 8);
6507 blues[i] = uchar((blue * (i<<1)) >> 8);
6508 }
6509 for (int i=0; i<128; ++i) {
6510 reds[i+128] = uchar(qMin(red + (i << 1), 255));
6511 greens[i+128] = uchar(qMin(green + (i << 1), 255));
6512 blues[i+128] = uchar(qMin(blue + (i << 1), 255));
6513 }
6514
6515 int intensity = qt_intensity(red, green, blue);
6516 const int factor = 191;
6517
6518 // High intensity colors needs dark shifting in the color table, while
6519 // low intensity colors needs light shifting. This is to increase the
6520 // perceived contrast.
6521 if ((red - factor > green && red - factor > blue)
6522 || (green - factor > red && green - factor > blue)
6523 || (blue - factor > red && blue - factor > green))
6524 intensity = qMin(255, intensity + 91);
6525 else if (intensity <= 128)
6526 intensity -= 51;
6527
6528 for (int y=0; y<im.height(); ++y) {
6529 QRgb *scanLine = (QRgb*)im.scanLine(y);
6530 for (int x=0; x<im.width(); ++x) {
6531 QRgb pixel = *scanLine;
6532 // Calculate color table index, taking intensity adjustment
6533 // and a magic offset into account.
6534 uint ci = uint(qGray(pixel)/3 + (130 - intensity / 3));
6535 *scanLine = qRgba(reds[ci], greens[ci], blues[ci], qAlpha(pixel));
6536 ++scanLine;
6537 }
6538 }
6539
6540 return QPixmap::fromImage(im);
6541 }
6542 case QIcon::Selected: {
6543 QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
6545 color.setAlphaF(0.3f);
6548 painter.fillRect(0, 0, img.width(), img.height(), color);
6549 painter.end();
6550 return QPixmap::fromImage(img); }
6551 case QIcon::Active:
6552 return pixmap;
6553 default:
6554 break;
6555 }
6556 return pixmap;
6557}
6558
6563 Qt::Orientation /* orientation */, const QStyleOption * /* option */,
6564 const QWidget * /* widget */) const
6565{
6566 return -1;
6567}
6568
6573{
6574 QStyle::polish(pal);
6575}
6576
6581{
6583}
6584
6589{
6591}
6592
6597{
6599}
6600
6605{
6606 Q_D(const QCommonStyle);
6607 d->tabBarcloseButtonIcon = QIcon();
6608 QStyle::unpolish(application);
6609}
6610
6611
6613
6614#include "moc_qcommonstyle.cpp"
void stop()
Stops the animation.
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
QIcon icon
the icon shown on the button
QSize iconSize
the icon size used for this button.
QString text
the text shown on the button
\inmodule QtGui
The QApplication class manages the GUI application's control flow and main settings.
\inmodule QtGui
Definition qbrush.h:30
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
\inmodule QtCore
Definition qchar.h:48
@ LineSeparator
Definition qchar.h:64
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
Definition qchar.h:458
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
Definition qcolor.cpp:1376
int red() const noexcept
Returns the red color component of this color.
Definition qcolor.cpp:1528
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 getHsv(int *h, int *s, int *v, int *a=nullptr) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
Definition qcolor.cpp:1045
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
Definition qcolor.h:285
QString calculateElidedText(const QString &text, const QTextOption &textOption, const QFont &font, const QRect &textRect, const Qt::Alignment valign, Qt::TextElideMode textElideMode, int flags, bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
~QCommonStyle()
Destroys the style.
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
QCommonStyle()
Constructs a QCommonStyle.
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 layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=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
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition qdockwidget.h:20
@ MouseButtonPress
Definition qcoreevent.h:60
Definition qflags.h:17
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
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
@ AllNonFixedFieldsGrow
Definition qformlayout.h:36
@ Plain
Definition qframe.h:49
@ Raised
Definition qframe.h:50
@ Sunken
Definition qframe.h:51
int midLineWidth
the width of the mid-line
Definition qframe.h:23
@ Panel
Definition qframe.h:41
@ HLine
Definition qframe.h:43
@ StyledPanel
Definition qframe.h:45
@ NoFrame
Definition qframe.h:39
@ Box
Definition qframe.h:40
@ VLine
Definition qframe.h:44
@ WinPanel
Definition qframe.h:42
int lineWidth
the line width
Definition qframe.h:22
void setColorAt(qreal pos, const QColor &color)
Creates a stop point at the given position with the given color.
Definition qbrush.cpp:1563
static QPlatformTheme * platformTheme()
static bool isRightToLeft()
Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.
static bool desktopSettingsAware()
Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false.
QIcon windowIcon
the default window icon
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
static bool hasThemeIcon(const QString &name)
Definition qicon.cpp:1340
static QString themeName()
Definition qicon.cpp:1221
void addPixmap(const QPixmap &pixmap, Mode mode=Normal, State state=Off)
Adds pixmap to the icon, as a specialization for mode and state.
Definition qicon.cpp:1014
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
@ Selected
Definition qicon.h:22
@ Normal
Definition qicon.h:22
@ Active
Definition qicon.h:22
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
Definition qicon.cpp:1098
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition qicon.cpp:773
void addFile(const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
Adds an image from the file with the given fileName to the icon, as a specialization for size,...
Definition qicon.cpp:1067
State
This enum describes the state for which a pixmap is intended to be used.
Definition qicon.h:23
@ Off
Definition qicon.h:23
@ On
Definition qicon.h:23
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition qicon.cpp:880
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition qicon.cpp:788
static QIcon fromTheme(const QString &name)
Definition qicon.cpp:1296
\inmodule QtGui
Definition qimage.h:37
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition qimage.cpp:1615
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_ARGB32
Definition qimage.h:47
QImage mirrored(bool horizontally=false, bool vertically=true) const &
Definition qimage.h:218
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition qimage.h:124
QMargins contentsMargins
Definition qlayout.h:32
\inmodule QtCore
Definition qline.h:182
\inmodule QtGui
Definition qbrush.h:394
Definition qlist.h:74
T value(qsizetype i) const
Definition qlist.h:661
\inmodule QtCore
Definition qmargins.h:23
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:119
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:110
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:116
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:113
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition qobject.cpp:2521
qreal devicePixelRatio() const
\inmodule QtGui
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition qpainter.h:519
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
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 setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
@ Antialiasing
Definition qpainter.h:52
bool end()
Ends painting.
@ CompositionMode_SourceAtop
Definition qpainter.h:107
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
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.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition qpalette.h:97
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:83
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:87
const QBrush & toolTipBase() const
Definition qpalette.h:90
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition qpalette.h:82
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition qpalette.h:85
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 & toolTipText() const
Definition qpalette.h:91
const QBrush & light() const
Returns the light brush of the current color group.
Definition qpalette.h:84
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
Definition qpalette.h:64
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:66
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition qpalette.h:86
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
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:48
@ Inactive
Definition qpalette.h:48
@ Disabled
Definition qpalette.h:48
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 & window() const
Returns the window (general background) brush of the current color group.
Definition qpalette.h:92
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:88
@ HighlightedText
Definition qpalette.h:52
@ AlternateBase
Definition qpalette.h:54
@ ButtonText
Definition qpalette.h:51
@ WindowText
Definition qpalette.h:50
@ Highlight
Definition qpalette.h:52
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition qpalette.h:95
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition qpalette.h:98
\inmodule QtGui
Definition qpen.h:25
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition qpen.cpp:618
void setColor(const QColor &color)
Sets the color of this pen's brush to the given color.
Definition qpen.cpp:731
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
int height() const
Returns the height of the pixmap.
Definition qpixmap.cpp:484
QImage toImage() const
Converts the pixmap to a QImage.
Definition qpixmap.cpp:412
QSize size() const
Returns the size of the pixmap.
Definition qpixmap.cpp:497
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:460
int width() const
Returns the width of the pixmap.
Definition qpixmap.cpp:472
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
Definition qpixmap.cpp:580
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1445
The QPlatformTheme class allows customizing the UI based on themes.
virtual QVariant themeHint(ThemeHint hint) const
static QVariant defaultThemeHint(ThemeHint hint)
ThemeHint
This enum describes the available theme hints.
@ DialogButtonBoxButtonsHaveIcons
@ ItemViewActivateItemOnSingleClick
\inmodule QtCore\reentrant
Definition qpoint.h:214
constexpr qreal & ry() noexcept
Returns a reference to the y coordinate of this point.
Definition qpoint.h:358
\inmodule QtCore\reentrant
Definition qpoint.h:23
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
The QPolygon class provides a list of points using integer precision.
Definition qpolygon.h:23
\inmodule QtCore\reentrant
Definition qrect.h:483
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:721
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
Definition qrect.h:166
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 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 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 void setRect(int x, int y, int w, int h) noexcept
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
Definition qrect.h:345
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 QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
constexpr QRect transposed() const noexcept
Definition qrect.h:266
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 void setCoords(int x1, int y1, int x2, int y2) noexcept
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its botto...
Definition qrect.h:361
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 QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
Definition qrect.h:260
QRect united(const QRect &other) const noexcept
Definition qrect.h:419
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 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
\inmodule QtCore
Definition qsize.h:207
constexpr QSize toSize() const noexcept
Returns an integer based copy of this size.
Definition qsize.h:390
\inmodule QtCore
Definition qsize.h:25
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition qsize.h:196
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 QSize transposed() const noexcept
Definition qsize.h:141
constexpr int & rwidth() noexcept
Returns a reference to the width.
Definition qsize.h:153
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
@ TicksBothSides
Definition qslider.h:31
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString & replace(qsizetype i, qsizetype len, QChar after)
Definition qstring.cpp:3794
void chop(qsizetype n)
Removes n characters from the end of the string.
Definition qstring.cpp:6180
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition qstring.h:898
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 endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition qstring.cpp:5350
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
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Definition qstring.cpp:7005
The QStyleHintReturnMask class provides style hints that return a QRegion.
The QStyleHintReturnVariant class provides style hints that return a QVariant.
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionHeaderV2::textElideMode
ButtonFeatures features
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
QStyle::SubControls subControls
QStyle::SubControls activeSubControls
\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
\variable QStyleOptionButton::features
\variable QStyleOptionToolBox::selectedPosition
\variable QStyleOptionComboBox::editable
\variable QStyleOptionDockWidget::title
ToolButtonFeatures features
Qt::ToolButtonStyle toolButtonStyle
Qt::ArrowType arrowType
The QStyleOption class stores the parameters used by QStyle functions.
QFontMetrics fontMetrics
QStyle::State state
QPalette palette
Qt::LayoutDirection direction
QStyle * proxyStyle
Definition qstyle_p.h:38
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ State_Sibling
Definition qstyle.h:88
@ State_Window
Definition qstyle.h:84
@ State_Editing
Definition qstyle.h:89
@ State_MouseOver
Definition qstyle.h:80
@ State_Item
Definition qstyle.h:87
@ State_Sunken
Definition qstyle.h:69
@ State_HasFocus
Definition qstyle.h:75
@ State_Active
Definition qstyle.h:83
@ State_Off
Definition qstyle.h:70
@ State_Children
Definition qstyle.h:86
@ State_Open
Definition qstyle.h:85
@ State_NoChange
Definition qstyle.h:71
@ State_AutoRaise
Definition qstyle.h:79
@ State_KeyboardFocusChange
Definition qstyle.h:90
@ State_Enabled
Definition qstyle.h:67
@ State_DownArrow
Definition qstyle.h:73
@ State_Horizontal
Definition qstyle.h:74
@ State_On
Definition qstyle.h:72
@ State_Raised
Definition qstyle.h:68
@ State_Selected
Definition qstyle.h:82
@ State_None
Definition qstyle.h:66
ContentsType
This enum describes the available contents types.
Definition qstyle.h:544
@ CT_Menu
Definition qstyle.h:555
@ CT_ProgressBar
Definition qstyle.h:551
@ CT_CheckBox
Definition qstyle.h:546
@ CT_ItemViewItem
Definition qstyle.h:567
@ CT_SpinBox
Definition qstyle.h:560
@ CT_ToolButton
Definition qstyle.h:548
@ CT_MenuBar
Definition qstyle.h:554
@ CT_PushButton
Definition qstyle.h:545
@ CT_MenuItem
Definition qstyle.h:552
@ CT_RadioButton
Definition qstyle.h:547
@ CT_MenuBarItem
Definition qstyle.h:553
@ CT_MdiControls
Definition qstyle.h:566
@ CT_TabBarTab
Definition qstyle.h:556
@ CT_LineEdit
Definition qstyle.h:559
@ CT_ScrollBar
Definition qstyle.h:558
@ CT_HeaderSection
Definition qstyle.h:564
@ CT_TabWidget
Definition qstyle.h:562
@ CT_Slider
Definition qstyle.h:557
@ CT_ComboBox
Definition qstyle.h:549
@ CT_GroupBox
Definition qstyle.h:565
virtual void polish(QWidget *widget)
Initializes the appearance of the given widget.
Definition qstyle.cpp:436
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
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
Definition qstyle.cpp:2203
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
StyleHint
This enum describes the available style hints.
Definition qstyle.h:582
@ SH_TitleBar_ShowToolTipsOnButtons
Definition qstyle.h:697
@ SH_ToolBar_Movable
Definition qstyle.h:670
@ SH_TabBar_ElideMode
Definition qstyle.h:650
@ SH_ComboBox_ListMouseTracking
Definition qstyle.h:602
@ SH_GroupBox_TextLabelColor
Definition qstyle.h:615
@ SH_TabBar_CloseButtonPosition
Definition qstyle.h:675
@ SH_Slider_PageSetButtons
Definition qstyle.h:648
@ SH_TitleBar_NoBorder
Definition qstyle.h:609
@ SH_Menu_Scrollable
Definition qstyle.h:613
@ SH_ScrollView_FrameOnlyAroundContents
Definition qstyle.h:600
@ SH_Splitter_OpaqueResize
Definition qstyle.h:684
@ SH_MainWindow_SpaceBelowMenuBar
Definition qstyle.h:595
@ SH_ProgressDialog_CenterCancelButton
Definition qstyle.h:592
@ SH_Menu_Mask
Definition qstyle.h:663
@ SH_ComboBox_Popup
Definition qstyle.h:608
@ SH_EtchDisabledText
Definition qstyle.h:583
@ SH_SpinBox_AnimateButton
Definition qstyle.h:625
@ SH_Menu_SubMenuUniDirectionFailCount
Definition qstyle.h:691
@ SH_TextControl_FocusIndicatorTextCharFormat
Definition qstyle.h:660
@ SH_MessageBox_UseBorderForButtonSpacing
Definition qstyle.h:633
@ SH_SpinBox_ClickAutoRepeatRate
Definition qstyle.h:627
@ SH_TabBar_Alignment
Definition qstyle.h:588
@ SH_ItemView_PaintAlternatingRowColorsForEmptyArea
Definition qstyle.h:667
@ SH_ComboBox_UseNativePopup
Definition qstyle.h:687
@ SH_ItemView_ChangeHighlightOnFocus
Definition qstyle.h:605
@ SH_SpinBox_KeyPressAutoRepeatRate
Definition qstyle.h:626
@ SH_ItemView_MovementWithoutUpdatingSelection
Definition qstyle.h:657
@ SH_MenuBar_AltKeyNavigation
Definition qstyle.h:601
@ SH_Menu_SubMenuUniDirection
Definition qstyle.h:690
@ SH_CustomBase
Definition qstyle.h:707
@ SH_ScrollBar_RollBetweenButtons
Definition qstyle.h:646
@ SH_Menu_MouseTracking
Definition qstyle.h:603
@ SH_ScrollBar_Transient
Definition qstyle.h:679
@ SH_Table_GridLineColor
Definition qstyle.h:617
@ SH_TabBar_AllowWheelScrolling
Definition qstyle.h:702
@ SH_SpinControls_DisableOnBounds
Definition qstyle.h:639
@ SH_ScrollBar_MiddleClickAbsolutePosition
Definition qstyle.h:585
@ SH_Menu_FlashTriggeredItem
Definition qstyle.h:664
@ SH_Menu_SubMenuPopupDelay
Definition qstyle.h:599
@ SH_ItemView_ArrowKeysNavigateIntoChildren
Definition qstyle.h:662
@ SH_Slider_AbsoluteSetButtons
Definition qstyle.h:647
@ SH_Widget_Animation_Duration
Definition qstyle.h:698
@ SH_Menu_SubMenuResetWhenReenteringParent
Definition qstyle.h:694
@ SH_ComboBox_PopupFrameStyle
Definition qstyle.h:652
@ SH_Slider_SloppyKeyEvents
Definition qstyle.h:591
@ SH_TabWidget_DefaultTabPosition
Definition qstyle.h:669
@ SH_DitherDisabledText
Definition qstyle.h:584
@ SH_TabBar_ChangeCurrentDelay
Definition qstyle.h:689
@ SH_Header_ArrowAlignment
Definition qstyle.h:589
@ SH_Widget_Animate
Definition qstyle.h:683
@ SH_ToolBox_SelectedPageTitleBold
Definition qstyle.h:620
@ SH_LineEdit_PasswordMaskDelay
Definition qstyle.h:688
@ SH_SpinBox_SelectOnStep
Definition qstyle.h:704
@ SH_ToolButtonStyle
Definition qstyle.h:677
@ SH_TabBar_PreferNoArrows
Definition qstyle.h:621
@ SH_Menu_KeyboardSearch
Definition qstyle.h:649
@ SH_Button_FocusPolicy
Definition qstyle.h:632
@ SH_Menu_SupportsSections
Definition qstyle.h:680
@ SH_Menu_SubMenuSloppySelectOtherActions
Definition qstyle.h:692
@ SH_Menu_SelectionWrap
Definition qstyle.h:656
@ SH_FormLayoutWrapPolicy
Definition qstyle.h:668
@ SH_Widget_ShareActivation
Definition qstyle.h:606
@ SH_ComboBox_LayoutDirection
Definition qstyle.h:641
@ SH_DialogButtons_DefaultButton
Definition qstyle.h:619
@ SH_ComboBox_AllowWheelScrolling
Definition qstyle.h:699
@ SH_ToolButton_PopupDelay
Definition qstyle.h:635
@ SH_Menu_AllowActiveAndDisabled
Definition qstyle.h:597
@ SH_SpinBox_StepModifier
Definition qstyle.h:701
@ SH_TabBar_SelectMouseType
Definition qstyle.h:587
@ SH_Menu_FillScreenWithScroll
Definition qstyle.h:628
@ SH_Table_AlwaysDrawLeftTopGridLines
Definition qstyle.h:703
@ SH_FontDialog_SelectAssociatedText
Definition qstyle.h:596
@ SH_ToolTipLabel_Opacity
Definition qstyle.h:629
@ SH_ScrollBar_LeftClickAbsolutePosition
Definition qstyle.h:622
@ SH_DialogButtonBox_ButtonsHaveIcons
Definition qstyle.h:654
@ SH_MenuBar_MouseTracking
Definition qstyle.h:604
@ SH_FormLayoutFieldGrowthPolicy
Definition qstyle.h:671
@ SH_UnderlineShortcut
Definition qstyle.h:624
@ SH_SpinBox_ClickAutoRepeatThreshold
Definition qstyle.h:666
@ SH_ScrollBar_ContextMenu
Definition qstyle.h:645
@ SH_FormLayoutFormAlignment
Definition qstyle.h:672
@ SH_Menu_SubMenuDontStartSloppyOnLeave
Definition qstyle.h:695
@ SH_MessageBox_CenterButtons
Definition qstyle.h:655
@ SH_TitleBar_ModifyNotification
Definition qstyle.h:631
@ SH_Slider_StopMouseOverSlider
Definition qstyle.h:610
@ SH_DrawMenuBarSeparator
Definition qstyle.h:630
@ SH_RequestSoftwareInputPanel
Definition qstyle.h:678
@ SH_ToolTip_Mask
Definition qstyle.h:658
@ SH_Slider_SnapToValue
Definition qstyle.h:590
@ SH_LineEdit_PasswordCharacter
Definition qstyle.h:618
@ SH_SpinBox_ButtonsInsideFrame
Definition qstyle.h:700
@ SH_ItemView_DrawDelegateFrame
Definition qstyle.h:674
@ SH_Menu_FadeOutOnHide
Definition qstyle.h:665
@ SH_GroupBox_TextLabelVerticalAlignment
Definition qstyle.h:614
@ SH_ItemView_ScrollMode
Definition qstyle.h:696
@ SH_ScrollBar_ScrollWhenPointerLeavesControl
Definition qstyle.h:586
@ SH_ToolTip_FallAsleepDelay
Definition qstyle.h:682
@ SH_PrintDialog_RightAlignButtons
Definition qstyle.h:594
@ SH_BlinkCursorWhenTextSelected
Definition qstyle.h:611
@ SH_DialogButtonLayout
Definition qstyle.h:651
@ SH_TitleBar_AutoRaise
Definition qstyle.h:634
@ SH_ListViewExpand_SelectMouseType
Definition qstyle.h:623
@ SH_ItemView_EllipsisLocation
Definition qstyle.h:642
@ SH_ItemView_ActivateItemOnSingleClick
Definition qstyle.h:644
@ SH_MessageBox_TextInteractionFlags
Definition qstyle.h:653
@ SH_WindowFrame_Mask
Definition qstyle.h:638
@ SH_RichText_FullWidthSelection
Definition qstyle.h:612
@ SH_Menu_SloppySubMenus
Definition qstyle.h:616
@ SH_RubberBand_Mask
Definition qstyle.h:637
@ SH_FormLayoutLabelAlignment
Definition qstyle.h:673
@ SH_ItemView_ShowDecorationSelected
Definition qstyle.h:643
@ SH_DockWidget_ButtonsHaveFrame
Definition qstyle.h:676
@ SH_WizardStyle
Definition qstyle.h:661
@ SH_Menu_SpaceActivatesItem
Definition qstyle.h:598
@ SH_ToolTip_WakeUpDelay
Definition qstyle.h:681
@ SH_FocusFrame_AboveWidget
Definition qstyle.h:659
@ SH_FocusFrame_Mask
Definition qstyle.h:636
@ SH_ProgressDialog_TextLabelAlignment
Definition qstyle.h:593
@ SH_Dial_BackgroundRole
Definition qstyle.h:640
@ SH_Menu_SubMenuSloppyCloseTimeout
Definition qstyle.h:693
@ SH_Workspace_FillSpaceOnMaximize
Definition qstyle.h:607
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual ~QStyle()
Destroys the style object.
Definition qstyle.cpp:384
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
virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
Returns the area within the given rectangle in which to draw the provided text according to the speci...
Definition qstyle.cpp:510
StandardPixmap
This enum describes the available standard pixmaps.
Definition qstyle.h:714
@ SP_DockWidgetCloseButton
Definition qstyle.h:723
@ SP_DirIcon
Definition qstyle.h:753
@ SP_FileIcon
Definition qstyle.h:740
@ SP_ArrowForward
Definition qstyle.h:770
@ SP_DirLinkIcon
Definition qstyle.h:738
@ SP_MediaVolume
Definition qstyle.h:783
@ SP_DriveNetIcon
Definition qstyle.h:735
@ SP_TitleBarCloseButton
Definition qstyle.h:718
@ SP_BrowserStop
Definition qstyle.h:775
@ SP_ComputerIcon
Definition qstyle.h:730
@ SP_MediaPlay
Definition qstyle.h:776
@ SP_FileDialogBack
Definition qstyle.h:752
@ SP_DialogDiscardButton
Definition qstyle.h:762
@ SP_MediaSkipBackward
Definition qstyle.h:780
@ SP_TitleBarMenuButton
Definition qstyle.h:715
@ SP_DesktopIcon
Definition qstyle.h:728
@ SP_DriveCDIcon
Definition qstyle.h:733
@ SP_TrashIcon
Definition qstyle.h:729
@ SP_DialogNoButton
Definition qstyle.h:764
@ SP_TitleBarMinButton
Definition qstyle.h:716
@ SP_MediaSeekBackward
Definition qstyle.h:782
@ SP_DialogCloseButton
Definition qstyle.h:759
@ SP_TitleBarMaxButton
Definition qstyle.h:717
@ SP_FileDialogListView
Definition qstyle.h:751
@ SP_MediaStop
Definition qstyle.h:777
@ SP_TitleBarContextHelpButton
Definition qstyle.h:722
@ SP_DirHomeIcon
Definition qstyle.h:771
@ SP_MediaSeekForward
Definition qstyle.h:781
@ SP_MediaVolumeMuted
Definition qstyle.h:784
@ SP_DialogOpenButton
Definition qstyle.h:757
@ SP_TitleBarNormalButton
Definition qstyle.h:719
@ SP_MessageBoxQuestion
Definition qstyle.h:727
@ SP_LineEditClearButton
Definition qstyle.h:785
@ SP_CommandLink
Definition qstyle.h:772
@ SP_ArrowBack
Definition qstyle.h:769
@ SP_ArrowDown
Definition qstyle.h:766
@ SP_TitleBarShadeButton
Definition qstyle.h:720
@ SP_TabCloseButton
Definition qstyle.h:793
@ SP_VistaShield
Definition qstyle.h:773
@ SP_FileDialogNewFolder
Definition qstyle.h:747
@ SP_FileDialogEnd
Definition qstyle.h:745
@ SP_CustomBase
Definition qstyle.h:796
@ SP_FileDialogInfoView
Definition qstyle.h:749
@ SP_ArrowLeft
Definition qstyle.h:767
@ SP_DialogCancelButton
Definition qstyle.h:755
@ SP_FileDialogStart
Definition qstyle.h:744
@ SP_MediaPause
Definition qstyle.h:778
@ SP_DriveHDIcon
Definition qstyle.h:732
@ SP_DriveDVDIcon
Definition qstyle.h:734
@ SP_DriveFDIcon
Definition qstyle.h:731
@ SP_BrowserReload
Definition qstyle.h:774
@ SP_DialogHelpButton
Definition qstyle.h:756
@ SP_DialogSaveButton
Definition qstyle.h:758
@ SP_FileDialogDetailedView
Definition qstyle.h:748
@ SP_MessageBoxCritical
Definition qstyle.h:726
@ SP_MediaSkipForward
Definition qstyle.h:779
@ SP_MessageBoxInformation
Definition qstyle.h:724
@ SP_DialogResetButton
Definition qstyle.h:761
@ SP_DialogOkButton
Definition qstyle.h:754
@ SP_ArrowUp
Definition qstyle.h:765
@ SP_FileDialogContentsView
Definition qstyle.h:750
@ SP_TitleBarUnshadeButton
Definition qstyle.h:721
@ SP_DialogYesButton
Definition qstyle.h:763
@ SP_FileDialogToParent
Definition qstyle.h:746
@ SP_FileLinkIcon
Definition qstyle.h:741
@ SP_ToolBarVerticalExtensionButton
Definition qstyle.h:743
@ SP_DialogApplyButton
Definition qstyle.h:760
@ SP_ToolBarHorizontalExtensionButton
Definition qstyle.h:742
@ SP_MessageBoxWarning
Definition qstyle.h:725
@ SP_ArrowRight
Definition qstyle.h:768
@ SP_DirOpenIcon
Definition qstyle.h:736
@ SP_DirClosedIcon
Definition qstyle.h:737
ControlElement
This enum represents a control element.
Definition qstyle.h:170
@ CE_ColumnViewGrip
Definition qstyle.h:228
@ CE_CheckBox
Definition qstyle.h:175
@ CE_ScrollBarAddLine
Definition qstyle.h:212
@ CE_ProgressBarLabel
Definition qstyle.h:188
@ CE_ScrollBarAddPage
Definition qstyle.h:214
@ CE_DockWidgetTitle
Definition qstyle.h:210
@ CE_Header
Definition qstyle.h:202
@ CE_TabBarTabLabel
Definition qstyle.h:183
@ CE_ScrollBarSubLine
Definition qstyle.h:213
@ CE_ToolBoxTab
Definition qstyle.h:206
@ CE_ShapedFrame
Definition qstyle.h:232
@ CE_RadioButton
Definition qstyle.h:178
@ CE_ToolButtonLabel
Definition qstyle.h:200
@ CE_ItemViewItem
Definition qstyle.h:230
@ CE_RubberBand
Definition qstyle.h:209
@ CE_HeaderSection
Definition qstyle.h:203
@ CE_TabBarTabShape
Definition qstyle.h:182
@ CE_RadioButtonLabel
Definition qstyle.h:179
@ CE_ProgressBarContents
Definition qstyle.h:187
@ CE_ToolBar
Definition qstyle.h:223
@ CE_ScrollBarFirst
Definition qstyle.h:217
@ CE_MenuBarItem
Definition qstyle.h:197
@ CE_FocusFrame
Definition qstyle.h:220
@ CE_CheckBoxLabel
Definition qstyle.h:176
@ CE_ProgressBar
Definition qstyle.h:185
@ CE_PushButton
Definition qstyle.h:171
@ CE_ScrollBarLast
Definition qstyle.h:218
@ CE_ToolBoxTabShape
Definition qstyle.h:224
@ CE_HeaderLabel
Definition qstyle.h:204
@ CE_MenuTearoff
Definition qstyle.h:194
@ CE_PushButtonBevel
Definition qstyle.h:172
@ CE_HeaderEmptyArea
Definition qstyle.h:226
@ CE_ComboBoxLabel
Definition qstyle.h:221
@ CE_MenuBarEmptyArea
Definition qstyle.h:198
@ CE_ToolBoxTabLabel
Definition qstyle.h:225
@ CE_TabBarTab
Definition qstyle.h:181
@ CE_SizeGrip
Definition qstyle.h:207
@ CE_ProgressBarGroove
Definition qstyle.h:186
@ CE_ScrollBarSubPage
Definition qstyle.h:215
@ CE_ScrollBarSlider
Definition qstyle.h:216
@ CE_MenuScroller
Definition qstyle.h:191
@ CE_PushButtonLabel
Definition qstyle.h:173
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
Definition qstyle.cpp:2174
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const =0
Returns the sub-area for the given element as described in the provided style option.
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
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
Definition qstyle.cpp:2144
PixelMetric
This enum describes the various available pixel metrics.
Definition qstyle.h:413
@ PM_MenuVMargin
Definition qstyle.h:452
@ PM_LayoutBottomMargin
Definition qstyle.h:513
@ PM_MenuBarHMargin
Definition qstyle.h:460
@ PM_FocusFrameVMargin
Definition qstyle.h:496
@ PM_MenuPanelWidth
Definition qstyle.h:453
@ PM_TabBar_ScrollButtonOverlap
Definition qstyle.h:516
@ PM_TextCursorWidth
Definition qstyle.h:518
@ PM_ScrollBarExtent
Definition qstyle.h:426
@ PM_TitleBarButtonIconSize
Definition qstyle.h:531
@ PM_DockWidgetFrameWidth
Definition qstyle.h:437
@ PM_TitleBarButtonSize
Definition qstyle.h:532
@ PM_TitleBarHeight
Definition qstyle.h:448
@ PM_SizeGripSize
Definition qstyle.h:502
@ PM_DockWidgetTitleMargin
Definition qstyle.h:503
@ PM_ExclusiveIndicatorHeight
Definition qstyle.h:465
@ PM_TabBarTabHSpace
Definition qstyle.h:440
@ PM_LayoutLeftMargin
Definition qstyle.h:510
@ PM_LineEditIconMargin
Definition qstyle.h:535
@ PM_DefaultFrameWidth
Definition qstyle.h:420
@ PM_MaximumDragDistance
Definition qstyle.h:424
@ PM_ToolBarHandleExtent
Definition qstyle.h:482
@ PM_ButtonShiftHorizontal
Definition qstyle.h:417
@ PM_MdiSubWindowFrameWidth
Definition qstyle.h:471
@ PM_ToolBarItemSpacing
Definition qstyle.h:483
@ PM_DockWidgetTitleBarButtonMargin
Definition qstyle.h:507
@ PM_ToolBarSeparatorExtent
Definition qstyle.h:485
@ PM_IndicatorWidth
Definition qstyle.h:462
@ PM_TabBarBaseOverlap
Definition qstyle.h:443
@ PM_HeaderDefaultSectionSizeHorizontal
Definition qstyle.h:528
@ PM_ScrollView_ScrollBarOverlap
Definition qstyle.h:524
@ PM_DockWidgetSeparatorExtent
Definition qstyle.h:435
@ PM_TabCloseIndicatorWidth
Definition qstyle.h:520
@ PM_MenuTearoffHeight
Definition qstyle.h:454
@ PM_CheckBoxLabelSpacing
Definition qstyle.h:500
@ PM_LayoutVerticalSpacing
Definition qstyle.h:515
@ PM_TabBarTabShiftVertical
Definition qstyle.h:478
@ PM_LayoutHorizontalSpacing
Definition qstyle.h:514
@ PM_TabBarBaseHeight
Definition qstyle.h:442
@ PM_SliderTickmarkOffset
Definition qstyle.h:432
@ PM_ButtonShiftVertical
Definition qstyle.h:418
@ PM_MessageBoxIconSize
Definition qstyle.h:504
@ PM_IndicatorHeight
Definition qstyle.h:463
@ PM_ButtonDefaultIndicator
Definition qstyle.h:415
@ PM_LayoutTopMargin
Definition qstyle.h:511
@ PM_SliderControlThickness
Definition qstyle.h:430
@ PM_ComboBoxFrameWidth
Definition qstyle.h:422
@ PM_MenuBarPanelWidth
Definition qstyle.h:457
@ PM_ToolBarItemMargin
Definition qstyle.h:484
@ PM_SliderSpaceAvailable
Definition qstyle.h:433
@ PM_ToolBarIconSize
Definition qstyle.h:490
@ PM_MenuButtonIndicator
Definition qstyle.h:416
@ PM_MenuDesktopFrameWidth
Definition qstyle.h:455
@ PM_HeaderMargin
Definition qstyle.h:474
@ PM_TabBarIconSize
Definition qstyle.h:501
@ PM_LineEditIconSize
Definition qstyle.h:534
@ PM_TabBarTabVSpace
Definition qstyle.h:441
@ PM_MenuHMargin
Definition qstyle.h:451
@ PM_SmallIconSize
Definition qstyle.h:493
@ PM_HeaderMarkSize
Definition qstyle.h:475
@ PM_ProgressBarChunkWidth
Definition qstyle.h:445
@ PM_LargeIconSize
Definition qstyle.h:494
@ PM_MenuBarItemSpacing
Definition qstyle.h:458
@ PM_DialogButtonsSeparator
Definition qstyle.h:467
@ PM_IconViewIconSize
Definition qstyle.h:492
@ PM_ListViewIconSize
Definition qstyle.h:491
@ PM_SubMenuOverlap
Definition qstyle.h:525
@ PM_TabBarScrollButtonWidth
Definition qstyle.h:479
@ PM_DockWidgetHandleExtent
Definition qstyle.h:436
@ PM_SpinBoxSliderHeight
Definition qstyle.h:488
@ PM_ButtonMargin
Definition qstyle.h:414
@ PM_ToolBarExtensionExtent
Definition qstyle.h:486
@ PM_TabCloseIndicatorHeight
Definition qstyle.h:521
@ PM_SliderThickness
Definition qstyle.h:429
@ PM_HeaderDefaultSectionSizeVertical
Definition qstyle.h:529
@ PM_SliderLength
Definition qstyle.h:431
@ PM_DialogButtonsButtonHeight
Definition qstyle.h:469
@ PM_TreeViewIndentation
Definition qstyle.h:526
@ PM_DialogButtonsButtonWidth
Definition qstyle.h:468
@ PM_RadioButtonLabelSpacing
Definition qstyle.h:509
@ PM_TabBarTabShiftHorizontal
Definition qstyle.h:477
@ PM_ScrollView_ScrollBarSpacing
Definition qstyle.h:523
@ PM_MdiSubWindowMinimizedWidth
Definition qstyle.h:472
@ PM_SpinBoxFrameWidth
Definition qstyle.h:421
@ PM_LayoutRightMargin
Definition qstyle.h:512
@ PM_FocusFrameHMargin
Definition qstyle.h:497
@ PM_ExclusiveIndicatorWidth
Definition qstyle.h:464
@ PM_ToolTipLabelFrameWidth
Definition qstyle.h:499
@ PM_MenuScrollerHeight
Definition qstyle.h:450
@ PM_TabBarTabOverlap
Definition qstyle.h:439
@ PM_ScrollBarSliderMin
Definition qstyle.h:427
@ PM_MenuBarVMargin
Definition qstyle.h:459
@ PM_ButtonIconSize
Definition qstyle.h:505
@ PM_ToolBarFrameWidth
Definition qstyle.h:481
@ PM_HeaderGripMargin
Definition qstyle.h:476
@ RSIP_OnMouseClick
Definition qstyle.h:578
ComplexControl
This enum describes the available complex controls.
Definition qstyle.h:331
@ CC_MdiControls
Definition qstyle.h:340
@ CC_ComboBox
Definition qstyle.h:333
@ CC_GroupBox
Definition qstyle.h:339
@ CC_Slider
Definition qstyle.h:335
@ CC_Dial
Definition qstyle.h:338
@ CC_ToolButton
Definition qstyle.h:336
@ CC_TitleBar
Definition qstyle.h:337
@ CC_SpinBox
Definition qstyle.h:332
@ CC_ScrollBar
Definition qstyle.h:334
PrimitiveElement
This enum describes the various primitive elements.
Definition qstyle.h:102
@ PE_IndicatorToolBarHandle
Definition qstyle.h:141
@ PE_FrameButtonTool
Definition qstyle.h:114
@ PE_PanelMenu
Definition qstyle.h:159
@ PE_IndicatorArrowLeft
Definition qstyle.h:125
@ PE_PanelToolBar
Definition qstyle.h:121
@ PE_PanelButtonTool
Definition qstyle.h:119
@ PE_IndicatorArrowRight
Definition qstyle.h:126
@ PE_IndicatorSpinDown
Definition qstyle.h:137
@ PE_FrameLineEdit
Definition qstyle.h:108
@ PE_PanelLineEdit
Definition qstyle.h:122
@ PE_IndicatorHeaderArrow
Definition qstyle.h:133
@ PE_PanelScrollAreaCorner
Definition qstyle.h:146
@ PE_IndicatorButtonDropDown
Definition qstyle.h:129
@ PE_FrameTabWidget
Definition qstyle.h:111
@ PE_FrameGroupBox
Definition qstyle.h:107
@ PE_PanelButtonCommand
Definition qstyle.h:117
@ PE_PanelItemViewRow
Definition qstyle.h:154
@ PE_IndicatorSpinMinus
Definition qstyle.h:138
@ PE_IndicatorArrowDown
Definition qstyle.h:124
@ PE_FrameWindow
Definition qstyle.h:112
@ PE_FrameButtonBevel
Definition qstyle.h:113
@ PE_IndicatorCheckBox
Definition qstyle.h:131
@ PE_IndicatorSpinUp
Definition qstyle.h:140
@ PE_IndicatorProgressChunk
Definition qstyle.h:135
@ PE_IndicatorColumnViewArrow
Definition qstyle.h:150
@ PE_IndicatorItemViewItemDrop
Definition qstyle.h:151
@ PE_PanelTipLabel
Definition qstyle.h:143
@ PE_PanelMenuBar
Definition qstyle.h:120
@ PE_Frame
Definition qstyle.h:103
@ PE_PanelButtonBevel
Definition qstyle.h:118
@ PE_IndicatorRadioButton
Definition qstyle.h:136
@ PE_IndicatorToolBarSeparator
Definition qstyle.h:142
@ PE_FrameTabBarBase
Definition qstyle.h:115
@ PE_IndicatorArrowUp
Definition qstyle.h:127
@ PE_FrameDockWidget
Definition qstyle.h:105
@ PE_IndicatorSpinPlus
Definition qstyle.h:139
@ PE_IndicatorMenuCheckMark
Definition qstyle.h:134
@ PE_IndicatorBranch
Definition qstyle.h:128
@ PE_FrameDefaultButton
Definition qstyle.h:104
@ PE_FrameFocusRect
Definition qstyle.h:106
@ PE_FrameMenu
Definition qstyle.h:109
@ PE_PanelItemViewItem
Definition qstyle.h:153
@ PE_FrameStatusBarItem
Definition qstyle.h:110
@ PE_IndicatorItemViewItemCheck
Definition qstyle.h:130
@ PE_IndicatorTabTear
Definition qstyle.h:144
@ PE_IndicatorTabClose
Definition qstyle.h:158
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition qstyle.cpp:574
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const =0
virtual void unpolish(QWidget *widget)
Uninitialize the given {widget}'s appearance.
Definition qstyle.cpp:455
SubElement
This enum represents a sub-area of a widget.
Definition qstyle.h:242
@ SE_ShapedFrameContents
Definition qstyle.h:312
@ SE_HeaderLabel
Definition qstyle.h:266
@ SE_ProgressBarGroove
Definition qstyle.h:260
@ SE_ProgressBarLabel
Definition qstyle.h:262
@ SE_CheckBoxFocusRect
Definition qstyle.h:248
@ SE_TreeViewDisclosureItem
Definition qstyle.h:279
@ SE_TabWidgetTabPane
Definition qstyle.h:270
@ SE_TabBarTabRightButton
Definition qstyle.h:309
@ SE_CheckBoxContents
Definition qstyle.h:247
@ SE_ItemViewItemDecoration
Definition qstyle.h:304
@ SE_ItemViewItemFocusRect
Definition qstyle.h:306
@ SE_TabWidgetRightCorner
Definition qstyle.h:273
@ SE_TabBarTabText
Definition qstyle.h:310
@ SE_DockWidgetIcon
Definition qstyle.h:287
@ SE_ItemViewItemCheckIndicator
Definition qstyle.h:275
@ SE_LineEditContents
Definition qstyle.h:281
@ SE_HeaderArrow
Definition qstyle.h:267
@ SE_SliderFocusRect
Definition qstyle.h:258
@ SE_PushButtonFocusRect
Definition qstyle.h:244
@ SE_RadioButtonFocusRect
Definition qstyle.h:253
@ SE_CheckBoxClickRect
Definition qstyle.h:249
@ SE_ComboBoxFocusRect
Definition qstyle.h:256
@ SE_PushButtonContents
Definition qstyle.h:243
@ SE_ToolBarHandle
Definition qstyle.h:314
@ SE_RadioButtonContents
Definition qstyle.h:252
@ SE_DockWidgetTitleBarText
Definition qstyle.h:286
@ SE_ProgressBarContents
Definition qstyle.h:261
@ SE_TabBarScrollRightButton
Definition qstyle.h:317
@ SE_TabBarScrollLeftButton
Definition qstyle.h:316
@ SE_TabWidgetTabBar
Definition qstyle.h:269
@ SE_CheckBoxIndicator
Definition qstyle.h:246
@ SE_TabBarTabLeftButton
Definition qstyle.h:308
@ SE_DockWidgetFloatButton
Definition qstyle.h:285
@ SE_ItemViewItemText
Definition qstyle.h:305
@ SE_TabBarTearIndicator
Definition qstyle.h:276
@ SE_RadioButtonIndicator
Definition qstyle.h:251
@ SE_RadioButtonClickRect
Definition qstyle.h:254
@ SE_PushButtonBevel
Definition qstyle.h:320
@ SE_DockWidgetCloseButton
Definition qstyle.h:284
@ SE_TabWidgetLeftCorner
Definition qstyle.h:272
@ SE_ToolBoxTabContents
Definition qstyle.h:264
@ SE_TabWidgetTabContents
Definition qstyle.h:271
@ SE_FrameContents
Definition qstyle.h:282
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
const QStyle * proxy() const
Definition qstyle.cpp:2401
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
@ SC_ScrollBarSubLine
Definition qstyle.h:351
@ SC_SliderGroove
Definition qstyle.h:369
@ SC_TitleBarMinButton
Definition qstyle.h:377
@ SC_ScrollBarAddPage
Definition qstyle.h:352
@ SC_ScrollBarLast
Definition qstyle.h:355
@ SC_TitleBarLabel
Definition qstyle.h:384
@ SC_TitleBarUnshadeButton
Definition qstyle.h:382
@ SC_ComboBoxFrame
Definition qstyle.h:364
@ SC_MdiMinButton
Definition qstyle.h:395
@ SC_TitleBarNormalButton
Definition qstyle.h:380
@ SC_ScrollBarAddLine
Definition qstyle.h:350
@ SC_ToolButton
Definition qstyle.h:373
@ SC_DialTickmarks
Definition qstyle.h:388
@ SC_ScrollBarGroove
Definition qstyle.h:357
@ SC_MdiNormalButton
Definition qstyle.h:396
@ SC_ScrollBarFirst
Definition qstyle.h:354
@ SC_ScrollBarSlider
Definition qstyle.h:356
@ SC_GroupBoxContents
Definition qstyle.h:392
@ SC_ScrollBarSubPage
Definition qstyle.h:353
@ SC_SpinBoxDown
Definition qstyle.h:360
@ SC_ComboBoxListBoxPopup
Definition qstyle.h:367
@ SC_SpinBoxUp
Definition qstyle.h:359
@ SC_MdiCloseButton
Definition qstyle.h:397
@ SC_GroupBoxCheckBox
Definition qstyle.h:390
@ SC_TitleBarShadeButton
Definition qstyle.h:381
@ SC_GroupBoxLabel
Definition qstyle.h:391
@ SC_None
Definition qstyle.h:348
@ SC_ComboBoxEditField
Definition qstyle.h:365
@ SC_SliderTickmarks
Definition qstyle.h:371
@ SC_TitleBarSysMenu
Definition qstyle.h:376
@ SC_TitleBarMaxButton
Definition qstyle.h:378
@ SC_TitleBarCloseButton
Definition qstyle.h:379
@ SC_SpinBoxFrame
Definition qstyle.h:361
@ SC_ComboBoxArrow
Definition qstyle.h:366
@ SC_TitleBarContextHelpButton
Definition qstyle.h:383
@ SC_GroupBoxFrame
Definition qstyle.h:393
@ SC_SpinBoxEditField
Definition qstyle.h:362
@ SC_SliderHandle
Definition qstyle.h:370
@ SC_ToolButtonMenu
Definition qstyle.h:374
@ RightSide
Definition qtabbar.h:49
@ 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 qtextlayout.h:70
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
QString text() const
Returns the layout's text.
int lineCount() const
Returns the number of lines in this text layout.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
void draw(QPainter *p, const QPointF &pos, const QList< FormatRange > &selections=QList< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
void endLayout()
Ends the layout process.
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
\reentrant
qreal height() const
Returns the line's height.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
\reentrant
Definition qtextoption.h:18
void setTextDirection(Qt::LayoutDirection aDirection)
Sets the direction of the text layout defined by the option to the given direction.
Definition qtextoption.h:57
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
Definition qtextoption.h:67
void setAlignment(Qt::Alignment alignment)
Sets the option's text alignment to the specified alignment.
The QToolBar class provides a movable panel that contains a set of controls.
Definition qtoolbar.h:23
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
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.
\inmodule QtCore
Definition qvariant.h:64
QChar toChar() const
Returns the variant as a QChar if the variant has userType() \l QMetaType::QChar, \l QMetaType::Int,...
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Qt::LayoutDirection layoutDirection
the layout direction for this widget.
Definition qwidget.h:170
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
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
bool isEnabled() const
Definition qwidget.h:814
QStyle * style() const
Definition qwidget.cpp:2607
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
QPalette::ColorRole foregroundRole() const
Returns the foreground role.
Definition qwidget.cpp:4418
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition qwidget.h:811
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition qwidget.h:910
@ ClassicStyle
Definition qwizard.h:55
QOpenGLWidget * widget
[1]
QPixmap p2
QPixmap p1
[0]
QString text
qreal spacing
QPushButton * button
[2]
qSwap(pi, e)
opt iconSize
rect
[4]
QPixmap pix
QStyleOptionButton subopt
[2]
uint alignment
QStyleOptionButton opt
fontMetrics
else opt state
[0]
QRect textRect
const QStyleOptionButton * btn
[3]
struct wl_display * display
Definition linuxdmabuf.h:41
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)
Combined button and popup list for selecting options.
@ WindowMinimized
Definition qnamespace.h:252
@ WindowMaximized
Definition qnamespace.h:253
@ BottomLeftCorner
@ TopRightCorner
@ TopLeftCorner
@ BottomRightCorner
@ Unchecked
@ Checked
@ PartiallyChecked
@ AlignRight
Definition qnamespace.h:145
@ AlignVCenter
Definition qnamespace.h:154
@ AlignTop
Definition qnamespace.h:152
@ AlignTrailing
Definition qnamespace.h:146
@ AlignHCenter
Definition qnamespace.h:147
@ AlignCenter
Definition qnamespace.h:162
@ AlignAbsolute
Definition qnamespace.h:149
@ AlignLeft
Definition qnamespace.h:143
@ LeftButton
Definition qnamespace.h:57
@ MiddleButton
Definition qnamespace.h:59
@ LinksAccessibleByMouse
@ WA_NoSystemBackground
Definition qnamespace.h:290
LayoutDirection
@ LeftToRight
@ LayoutDirectionAuto
@ RightToLeft
@ StrongFocus
Definition qnamespace.h:109
Orientation
Definition qnamespace.h:97
@ Horizontal
Definition qnamespace.h:98
@ UpArrow
@ RightArrow
@ LeftArrow
@ DownArrow
@ TextSingleLine
Definition qnamespace.h:169
@ TextDontClip
Definition qnamespace.h:170
@ TextHideMnemonic
Definition qnamespace.h:177
@ TextShowMnemonic
Definition qnamespace.h:172
@ OpaqueMode
Definition qnamespace.h:507
@ white
Definition qnamespace.h:30
@ black
Definition qnamespace.h:29
@ DotLine
@ DashLine
@ NoPen
@ DecorationRole
@ CheckStateRole
@ DisplayRole
@ ControlModifier
@ Dense4Pattern
@ NoBrush
@ UniqueConnection
@ WindowContextHelpButtonHint
Definition qnamespace.h:230
@ WindowType_Mask
Definition qnamespace.h:219
@ WindowMaximizeButtonHint
Definition qnamespace.h:228
@ WindowMinimizeButtonHint
Definition qnamespace.h:227
@ WindowShadeButtonHint
Definition qnamespace.h:231
@ Tool
Definition qnamespace.h:211
@ WindowTitleHint
Definition qnamespace.h:225
@ WindowSystemMenuHint
Definition qnamespace.h:226
TextElideMode
Definition qnamespace.h:187
@ ElideMiddle
Definition qnamespace.h:190
@ ElideRight
Definition qnamespace.h:189
@ ElideNone
Definition qnamespace.h:191
@ ToolButtonTextOnly
@ ToolButtonTextUnderIcon
@ ToolButtonIconOnly
Definition brush.cpp:5
Definition image.cpp:4
static jboolean copy(JNIEnv *, jobject)
static QString wrapText(const QString &names, int optionNameMaxWidth, const QString &description)
static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight=-1, int *lastVisibleLine=nullptr)
static QString clearText16IconPath()
static uint qt_intensity(uint r, uint g, uint b)
static qreal qt_getDevicePixelRatio(const QWidget *widget)
static const char *const filedialog_end_xpm[]
static const char *const tb_extension_arrow_v_xpm[]
static const char *const information_xpm[]
static const char *const qt_help_xpm[]
static const char *const tb_extension_arrow_h_xpm[]
static const char *const qt_normalizeup_xpm[]
static const char *const qt_shade_xpm[]
static const char *const dock_widget_close_xpm[]
static const char *const qt_unshade_xpm[]
static const char *const qt_menu_xpm[]
static const char *const warning_xpm[]
static const char *const qt_minimize_xpm[]
static const char *const filedialog_start_xpm[]
static const char *const question_xpm[]
static const char *const critical_xpm[]
static const char *const qt_close_xpm[]
static const char *const qt_maximize_xpm[]
#define Q_FALLTHROUGH()
#define qApp
AudioChannelLayoutTag tag
static QString header(const QString &name)
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth)
Definition qdrawutil.cpp:86
void qDrawWinPanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, const QBrush *fill)
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c, int lineWidth, const QBrush *fill)
#define QFIXED_MAX
Definition qfixed_p.h:127
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:287
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
return ret
auto qCos(T v)
Definition qmath.h:60
int qCeil(T v)
Definition qmath.h:36
auto qSin(T v)
Definition qmath.h:54
static QT_BEGIN_NAMESPACE const qreal Q_PI
Definition qmath_p.h:24
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
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
static QString themeName()
GLint GLfloat GLfloat GLfloat v2
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum mode
const GLfloat * m
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLuint GLfloat GLfloat GLfloat x1
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLdouble GLdouble right
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLsizei range
GLint GLsizei width
GLint left
GLuint GLsizei const GLchar * label
[43]
GLint GLint bottom
GLuint GLfloat x0
GLenum target
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLenum GLuint GLintptr offset
GLboolean GLboolean g
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
GLbyte GLbyte blue
Definition qopenglext.h:385
GLint void * img
Definition qopenglext.h:233
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLenum GLsizei len
GLfixed GLfixed x2
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint GLenum option
GLbyte green
Definition qopenglext.h:385
static const QRectF boundingRect(const QPointF *points, int pointCount)
static void stopAnimation(QObject *object)
static bool isWindow(QObject *object)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
constexpr int qGray(int r, int g, int b)
Definition qrgb.h:36
constexpr QRgb qRgba(int r, int g, int b, int a)
Definition qrgb.h:33
constexpr int qAlpha(QRgb rgb)
Definition qrgb.h:27
Int aligned(Int v, Int byteAlign)
static const struct TessellationWindingOrderTab cw[]
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define sp
constexpr bool verticalTabs(QTabBar::Shape shape) noexcept
Definition qtabbar_p.h:248
#define tr(X)
#define Q_UNUSED(x)
unsigned char uchar
Definition qtypes.h:27
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
QVideoFrameFormat::PixelFormat fmt
const char className[16]
[1]
Definition qwizard.cpp:100
QWidget * panel
Definition settings.cpp:7
obj metaObject() -> className()
QPropertyAnimation animation
[0]
p rx()++
QSharedPointer< T > other(t)
[5]
Text files * txt
QApplication app(argc, argv)
[0]
widget render & pixmap
QPainter painter(this)
[7]
QFrame frame
[0]
QJSEngine engine
[0]
QGraphicsSvgItem * red