Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
100{
101 QPainterStateSaver(QPainter *p, bool bSaveRestore = true)
102 : m_painter(p)
103 , m_bSaveRestore(bSaveRestore)
104 {
105 if (m_bSaveRestore)
106 m_painter->save();
107 }
109 {
110 restore();
111 }
112 void restore()
113 {
114 if (m_bSaveRestore) {
115 m_bSaveRestore = false;
116 m_painter->restore();
117 }
118 }
119private:
120 QPainter *m_painter;
121 bool m_bSaveRestore;
122};
123
154
160
166
167
172 const QWidget *widget) const
173{
174 Q_D(const QCommonStyle);
175 switch (pe) {
179 opt->state & (State_Sunken | State_On), 1, 0);
180 break;
186 opt->state & (State_Sunken | State_On), 1,
188 break;
191 break;
193 if (opt->state & State_NoChange) {
194 p->setPen(opt->palette.windowText().color());
195 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
196 p->drawRect(opt->rect);
197 p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight());
198 } else {
202 }
203 break;
205 QRect ir = opt->rect;
206 p->setPen(opt->palette.dark().color());
207 p->drawArc(opt->rect, 0, 5760);
208 if (opt->state & (State_Sunken | State_On)) {
209 ir.adjust(2, 2, -2, -2);
210 p->setBrush(opt->palette.windowText());
211 p->drawEllipse(ir);
212 }
213 break; }
215 if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
216 QColor bg = fropt->backgroundColor;
218 if (bg.isValid()) {
219 int h, s, v;
220 bg.getHsv(&h, &s, &v);
221 if (v >= 128)
223 else
225 } else {
227 }
228 const QRect focusRect = opt->rect.adjusted(1, 1, -1, -1);
229 qDrawPlainRect(p, focusRect, color, 1);
230 }
231 break;
233 const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width();
234 const int markH = markW;
235 int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1;
236 int posY = opt->rect.y() + (opt->rect.height() - markH)/2;
237
238 QList<QLineF> a;
239 a.reserve(markH);
240
241 int i, xx, yy;
242 xx = posX;
243 yy = 3 + posY;
244 for (i = 0; i < markW/2; ++i) {
245 a << QLineF(xx, yy, xx, yy + 2);
246 ++xx;
247 ++yy;
248 }
249 yy -= 2;
250 for (; i < markH; ++i) {
251 a << QLineF(xx, yy, xx, yy + 2);
252 ++xx;
253 --yy;
254 }
255 if (!(opt->state & State_Enabled) && !(opt->state & State_On)) {
257 p->translate(1, 1);
258 p->setPen(opt->palette.light().color());
259 p->drawLines(a);
260 }
261 p->setPen((opt->state & State_On) ? opt->palette.highlightedText().color() : opt->palette.text().color());
262 p->drawLines(a);
263 break; }
264 case PE_Frame:
265 case PE_FrameMenu:
266 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
267 if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) {
270 } else {
272 }
273 }
274 break;
275#if QT_CONFIG(toolbar)
276 case PE_PanelMenuBar:
277 if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
278 break;
279 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)){
282
283 }
284 else if (const QStyleOptionToolBar *frame = qstyleoption_cast<const QStyleOptionToolBar *>(opt)){
287 }
288
289 break;
290 case PE_PanelMenu:
291 break;
292 case PE_PanelToolBar:
293 break;
294#endif // QT_CONFIG(toolbar)
295#if QT_CONFIG(progressbar)
297 {
298 bool vertical = false;
299 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt))
300 vertical = !(pb->state & QStyle::State_Horizontal);
301 if (!vertical) {
302 p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
304 } else {
305 p->fillRect(opt->rect.x() + 2, opt->rect.y(), opt->rect.width() -6, opt->rect.height() - 2,
307 }
308 }
309 break;
310#endif // QT_CONFIG(progressbar)
311 case PE_IndicatorBranch: {
312 static const int decoration_size = 9;
313 int mid_h = opt->rect.x() + opt->rect.width() / 2;
314 int mid_v = opt->rect.y() + opt->rect.height() / 2;
315 int bef_h = mid_h;
316 int bef_v = mid_v;
317 int aft_h = mid_h;
318 int aft_v = mid_v;
319 if (opt->state & State_Children) {
320 int delta = decoration_size / 2;
321 bef_h -= delta;
322 bef_v -= delta;
323 aft_h += delta;
324 aft_v += delta;
325 p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
326 if (!(opt->state & State_Open))
327 p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
328 QPen oldPen = p->pen();
329 p->setPen(opt->palette.dark().color());
330 p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
331 p->setPen(oldPen);
332 }
334 if (opt->state & State_Item) {
336 p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
337 else
338 p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
339 }
340 if (opt->state & State_Sibling)
341 p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
343 p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
344 break; }
346 qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, nullptr);
347 break;
349 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
350 QPen oldPen = p->pen();
351 if (header->sortIndicator & QStyleOptionHeader::SortUp) {
352 p->setPen(QPen(opt->palette.light(), 0));
353 p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),
354 opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
355 p->setPen(QPen(opt->palette.dark(), 0));
356 const QPoint points[] = {
357 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()),
358 QPoint(opt->rect.x(), opt->rect.y()),
359 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y()),
360 };
361 p->drawPolyline(points, sizeof points / sizeof *points);
362 } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
363 p->setPen(QPen(opt->palette.light(), 0));
364 const QPoint points[] = {
365 QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height()),
366 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()),
367 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y()),
368 };
369 p->drawPolyline(points, sizeof points / sizeof *points);
370 p->setPen(QPen(opt->palette.dark(), 0));
371 p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),
372 opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
373 }
374 p->setPen(oldPen);
375 }
376 break;
377#if QT_CONFIG(tabbar)
379 if (const QStyleOptionTabBarBase *tbb
380 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
382 switch (tbb->shape) {
385 p->setPen(QPen(tbb->palette.light(), 0));
386 p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
387 break;
390 p->setPen(QPen(tbb->palette.light(), 0));
391 p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
392 break;
395 p->setPen(QPen(tbb->palette.shadow(), 0));
396 p->drawLine(tbb->rect.left(), tbb->rect.bottom(),
397 tbb->rect.right(), tbb->rect.bottom());
398 p->setPen(QPen(tbb->palette.dark(), 0));
399 p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1,
400 tbb->rect.right() - 1, tbb->rect.bottom() - 1);
401 break;
404 p->setPen(QPen(tbb->palette.dark(), 0));
405 p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
406 break;
407 }
408 }
409 break;
411 if (d->tabBarcloseButtonIcon.isNull())
412 d->tabBarcloseButtonIcon = proxy()->standardIcon(QStyle::SP_TabCloseButton, opt, widget);
413
418 if (!(opt->state & State_Raised)
419 && !(opt->state & State_Sunken)
422
424 QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(size, size), p->device()->devicePixelRatio(), mode, state);
426 break;
427 }
428#else
429 Q_UNUSED(d);
430#endif // QT_CONFIG(tabbar)
432 case PE_FrameWindow:
433 qDrawWinPanel(p, opt->rect, opt->palette, false, nullptr);
434 break;
435 case PE_FrameLineEdit:
437 break;
438#if QT_CONFIG(groupbox)
439 case PE_FrameGroupBox:
440 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
441 if (frame->features & QStyleOptionFrame::Flat) {
442 QRect fr = frame->rect;
443 QPoint p1(fr.x(), fr.y() + 1);
444 QPoint p2(fr.x() + fr.width(), p1.y());
445 qDrawShadeLine(p, p1, p2, frame->palette, true,
447 } else {
449 frame->rect.height(), frame->palette, true,
451 }
452 }
453 break;
454#endif // QT_CONFIG(groupbox)
455#if QT_CONFIG(dockwidget)
457 if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
458 int lw = frame->lineWidth;
459 if (lw <= 0)
461
462 qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
463 }
464 break;
465#endif // QT_CONFIG(dockwidget)
466#if QT_CONFIG(toolbar)
469 p->translate(opt->rect.x(), opt->rect.y());
470 if (opt->state & State_Horizontal) {
471 int x = opt->rect.width() / 3;
473 x -= 2;
474 if (opt->rect.height() > 4) {
475 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
476 opt->palette, false, 1, nullptr);
477 qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,
478 opt->palette, false, 1, nullptr);
479 }
480 } else {
481 if (opt->rect.width() > 4) {
482 int y = opt->rect.height() / 3;
483 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
484 opt->palette, false, 1, nullptr);
485 qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,
486 opt->palette, false, 1, nullptr);
487 }
488 }
489 break;
490 }
492 {
493 QPoint p1, p2;
494 if (opt->state & State_Horizontal) {
495 p1 = QPoint(opt->rect.width()/2, 0);
496 p2 = QPoint(p1.x(), opt->rect.height());
497 } else {
498 p1 = QPoint(0, opt->rect.height()/2);
499 p2 = QPoint(opt->rect.width(), p1.y());
500 }
501 qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
502 break;
503 }
504#endif // QT_CONFIG(toolbar)
505#if QT_CONFIG(spinbox)
508 QRect r = opt->rect;
510 QRect br = r.adjusted(fw, fw, -fw, -fw);
511 int x = br.x();
512 int y = br.y();
513 int w = br.width();
514 int h = br.height();
516 const qreal devicePixelRatio = p->device()->devicePixelRatio();
517 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
518 const qreal inverseScale = qreal(1) / devicePixelRatio;
519 p->scale(inverseScale, inverseScale);
520 x = qRound(devicePixelRatio * x);
521 y = qRound(devicePixelRatio * y);
522 w = qRound(devicePixelRatio * w);
523 h = qRound(devicePixelRatio * h);
524 p->translate(0.5, 0.5);
525 }
526 int len = std::min(w, h);
527 if (len & 1)
528 ++len;
529 int step = (len + 4) / 5;
530 if (step & 1)
531 ++step;
532 const int step2 = step / 2;
533 QPoint center(x + w / 2, y + h / 2);
534 if (opt->state & State_Sunken) {
537 }
538 p->translate(center);
539 p->fillRect(-len / 2, -step2, len, step, opt->palette.buttonText());
540 if (pe == PE_IndicatorSpinPlus)
541 p->fillRect(-step2, -len / 2, step, len, opt->palette.buttonText());
542 break; }
545 QRect r = opt->rect;
547 // QRect br = r.adjusted(fw, fw, -fw, -fw);
548 int x = r.x();
549 int y = r.y();
550 int w = r.width();
551 int h = r.height();
553 const qreal devicePixelRatio = p->device()->devicePixelRatio();
554 if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
555 const qreal inverseScale = qreal(1) / devicePixelRatio;
556 p->scale(inverseScale, inverseScale);
557 x = qRound(devicePixelRatio * x);
558 y = qRound(devicePixelRatio * y);
559 w = qRound(devicePixelRatio * w);
560 h = qRound(devicePixelRatio * h);
561 p->translate(0.5, 0.5);
562 }
563 int sw = w-4;
564 if (sw < 3)
565 break;
566 else if (!(sw & 1))
567 sw--;
568 sw -= (sw / 7) * 2; // Empty border
569 int sh = sw/2 + 2; // Must have empty row at foot of arrow
570
571 int sx = x + w / 2 - sw / 2;
572 int sy = y + h / 2 - sh / 2;
573
574 if (pe == PE_IndicatorSpinUp && fw)
575 --sy;
576
577 int bsx = 0;
578 int bsy = 0;
579 if (opt->state & State_Sunken) {
582 }
583 p->translate(sx + bsx, sy + bsy);
584 p->setPen(opt->palette.buttonText().color());
585 p->setBrush(opt->palette.buttonText());
586 if (pe == PE_IndicatorSpinDown) {
587 const QPoint points[] = { QPoint(0, 1), QPoint(sw-1, 1), QPoint(sh-2, sh-1) };
588 p->drawPolygon(points, sizeof points / sizeof *points);
589 } else {
590 const QPoint points[] = { QPoint(0, sh-1), QPoint(sw-1, sh-1), QPoint(sh-2, 1) };
591 p->drawPolygon(points, sizeof points / sizeof *points);
592 }
593 break; }
594#endif // QT_CONFIG(spinbox)
595 case PE_PanelTipLabel: {
598 break;
599 }
600#if QT_CONFIG(tabbar)
602 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
603 bool rtl = tab->direction == Qt::RightToLeft;
604 const bool horizontal = tab->rect.height() > tab->rect.width();
605 const int margin = 4;
607
608 if (horizontal) {
609 QRect rect = tab->rect.adjusted(rtl ? margin : 0, 0, rtl ? 1 : -margin, 0);
610 rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
611 rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
612
613 path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
614 int count = 4;
615 for (int jags = 1; jags <= count; ++jags, rtl = !rtl)
616 path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
617 } else {
618 QRect rect = tab->rect.adjusted(0, 0, 0, -margin);
619 rect.setLeft(rect.left() + ((tab->state & State_Selected) ? 1 : 3));
620 rect.setRight(rect.right() - ((tab->state & State_Selected) ? 0 : 2));
621
622 path.moveTo(QPoint(rect.left(), rect.top()));
623 int count = 4;
624 for (int jags = 1; jags <= count; ++jags, rtl = !rtl)
625 path.lineTo(QPoint(rect.left() + jags * rect.width()/count, rtl ? rect.top() : rect.bottom()));
626 }
627
628 p->setPen(QPen(tab->palette.dark(), qreal(.8)));
629 p->setBrush(tab->palette.window());
630 p->setRenderHint(QPainter::Antialiasing);
631 p->drawPath(path);
632 }
633 break;
634#endif // QT_CONFIG(tabbar)
635#if QT_CONFIG(lineedit)
636 case PE_PanelLineEdit:
637 if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
638 p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth),
640
641 if (panel->lineWidth > 0)
643 }
644 break;
645#endif // QT_CONFIG(lineedit)
646#if QT_CONFIG(columnview)
648 if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
649 bool reverse = (viewOpt->direction == Qt::RightToLeft);
652 int x = viewOpt->rect.x() + 1;
653 int offset = (viewOpt->rect.height() / 3);
654 int height = (viewOpt->rect.height()) - offset * 2;
655 if (height % 2 == 1)
656 --height;
657 int x2 = x + height - 1;
658 if (reverse) {
659 x = viewOpt->rect.x() + viewOpt->rect.width() - 1;
660 x2 = x - height + 1;
661 }
662 path.moveTo(x, viewOpt->rect.y() + offset);
663 path.lineTo(x, viewOpt->rect.y() + offset + height);
664 path.lineTo(x2, viewOpt->rect.y() + offset+height/2);
665 path.closeSubpath();
666 if (viewOpt->state & QStyle::State_Selected ) {
667 if (viewOpt->showDecorationSelected) {
668 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::HighlightedText);
669 p->setPen(color);
670 p->setBrush(color);
671 } else {
672 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::WindowText);
673 p->setPen(color);
674 p->setBrush(color);
675 }
676
677 } else {
678 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Mid);
679 p->setPen(color);
680 p->setBrush(color);
681 }
682 p->drawPath(path);
683
684 // draw the vertical and top triangle line
685 if (!(viewOpt->state & QStyle::State_Selected)) {
686 QPainterPath lines;
687 lines.moveTo(x, viewOpt->rect.y() + offset);
688 lines.lineTo(x, viewOpt->rect.y() + offset + height);
689 lines.moveTo(x, viewOpt->rect.y() + offset);
690 lines.lineTo(x2, viewOpt->rect.y() + offset+height/2);
691 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Dark);
692 p->setPen(color);
693 p->drawPath(lines);
694 }
695 }
696 break; }
697#endif //QT_CONFIG(columnview)
699 QRect rect = opt->rect;
700 if (opt->rect.height() == 0)
701 p->drawLine(rect.topLeft(), rect.topRight());
702 else
703 p->drawRect(rect);
704 break; }
705#if QT_CONFIG(itemviews)
707 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
710 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
712
713 if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected)
714 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
715 else if (vopt->features & QStyleOptionViewItem::Alternate)
716 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
717 }
718 break;
720 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
723 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
725
726 if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) {
727 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
728 } else {
729 if (vopt->backgroundBrush.style() != Qt::NoBrush) {
730 QPointF oldBO = p->brushOrigin();
731 p->setBrushOrigin(vopt->rect.topLeft());
732 p->fillRect(vopt->rect, vopt->backgroundBrush);
733 p->setBrushOrigin(oldBO);
734 }
735
736 if (vopt->state & QStyle::State_Selected) {
738 p->fillRect(textRect, vopt->palette.brush(cg, QPalette::Highlight));
739 }
740 }
741 }
742 break;
743#endif // QT_CONFIG(itemviews)
746 p->fillRect(opt->rect, brush);
747 } break;
752 {
753 const QRect &r = opt->rect;
754 if (r.width() <= 1 || r.height() <= 1)
755 break;
756 int size = qMin(r.height(), r.width());
758 const qreal dpr = p->device()->devicePixelRatio();
759 const QString pixmapName = QStyleHelper::uniqueName("$qt_ia-"_L1
761 % HexString<uint>(pe),
762 opt, QSize(size, size), dpr);
763 if (!QPixmapCache::find(pixmapName, &pixmap)) {
764 // dpr scaling does not work well on such small pixel sizes, do it on our own
765 const int border = 1 * dpr;
766 const int sizeDpr = size * dpr;
767 int width = sizeDpr - 2 * border - 1;
768 int height = width / 2;
769 const int add = ((width & 1) == 1);
771 std::swap(width, height);
772 pixmap = styleCachePixmap(QSize(sizeDpr, sizeDpr), 1);
773
774 std::array<QPointF, 4> poly;
775 switch (pe) {
777 poly = {QPointF(0, height), QPointF(width, height),
778 QPointF(width / 2 + add, 0), QPointF(width / 2, 0)};
779 break;
781 poly = {QPointF(0, 0), QPointF(width, 0),
782 QPointF(width / 2 + add, height), QPointF(width / 2, height)};
783 break;
785 poly = {QPointF(0, 0), QPointF(0, height),
786 QPointF(width, height / 2 + add), QPointF(width, height / 2)};
787 break;
789 poly = {QPointF(width, 0), QPointF(width, height),
790 QPointF(0, height / 2 + add), QPointF(0, height / 2)};
791 break;
792 default:
793 break;
794 }
795
796 QPainter imagePainter(&pixmap);
797 imagePainter.translate((sizeDpr - width) / 2, (sizeDpr - height) / 2);
798 if (opt->state & State_Sunken) {
799 const auto bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget);
800 const auto bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
801 imagePainter.translate(bsx, bsy);
802 }
803 imagePainter.setPen(opt->palette.buttonText().color());
804 imagePainter.setBrush(opt->palette.buttonText());
805
806 if (!(opt->state & State_Enabled)) {
807 const int ofs = qRound(1 * dpr);
808 imagePainter.translate(ofs, ofs);
809 imagePainter.setBrush(opt->palette.light().color());
810 imagePainter.setPen(opt->palette.light().color());
811 imagePainter.drawPolygon(poly.data(), int(poly.size()));
812 imagePainter.drawPoints(poly.data(), int(poly.size()));
813 imagePainter.translate(-ofs, -ofs);
814 imagePainter.setBrush(opt->palette.mid().color());
815 imagePainter.setPen(opt->palette.mid().color());
816 }
817 imagePainter.drawPolygon(poly.data(), int(poly.size()));
818 // sometimes the corners are not drawn by drawPolygon for unknown reaons, so re-draw them again
819 imagePainter.drawPoints(poly.data(), int(poly.size()));
820 imagePainter.end();
821 pixmap.setDevicePixelRatio(dpr);
822 QPixmapCache::insert(pixmapName, pixmap);
823 }
824 int xOffset = r.x() + (r.width() - size)/2;
825 int yOffset = r.y() + (r.height() - size)/2;
826 p->drawPixmap(xOffset, yOffset, pixmap);
827 }
828 break;
829 default:
830 break;
831 }
832}
833
834#if QT_CONFIG(toolbutton)
835static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton,
836 const QRect &rect, QPainter *painter, const QWidget *widget = nullptr)
837{
839 switch (toolbutton->arrowType) {
840 case Qt::LeftArrow:
842 break;
843 case Qt::RightArrow:
845 break;
846 case Qt::UpArrow:
848 break;
849 case Qt::DownArrow:
851 break;
852 default:
853 return;
854 }
855 QStyleOption arrowOpt = *toolbutton;
856 arrowOpt.rect = rect;
857 style->drawPrimitive(pe, &arrowOpt, painter, widget);
858}
859#endif // QT_CONFIG(toolbutton)
860
861static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr)
862{
863 if (lastVisibleLine)
864 *lastVisibleLine = -1;
865 qreal height = 0;
866 qreal widthUsed = 0;
867 textLayout.beginLayout();
868 int i = 0;
869 while (true) {
870 QTextLine line = textLayout.createLine();
871 if (!line.isValid())
872 break;
873 line.setLineWidth(lineWidth);
874 line.setPosition(QPointF(0, height));
875 height += line.height();
876 widthUsed = qMax(widthUsed, line.naturalTextWidth());
877 // we assume that the height of the next line is the same as the current one
878 if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) {
879 const QTextLine nextLine = textLayout.createLine();
880 *lastVisibleLine = nextLine.isValid() ? i : -1;
881 break;
882 }
883 ++i;
884 }
885 textLayout.endLayout();
886 return QSizeF(widthUsed, height);
887}
888
890 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
891 Qt::TextElideMode textElideMode, int flags,
892 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const
893{
894 QTextLayout textLayout(text, font);
895 textLayout.setTextOption(textOption);
896
897 // In AlignVCenter mode when more than one line is displayed and the height only allows
898 // some of the lines it makes no sense to display those. From a users perspective it makes
899 // more sense to see the start of the text instead something inbetween.
900 const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter);
901
902 int lastVisibleLine = -1;
903 viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine);
904
905 const QRectF boundingRect = textLayout.boundingRect();
906 // don't care about LTR/RTL here, only need the height
907 const QRect layoutRect = QStyle::alignedRect(Qt::LayoutDirectionAuto, valign,
908 boundingRect.size().toSize(), textRect);
909
910 if (paintStartPosition)
911 *paintStartPosition = QPointF(textRect.x(), layoutRect.top());
912
913 QString ret;
914 qreal height = 0;
915 const int lineCount = textLayout.lineCount();
916 for (int i = 0; i < lineCount; ++i) {
917 const QTextLine line = textLayout.lineAt(i);
918 height += line.height();
919
920 // above visible rect
921 if (height + layoutRect.top() <= textRect.top()) {
922 if (paintStartPosition)
923 paintStartPosition->ry() += line.height();
924 continue;
925 }
926
927 const int start = line.textStart();
928 const int length = line.textLength();
929 const bool drawElided = line.naturalTextWidth() > textRect.width();
930 bool elideLastVisibleLine = lastVisibleLine == i;
931 if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) {
932 const QTextLine nextLine = textLayout.lineAt(i + 1);
933 const int nextHeight = height + nextLine.height() / 2;
934 // elide when less than the next half line is visible
935 if (nextHeight + layoutRect.top() > textRect.height() + textRect.top())
936 elideLastVisibleLine = true;
937 }
938
939 QString text = textLayout.text().mid(start, length);
940 if (drawElided || elideLastVisibleLine) {
941 if (elideLastVisibleLine) {
942 if (text.endsWith(QChar::LineSeparator))
943 text.chop(1);
944 text += QChar(0x2026);
945 }
947 ret += engine.elidedText(textElideMode, textRect.width(), flags);
948
949 // no newline for the last line (last visible or real)
950 // sometimes drawElided is true but no eliding is done so the text ends
951 // with QChar::LineSeparator - don't add another one. This happened with
952 // arabic text in the testcase for QTBUG-72805
953 if (i < lineCount - 1 &&
954 !ret.endsWith(QChar::LineSeparator))
955 ret += QChar::LineSeparator;
956 } else {
957 ret += text;
958 }
959
960 // below visible text, can stop
961 if ((height + layoutRect.top() >= textRect.bottom()) ||
962 (lastVisibleLine >= 0 && lastVisibleLine == i))
963 break;
964 }
965 return ret;
966}
967
968#if QT_CONFIG(itemviews)
969
970QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int role) const
971{
972 const QWidget *widget = option->widget;
973 switch (role) {
975 if (option->features & QStyleOptionViewItem::HasCheckIndicator)
978 break;
979 case Qt::DisplayRole:
980 if (option->features & QStyleOptionViewItem::HasDisplay) {
981 QTextOption textOption;
983 QTextLayout textLayout(option->text, option->font);
984 textLayout.setTextOption(textOption);
985 const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
986 const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, option, widget) + 1;
987 QRect bounds = option->rect;
988 switch (option->decorationPosition) {
989 case QStyleOptionViewItem::Left:
990 case QStyleOptionViewItem::Right: {
991 if (wrapText && bounds.isValid()) {
992 int width = bounds.width() - 2 * textMargin;
993 if (option->features & QStyleOptionViewItem::HasDecoration)
994 width -= option->decorationSize.width() + 2 * textMargin;
995 bounds.setWidth(width);
996 } else
997 bounds.setWidth(QFIXED_MAX);
998 break;
999 }
1000 case QStyleOptionViewItem::Top:
1001 case QStyleOptionViewItem::Bottom: {
1002 int width;
1003 if (wrapText) {
1004 if (bounds.isValid())
1005 width = bounds.width() - 2 * textMargin;
1006 else if (option->features & QStyleOptionViewItem::HasDecoration)
1007 width = option->decorationSize.width();
1008 else
1009 width = 0;
1010 } else {
1011 width = QFIXED_MAX;
1012 }
1013 bounds.setWidth(width);
1014 break;
1015 }
1016 default:
1017 break;
1018 }
1019
1020 if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
1021 bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option, widget) - 2 * textMargin);
1022
1023 const int lineWidth = bounds.width();
1024 const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
1025 return QSize(qCeil(size.width()) + 2 * textMargin, qCeil(size.height()));
1026 }
1027 break;
1028 case Qt::DecorationRole:
1029 if (option->features & QStyleOptionViewItem::HasDecoration) {
1030 return option->decorationSize;
1031 }
1032 break;
1033 default:
1034 break;
1035 }
1036
1037 return QSize(0, 0);
1038}
1039
1040void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const
1041{
1042 const QWidget *widget = option->widget;
1043 const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
1044
1045 QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
1046 const bool wrapText = option->features & QStyleOptionViewItem::WrapText;
1047 QTextOption textOption;
1048 textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
1049 textOption.setTextDirection(option->direction);
1050 textOption.setAlignment(QStyle::visualAlignment(option->direction, option->displayAlignment));
1051
1052 QPointF paintPosition;
1053 const QString newText = calculateElidedText(option->text, textOption,
1054 option->font, textRect, option->displayAlignment,
1055 option->textElideMode, 0,
1056 true, &paintPosition);
1057
1058 QTextLayout textLayout(newText, option->font);
1059 textLayout.setTextOption(textOption);
1060 viewItemTextLayout(textLayout, textRect.width());
1061 textLayout.draw(p, paintPosition);
1062}
1063
1072void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
1073 QRect *pixmapRect, QRect *textRect, bool sizehint) const
1074{
1075 Q_ASSERT(checkRect && pixmapRect && textRect);
1076 *pixmapRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DecorationRole));
1077 *textRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DisplayRole));
1078 *checkRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::CheckStateRole));
1079
1080 const QWidget *widget = opt->widget;
1081 const bool hasCheck = checkRect->isValid();
1082 const bool hasPixmap = pixmapRect->isValid();
1083 const bool hasText = textRect->isValid();
1084 const bool hasMargin = (hasText | hasPixmap | hasCheck);
1085 const int frameHMargin = hasMargin ?
1087 const int textMargin = hasText ? frameHMargin : 0;
1088 const int pixmapMargin = hasPixmap ? frameHMargin : 0;
1089 const int checkMargin = hasCheck ? frameHMargin : 0;
1090 const int x = opt->rect.left();
1091 const int y = opt->rect.top();
1092 int w, h;
1093
1094 if (textRect->height() == 0 && (!hasPixmap || !sizehint)) {
1095 //if there is no text, we still want to have a decent height for the item sizeHint and the editor size
1097 }
1098
1099 QSize pm(0, 0);
1100 if (hasPixmap) {
1101 pm = pixmapRect->size();
1102 pm.rwidth() += 2 * pixmapMargin;
1103 }
1104 if (sizehint) {
1105 h = qMax(checkRect->height(), qMax(textRect->height(), pm.height()));
1106 if (opt->decorationPosition == QStyleOptionViewItem::Left
1107 || opt->decorationPosition == QStyleOptionViewItem::Right) {
1108 w = textRect->width() + pm.width();
1109 } else {
1110 w = qMax(textRect->width(), pm.width());
1111 }
1112 } else {
1113 w = opt->rect.width();
1114 h = opt->rect.height();
1115 }
1116
1117 int cw = 0;
1118 QRect check;
1119 if (hasCheck) {
1120 cw = checkRect->width() + 2 * checkMargin;
1121 if (sizehint) w += cw;
1122 if (opt->direction == Qt::RightToLeft) {
1123 check.setRect(x + w - cw, y, cw, h);
1124 } else {
1125 check.setRect(x, y, cw, h);
1126 }
1127 }
1128
1129 QRect display;
1131 switch (opt->decorationPosition) {
1132 case QStyleOptionViewItem::Top: {
1133 if (hasPixmap)
1134 pm.setHeight(pm.height() + pixmapMargin); // add space
1135 h = sizehint ? textRect->height() : h - pm.height();
1136
1137 if (opt->direction == Qt::RightToLeft) {
1138 decoration.setRect(x, y, w - cw, pm.height());
1139 display.setRect(x, y + pm.height(), w - cw, h);
1140 } else {
1141 decoration.setRect(x + cw, y, w - cw, pm.height());
1142 display.setRect(x + cw, y + pm.height(), w - cw, h);
1143 }
1144 break; }
1145 case QStyleOptionViewItem::Bottom: {
1146 if (hasText)
1147 textRect->setHeight(textRect->height() + textMargin); // add space
1148 h = sizehint ? textRect->height() + pm.height() : h;
1149
1150 if (opt->direction == Qt::RightToLeft) {
1151 display.setRect(x, y, w - cw, textRect->height());
1152 decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height());
1153 } else {
1154 display.setRect(x + cw, y, w - cw, textRect->height());
1155 decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height());
1156 }
1157 break; }
1158 case QStyleOptionViewItem::Left: {
1159 if (opt->direction == Qt::LeftToRight) {
1160 decoration.setRect(x + cw, y, pm.width(), h);
1161 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
1162 } else {
1163 display.setRect(x, y, w - pm.width() - cw, h);
1164 decoration.setRect(display.right() + 1, y, pm.width(), h);
1165 }
1166 break; }
1167 case QStyleOptionViewItem::Right: {
1168 if (opt->direction == Qt::LeftToRight) {
1169 display.setRect(x + cw, y, w - pm.width() - cw, h);
1170 decoration.setRect(display.right() + 1, y, pm.width(), h);
1171 } else {
1172 decoration.setRect(x, y, pm.width(), h);
1173 display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h);
1174 }
1175 break; }
1176 default:
1177 qCWarning(lcCommonStyle, "doLayout: decoration position is invalid");
1178 decoration = *pixmapRect;
1179 break;
1180 }
1181
1182 if (!sizehint) { // we only need to do the internal layout if we are going to paint
1184 checkRect->size(), check);
1185 *pixmapRect = QStyle::alignedRect(opt->direction, opt->decorationAlignment,
1186 pixmapRect->size(), decoration);
1187 // the textRect takes up all remaining size
1188 *textRect = display;
1189 } else {
1190 *checkRect = check;
1191 *pixmapRect = decoration;
1192 *textRect = display;
1193 }
1194}
1195#endif // QT_CONFIG(itemviews)
1196
1197#if QT_CONFIG(toolbutton)
1198QString QCommonStylePrivate::toolButtonElideText(const QStyleOptionToolButton *option,
1199 const QRect &textRect, int flags) const
1200{
1201 if (option->fontMetrics.horizontalAdvance(option->text) <= textRect.width())
1202 return option->text;
1203
1204 QString text = option->text;
1205 text.replace(u'\n', QChar::LineSeparator);
1206 QTextOption textOption;
1208 textOption.setTextDirection(option->direction);
1209
1210 return calculateElidedText(text, textOption,
1213 false, nullptr);
1214}
1215#endif // QT_CONFIG(toolbutton)
1216
1217#if QT_CONFIG(tabbar)
1223void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const
1224{
1226 Q_ASSERT(iconRect);
1227 QRect tr = opt->rect;
1228 bool verticalTabs = opt->shape == QTabBar::RoundedEast
1229 || opt->shape == QTabBar::RoundedWest
1230 || opt->shape == QTabBar::TriangularEast
1231 || opt->shape == QTabBar::TriangularWest;
1232 if (verticalTabs)
1233 tr.setRect(0, 0, tr.height(), tr.width()); // 0, 0 as we will have a translate transform
1234
1239 if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth)
1240 verticalShift = -verticalShift;
1241 tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding);
1242 bool selected = opt->state & QStyle::State_Selected;
1243 if (selected) {
1244 tr.setTop(tr.top() - verticalShift);
1245 tr.setRight(tr.right() - horizontalShift);
1246 }
1247
1248 // left widget
1249 if (!opt->leftButtonSize.isEmpty()) {
1250 tr.setLeft(tr.left() + 4 +
1251 (verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width()));
1252 }
1253 // right widget
1254 if (!opt->rightButtonSize.isEmpty()) {
1255 tr.setRight(tr.right() - 4 -
1256 (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width()));
1257 }
1258
1259 // icon
1260 if (!opt->icon.isNull()) {
1262 if (!iconSize.isValid()) {
1264 iconSize = QSize(iconExtent, iconExtent);
1265 }
1266 QSize tabIconSize = opt->icon.actualSize(iconSize,
1268 (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off);
1269 // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize
1270 tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height()));
1271
1272 const int offsetX = (iconSize.width() - tabIconSize.width()) / 2;
1273 *iconRect = QRect(tr.left() + offsetX, tr.center().y() - tabIconSize.height() / 2,
1274 tabIconSize.width(), tabIconSize.height());
1275 if (!verticalTabs)
1276 *iconRect = QStyle::visualRect(opt->direction, opt->rect, *iconRect);
1277 tr.setLeft(tr.left() + tabIconSize.width() + 4);
1278 }
1279
1280 if (!verticalTabs)
1282
1283 *textRect = tr;
1284}
1285#endif // QT_CONFIG(tabbar)
1286
1287#if QT_CONFIG(animation)
1289QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const
1290{
1291 return animations.value(target);
1292}
1293
1295void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const
1296{
1297 Q_Q(const QCommonStyle);
1298 const auto target = animation->target();
1301 q, [this, target]() { removeAnimation(target); });
1302 animations.insert(target, animation);
1303 animation->start();
1304}
1305
1307void QCommonStylePrivate::stopAnimation(const QObject *target) const
1308{
1309 QStyleAnimation *animation = animations.take(target);
1310 if (animation) {
1311 animation->stop();
1312 delete animation;
1313 }
1314}
1315
1317void QCommonStylePrivate::removeAnimation(const QObject *target) const
1318{
1319 animations.remove(target);
1320}
1321#endif
1322
1327 QPainter *p, const QWidget *widget) const
1328{
1329 Q_D(const QCommonStyle);
1330 switch (element) {
1331
1332 case CE_PushButton:
1333 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1338 if (btn->state & State_HasFocus) {
1340 fropt.QStyleOption::operator=(*btn);
1343 }
1344 }
1345 break;
1346 case CE_PushButtonBevel:
1347 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1348 QRect br = btn->rect;
1353 br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
1355 || btn->state & (State_Sunken | State_On)
1357 QStyleOptionButton tmpBtn = *btn;
1358 tmpBtn.rect = br;
1360 }
1363 QRect ir = btn->rect;
1364 QStyleOptionButton newBtn = *btn;
1365 newBtn.rect = QRect(ir.right() - mbi - 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6);
1366 newBtn.rect = visualRect(btn->direction, br, newBtn.rect);
1368 }
1369 }
1370 break;
1371 case CE_PushButtonLabel:
1372 if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1377
1378 if (button->features & QStyleOptionButton::HasMenu) {
1379 int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget);
1380 if (button->direction == Qt::LeftToRight)
1381 textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
1382 else
1383 textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
1384 }
1385
1386 if (!button->icon.isNull()) {
1387 //Center both icon and text
1389 if (mode == QIcon::Normal && button->state & State_HasFocus)
1392 if (button->state & State_On)
1393 state = QIcon::On;
1394
1395 QPixmap pixmap = button->icon.pixmap(button->iconSize, p->device()->devicePixelRatio(), mode, state);
1396 int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
1397 int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
1398 int labelWidth = pixmapWidth;
1399 int labelHeight = pixmapHeight;
1400 int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
1401 if (!button->text.isEmpty()) {
1402 int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
1403 labelWidth += (textWidth + iconSpacing);
1404 }
1405
1406 QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
1407 textRect.y() + (textRect.height() - labelHeight) / 2,
1408 pixmapWidth, pixmapHeight);
1409
1410 iconRect = visualRect(button->direction, textRect, iconRect);
1411
1412 if (button->direction == Qt::RightToLeft)
1413 textRect.setRight(iconRect.left() - iconSpacing / 2);
1414 else
1415 textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing / 2);
1416
1417 // qt_format_text reverses again when painter->layoutDirection is also RightToLeft
1418 if (p->layoutDirection() == button->direction)
1419 tf |= Qt::AlignLeft;
1420 else
1421 tf |= Qt::AlignRight;
1422
1423 if (button->state & (State_On | State_Sunken))
1424 iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget),
1426 p->drawPixmap(iconRect, pixmap);
1427 } else {
1428 tf |= Qt::AlignHCenter;
1429 }
1430 if (button->state & (State_On | State_Sunken))
1433
1436 }
1437 break;
1438 case CE_RadioButton:
1439 case CE_CheckBox:
1440 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1441 bool isRadio = (element == CE_RadioButton);
1446 &subopt, p, widget);
1450 if (btn->state & State_HasFocus) {
1452 fropt.QStyleOption::operator=(*btn);
1456 }
1457 }
1458 break;
1460 case CE_CheckBoxLabel:
1461 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1463
1466 QPixmap pix;
1468 if (!btn->icon.isNull()) {
1469 pix = btn->icon.pixmap(btn->iconSize, p->device()->devicePixelRatio(), btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
1473 else
1475 }
1476 if (!btn->text.isEmpty()){
1479 }
1480 }
1481 break;
1482#if QT_CONFIG(menu)
1483 case CE_MenuScroller: {
1484 QStyleOption arrowOpt = *opt;
1485 arrowOpt.state |= State_Enabled;
1487 &arrowOpt, p, widget);
1488 break; }
1489 case CE_MenuTearoff:
1490 if (opt->state & State_Selected)
1491 p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight));
1492 else
1493 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1494 p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1495 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1,
1496 opt->rect.x() + opt->rect.width() - 4,
1497 opt->rect.y() + opt->rect.height() / 2 - 1);
1498 p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1499 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2,
1500 opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
1501 break;
1502#endif // QT_CONFIG(menu)
1503#if QT_CONFIG(menubar)
1504 case CE_MenuBarItem:
1505 if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1510 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
1511 QPixmap pix = mbi->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1512 if (!pix.isNull())
1513 proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
1514 else
1515 proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
1516 mbi->text, QPalette::ButtonText);
1517 }
1518 break;
1521 p->eraseRect(opt->rect);
1522 break;
1523#endif // QT_CONFIG(menubar)
1524#if QT_CONFIG(progressbar)
1525 case CE_ProgressBar:
1526 if (const QStyleOptionProgressBar *pb
1527 = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1533 if (pb->textVisible) {
1536 }
1537 }
1538 break;
1540 if (opt->rect.isValid())
1541 qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
1543 break;
1545 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1546 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1547 if (!vertical) {
1549 if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
1550 && ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) {
1551 textRole = QPalette::HighlightedText;
1552 //Draw text shadow, This will increase readability when the background of same color
1553 QRect shadowRect(pb->rect);
1554 shadowRect.translate(1,1);
1555 QColor shadowColor = (pb->palette.color(textRole).value() <= 128)
1556 ? QColor(255,255,255,160) : QColor(0,0,0,160);
1557 QPalette shadowPalette = pb->palette;
1558 shadowPalette.setColor(textRole, shadowColor);
1559 proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette,
1560 pb->state & State_Enabled, pb->text, textRole);
1561 }
1562 proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette,
1563 pb->state & State_Enabled, pb->text, textRole);
1564 }
1565 }
1566 break;
1568 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1569
1570 QRect rect = pb->rect;
1571 const bool vertical = !(pb->state & QStyle::State_Horizontal);
1572 const bool inverted = pb->invertedAppearance;
1573 qint64 minimum = qint64(pb->minimum);
1574 qint64 maximum = qint64(pb->maximum);
1575 qint64 progress = qint64(pb->progress);
1576
1577 QTransform m;
1578
1579 if (vertical) {
1580 rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height
1581 m.rotate(90);
1582 m.translate(0, -(rect.height() + rect.y()*2));
1583 }
1584
1585 QPalette pal2 = pb->palette;
1586 // Correct the highlight color if it is the same as the background
1587 if (pal2.highlight() == pal2.window())
1588 pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
1590 bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
1591 if (inverted)
1592 reverse = !reverse;
1593 int w = rect.width();
1594 if (pb->minimum == 0 && pb->maximum == 0) {
1595 // draw busy indicator
1596 int x = (progress - minimum) % (w * 2);
1597 if (x > w)
1598 x = 2 * w - x;
1599 x = reverse ? rect.right() - x : x + rect.x();
1600 p->setPen(QPen(pal2.highlight().color(), 4));
1601 p->drawLine(x, rect.y(), x, rect.height());
1602 } else {
1603 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
1604 if (!unit_width)
1605 return;
1606
1607 int u;
1608 if (unit_width > 1)
1609 u = ((rect.width() + unit_width) / unit_width);
1610 else
1611 u = w / unit_width;
1612 qint64 p_v = progress - minimum;
1613 qint64 t_s = (maximum - minimum) ? (maximum - minimum) : qint64(1);
1614
1615 if (u > 0 && p_v >= INT_MAX / u && t_s >= u) {
1616 // scale down to something usable.
1617 p_v /= u;
1618 t_s /= u;
1619 }
1620
1621 // nu < tnu, if last chunk is only a partial chunk
1622 int tnu, nu;
1623 tnu = nu = p_v * u / t_s;
1624
1625 if (nu * unit_width > w)
1626 --nu;
1627
1628 // Draw nu units out of a possible u of unit_width
1629 // width, each a rectangle bordered by background
1630 // color, all in a sunken panel with a percentage text
1631 // display at the end.
1632 int x = 0;
1633 int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0)
1634 : rect.x();
1635
1636 QStyleOptionProgressBar pbBits = *pb;
1637 pbBits.rect = rect;
1638 pbBits.palette = pal2;
1639 int myY = pbBits.rect.y();
1640 int myHeight = pbBits.rect.height();
1641 pbBits.state = State_None;
1642 for (int i = 0; i < nu; ++i) {
1643 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1644 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1646 x += reverse ? -unit_width : unit_width;
1647 }
1648
1649 // Draw the last partial chunk to fill up the
1650 // progress bar entirely
1651 if (nu < tnu) {
1652 int pixels_left = w - (nu * unit_width);
1653 int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x;
1654 pbBits.rect.setRect(offset, myY, pixels_left, myHeight);
1655 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect();
1657 }
1658 }
1659 }
1660 break;
1661#endif // QT_CONFIG(progressbar)
1662 case CE_HeaderLabel:
1663 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
1664 QRect rect = header->rect;
1665 if (!header->icon.isNull()) {
1666 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
1668 = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1669 int pixw = pixmap.width() / pixmap.devicePixelRatio();
1670
1671 QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect);
1672 QRect inter = aligned.intersected(rect);
1673 p->drawPixmap(inter.x(), inter.y(), pixmap,
1674 inter.x() - aligned.x(), inter.y() - aligned.y(),
1675 aligned.width() * pixmap.devicePixelRatio(),
1676 pixmap.height() * pixmap.devicePixelRatio());
1677
1678 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
1679 if (header->direction == Qt::LeftToRight)
1680 rect.setLeft(rect.left() + pixw + margin);
1681 else
1682 rect.setRight(rect.right() - pixw - margin);
1683 }
1684 QFontMetrics fm(header->fontMetrics);
1685 if (header->state & QStyle::State_On) {
1686 QFont fnt = p->font();
1687 // the font already has a weight set; don't override that
1688 if (!(fnt.resolveMask() & QFont::WeightResolved)) {
1689 fnt.setBold(true);
1690 p->setFont(fnt);
1691 fm = QFontMetrics((p->font()));
1692 }
1693 }
1694 QString text = header->text;
1695 if (const QStyleOptionHeaderV2 *headerV2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(header)) {
1696 if (headerV2->textElideMode != Qt::ElideNone)
1697 text = fm.elidedText(header->text, headerV2->textElideMode, rect.width());
1698 }
1699 proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
1700 header->state.testFlag(State_Enabled), text, QPalette::ButtonText);
1701 }
1702 break;
1703#if QT_CONFIG(toolbutton)
1704 case CE_ToolButtonLabel:
1705 if (const QStyleOptionToolButton *toolbutton
1706 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1707 QRect rect = toolbutton->rect;
1708 int shiftX = 0;
1709 int shiftY = 0;
1710 if (toolbutton->state & (State_Sunken | State_On)) {
1711 shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget);
1712 shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget);
1713 }
1714 // Arrow type always overrules and is always shown
1715 bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow;
1716 if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty())
1717 || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) {
1721 rect.translate(shiftX, shiftY);
1722 p->setFont(toolbutton->font);
1723 const QString text = d->toolButtonElideText(toolbutton, rect, alignment);
1724 proxy()->drawItemText(p, rect, alignment, toolbutton->palette,
1727 } else {
1728 QPixmap pm;
1729 QSize pmSize = toolbutton->iconSize;
1730 if (!toolbutton->icon.isNull()) {
1731 QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off;
1733 if (!(toolbutton->state & State_Enabled))
1735 else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise))
1737 else
1739 pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), p->device()->devicePixelRatio(),
1740 mode, state);
1741 pmSize = pm.size() / pm.devicePixelRatio();
1742 }
1743
1744 if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) {
1745 p->setFont(toolbutton->font);
1746 QRect pr = rect,
1747 tr = rect;
1751
1752 if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
1753 pr.setHeight(pmSize.height() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint()
1754 tr.adjust(0, pr.height() - 1, 0, -1);
1755 pr.translate(shiftX, shiftY);
1756 if (!hasArrow) {
1758 } else {
1759 drawArrow(proxy(), toolbutton, pr, p, widget);
1760 }
1762 } else {
1763 pr.setWidth(pmSize.width() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint()
1764 tr.adjust(pr.width(), 0, 0, 0);
1765 pr.translate(shiftX, shiftY);
1766 if (!hasArrow) {
1768 } else {
1769 drawArrow(proxy(), toolbutton, pr, p, widget);
1770 }
1772 }
1773 tr.translate(shiftX, shiftY);
1774 const QString text = d->toolButtonElideText(toolbutton, tr, alignment);
1775 proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette,
1776 toolbutton->state & State_Enabled, text,
1778 } else {
1779 rect.translate(shiftX, shiftY);
1780 if (hasArrow) {
1781 drawArrow(proxy(), toolbutton, rect, p, widget);
1782 } else {
1784 }
1785 }
1786 }
1787 }
1788 break;
1789#endif // QT_CONFIG(toolbutton)
1790#if QT_CONFIG(toolbox)
1791 case CE_ToolBoxTab:
1792 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1795 }
1796 break;
1797 case CE_ToolBoxTabShape:
1798 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1799 p->setPen(tb->palette.mid().color().darker(150));
1800 int d = 20 + tb->rect.height() - 3;
1801 if (tb->direction != Qt::RightToLeft) {
1802 const QPoint points[] = {
1803 QPoint(-1, tb->rect.height() + 1),
1804 QPoint(-1, 1),
1805 QPoint(tb->rect.width() - d, 1),
1806 QPoint(tb->rect.width() - 20, tb->rect.height() - 2),
1807 QPoint(tb->rect.width() - 1, tb->rect.height() - 2),
1808 QPoint(tb->rect.width() - 1, tb->rect.height() + 1),
1809 QPoint(-1, tb->rect.height() + 1),
1810 };
1811 p->drawPolygon(points, sizeof points / sizeof *points);
1812 } else {
1813 const QPoint points[] = {
1814 QPoint(tb->rect.width(), tb->rect.height() + 1),
1815 QPoint(tb->rect.width(), 1),
1816 QPoint(d - 1, 1),
1817 QPoint(20 - 1, tb->rect.height() - 2),
1818 QPoint(0, tb->rect.height() - 2),
1819 QPoint(0, tb->rect.height() + 1),
1820 QPoint(tb->rect.width(), tb->rect.height() + 1),
1821 };
1822 p->drawPolygon(points, sizeof points / sizeof *points);
1823 }
1824 p->setPen(tb->palette.light().color());
1825 if (tb->direction != Qt::RightToLeft) {
1826 p->drawLine(0, 2, tb->rect.width() - d, 2);
1827 p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1);
1828 p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1,
1829 tb->rect.width(), tb->rect.height() - 1);
1830 } else {
1831 p->drawLine(tb->rect.width() - 1, 2, d - 1, 2);
1832 p->drawLine(d, 2, 20, tb->rect.height() - 1);
1833 p->drawLine(19, tb->rect.height() - 1,
1834 -1, tb->rect.height() - 1);
1835 }
1836 p->setBrush(Qt::NoBrush);
1837 }
1838 break;
1839#endif // QT_CONFIG(toolbox)
1840#if QT_CONFIG(tabbar)
1841 case CE_TabBarTab:
1842 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1845 }
1846 break;
1847 case CE_TabBarTabShape:
1848 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
1849 QPainterStateSaver pss(p);
1850 QRect rect(tab->rect);
1851 bool selected = tab->state & State_Selected;
1852 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1853 int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget);
1854
1855 if (!selected) {
1856 switch (tab->shape) {
1858 rect.adjust(0, 0, 0, -tabOverlap);
1859 if (!selected)
1860 rect.adjust(1, 1, -1, 0);
1861 break;
1863 rect.adjust(0, tabOverlap, 0, 0);
1864 if (!selected)
1865 rect.adjust(1, 0, -1, -1);
1866 break;
1868 rect.adjust(tabOverlap, 0, 0, 0);
1869 if (!selected)
1870 rect.adjust(0, 1, -1, -1);
1871 break;
1873 rect.adjust(0, 0, -tabOverlap, 0);
1874 if (!selected)
1875 rect.adjust(1, 1, 0, -1);
1876 break;
1877 default:
1878 break;
1879 }
1880 }
1881
1882 p->setPen(QPen(tab->palette.windowText(), 0));
1883 if (selected) {
1884 p->setBrush(tab->palette.base());
1885 } else {
1886 if (widget && widget->parentWidget())
1887 p->setBrush(widget->parentWidget()->palette().window());
1888 else
1889 p->setBrush(tab->palette.window());
1890 }
1891
1892 int y;
1893 int x;
1894 QPolygon a(10);
1895 switch (tab->shape) {
1898 a.setPoint(0, 0, -1);
1899 a.setPoint(1, 0, 0);
1900 y = rect.height() - 2;
1901 x = y / 3;
1902 a.setPoint(2, x++, y - 1);
1903 ++x;
1904 a.setPoint(3, x++, y++);
1905 a.setPoint(4, x, y);
1906
1907 int i;
1908 int right = rect.width() - 1;
1909 for (i = 0; i < 5; ++i)
1910 a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y());
1911 if (tab->shape == QTabBar::TriangularNorth)
1912 for (i = 0; i < 10; ++i)
1913 a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y());
1914
1915 a.translate(rect.left(), rect.top());
1916 p->setRenderHint(QPainter::Antialiasing);
1917 p->translate(0, 0.5);
1918
1920 path.addPolygon(a);
1921 p->drawPath(path);
1922 break; }
1925 a.setPoint(0, -1, 0);
1926 a.setPoint(1, 0, 0);
1927 x = rect.width() - 2;
1928 y = x / 3;
1929 a.setPoint(2, x - 1, y++);
1930 ++y;
1931 a.setPoint(3, x++, y++);
1932 a.setPoint(4, x, y);
1933 int i;
1934 int bottom = rect.height() - 1;
1935 for (i = 0; i < 5; ++i)
1936 a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y());
1937 if (tab->shape == QTabBar::TriangularWest)
1938 for (i = 0; i < 10; ++i)
1939 a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y());
1940 a.translate(rect.left(), rect.top());
1941 p->setRenderHint(QPainter::Antialiasing);
1942 p->translate(0.5, 0);
1944 path.addPolygon(a);
1945 p->drawPath(path);
1946 break; }
1947 default:
1948 break;
1949 }
1950 }
1951 break;
1952 case CE_ToolBoxTabLabel:
1953 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
1954 bool enabled = tb->state & State_Enabled;
1955 bool selected = tb->state & State_Selected;
1956 int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget);
1957 QPixmap pm = tb->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(),
1959
1961 QRect tr, ir;
1962 int ih = 0;
1963 if (pm.isNull()) {
1964 tr = cr;
1965 tr.adjust(4, 0, -8, 0);
1966 } else {
1967 int iw = pm.width() / pm.devicePixelRatio() + 4;
1968 ih = pm.height()/ pm.devicePixelRatio();
1969 ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih);
1970 tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height());
1971 }
1972
1974 QFont f(p->font());
1975 f.setBold(true);
1976 p->setFont(f);
1977 }
1978
1979 QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width());
1980
1981 if (ih)
1982 p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm);
1983
1988
1989 if (!txt.isEmpty() && opt->state & State_HasFocus) {
1991 opt.rect = tr;
1992 opt.palette = tb->palette;
1995 }
1996 }
1997 break;
1998 case CE_TabBarTabLabel:
1999 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2000 QRect tr = tab->rect;
2001 bool verticalTabs = tab->shape == QTabBar::RoundedEast
2002 || tab->shape == QTabBar::RoundedWest
2003 || tab->shape == QTabBar::TriangularEast
2004 || tab->shape == QTabBar::TriangularWest;
2005
2009
2011 if (verticalTabs) {
2012 int newX, newY, newRot;
2013 if (tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::TriangularEast) {
2014 newX = tr.width() + tr.x();
2015 newY = tr.y();
2016 newRot = 90;
2017 } else {
2018 newX = tr.x();
2019 newY = tr.y() + tr.height();
2020 newRot = -90;
2021 }
2023 m.rotate(newRot);
2024 p->setTransform(m, true);
2025 }
2026 QRect iconRect;
2027 d->tabLayout(tab, widget, &tr, &iconRect);
2028
2029 // compute tr again, unless tab is moving, because the style may override subElementRect
2030 if (tab->position != QStyleOptionTab::TabPosition::Moving)
2032
2033 if (!tab->icon.isNull()) {
2034 QPixmap tabIcon = tab->icon.pixmap(tab->iconSize, p->device()->devicePixelRatio(),
2035 (tab->state & State_Enabled) ? QIcon::Normal
2037 (tab->state & State_Selected) ? QIcon::On
2038 : QIcon::Off);
2039 p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
2040 }
2041
2042 proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text,
2044 pss.restore();
2045
2046 if (tab->state & State_HasFocus) {
2047 const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth, opt, widget);
2048
2049 int x1, x2;
2050 x1 = tab->rect.left();
2051 x2 = tab->rect.right() - 1;
2052
2054 fropt.QStyleOption::operator=(*tab);
2055 fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET,
2056 x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET);
2058 }
2059 }
2060 break;
2061#endif // QT_CONFIG(tabbar)
2062#if QT_CONFIG(sizegrip)
2063 case CE_SizeGrip: {
2064 QPainterStateSaver pss(p);
2065 int x, y, w, h;
2066 opt->rect.getRect(&x, &y, &w, &h);
2067
2068 int sw = qMin(h, w);
2069 if (h > w)
2070 p->translate(0, h - w);
2071 else
2072 p->translate(w - h, 0);
2073
2074 int sx = x;
2075 int sy = y;
2076 int s = sw / 3;
2077
2078 Qt::Corner corner;
2079 if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt))
2080 corner = sgOpt->corner;
2081 else if (opt->direction == Qt::RightToLeft)
2082 corner = Qt::BottomLeftCorner;
2083 else
2084 corner = Qt::BottomRightCorner;
2085
2086 if (corner == Qt::BottomLeftCorner) {
2087 sx = x + sw;
2088 for (int i = 0; i < 4; ++i) {
2089 p->setPen(QPen(opt->palette.light().color(), 1));
2090 p->drawLine(x, sy - 1 , sx + 1, sw);
2091 p->setPen(QPen(opt->palette.dark().color(), 1));
2092 p->drawLine(x, sy, sx, sw);
2093 p->setPen(QPen(opt->palette.dark().color(), 1));
2094 p->drawLine(x, sy + 1, sx - 1, sw);
2095 sx -= s;
2096 sy += s;
2097 }
2098 } else if (corner == Qt::BottomRightCorner) {
2099 for (int i = 0; i < 4; ++i) {
2100 p->setPen(QPen(opt->palette.light().color(), 1));
2101 p->drawLine(sx - 1, sw, sw, sy - 1);
2102 p->setPen(QPen(opt->palette.dark().color(), 1));
2103 p->drawLine(sx, sw, sw, sy);
2104 p->setPen(QPen(opt->palette.dark().color(), 1));
2105 p->drawLine(sx + 1, sw, sw, sy + 1);
2106 sx += s;
2107 sy += s;
2108 }
2109 } else if (corner == Qt::TopRightCorner) {
2110 sy = y + sw;
2111 for (int i = 0; i < 4; ++i) {
2112 p->setPen(QPen(opt->palette.light().color(), 1));
2113 p->drawLine(sx - 1, y, sw, sy + 1);
2114 p->setPen(QPen(opt->palette.dark().color(), 1));
2115 p->drawLine(sx, y, sw, sy);
2116 p->setPen(QPen(opt->palette.dark().color(), 1));
2117 p->drawLine(sx + 1, y, sw, sy - 1);
2118 sx += s;
2119 sy -= s;
2120 }
2121 } else if (corner == Qt::TopLeftCorner) {
2122 for (int i = 0; i < 4; ++i) {
2123 p->setPen(QPen(opt->palette.light().color(), 1));
2124 p->drawLine(x, sy - 1, sx - 1, y);
2125 p->setPen(QPen(opt->palette.dark().color(), 1));
2126 p->drawLine(x, sy, sx, y);
2127 p->setPen(QPen(opt->palette.dark().color(), 1));
2128 p->drawLine(x, sy + 1, sx + 1, y);
2129 sx += s;
2130 sy += s;
2131 }
2132 }
2133 break; }
2134#endif // QT_CONFIG(sizegrip)
2135#if QT_CONFIG(rubberband)
2136 case CE_RubberBand: {
2137 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
2138 QPixmap tiledPixmap(16, 16);
2139 QPainter pixmapPainter(&tiledPixmap);
2140 pixmapPainter.setPen(Qt::NoPen);
2141 pixmapPainter.setBrush(Qt::Dense4Pattern);
2142 pixmapPainter.setBackground(QBrush(opt->palette.base()));
2143 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
2144 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
2145 pixmapPainter.end();
2146 // ### workaround for borked XRENDER
2147 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
2148
2149 QPainterStateSaver pss(p);
2150 QRect r = opt->rect;
2153 p->setClipRegion(mask.region);
2154 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
2156 p->setBrush(Qt::NoBrush);
2157 p->drawRect(r.adjusted(0, 0, -1, -1));
2158 if (rbOpt->shape == QRubberBand::Rectangle)
2159 p->drawRect(r.adjusted(3, 3, -4, -4));
2160 }
2161 break; }
2162#endif // QT_CONFIG(rubberband)
2163#if QT_CONFIG(dockwidget)
2164 case CE_DockWidgetTitle:
2165 if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
2166 QRect r = dwOpt->rect.adjusted(0, 0, -1, -1);
2167 if (dwOpt->movable) {
2168 p->setPen(dwOpt->palette.color(QPalette::Dark));
2169 p->drawRect(r);
2170 }
2171
2172 if (!dwOpt->title.isEmpty()) {
2173 const bool verticalTitleBar = dwOpt->verticalTitleBar;
2174
2175 QPainterStateSaver pss(p, verticalTitleBar);
2176 if (verticalTitleBar) {
2177 r = r.transposed();
2178
2179 p->translate(r.left(), r.top() + r.width());
2180 p->rotate(-90);
2181 p->translate(-r.left(), -r.top());
2182 }
2183
2184 const int indent = p->fontMetrics().descent();
2185 proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),
2187 dwOpt->state & State_Enabled, dwOpt->title,
2189 }
2190 }
2191 break;
2192#endif // QT_CONFIG(dockwidget)
2193 case CE_Header:
2194 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2195 QRegion clipRegion = p->clipRegion();
2196 p->setClipRect(opt->rect);
2198 // opt can be a QStyleOptionHeaderV2 and we must pass it to the subcontrol drawings
2200 QStyleOptionHeader &v1Copy = subopt;
2201 if (auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(opt))
2202 subopt = *v2;
2203 else
2204 v1Copy = *header;
2206 if (subopt.rect.isValid())
2208 if (header->sortIndicator != QStyleOptionHeader::None) {
2211 }
2212 p->setClipRegion(clipRegion);
2213 }
2214 break;
2215 case CE_FocusFrame:
2216 p->fillRect(opt->rect, opt->palette.windowText());
2217 break;
2218 case CE_HeaderSection:
2220 opt->state & State_Sunken, 1,
2222 break;
2223 case CE_HeaderEmptyArea:
2224 p->fillRect(opt->rect, opt->palette.window());
2225 break;
2226#if QT_CONFIG(combobox)
2227 case CE_ComboBoxLabel:
2228 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2230 QPainterStateSaver pss(p);
2231 p->setClipRect(editRect);
2232 if (!cb->currentIcon.isNull()) {
2235 QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, p->device()->devicePixelRatio(), mode);
2236 QRect iconRect(editRect);
2237 iconRect.setWidth(cb->iconSize.width() + 4);
2238 iconRect = alignedRect(cb->direction,
2240 iconRect.size(), editRect);
2241 if (cb->editable)
2242 p->fillRect(iconRect, opt->palette.brush(QPalette::Base));
2244
2245 if (cb->direction == Qt::RightToLeft)
2246 editRect.translate(-4 - cb->iconSize.width(), 0);
2247 else
2248 editRect.translate(cb->iconSize.width() + 4, 0);
2249 }
2250 if (!cb->currentText.isEmpty() && !cb->editable) {
2251 proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0),
2252 visualAlignment(cb->direction, cb->textAlignment),
2253 cb->palette, cb->state & State_Enabled, cb->currentText);
2254 }
2255 }
2256 break;
2257#endif // QT_CONFIG(combobox)
2258#if QT_CONFIG(toolbar)
2259 case CE_ToolBar:
2260 if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
2261 // Compatibility with styles that use PE_PanelToolBar
2263 frame.QStyleOption::operator=(*toolBar);
2264 frame.lineWidth = toolBar->lineWidth;
2265 frame.midLineWidth = toolBar->midLineWidth;
2267
2268 if (widget && qobject_cast<QToolBar *>(widget->parentWidget()))
2269 break;
2270 qDrawShadePanel(p, toolBar->rect, toolBar->palette, false, toolBar->lineWidth,
2271 &toolBar->palette.brush(QPalette::Button));
2272 }
2273 break;
2274#endif // QT_CONFIG(toolbar)
2275 case CE_ColumnViewGrip: {
2276 // draw background gradients
2277 QLinearGradient g(0, 0, opt->rect.width(), 0);
2278 g.setColorAt(0, opt->palette.color(QPalette::Active, QPalette::Mid));
2279 g.setColorAt(0.5, Qt::white);
2280 p->fillRect(QRect(0, 0, opt->rect.width(), opt->rect.height()), g);
2281
2282 // draw the two lines
2283 QPen pen(p->pen());
2284 pen.setWidth(opt->rect.width()/20);
2286 p->setPen(pen);
2287
2288 int line1starting = opt->rect.width()*8 / 20;
2289 int line2starting = opt->rect.width()*13 / 20;
2290 int top = opt->rect.height()*20/75;
2291 int bottom = opt->rect.height() - 1 - top;
2292 p->drawLine(line1starting, top, line1starting, bottom);
2293 p->drawLine(line2starting, top, line2starting, bottom);
2294 }
2295 break;
2296
2297#if QT_CONFIG(itemviews)
2298 case CE_ItemViewItem:
2299 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
2300 QPainterStateSaver pss(p);
2301 // the style calling this might want to clip, so respect any region already set
2302 const QRegion clipRegion = p->hasClipping() ? (p->clipRegion() & opt->rect) : opt->rect;
2303 p->setClipRegion(clipRegion);
2304
2308
2309 // draw the background
2311
2312 // draw the check mark
2313 if (vopt->features & QStyleOptionViewItem::HasCheckIndicator) {
2314 QStyleOptionViewItem option(*vopt);
2315 option.rect = checkRect;
2316 option.state = option.state & ~QStyle::State_HasFocus;
2317
2318 switch (vopt->checkState) {
2319 case Qt::Unchecked:
2320 option.state |= QStyle::State_Off;
2321 break;
2324 break;
2325 case Qt::Checked:
2326 option.state |= QStyle::State_On;
2327 break;
2328 }
2330 }
2331
2332 // draw the icon
2334 if (!(vopt->state & QStyle::State_Enabled))
2336 else if (vopt->state & QStyle::State_Selected)
2339 vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state);
2340
2341 // draw the text
2342 if (!vopt->text.isEmpty()) {
2345 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
2346 cg = QPalette::Inactive;
2347
2348 if (vopt->state & QStyle::State_Selected) {
2349 p->setPen(vopt->palette.color(cg, QPalette::HighlightedText));
2350 } else {
2351 p->setPen(vopt->palette.color(cg, QPalette::Text));
2352 }
2353 if (vopt->state & QStyle::State_Editing) {
2354 p->setPen(vopt->palette.color(cg, QPalette::Text));
2355 p->drawRect(textRect.adjusted(0, 0, -1, -1));
2356 }
2357
2358 d->viewItemDrawText(p, vopt, textRect);
2359 }
2360
2361 // draw the focus rect
2362 if (vopt->state & QStyle::State_HasFocus) {
2364 o.QStyleOption::operator=(*vopt);
2367 o.state |= QStyle::State_Item;
2368 QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled)
2370 o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected)
2373 }
2374 }
2375 break;
2376
2377#endif // QT_CONFIG(itemviews)
2378#ifndef QT_NO_FRAME
2379 case CE_ShapedFrame:
2380 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2381 int frameShape = f->frameShape;
2382 int frameShadow = QFrame::Plain;
2383 if (f->state & QStyle::State_Sunken) {
2384 frameShadow = QFrame::Sunken;
2385 } else if (f->state & QStyle::State_Raised) {
2386 frameShadow = QFrame::Raised;
2387 }
2388
2389 int lw = f->lineWidth;
2390 int mlw = f->midLineWidth;
2392 if (widget)
2393 foregroundRole = widget->foregroundRole();
2394
2395 switch (frameShape) {
2396 case QFrame::Box:
2397 if (frameShadow == QFrame::Plain) {
2398 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2399 } else {
2400 qDrawShadeRect(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2401 }
2402 break;
2404 //keep the compatibility with Qt 4.4 if there is a proxy style.
2405 //be sure to call drawPrimitive(QStyle::PE_Frame) on the proxy style
2406 if (widget) {
2408 } else {
2410 }
2411 break;
2412 case QFrame::Panel:
2413 if (frameShadow == QFrame::Plain) {
2414 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2415 } else {
2416 qDrawShadePanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw);
2417 }
2418 break;
2419 case QFrame::WinPanel:
2420 if (frameShadow == QFrame::Plain) {
2421 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2422 } else {
2423 qDrawWinPanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken);
2424 }
2425 break;
2426 case QFrame::HLine:
2427 case QFrame::VLine: {
2428 QPoint p1, p2;
2429 if (frameShape == QFrame::HLine) {
2430 p1 = QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height() / 2);
2431 p2 = QPoint(opt->rect.x() + opt->rect.width(), p1.y());
2432 } else {
2433 p1 = QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
2434 p2 = QPoint(p1.x(), p1.y() + opt->rect.height());
2435 }
2436 if (frameShadow == QFrame::Plain) {
2437 QPen oldPen = p->pen();
2438 p->setPen(QPen(opt->palette.brush(foregroundRole), lw));
2439 p->drawLine(p1, p2);
2440 p->setPen(oldPen);
2441 } else {
2442 qDrawShadeLine(p, p1, p2, f->palette, frameShadow == QFrame::Sunken, lw, mlw);
2443 }
2444 break;
2445 }
2446 }
2447 }
2448 break;
2449#endif
2450 default:
2451 break;
2452 }
2453#if !QT_CONFIG(tabbar) && !QT_CONFIG(itemviews)
2454 Q_UNUSED(d);
2455#endif
2456}
2457
2462 const QWidget *widget) const
2463{
2464 Q_D(const QCommonStyle);
2465 QRect r;
2466 switch (sr) {
2468 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2469 int dx1, dx2;
2473 dx2 = dx1 * 2;
2474 r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2,
2475 opt->rect.height() - dx2);
2477 }
2478 break;
2480 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2481 int dbw1 = 0, dbw2 = 0;
2484 dbw2 = dbw1 * 2;
2485 }
2486
2487 int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1,
2488 dfw2 = dfw1 * 2;
2489
2490 r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1,
2491 btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2);
2493 }
2494 break;
2495 case SE_PushButtonBevel:
2496 {
2497 r = opt->rect;
2499 }
2500 break;
2502 {
2504 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2507 }
2508 break;
2509
2511 {
2512 // Deal with the logical first, then convert it back to screen coords.
2516 r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2517 opt->rect.height());
2519 }
2520 break;
2521
2523 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2524 if (btn->icon.isNull() && btn->text.isEmpty()) {
2526 r.adjust(1, 1, -1, -1);
2527 break;
2528 }
2529 // As above, deal with the logical first, then convert it back to screen coords.
2532
2533 QRect iconRect, textRect;
2534 if (!btn->text.isEmpty()) {
2538 }
2539 if (!btn->icon.isNull()) {
2543 if (!textRect.isEmpty())
2544 textRect.translate(iconRect.right() + 4, 0);
2545 }
2546 r = iconRect | textRect;
2547 r.adjust(-3, -2, 3, 2);
2548 r = r.intersected(btn->rect);
2550 }
2551 break;
2552
2554 {
2556 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2559 }
2560 break;
2561
2563 {
2567 r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2568 opt->rect.height());
2570 break;
2571 }
2572
2574 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
2575 if (btn->icon.isNull() && btn->text.isEmpty()) {
2577 r.adjust(1, 1, -1, -1);
2578 break;
2579 }
2582
2583 QRect iconRect, textRect;
2584 if (!btn->text.isEmpty()){
2587 }
2588 if (!btn->icon.isNull()) {
2591 if (!textRect.isEmpty())
2592 textRect.translate(iconRect.right() + 4, 0);
2593 }
2594 r = iconRect | textRect;
2595 r.adjust(-3, -2, 3, 2);
2596 r = r.intersected(btn->rect);
2598 }
2599 break;
2600#if QT_CONFIG(slider)
2601 case SE_SliderFocusRect:
2602 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
2603 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
2604 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
2605 if (slider->orientation == Qt::Horizontal)
2606 r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2);
2607 else
2608 r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height());
2609 r = r.intersected(slider->rect);
2611 }
2612 break;
2613#endif // QT_CONFIG(slider)
2614#if QT_CONFIG(progressbar)
2618 if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
2619 int textw = 0;
2620 const bool vertical = !(pb->state & QStyle::State_Horizontal);
2621 if (!vertical) {
2622 if (pb->textVisible)
2623 textw = qMax(pb->fontMetrics.horizontalAdvance(pb->text), pb->fontMetrics.horizontalAdvance("100%"_L1)) + 6;
2624 }
2625
2626 if ((pb->textAlignment & Qt::AlignCenter) == 0) {
2627 if (sr != SE_ProgressBarLabel)
2628 r.setCoords(pb->rect.left(), pb->rect.top(),
2629 pb->rect.right() - textw, pb->rect.bottom());
2630 else
2631 r.setCoords(pb->rect.right() - textw, pb->rect.top(),
2632 pb->rect.right(), pb->rect.bottom());
2633 } else {
2634 r = pb->rect;
2635 }
2636 r = visualRect(pb->direction, pb->rect, r);
2637 }
2638 break;
2639#endif // QT_CONFIG(progressbar)
2640#if QT_CONFIG(combobox)
2642 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
2643 int margin = cb->frame ? 3 : 0;
2644 r.setRect(opt->rect.left() + margin, opt->rect.top() + margin,
2645 opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin);
2647 }
2648 break;
2649#endif // QT_CONFIG(combobox)
2650#if QT_CONFIG(toolbox)
2652 r = opt->rect;
2653 r.adjust(0, 0, -30, 0);
2654 break;
2655#endif // QT_CONFIG(toolbox)
2656 case SE_HeaderLabel: {
2658 r.setRect(opt->rect.x() + margin, opt->rect.y() + margin,
2659 opt->rect.width() - margin * 2, opt->rect.height() - margin * 2);
2660
2661 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
2662 // Subtract width needed for arrow, if there is one
2663 if (header->sortIndicator != QStyleOptionHeader::None) {
2664 if (opt->state & State_Horizontal)
2665 r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
2666 else
2667 r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2));
2668 }
2669 }
2671 break; }
2672 case SE_HeaderArrow: {
2673 int h = opt->rect.height();
2674 int w = opt->rect.width();
2675 int x = opt->rect.x();
2676 int y = opt->rect.y();
2678
2679 if (opt->state & State_Horizontal) {
2680 int horiz_size = h / 2;
2681 r.setRect(x + w - margin * 2 - horiz_size, y + 5,
2682 horiz_size, h - margin * 2 - 5);
2683 } else {
2684 int vert_size = w / 2;
2685 r.setRect(x + 5, y + h - margin * 2 - vert_size,
2686 w - margin * 2 - 5, vert_size);
2687 }
2689 break; }
2690
2694 break;
2698 break;
2699#if QT_CONFIG(tabwidget)
2700 case SE_TabWidgetTabBar:
2701 if (const QStyleOptionTabWidgetFrame *twf
2702 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2703 r.setSize(twf->tabBarSize);
2704 const uint alingMask = Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter;
2705 switch (twf->shape) {
2708 // Constrain the size now, otherwise, center could get off the page
2709 // This of course repeated for all the other directions
2710 r.setWidth(qMin(r.width(), twf->rect.width()
2711 - twf->leftCornerWidgetSize.width()
2712 - twf->rightCornerWidgetSize.width()));
2713 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2714 default:
2715 case Qt::AlignLeft:
2716 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0));
2717 break;
2718 case Qt::AlignHCenter:
2719 r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2720 + (twf->leftCornerWidgetSize.width() / 2)
2721 - (twf->rightCornerWidgetSize.width() / 2), 0));
2722 break;
2723 case Qt::AlignRight:
2724 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2725 - twf->rightCornerWidgetSize.width(), 0));
2726 break;
2727 }
2728 r = visualRect(twf->direction, twf->rect, r);
2729 break;
2732 r.setWidth(qMin(r.width(), twf->rect.width()
2733 - twf->leftCornerWidgetSize.width()
2734 - twf->rightCornerWidgetSize.width()));
2735 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2736 default:
2737 case Qt::AlignLeft:
2738 r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(),
2739 twf->rect.height() - twf->tabBarSize.height()));
2740 break;
2741 case Qt::AlignHCenter:
2742 r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2743 + (twf->leftCornerWidgetSize.width() / 2)
2744 - (twf->rightCornerWidgetSize.width() / 2),
2745 twf->rect.height() - twf->tabBarSize.height()));
2746 break;
2747 case Qt::AlignRight:
2748 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width()
2749 - twf->rightCornerWidgetSize.width(),
2750 twf->rect.height() - twf->tabBarSize.height()));
2751 break;
2752 }
2753 r = visualRect(twf->direction, twf->rect, r);
2754 break;
2757 r.setHeight(qMin(r.height(), twf->rect.height()
2758 - twf->leftCornerWidgetSize.height()
2759 - twf->rightCornerWidgetSize.height()));
2760 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2761 default:
2762 case Qt::AlignLeft:
2763 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2764 twf->leftCornerWidgetSize.height()));
2765 break;
2766 case Qt::AlignHCenter:
2767 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2768 twf->rect.center().y() - r.height() / 2));
2769 break;
2770 case Qt::AlignRight:
2771 r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(),
2772 twf->rect.height() - twf->tabBarSize.height()
2773 - twf->rightCornerWidgetSize.height()));
2774 break;
2775 }
2776 break;
2779 r.setHeight(qMin(r.height(), twf->rect.height()
2780 - twf->leftCornerWidgetSize.height()
2781 - twf->rightCornerWidgetSize.height()));
2782 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {
2783 default:
2784 case Qt::AlignLeft:
2785 r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height()));
2786 break;
2787 case Qt::AlignHCenter:
2788 r.moveTopLeft(QPoint(0, twf->rect.center().y() - r.height() / 2));
2789 break;
2790 case Qt::AlignRight:
2791 r.moveTopLeft(QPoint(0, twf->rect.height() - twf->tabBarSize.height()
2792 - twf->rightCornerWidgetSize.height()));
2793 break;
2794 }
2795 break;
2796 }
2797 }
2798 break;
2801 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2802 QStyleOptionTab tabopt;
2803 tabopt.shape = twf->shape;
2804 int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget);
2805 if (twf->lineWidth == 0)
2806 overlap = 0;
2807 switch (twf->shape) {
2810 r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)),
2811 QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2812 break;
2815 r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2816 break;
2819 r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2820 break;
2823 r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0),
2824 QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2825 break;
2826 }
2827 if (sr == SE_TabWidgetTabContents && twf->lineWidth > 0)
2828 r.adjust(2, 2, -2, -2);
2829 }
2830 break;
2832 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2834 switch (twf->shape) {
2837 r = QRect(QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()),
2838 twf->leftCornerWidgetSize);
2839 break;
2842 r = QRect(QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize);
2843 break;
2844 default:
2845 break;
2846 }
2847 r = visualRect(twf->direction, twf->rect, r);
2848 }
2849 break;
2851 if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
2853 switch (twf->shape) {
2856 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2857 paneRect.y() - twf->rightCornerWidgetSize.height()),
2858 twf->rightCornerWidgetSize);
2859 break;
2862 r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2863 paneRect.height()), twf->rightCornerWidgetSize);
2864 break;
2865 default:
2866 break;
2867 }
2868 r = visualRect(twf->direction, twf->rect, r);
2869 }
2870 break;
2871 case SE_TabBarTabText:
2872 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2873 QRect dummyIconRect;
2874 d->tabLayout(tab, widget, &r, &dummyIconRect);
2875 }
2876 break;
2879 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2880 bool selected = tab->state & State_Selected;
2881 int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
2882 int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
2883 int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
2884 hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt
2885
2886 bool verticalTabs = tab->shape == QTabBar::RoundedEast
2887 || tab->shape == QTabBar::RoundedWest
2888 || tab->shape == QTabBar::TriangularEast
2889 || tab->shape == QTabBar::TriangularWest;
2890
2891 QRect tr = tab->rect;
2892 if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth)
2893 verticalShift = -verticalShift;
2894 if (verticalTabs) {
2895 qSwap(horizontalShift, verticalShift);
2896 horizontalShift *= -1;
2897 verticalShift *= -1;
2898 }
2899 if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest)
2900 horizontalShift = -horizontalShift;
2901
2902 tr.adjust(0, 0, horizontalShift, verticalShift);
2903 if (selected)
2904 {
2905 tr.setBottom(tr.bottom() - verticalShift);
2906 tr.setRight(tr.right() - horizontalShift);
2907 }
2908
2909 QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize;
2910 int w = size.width();
2911 int h = size.height();
2912 int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2));
2913 int midWidth = ((tr.width() - w) / 2);
2914
2915 bool atTheTop = true;
2916 switch (tab->shape) {
2919 atTheTop = (sr == SE_TabBarTabLeftButton);
2920 break;
2923 atTheTop = (sr == SE_TabBarTabRightButton);
2924 break;
2925 default:
2926 if (sr == SE_TabBarTabLeftButton)
2927 r = QRect(tab->rect.x() + hpadding, midHeight, w, h);
2928 else
2929 r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h);
2930 r = visualRect(tab->direction, tab->rect, r);
2931 }
2932 if (verticalTabs) {
2933 if (atTheTop)
2934 r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h);
2935 else
2936 r = QRect(midWidth, tr.y() + hpadding, w, h);
2937 }
2938 }
2939
2940 break;
2941#endif // QT_CONFIG(tabwidget)
2942#if QT_CONFIG(tabbar)
2944 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
2945 switch (tab->shape) {
2950 r.setRect(tab->rect.left(), tab->rect.top(), 8, opt->rect.height());
2951 break;
2956 r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 8);
2957 break;
2958 default:
2959 break;
2960 }
2962 }
2963 break;
2965 const bool vertical = opt->rect.width() < opt->rect.height();
2967 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget);
2968 const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, nullptr, widget);
2969
2970 r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth)
2971 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height()));
2972 break; }
2974 const bool vertical = opt->rect.width() < opt->rect.height();
2976 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget);
2977
2978 r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth)
2979 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height()));
2980 break; }
2981#endif
2983 r = opt->rect;
2984 break;
2986 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2987 r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth);
2989 }
2990 break;
2991 case SE_FrameContents:
2992 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
2994 r = opt->rect.adjusted(fw, fw, -fw, -fw);
2996 }
2997 break;
2999 if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
3000 int frameShape = f->frameShape;
3001 int frameShadow = QFrame::Plain;
3002 if (f->state & QStyle::State_Sunken) {
3003 frameShadow = QFrame::Sunken;
3004 } else if (f->state & QStyle::State_Raised) {
3005 frameShadow = QFrame::Raised;
3006 }
3007
3008 int frameWidth = 0;
3009
3010 switch (frameShape) {
3011 case QFrame::NoFrame:
3012 frameWidth = 0;
3013 break;
3014
3015 case QFrame::Box:
3016 case QFrame::HLine:
3017 case QFrame::VLine:
3018 switch (frameShadow) {
3019 case QFrame::Plain:
3020 frameWidth = f->lineWidth;
3021 break;
3022 case QFrame::Raised:
3023 case QFrame::Sunken:
3024 frameWidth = (short)(f->lineWidth*2 + f->midLineWidth);
3025 break;
3026 }
3027 break;
3028
3030 //keep the compatibility with Qt 4.4 if there is a proxy style.
3031 //be sure to call drawPrimitive(QStyle::SE_FrameContents) on the proxy style
3032 if (widget)
3034 else
3036
3037 case QFrame::WinPanel:
3038 frameWidth = 2;
3039 break;
3040
3041 case QFrame::Panel:
3042 switch (frameShadow) {
3043 case QFrame::Plain:
3044 case QFrame::Raised:
3045 case QFrame::Sunken:
3046 frameWidth = f->lineWidth;
3047 break;
3048 }
3049 break;
3050 }
3051 r = f->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
3052 }
3053 break;
3054#if QT_CONFIG(dockwidget)
3058 case SE_DockWidgetIcon: {
3062 QRect rect = opt->rect;
3063
3064 const QStyleOptionDockWidget *dwOpt
3065 = qstyleoption_cast<const QStyleOptionDockWidget*>(opt);
3066 bool canClose = dwOpt == nullptr ? true : dwOpt->closable;
3067 bool canFloat = dwOpt == nullptr ? false : dwOpt->floatable;
3068
3069 const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
3070
3071 // If this is a vertical titlebar, we transpose and work as if it was
3072 // horizontal, then transpose again.
3073
3074 if (verticalTitleBar)
3075 rect = rect.transposed();
3076
3077 do {
3078
3079 int right = rect.right();
3080 int left = rect.left();
3081
3082 QRect closeRect;
3083 if (canClose) {
3085 opt, widget).actualSize(QSize(iconSize, iconSize));
3086 sz += QSize(buttonMargin, buttonMargin);
3087 if (verticalTitleBar)
3088 sz = sz.transposed();
3089 closeRect = QRect(right - sz.width(),
3090 rect.center().y() - sz.height()/2,
3091 sz.width(), sz.height());
3092 right = closeRect.left() - 1;
3093 }
3094 if (sr == SE_DockWidgetCloseButton) {
3095 r = closeRect;
3096 break;
3097 }
3098
3099 QRect floatRect;
3100 if (canFloat) {
3102 opt, widget).actualSize(QSize(iconSize, iconSize));
3103 sz += QSize(buttonMargin, buttonMargin);
3104 if (verticalTitleBar)
3105 sz = sz.transposed();
3106 floatRect = QRect(right - sz.width(),
3107 rect.center().y() - sz.height()/2,
3108 sz.width(), sz.height());
3109 right = floatRect.left() - 1;
3110 }
3111 if (sr == SE_DockWidgetFloatButton) {
3112 r = floatRect;
3113 break;
3114 }
3115
3116 QRect iconRect;
3117 if (const QDockWidget *dw = qobject_cast<const QDockWidget*>(widget)) {
3118 QIcon icon;
3119 if (dw->isFloating())
3120 icon = dw->windowIcon();
3121 if (!icon.isNull()
3123 QSize sz = icon.actualSize(QSize(r.height(), r.height()));
3124 if (verticalTitleBar)
3125 sz = sz.transposed();
3126 iconRect = QRect(left, rect.center().y() - sz.height()/2,
3127 sz.width(), sz.height());
3128 left = iconRect.right() + margin;
3129 }
3130 }
3131 if (sr == SE_DockWidgetIcon) {
3132 r = iconRect;
3133 break;
3134 }
3135
3136 QRect textRect = QRect(left, rect.top(),
3137 right - left, rect.height());
3138 if (sr == SE_DockWidgetTitleBarText) {
3139 r = textRect;
3140 break;
3141 }
3142
3143 } while (false);
3144
3145 if (verticalTitleBar) {
3146 r = QRect(rect.left() + r.top() - rect.top(),
3147 rect.top() + rect.right() - r.right(),
3148 r.height(), r.width());
3149 } else {
3151 }
3152 break;
3153 }
3154#endif
3155#if QT_CONFIG(itemviews)
3157 if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
3159 break;
3160 }
3161 Q_FALLTHROUGH();
3165 if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
3166 if (!d->isViewItemCached(*vopt)) {
3167 d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false);
3168 if (d->cachedOption) {
3169 delete d->cachedOption;
3170 d->cachedOption = nullptr;
3171 }
3172 d->cachedOption = new QStyleOptionViewItem(*vopt);
3173 }
3175 r = d->checkRect;
3176 else if (sr == SE_ItemViewItemDecoration)
3177 r = d->decorationRect;
3178 else if (sr == SE_ItemViewItemText || sr == SE_ItemViewItemFocusRect)
3179 r = d->displayRect;
3180 }
3181 break;
3182#endif // QT_CONFIG(itemviews)
3183#if QT_CONFIG(toolbar)
3184 case SE_ToolBarHandle:
3185 if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
3186 if (tbopt->features & QStyleOptionToolBar::Movable) {
3188 //have all the information we need (ie. the layout's margin)
3189 const QToolBar *tb = qobject_cast<const QToolBar*>(widget);
3190 const QMargins margins = tb && tb->layout() ? tb->layout()->contentsMargins() : QMargins(2, 2, 2, 2);
3191 const int handleExtent = proxy()->pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb);
3192 if (tbopt->state & QStyle::State_Horizontal) {
3193 r = QRect(margins.left(), margins.top(),
3194 handleExtent,
3195 tbopt->rect.height() - (margins.top() + margins.bottom()));
3196 r = QStyle::visualRect(tbopt->direction, tbopt->rect, r);
3197 } else {
3198 r = QRect(margins.left(), margins.top(),
3199 tbopt->rect.width() - (margins.left() + margins.right()),
3200 handleExtent);
3201 }
3202 }
3203 }
3204 break;
3205#endif // QT_CONFIG(toolbar)
3206 default:
3207 break;
3208 }
3209 return r;
3210#if !QT_CONFIG(tabwidget) && !QT_CONFIG(itemviews)
3211 Q_UNUSED(d);
3212#endif
3213}
3214
3215#if QT_CONFIG(dial)
3216
3217// in lieu of std::array, minimal API
3218template <int N>
3219struct StaticPolygonF
3220{
3221 QPointF data[N];
3222
3223 constexpr int size() const { return N; }
3224 constexpr const QPointF *cbegin() const { return data; }
3225 constexpr const QPointF &operator[](int idx) const { return data[idx]; }
3226};
3227
3228static StaticPolygonF<3> calcArrow(const QStyleOptionSlider *dial, qreal &a)
3229{
3230 int width = dial->rect.width();
3231 int height = dial->rect.height();
3232 int r = qMin(width, height) / 2;
3233 int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
3234
3235 if (dial->maximum == dial->minimum)
3236 a = Q_PI / 2;
3237 else if (dial->dialWrapping)
3238 a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
3239 / (dial->maximum - dial->minimum);
3240 else
3241 a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
3242 / (dial->maximum - dial->minimum)) / 6;
3243
3244 int xc = width / 2 + dial->rect.left();
3245 int yc = height / 2 + dial->rect.top();
3246
3247 int len = r - QStyleHelper::calcBigLineSize(r) - 5;
3248 if (len < 5)
3249 len = 5;
3250 int back = len / 2;
3251
3252 StaticPolygonF<3> arrow = {{
3253 QPointF(0.5 + xc + len * qCos(a),
3254 0.5 + yc - len * qSin(a)),
3255 QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6),
3256 0.5 + yc - back * qSin(a + Q_PI * 5 / 6)),
3257 QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6),
3258 0.5 + yc - back * qSin(a - Q_PI * 5 / 6)),
3259 }};
3260 return arrow;
3261}
3262
3263#endif // QT_CONFIG(dial)
3264
3269 QPainter *p, const QWidget *widget) const
3270{
3271 switch (cc) {
3272#if QT_CONFIG(slider)
3273 case CC_Slider:
3274 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3275 if (slider->subControls == SC_SliderTickmarks) {
3276 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
3277 int ticks = slider->tickPosition;
3278 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
3279 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
3280 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
3281 int interval = slider->tickInterval;
3282 if (interval <= 0) {
3283 interval = slider->singleStep;
3284 if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
3285 available)
3286 - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3287 0, available) < 3)
3288 interval = slider->pageStep;
3289 }
3290 if (!interval)
3291 interval = 1;
3292 int fudge = len / 2;
3293 int pos;
3294 // Since there is no subrect for tickmarks do a translation here.
3295 QPainterStateSaver pss(p);
3296 p->translate(slider->rect.x(), slider->rect.y());
3297 p->setPen(slider->palette.windowText().color());
3298 int v = slider->minimum;
3299 while (v <= slider->maximum + 1) {
3300 if (v == slider->maximum + 1 && interval == 1)
3301 break;
3302 const int v_ = qMin(v, slider->maximum);
3303 pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
3304 v_, available) + fudge;
3305 if (slider->orientation == Qt::Horizontal) {
3306 if (ticks & QSlider::TicksAbove)
3307 p->drawLine(pos, 0, pos, tickOffset - 2);
3308 if (ticks & QSlider::TicksBelow)
3309 p->drawLine(pos, tickOffset + thickness + 1, pos,
3310 slider->rect.height()-1);
3311 } else {
3312 if (ticks & QSlider::TicksAbove)
3313 p->drawLine(0, pos, tickOffset - 2, pos);
3314 if (ticks & QSlider::TicksBelow)
3315 p->drawLine(tickOffset + thickness + 1, pos,
3316 slider->rect.width()-1, pos);
3317 }
3318 // in the case where maximum is max int
3319 int nextInterval = v + interval;
3320 if (nextInterval < v)
3321 break;
3322 v = nextInterval;
3323 }
3324 }
3325 }
3326 break;
3327#endif // QT_CONFIG(slider)
3328#if QT_CONFIG(scrollbar)
3329 case CC_ScrollBar:
3330 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3331 // Make a copy here and reset it for each primitive.
3332 QStyleOptionSlider newScrollbar = *scrollbar;
3333 State saveFlags = scrollbar->state;
3334
3335 if (scrollbar->subControls & SC_ScrollBarSubLine) {
3336 newScrollbar.state = saveFlags;
3337 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget);
3338 if (newScrollbar.rect.isValid()) {
3339 if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
3340 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3341 proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget);
3342 }
3343 }
3344 if (scrollbar->subControls & SC_ScrollBarAddLine) {
3345 newScrollbar.rect = scrollbar->rect;
3346 newScrollbar.state = saveFlags;
3347 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget);
3348 if (newScrollbar.rect.isValid()) {
3349 if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
3350 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3351 proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget);
3352 }
3353 }
3354 if (scrollbar->subControls & SC_ScrollBarSubPage) {
3355 newScrollbar.rect = scrollbar->rect;
3356 newScrollbar.state = saveFlags;
3357 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget);
3358 if (newScrollbar.rect.isValid()) {
3359 if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage))
3360 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3361 proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget);
3362 }
3363 }
3364 if (scrollbar->subControls & SC_ScrollBarAddPage) {
3365 newScrollbar.rect = scrollbar->rect;
3366 newScrollbar.state = saveFlags;
3367 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget);
3368 if (newScrollbar.rect.isValid()) {
3369 if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage))
3370 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3371 proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget);
3372 }
3373 }
3374 if (scrollbar->subControls & SC_ScrollBarFirst) {
3375 newScrollbar.rect = scrollbar->rect;
3376 newScrollbar.state = saveFlags;
3377 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget);
3378 if (newScrollbar.rect.isValid()) {
3379 if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
3380 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3381 proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget);
3382 }
3383 }
3384 if (scrollbar->subControls & SC_ScrollBarLast) {
3385 newScrollbar.rect = scrollbar->rect;
3386 newScrollbar.state = saveFlags;
3387 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget);
3388 if (newScrollbar.rect.isValid()) {
3389 if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
3390 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3391 proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget);
3392 }
3393 }
3394 if (scrollbar->subControls & SC_ScrollBarSlider) {
3395 newScrollbar.rect = scrollbar->rect;
3396 newScrollbar.state = saveFlags;
3397 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget);
3398 if (newScrollbar.rect.isValid()) {
3399 if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
3400 newScrollbar.state &= ~(State_Sunken | State_MouseOver);
3401 proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget);
3402
3403 if (scrollbar->state & State_HasFocus) {
3405 fropt.QStyleOption::operator=(newScrollbar);
3406 fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2,
3407 newScrollbar.rect.width() - 5,
3408 newScrollbar.rect.height() - 5);
3410 }
3411 }
3412 }
3413 }
3414 break;
3415#endif // QT_CONFIG(scrollbar)
3416#if QT_CONFIG(spinbox)
3417 case CC_SpinBox:
3418 if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3419 QStyleOptionSpinBox copy = *sb;
3421
3422 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3424 qDrawWinPanel(p, r, sb->palette, true);
3425 }
3426
3427 if (sb->subControls & SC_SpinBoxUp) {
3428 copy.subControls = SC_SpinBoxUp;
3429 QPalette pal2 = sb->palette;
3430 if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
3432 copy.state &= ~State_Enabled;
3433 }
3434
3435 copy.palette = pal2;
3436
3437 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3438 copy.state |= State_On;
3439 copy.state |= State_Sunken;
3440 } else {
3441 copy.state |= State_Raised;
3442 copy.state &= ~State_Sunken;
3443 }
3444 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3446
3449 copy.rect.adjust(3, 0, -4, 0);
3450 proxy()->drawPrimitive(pe, &copy, p, widget);
3451 }
3452
3453 if (sb->subControls & SC_SpinBoxDown) {
3454 copy.subControls = SC_SpinBoxDown;
3455 copy.state = sb->state;
3456 QPalette pal2 = sb->palette;
3457 if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
3459 copy.state &= ~State_Enabled;
3460 }
3461 copy.palette = pal2;
3462
3463 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3464 copy.state |= State_On;
3465 copy.state |= State_Sunken;
3466 } else {
3467 copy.state |= State_Raised;
3468 copy.state &= ~State_Sunken;
3469 }
3470 pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3472
3475 copy.rect.adjust(3, 0, -4, 0);
3476 proxy()->drawPrimitive(pe, &copy, p, widget);
3477 }
3478 }
3479 break;
3480#endif // QT_CONFIG(spinbox)
3481#if QT_CONFIG(toolbutton)
3482 case CC_ToolButton:
3483 if (const QStyleOptionToolButton *toolbutton
3484 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3485 QRect button, menuarea;
3486 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
3487 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
3488
3489 State bflags = toolbutton->state & ~State_Sunken;
3490
3491 if (bflags & State_AutoRaise) {
3492 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
3493 bflags &= ~State_Raised;
3494 }
3495 }
3496 State mflags = bflags;
3497 if (toolbutton->state & State_Sunken) {
3498 if (toolbutton->activeSubControls & SC_ToolButton)
3499 bflags |= State_Sunken;
3500 mflags |= State_Sunken;
3501 }
3502
3503 QStyleOption tool = *toolbutton;
3504 if (toolbutton->subControls & SC_ToolButton) {
3505 if (bflags & (State_Sunken | State_On | State_Raised)) {
3506 tool.rect = button;
3507 tool.state = bflags;
3509 }
3510 }
3511
3512 if (toolbutton->state & State_HasFocus) {
3514 fr.QStyleOption::operator=(*toolbutton);
3515 fr.rect.adjust(3, 3, -3, -3);
3516 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
3517 fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator,
3518 toolbutton, widget), 0);
3520 }
3521 QStyleOptionToolButton label = *toolbutton;
3522 label.state = bflags;
3524 label.rect = button.adjusted(fw, fw, -fw, -fw);
3526
3527 if (toolbutton->subControls & SC_ToolButtonMenu) {
3528 tool.rect = menuarea;
3529 tool.state = mflags;
3530 if (mflags & (State_Sunken | State_On | State_Raised))
3533 } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
3534 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
3535 QRect ir = toolbutton->rect;
3536 QStyleOptionToolButton newBtn = *toolbutton;
3537 newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6);
3538 newBtn.rect = visualRect(toolbutton->direction, button, newBtn.rect);
3540 }
3541 }
3542 break;
3543#endif // QT_CONFIG(toolbutton)
3544 case CC_TitleBar:
3545 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
3546 QRect ir;
3547 if (opt->subControls & SC_TitleBarLabel) {
3548 QColor left = tb->palette.highlight().color();
3549 QColor right = tb->palette.base().color();
3550
3551 QBrush fillBrush(left);
3552 if (left != right) {
3553 QPoint p1(tb->rect.x(), tb->rect.top() + tb->rect.height()/2);
3554 QPoint p2(tb->rect.right(), tb->rect.top() + tb->rect.height()/2);
3555 QLinearGradient lg(p1, p2);
3556 lg.setColorAt(0, left);
3557 lg.setColorAt(1, right);
3558 fillBrush = lg;
3559 }
3560
3561 p->fillRect(opt->rect, fillBrush);
3562
3564
3565 p->setPen(tb->palette.highlightedText().color());
3566 p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(),
3568 }
3569
3570 bool down = false;
3571 QPixmap pm;
3572
3573 QStyleOption tool = *tb;
3574 if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3576 down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken);
3577 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool
3578#if QT_CONFIG(dockwidget)
3579 || qobject_cast<const QDockWidget *>(widget)
3580#endif
3581 )
3582 pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3583 else
3584 pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3585 tool.rect = ir;
3586 tool.state = down ? State_Sunken : State_Raised;
3588
3589 QPainterStateSaver pss(p, down);
3590 if (down)
3594 }
3595
3596 if (tb->subControls & SC_TitleBarMaxButton
3597 && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
3598 && !(tb->titleBarState & Qt::WindowMaximized)) {
3600
3601 down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
3602 pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3603 tool.rect = ir;
3604 tool.state = down ? State_Sunken : State_Raised;
3606
3607 QPainterStateSaver pss(p, down);
3608 if (down)
3612 }
3613
3614 if (tb->subControls & SC_TitleBarMinButton
3615 && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
3616 && !(tb->titleBarState & Qt::WindowMinimized)) {
3618 down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
3619 pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3620 tool.rect = ir;
3621 tool.state = down ? State_Sunken : State_Raised;
3623
3624 QPainterStateSaver pss(p, down);
3625 if (down)
3629 }
3630
3631 bool drawNormalButton = (tb->subControls & SC_TitleBarNormalButton)
3632 && (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3633 && (tb->titleBarState & Qt::WindowMinimized))
3634 || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3635 && (tb->titleBarState & Qt::WindowMaximized)));
3636
3637 if (drawNormalButton) {
3639 down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
3640 pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3641 tool.rect = ir;
3642 tool.state = down ? State_Sunken : State_Raised;
3644
3645 QPainterStateSaver pss(p, down);
3646 if (down)
3650 }
3651
3652 if (tb->subControls & SC_TitleBarShadeButton
3653 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3654 && !(tb->titleBarState & Qt::WindowMinimized)) {
3656 down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
3657 pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3658 tool.rect = ir;
3659 tool.state = down ? State_Sunken : State_Raised;
3661 QPainterStateSaver pss(p, down);
3662 if (down)
3666 }
3667
3668 if (tb->subControls & SC_TitleBarUnshadeButton
3669 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3670 && tb->titleBarState & Qt::WindowMinimized) {
3672
3673 down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
3674 pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(QSize(10, 10), p->device()->devicePixelRatio());
3675 tool.rect = ir;
3676 tool.state = down ? State_Sunken : State_Raised;
3678 QPainterStateSaver pss(p, down);
3679 if (down)
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 QPainterStateSaver pss(p, down);
3694 if (down)
3698 }
3699 if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3701 if (!tb->icon.isNull()) {
3702 tb->icon.paint(p, ir);
3703 } else {
3705 pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(QSize(iconSize, iconSize), p->device()->devicePixelRatio());
3706 tool.rect = ir;
3707 QPainterStateSaver pss(p);
3709 }
3710 }
3711 }
3712 break;
3713#if QT_CONFIG(dial)
3714 case CC_Dial:
3715 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3716 // OK, this is more a port of things over
3717 QPainterStateSaver pss(p);
3718
3719 // avoid dithering
3720 if (p->paintEngine()->hasFeature(QPaintEngine::Antialiasing))
3721 p->setRenderHint(QPainter::Antialiasing);
3722
3723 int width = dial->rect.width();
3724 int height = dial->rect.height();
3725 qreal r = qMin(width, height) / 2;
3726 qreal d_ = r / 6;
3727 qreal dx = dial->rect.x() + d_ + (width - 2 * r) / 2 + 1;
3728 qreal dy = dial->rect.y() + d_ + (height - 2 * r) / 2 + 1;
3729 QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2), int(r * 2 - 2 * d_ - 2));
3730
3731 QPalette pal = opt->palette;
3732 // draw notches
3733 if (dial->subControls & QStyle::SC_DialTickmarks) {
3734 p->setPen(pal.windowText().color());
3735 p->drawLines(QStyleHelper::calcLines(dial));
3736 }
3737
3738 if (dial->state & State_Enabled) {
3740 dial, widget))));
3741 p->setPen(Qt::NoPen);
3742 p->drawEllipse(br);
3743 p->setBrush(Qt::NoBrush);
3744 }
3745 p->setPen(QPen(pal.dark().color()));
3746 p->drawArc(br, 60 * 16, 180 * 16);
3747 p->setPen(QPen(pal.light().color()));
3748 p->drawArc(br, 240 * 16, 180 * 16);
3749
3750 qreal a;
3751 const StaticPolygonF<3> arrow = calcArrow(dial, a);
3752
3753 p->setPen(Qt::NoPen);
3754 p->setBrush(pal.button());
3755 p->drawPolygon(arrow.cbegin(), arrow.size());
3756
3757 a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]);
3758 p->setBrush(Qt::NoBrush);
3759
3760 if (a <= 0 || a > 200) {
3761 p->setPen(pal.light().color());
3762 p->drawLine(arrow[2], arrow[0]);
3763 p->drawLine(arrow[1], arrow[2]);
3764 p->setPen(pal.dark().color());
3765 p->drawLine(arrow[0], arrow[1]);
3766 } else if (a > 0 && a < 45) {
3767 p->setPen(pal.light().color());
3768 p->drawLine(arrow[2], arrow[0]);
3769 p->setPen(pal.dark().color());
3770 p->drawLine(arrow[1], arrow[2]);
3771 p->drawLine(arrow[0], arrow[1]);
3772 } else if (a >= 45 && a < 135) {
3773 p->setPen(pal.dark().color());
3774 p->drawLine(arrow[2], arrow[0]);
3775 p->drawLine(arrow[1], arrow[2]);
3776 p->setPen(pal.light().color());
3777 p->drawLine(arrow[0], arrow[1]);
3778 } else if (a >= 135 && a < 200) {
3779 p->setPen(pal.dark().color());
3780 p->drawLine(arrow[2], arrow[0]);
3781 p->setPen(pal.light().color());
3782 p->drawLine(arrow[0], arrow[1]);
3783 p->drawLine(arrow[1], arrow[2]);
3784 }
3785
3786 // draw focus rect around the dial
3788 fropt.rect = dial->rect;
3789 fropt.state = dial->state;
3790 fropt.palette = dial->palette;
3791 if (fropt.state & QStyle::State_HasFocus) {
3792 br.adjust(0, 0, 2, 2);
3793 if (dial->subControls & SC_DialTickmarks) {
3794 int r = qMin(width, height) / 2;
3795 br.translate(-r / 6, - r / 6);
3796 br.setWidth(br.width() + r / 3);
3797 br.setHeight(br.height() + r / 3);
3798 }
3799 fropt.rect = br.adjusted(-2, -2, 2, 2);
3801 }
3802 }
3803 break;
3804#endif // QT_CONFIG(dial)
3805#if QT_CONFIG(groupbox)
3806 case CC_GroupBox:
3807 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
3808 // Draw frame
3811 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
3813 frame.QStyleOption::operator=(*groupBox);
3814 frame.features = groupBox->features;
3815 frame.lineWidth = groupBox->lineWidth;
3816 frame.midLineWidth = groupBox->midLineWidth;
3818 QPainterStateSaver pss(p);
3819 QRegion region(groupBox->rect);
3820 if (!groupBox->text.isEmpty()) {
3821 bool ltr = groupBox->direction == Qt::LeftToRight;
3822 QRect finalRect;
3823 if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
3824 finalRect = checkBoxRect.united(textRect);
3825 finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
3826 } else {
3827 finalRect = textRect;
3828 }
3829 region -= finalRect;
3830 }
3831 p->setClipRegion(region);
3833 }
3834
3835 // Draw title
3836 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
3837 QColor textColor = groupBox->textColor;
3838 if (textColor.isValid())
3839 p->setPen(textColor);
3840 int alignment = int(groupBox->textAlignment);
3843
3847
3848 if (groupBox->state & State_HasFocus) {
3850 fropt.QStyleOption::operator=(*groupBox);
3851 fropt.rect = textRect;
3853 }
3854 }
3855
3856 // Draw checkbox
3857 if (groupBox->subControls & SC_GroupBoxCheckBox) {
3859 box.QStyleOption::operator=(*groupBox);
3860 box.rect = checkBoxRect;
3862 }
3863 }
3864 break;
3865#endif // QT_CONFIG(groupbox)
3866#if QT_CONFIG(mdiarea)
3867 case CC_MdiControls:
3868 {
3869 QStyleOptionButton btnOpt;
3870 btnOpt.QStyleOption::operator=(*opt);
3871 btnOpt.state &= ~State_MouseOver;
3872 int bsx = 0;
3873 int bsy = 0;
3874 const int buttonIconMetric = proxy()->pixelMetric(PM_TitleBarButtonIconSize, &btnOpt, widget);
3875 const QSize buttonIconSize(buttonIconMetric, buttonIconMetric);
3876 if (opt->subControls & QStyle::SC_MdiCloseButton) {
3877 if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
3878 btnOpt.state |= State_Sunken;
3879 btnOpt.state &= ~State_Raised;
3882 } else {
3883 btnOpt.state |= State_Raised;
3884 btnOpt.state &= ~State_Sunken;
3885 bsx = 0;
3886 bsy = 0;
3887 }
3890 QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3891 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3892 }
3893 if (opt->subControls & QStyle::SC_MdiNormalButton) {
3894 if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
3895 btnOpt.state |= State_Sunken;
3896 btnOpt.state &= ~State_Raised;
3899 } else {
3900 btnOpt.state |= State_Raised;
3901 btnOpt.state &= ~State_Sunken;
3902 bsx = 0;
3903 bsy = 0;
3904 }
3907 QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3908 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3909 }
3910 if (opt->subControls & QStyle::SC_MdiMinButton) {
3911 if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
3912 btnOpt.state |= State_Sunken;
3913 btnOpt.state &= ~State_Raised;
3916 } else {
3917 btnOpt.state |= State_Raised;
3918 btnOpt.state &= ~State_Sunken;
3919 bsx = 0;
3920 bsy = 0;
3921 }
3924 QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(buttonIconSize, p->device()->devicePixelRatio());
3925 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3926 }
3927 }
3928 break;
3929#endif // QT_CONFIG(mdiarea)
3930 default:
3931 qCWarning(lcCommonStyle, "QCommonStyle::drawComplexControl: Control %d not handled", cc);
3932 }
3933}
3934
3939 const QPoint &pt, const QWidget *widget) const
3940{
3941 SubControl sc = SC_None;
3942 switch (cc) {
3943#if QT_CONFIG(slider)
3944 case CC_Slider:
3945 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3946 QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget);
3947 if (r.isValid() && r.contains(pt)) {
3948 sc = SC_SliderHandle;
3949 } else {
3950 r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget);
3951 if (r.isValid() && r.contains(pt))
3952 sc = SC_SliderGroove;
3953 }
3954 }
3955 break;
3956#endif // QT_CONFIG(slider)
3957#if QT_CONFIG(scrollbar)
3958 case CC_ScrollBar:
3959 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
3960 QRect r;
3962 while (ctrl <= SC_ScrollBarGroove) {
3963 r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget);
3964 if (r.isValid() && r.contains(pt)) {
3965 sc = QStyle::SubControl(ctrl);
3966 break;
3967 }
3968 ctrl <<= 1;
3969 }
3970 }
3971 break;
3972#endif // QT_CONFIG(scrollbar)
3973#if QT_CONFIG(toolbutton)
3974 case CC_ToolButton:
3975 if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3976 QRect r;
3977 uint ctrl = SC_ToolButton;
3978 while (ctrl <= SC_ToolButtonMenu) {
3979 r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget);
3980 if (r.isValid() && r.contains(pt)) {
3981 sc = QStyle::SubControl(ctrl);
3982 break;
3983 }
3984 ctrl <<= 1;
3985 }
3986 }
3987 break;
3988#endif // QT_CONFIG(toolbutton)
3989#if QT_CONFIG(spinbox)
3990 case CC_SpinBox:
3991 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
3992 QRect r;
3993 uint ctrl = SC_SpinBoxUp;
3994 while (ctrl <= SC_SpinBoxEditField) {
3995 r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget);
3996 if (r.isValid() && r.contains(pt)) {
3997 sc = QStyle::SubControl(ctrl);
3998 break;
3999 }
4000 ctrl <<= 1;
4001 }
4002 }
4003 break;
4004#endif // QT_CONFIG(spinbox)
4005 case CC_TitleBar:
4006 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4007 QRect r;
4008 uint ctrl = SC_TitleBarSysMenu;
4009
4010 while (ctrl <= SC_TitleBarLabel) {
4011 r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget);
4012 if (r.isValid() && r.contains(pt)) {
4013 sc = QStyle::SubControl(ctrl);
4014 break;
4015 }
4016 ctrl <<= 1;
4017 }
4018 }
4019 break;
4020#if QT_CONFIG(combobox)
4021 case CC_ComboBox:
4022 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4023 QRect r;
4024 uint ctrl = SC_ComboBoxArrow; // Start here and go down.
4025 while (ctrl > 0) {
4027 if (r.isValid() && r.contains(pt)) {
4028 sc = QStyle::SubControl(ctrl);
4029 break;
4030 }
4031 ctrl >>= 1;
4032 }
4033 }
4034 break;
4035#endif // QT_CONFIG(combobox)
4036#if QT_CONFIG(groupbox)
4037 case CC_GroupBox:
4038 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4039 QRect r;
4041 while (ctrl <= SC_GroupBoxFrame) {
4043 if (r.isValid() && r.contains(pt)) {
4044 sc = QStyle::SubControl(ctrl);
4045 break;
4046 }
4047 ctrl <<= 1;
4048 }
4049 }
4050 break;
4051#endif // QT_CONFIG(groupbox)
4052 case CC_MdiControls:
4053 {
4054 QRect r;
4055 uint ctrl = SC_MdiMinButton;
4056 while (ctrl <= SC_MdiCloseButton) {
4058 if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) {
4059 sc = QStyle::SubControl(ctrl);
4060 return sc;
4061 }
4062 ctrl <<= 1;
4063 }
4064 }
4065 break;
4066 default:
4067 qCWarning(lcCommonStyle, "QCommonStyle::hitTestComplexControl: Case %d not handled", cc);
4068 }
4069 return sc;
4070}
4071
4076 SubControl sc, const QWidget *widget) const
4077{
4078 QRect ret;
4079 switch (cc) {
4080#if QT_CONFIG(slider)
4081 case CC_Slider:
4082 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4083 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
4084 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
4085
4086 switch (sc) {
4087 case SC_SliderHandle: {
4088 int sliderPos = 0;
4089 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
4090 bool horizontal = slider->orientation == Qt::Horizontal;
4091 sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
4092 slider->sliderPosition,
4093 (horizontal ? slider->rect.width()
4094 : slider->rect.height()) - len,
4095 slider->upsideDown);
4096 if (horizontal)
4097 ret.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
4098 else
4099 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
4100 break; }
4101 case SC_SliderGroove:
4102 if (slider->orientation == Qt::Horizontal)
4103 ret.setRect(slider->rect.x(), slider->rect.y() + tickOffset,
4104 slider->rect.width(), thickness);
4105 else
4106 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y(),
4107 thickness, slider->rect.height());
4108 break;
4109 default:
4110 break;
4111 }
4112 ret = visualRect(slider->direction, slider->rect, ret);
4113 }
4114 break;
4115#endif // QT_CONFIG(slider)
4116#if QT_CONFIG(scrollbar)
4117 case CC_ScrollBar:
4118 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4119 const QRect scrollBarRect = scrollbar->rect;
4120 int sbextent = 0;
4121 if (!proxy()->styleHint(SH_ScrollBar_Transient, scrollbar, widget))
4122 sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget);
4123 int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
4124 scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2);
4125 int sliderlen;
4126
4127 // calculate slider length
4128 if (scrollbar->maximum != scrollbar->minimum) {
4129 uint range = scrollbar->maximum - scrollbar->minimum;
4130 sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep);
4131
4132 int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);
4133 if (sliderlen < slidermin || range > INT_MAX / 2)
4134 sliderlen = slidermin;
4135 if (sliderlen > maxlen)
4136 sliderlen = maxlen;
4137 } else {
4138 sliderlen = maxlen;
4139 }
4140
4141 int sliderstart = sbextent + sliderPositionFromValue(scrollbar->minimum,
4142 scrollbar->maximum,
4143 scrollbar->sliderPosition,
4144 maxlen - sliderlen,
4145 scrollbar->upsideDown);
4146
4147 switch (sc) {
4148 case SC_ScrollBarSubLine: // top/left button
4149 if (scrollbar->orientation == Qt::Horizontal) {
4150 int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent);
4151 ret.setRect(0, 0, buttonWidth, scrollBarRect.height());
4152 } else {
4153 int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent);
4154 ret.setRect(0, 0, scrollBarRect.width(), buttonHeight);
4155 }
4156 break;
4157 case SC_ScrollBarAddLine: // bottom/right button
4158 if (scrollbar->orientation == Qt::Horizontal) {
4159 int buttonWidth = qMin(scrollBarRect.width()/2, sbextent);
4160 ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height());
4161 } else {
4162 int buttonHeight = qMin(scrollBarRect.height()/2, sbextent);
4163 ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight);
4164 }
4165 break;
4166 case SC_ScrollBarSubPage: // between top/left button and slider
4167 if (scrollbar->orientation == Qt::Horizontal)
4168 ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height());
4169 else
4170 ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent);
4171 break;
4172 case SC_ScrollBarAddPage: // between bottom/right button and slider
4173 if (scrollbar->orientation == Qt::Horizontal)
4174 ret.setRect(sliderstart + sliderlen, 0,
4175 maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height());
4176 else
4177 ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(),
4178 maxlen - sliderstart - sliderlen + sbextent);
4179 break;
4180 case SC_ScrollBarGroove:
4181 if (scrollbar->orientation == Qt::Horizontal)
4182 ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2,
4183 scrollBarRect.height());
4184 else
4185 ret.setRect(0, sbextent, scrollBarRect.width(),
4186 scrollBarRect.height() - sbextent * 2);
4187 break;
4188 case SC_ScrollBarSlider:
4189 if (scrollbar->orientation == Qt::Horizontal)
4190 ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
4191 else
4192 ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
4193 break;
4194 default:
4195 break;
4196 }
4197 ret = visualRect(scrollbar->direction, scrollBarRect, ret);
4198 }
4199 break;
4200#endif // QT_CONFIG(scrollbar)
4201#if QT_CONFIG(spinbox)
4202 case CC_SpinBox:
4203 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
4204 QSize bs;
4205 int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
4206 bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw));
4207 // 1.6 -approximate golden mean
4208 bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4)));
4209 int y = fw + spinbox->rect.y();
4210 int x, lx, rx;
4211 x = spinbox->rect.x() + spinbox->rect.width() - fw - bs.width();
4212 lx = fw;
4213 rx = x - fw;
4214 switch (sc) {
4215 case SC_SpinBoxUp:
4216 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4217 return QRect();
4218 ret = QRect(x, y, bs.width(), bs.height());
4219 break;
4220 case SC_SpinBoxDown:
4221 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
4222 return QRect();
4223
4224 ret = QRect(x, y + bs.height(), bs.width(), bs.height());
4225 break;
4227 if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
4228 ret = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
4229 } else {
4230 ret = QRect(lx, fw, rx, spinbox->rect.height() - 2*fw);
4231 }
4232 break;
4233 case SC_SpinBoxFrame:
4234 ret = spinbox->rect;
4235 break;
4236 default:
4237 break;
4238 }
4239 ret = visualRect(spinbox->direction, spinbox->rect, ret);
4240 }
4241 break;
4242#endif // Qt_NO_SPINBOX
4243#if QT_CONFIG(toolbutton)
4244 case CC_ToolButton:
4245 if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
4247 ret = tb->rect;
4248 switch (sc) {
4249 case SC_ToolButton:
4250 if ((tb->features
4253 ret.adjust(0, 0, -mbi, 0);
4254 break;
4255 case SC_ToolButtonMenu:
4256 if ((tb->features
4259 ret.adjust(ret.width() - mbi, 0, 0, 0);
4260 break;
4261 default:
4262 break;
4263 }
4264 ret = visualRect(tb->direction, tb->rect, ret);
4265 }
4266 break;
4267#endif // QT_CONFIG(toolbutton)
4268#if QT_CONFIG(combobox)
4269 case CC_ComboBox:
4270 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4271 const qreal dpi = QStyleHelper::dpi(opt);
4272 const int x = cb->rect.x(), y = cb->rect.y(), wi = cb->rect.width(), he = cb->rect.height();
4273 const int margin = cb->frame ? qRound(QStyleHelper::dpiScaled(3, dpi)) : 0;
4274 const int bmarg = cb->frame ? qRound(QStyleHelper::dpiScaled(2, dpi)) : 0;
4275 const int xpos = x + wi - bmarg - qRound(QStyleHelper::dpiScaled(16, dpi));
4276
4277
4278 switch (sc) {
4279 case SC_ComboBoxFrame:
4280 ret = cb->rect;
4281 break;
4282 case SC_ComboBoxArrow:
4283 ret.setRect(xpos, y + bmarg, qRound(QStyleHelper::dpiScaled(16, opt)), he - 2*bmarg);
4284 break;
4286 ret.setRect(x + margin, y + margin, wi - 2 * margin - qRound(QStyleHelper::dpiScaled(16, dpi)), he - 2 * margin);
4287 break;
4289 ret = cb->rect;
4290 break;
4291 default:
4292 break;
4293 }
4294 ret = visualRect(cb->direction, cb->rect, ret);
4295 }
4296 break;
4297#endif // QT_CONFIG(combobox)
4298 case CC_TitleBar:
4299 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4300 const int controlMargin = 2;
4301 const int controlHeight = tb->rect.height() - controlMargin *2;
4302 const int delta = controlHeight + controlMargin;
4303 int offset = 0;
4304
4305 bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
4306 bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
4307
4308 switch (sc) {
4309 case SC_TitleBarLabel:
4310 if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
4311 ret = tb->rect;
4312 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4313 ret.adjust(delta, 0, -delta, 0);
4314 if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
4315 ret.adjust(0, 0, -delta, 0);
4316 if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
4317 ret.adjust(0, 0, -delta, 0);
4318 if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
4319 ret.adjust(0, 0, -delta, 0);
4320 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4321 ret.adjust(0, 0, -delta, 0);
4322 }
4323 break;
4325 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4326 offset += delta;
4327 Q_FALLTHROUGH();
4329 if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4330 offset += delta;
4331 else if (sc == SC_TitleBarMinButton)
4332 break;
4333 Q_FALLTHROUGH();
4335 if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4336 offset += delta;
4337 else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4338 offset += delta;
4339 else if (sc == SC_TitleBarNormalButton)
4340 break;
4341 Q_FALLTHROUGH();
4343 if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4344 offset += delta;
4345 else if (sc == SC_TitleBarMaxButton)
4346 break;
4347 Q_FALLTHROUGH();
4349 if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4350 offset += delta;
4351 else if (sc == SC_TitleBarShadeButton)
4352 break;
4353 Q_FALLTHROUGH();
4355 if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4356 offset += delta;
4357 else if (sc == SC_TitleBarUnshadeButton)
4358 break;
4359 Q_FALLTHROUGH();
4361 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4362 offset += delta;
4363 else if (sc == SC_TitleBarCloseButton)
4364 break;
4365 ret.setRect(tb->rect.right() - offset, tb->rect.top() + controlMargin,
4366 controlHeight, controlHeight);
4367 break;
4368 case SC_TitleBarSysMenu:
4369 if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
4370 ret.setRect(tb->rect.left() + controlMargin, tb->rect.top() + controlMargin,
4371 controlHeight, controlHeight);
4372 }
4373 break;
4374 default:
4375 break;
4376 }
4377 ret = visualRect(tb->direction, tb->rect, ret);
4378 }
4379 break;
4380#if QT_CONFIG(groupbox)
4381 case CC_GroupBox: {
4382 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
4383 switch (sc) {
4384 case SC_GroupBoxFrame:
4385 case SC_GroupBoxContents: {
4386 int topMargin = 0;
4387 int topHeight = 0;
4389 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4390 if (groupBox->text.size() || hasCheckBox) {
4391 int checkBoxHeight = hasCheckBox ? proxy()->pixelMetric(PM_IndicatorHeight, groupBox, widget) : 0;
4392 topHeight = qMax(groupBox->fontMetrics.height(), checkBoxHeight);
4393 if (verticalAlignment & Qt::AlignVCenter)
4394 topMargin = topHeight / 2;
4395 else if (verticalAlignment & Qt::AlignTop)
4396 topMargin = topHeight + proxy()->pixelMetric(PM_FocusFrameVMargin, groupBox, widget);
4397 }
4398
4399 QRect frameRect = groupBox->rect;
4400 frameRect.setTop(topMargin);
4401
4402 if (sc == SC_GroupBoxFrame) {
4403 ret = frameRect;
4404 break;
4405 }
4406
4407 int frameWidth = 0;
4408 if ((groupBox->features & QStyleOptionFrame::Flat) == 0)
4410 ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin,
4411 -frameWidth, -frameWidth);
4412 break;
4413 }
4415 case SC_GroupBoxLabel: {
4417 int th = fontMetrics.height();
4418 int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + u' ').width();
4419 int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
4420 ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
4421
4422 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget);
4423 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
4424 int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;
4425 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4426 int checkBoxWidth = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
4427 int checkBoxHeight = hasCheckBox ? indicatorHeight : 0;
4428
4429 int h = qMax(th, checkBoxHeight);
4430 ret.setHeight(h);
4431
4432 // Adjusted rect for label + indicatorWidth + indicatorSpace
4433 QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
4434 QSize(tw + checkBoxWidth, h), ret);
4435
4436 // Adjust totalRect if checkbox is set
4437 if (hasCheckBox) {
4438 bool ltr = groupBox->direction == Qt::LeftToRight;
4439 int left = 0;
4440 // Adjust for check box
4441 if (sc == SC_GroupBoxCheckBox) {
4442 left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
4443 int top = totalRect.top() + (h - checkBoxHeight) / 2;
4444 totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
4445 // Adjust for label
4446 } else {
4447 left = ltr ? (totalRect.left() + checkBoxWidth - 2) : totalRect.left();
4448 int top = totalRect.top() + (h - th) / 2;
4449 totalRect.setRect(left, top, totalRect.width() - checkBoxWidth, th);
4450 }
4451 }
4452 ret = totalRect;
4453 break;
4454 }
4455 default:
4456 break;
4457 }
4458 }
4459 break;
4460 }
4461#endif // QT_CONFIG(groupbox)
4462#if QT_CONFIG(mdiarea)
4463 case CC_MdiControls:
4464 {
4465 int numSubControls = 0;
4466 if (opt->subControls & SC_MdiCloseButton)
4467 ++numSubControls;
4468 if (opt->subControls & SC_MdiMinButton)
4469 ++numSubControls;
4470 if (opt->subControls & SC_MdiNormalButton)
4471 ++numSubControls;
4472 if (numSubControls == 0)
4473 break;
4474
4475 int buttonWidth = opt->rect.width() / numSubControls - 1;
4476 int offset = 0;
4477 switch (sc) {
4478 case SC_MdiCloseButton:
4479 // Only one sub control, no offset needed.
4480 if (numSubControls == 1)
4481 break;
4482 offset += buttonWidth + 2;
4483 Q_FALLTHROUGH();
4484 case SC_MdiNormalButton:
4485 // No offset needed if
4486 // 1) There's only one sub control
4487 // 2) We have a close button and a normal button (offset already added in SC_MdiClose)
4488 if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton)))
4489 break;
4490 if (opt->subControls & SC_MdiNormalButton)
4491 offset += buttonWidth;
4492 break;
4493 default:
4494 break;
4495 }
4496
4497 // Subtract one pixel if we only have one sub control. At this point
4498 // buttonWidth is the actual width + 1 pixel margin, but we don't want the
4499 // margin when there are no other controllers.
4500 if (numSubControls == 1)
4501 --buttonWidth;
4502 ret = QRect(offset, 0, buttonWidth, opt->rect.height());
4503 break;
4504 }
4505#endif // QT_CONFIG(mdiarea)
4506 default:
4507 qCWarning(lcCommonStyle, "QCommonStyle::subControlRect: Case %d not handled", cc);
4508 }
4509#if !QT_CONFIG(slider) && !QT_CONFIG(spinbox) && !QT_CONFIG(toolbutton) && !QT_CONFIG(groupbox)
4511#endif
4512 return ret;
4513}
4514
4517{
4518 int ret;
4519
4520 switch (m) {
4523 ret = 2;
4524 break;
4525 case PM_MenuBarVMargin:
4526 case PM_MenuBarHMargin:
4527 ret = 0;
4528 break;
4529 case PM_TitleBarHeight:
4530 {
4531 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
4532 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) {
4534#if QT_CONFIG(dockwidget)
4535 } else if (qobject_cast<const QDockWidget*>(widget)) {
4537#endif
4538 } else {
4540 }
4541 } else {
4542 ret = int(QStyleHelper::dpiScaled(18., opt));
4543 }
4544 break;
4545 }
4547 ret = int(QStyleHelper::dpiScaled(16., opt));
4548 break;
4550 ret = int(QStyleHelper::dpiScaled(16., opt));
4551 break;
4552
4554 ret = int(QStyleHelper::dpiScaled(9., opt));
4555 break;
4556
4557 case PM_ButtonMargin:
4558 ret = int(QStyleHelper::dpiScaled(6., opt));
4559 break;
4560
4562 ret = int(QStyleHelper::dpiScaled(2., opt));
4563 break;
4564
4566 ret = 0;
4567 break;
4568
4570 ret = int(QStyleHelper::dpiScaled(12, opt));
4571 break;
4572
4575
4577 ret = 2;
4578 break;
4579
4582 case PM_MenuPanelWidth:
4586 break;
4587
4589 ret = int(QStyleHelper::dpiScaled(4, opt));
4590 break;
4591
4593 ret = int(QStyleHelper::dpiScaled(196, opt));
4594 break;
4595
4596#if QT_CONFIG(scrollbar)
4597 case PM_ScrollBarExtent:
4598 if (qstyleoption_cast<const QStyleOptionSlider *>(opt))
4599 ret = 16;
4600 else
4601 ret = int(QStyleHelper::dpiScaled(16, opt));
4602 break;
4603#endif
4606 break;
4607
4608#if QT_CONFIG(slider)
4609 case PM_SliderThickness:
4610 ret = int(QStyleHelper::dpiScaled(16, opt));
4611 break;
4612
4614 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4615 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height()
4616 : sl->rect.width();
4617 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget);
4618 int ticks = sl->tickPosition;
4619
4620 if (ticks == QSlider::TicksBothSides)
4621 ret = (space - thickness) / 2;
4622 else if (ticks == QSlider::TicksAbove)
4623 ret = space - thickness;
4624 else
4625 ret = 0;
4626 } else {
4627 ret = 0;
4628 }
4629 break;
4630
4632 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
4633 if (sl->orientation == Qt::Horizontal)
4634 ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4635 else
4636 ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget);
4637 } else {
4638 ret = 0;
4639 }
4640 break;
4641#endif // QT_CONFIG(slider)
4642#if QT_CONFIG(dockwidget)
4644 ret = int(QStyleHelper::dpiScaled(6, opt));
4645 break;
4646
4648 ret = int(QStyleHelper::dpiScaled(8, opt));
4649 break;
4651 ret = 0;
4652 break;
4654 ret = 1;
4655 break;
4656#endif // QT_CONFIG(dockwidget)
4657
4660 ret = 2;
4661 break;
4662
4664 ret = 0;
4665 break;
4666
4667#if QT_CONFIG(toolbar)
4669 ret = 1;
4670 break;
4671
4673 ret = 0;
4674 break;
4675
4677 ret = int(QStyleHelper::dpiScaled(4, opt));
4678 break;
4679
4681 ret = int(QStyleHelper::dpiScaled(8, opt));
4682 break;
4683
4685 ret = int(QStyleHelper::dpiScaled(6, opt));
4686 break;
4687
4689 ret = int(QStyleHelper::dpiScaled(12, opt));
4690 break;
4691#endif // QT_CONFIG(toolbar)
4692
4693#if QT_CONFIG(tabbar)
4695 ret = 3;
4696 break;
4697
4698 case PM_TabBarTabHSpace:
4699 ret = int(QStyleHelper::dpiScaled(24, opt));
4700 break;
4701
4703 ret = 0;
4704 break;
4705
4707 ret = 2;
4708 break;
4709
4710 case PM_TabBarTabVSpace:
4711 {
4712 const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt);
4713 if (tb && (tb->shape == QTabBar::RoundedNorth || tb->shape == QTabBar::RoundedSouth
4714 || tb->shape == QTabBar::RoundedWest || tb->shape == QTabBar::RoundedEast))
4715 ret = 8;
4716 else
4717 if (tb && (tb->shape == QTabBar::TriangularWest || tb->shape == QTabBar::TriangularEast))
4718 ret = 3;
4719 else
4720 ret = 2;
4721 break;
4722 }
4723#endif
4724
4726 ret = 9;
4727 break;
4728
4729 case PM_IndicatorWidth:
4730 ret = int(QStyleHelper::dpiScaled(13, opt));
4731 break;
4732
4733 case PM_IndicatorHeight:
4734 ret = int(QStyleHelper::dpiScaled(13, opt));
4735 break;
4736
4738 ret = int(QStyleHelper::dpiScaled(12, opt));
4739 break;
4740
4742 ret = int(QStyleHelper::dpiScaled(12, opt));
4743 break;
4744
4746 ret = int(QStyleHelper::dpiScaled(10, opt));
4747 break;
4748
4750 ret = int(QStyleHelper::dpiScaled(10, opt));
4751 break;
4752
4754 case PM_MenuHMargin:
4755 case PM_MenuVMargin:
4756 ret = 0;
4757 break;
4758
4759 case PM_HeaderMargin:
4760 ret = int(QStyleHelper::dpiScaled(4, opt));
4761 break;
4762 case PM_HeaderMarkSize:
4763 ret = int(QStyleHelper::dpiScaled(16, opt));
4764 break;
4766 ret = int(QStyleHelper::dpiScaled(4, opt));
4767 break;
4769 ret = int(QStyleHelper::dpiScaled(100, opt));
4770 break;
4772 ret = int(QStyleHelper::dpiScaled(30, opt));
4773 break;
4775 ret = int(QStyleHelper::dpiScaled(16, opt));
4776 break;
4778 case PM_LayoutTopMargin:
4781 {
4782 bool isWindow = false;
4783 if (opt) {
4785 } else if (widget) {
4787 }
4788 ret = int(QStyleHelper::dpiScaled(isWindow ? 11 : 9, opt));
4789 break;
4790 }
4793 ret = int(QStyleHelper::dpiScaled(6, opt));
4794 break;
4795
4796 case PM_ToolBarIconSize:
4797 ret = 0;
4799 ret = theme->themeHint(QPlatformTheme::ToolBarIconSize).toInt();
4800 if (ret <= 0)
4801 ret = int(QStyleHelper::dpiScaled(24, opt));
4802 break;
4803
4804 case PM_TabBarIconSize:
4806 break;
4808#if QT_CONFIG(filedialog)
4809 if (qobject_cast<const QSidebar *>(widget))
4810 ret = int(QStyleHelper::dpiScaled(24., opt));
4811 else
4812#endif
4814 break;
4815
4816 case PM_ButtonIconSize:
4817 case PM_SmallIconSize:
4818 ret = int(QStyleHelper::dpiScaled(16, opt));
4819 break;
4822 break;
4825 break;
4828 break;
4829
4830 case PM_LargeIconSize:
4831 ret = int(QStyleHelper::dpiScaled(32, opt));
4832 break;
4833
4835 ret = 1;
4836 break;
4839 ret = int(QStyleHelper::dpiScaled(6, opt));
4840 break;
4841 case PM_SizeGripSize:
4842 ret = int(QStyleHelper::dpiScaled(13, opt));
4843 break;
4845#ifdef Q_OS_MAC
4847 ret = 64; // No DPI scaling, it's handled elsewhere.
4848 } else
4849#endif
4850 {
4851 ret = int(QStyleHelper::dpiScaled(32, opt));
4852 }
4853 break;
4854 case PM_TextCursorWidth:
4856 break;
4858 ret = 1;
4859 break;
4862 ret = int(QStyleHelper::dpiScaled(16, opt));
4863 break;
4866 break;
4868 ret = 0;
4869 break;
4870 case PM_SubMenuOverlap:
4872 break;
4874 ret = int(QStyleHelper::dpiScaled(20, opt));
4875 break;
4876 default:
4877 ret = 0;
4878 break;
4879 }
4880
4881 return ret;
4882}
4883
4888 const QSize &contentsSize, const QWidget *widget) const
4889{
4890 Q_D(const QCommonStyle);
4891 QSize size(contentsSize);
4892 switch (contentsType) {
4893 case CT_PushButton:
4894 if (const auto *buttonOpt = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4895 int width = contentsSize.width();
4896 int height = contentsSize.height();
4897 const int buttonMargin = proxy()->pixelMetric(PM_ButtonMargin, buttonOpt, widget);
4898 const int defaultFrameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, buttonOpt, widget) * 2;
4899 width += buttonMargin + defaultFrameWidth;
4900 height += buttonMargin + defaultFrameWidth;
4901 if (buttonOpt->features.testFlag(QStyleOptionButton::AutoDefaultButton)) {
4902 const int buttonIndicator = proxy()->pixelMetric(PM_ButtonDefaultIndicator,
4903 buttonOpt,
4904 widget) * 2;
4905 width += buttonIndicator;
4906 height += buttonIndicator;
4907 }
4908 size = QSize(width, height);
4909 }
4910 break;
4911 case CT_RadioButton:
4912 case CT_CheckBox:
4913 if (const auto *buttonOpt = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
4914 const bool isRadio = (contentsType == CT_RadioButton);
4915
4916 const int width = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
4917 : PM_IndicatorWidth, buttonOpt, widget);
4918 const int height = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
4919 : PM_IndicatorHeight, buttonOpt, widget);
4920
4921 int margins = 0;
4922
4923 // we add 4 pixels for label margins
4924 if (!buttonOpt->icon.isNull() || !buttonOpt->text.isEmpty()) {
4925 margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
4927 }
4928
4929 size += QSize(width + margins, 4);
4930 size.setHeight(qMax(size.height(), height));
4931 }
4932 break;
4933#if QT_CONFIG(menu)
4934 case CT_MenuItem:
4935 if (const auto *menuItemOpt = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
4936 const bool checkable = menuItemOpt->menuHasCheckableItems;
4937 const int maxpmw = menuItemOpt->maxIconWidth;
4938 int width = size.width();
4939 int height;
4940 if (menuItemOpt->menuItemType == QStyleOptionMenuItem::Separator) {
4941 width = 10;
4942 height = 2;
4943 } else {
4944 height = menuItemOpt->fontMetrics.height() + 8;
4945 if (!menuItemOpt->icon.isNull()) {
4946 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
4947 height = qMax(height,
4948 menuItemOpt->icon.actualSize(QSize(iconExtent,
4949 iconExtent)).height() + 4);
4950 }
4951 }
4952 if (menuItemOpt->text.contains(u'\t'))
4953 width += 12;
4954 if (maxpmw > 0)
4955 width += maxpmw + 6;
4956 if (checkable && maxpmw < 20)
4957 width += 20 - maxpmw;
4958 if (checkable || maxpmw > 0)
4959 width += 2;
4960 width += 12;
4961 size = QSize(width, height);
4962 }
4963 break;
4964#endif // QT_CONFIG(menu)
4965#if QT_CONFIG(toolbutton)
4966 case CT_ToolButton:
4967 size = QSize(size.width() + 6, size.height() + 5);
4968 break;
4969#endif // QT_CONFIG(toolbutton)
4970#if QT_CONFIG(combobox)
4971 case CT_ComboBox:
4972 if (const auto *comboBoxOpt = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
4973 const int frameWidth = comboBoxOpt->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth,
4974 opt,
4975 widget) * 2 : 0;
4976 const int textMargins = 2 * (proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget) + 1);
4977
4978 // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
4979 const int other = qMax(23, 2 * textMargins
4981 opt, widget));
4982
4983 size = QSize(size.width() + frameWidth + other, size.height() + frameWidth);
4984 }
4985 break;
4986#endif // QT_CONFIG(combobox)
4987 case CT_HeaderSection:
4988 if (const auto *headerOpt = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
4989 const bool nullIcon = headerOpt->icon.isNull();
4990 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, headerOpt, widget);
4991 const int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize,
4992 headerOpt,
4993 widget);
4994 const QSize textSize = headerOpt->fontMetrics.size(0, headerOpt->text);
4995 size.setHeight(margin + qMax(iconSize, textSize.height()) + margin);
4996 size.setWidth((nullIcon ? 0 : margin) + iconSize
4997 + (headerOpt->text.isNull() ? 0 : margin) + textSize.width() + margin);
4998 if (headerOpt->sortIndicator != QStyleOptionHeader::None) {
4999 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, headerOpt, widget);
5000 if (headerOpt->orientation == Qt::Horizontal)
5001 size.rwidth() += size.height() + margin;
5002 else
5003 size.rheight() += size.width() + margin;
5004 }
5005 }
5006 break;
5007 case CT_TabWidget:
5008 size += QSize(4, 4);
5009 break;
5010 case CT_LineEdit:
5011 if (const auto *frameOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt))
5012 size += QSize(2 * frameOpt->lineWidth, 2 * frameOpt->lineWidth);
5013 break;
5014#if QT_CONFIG(groupbox)
5015 case CT_GroupBox:
5016 if (const auto *groupBoxOpt = qstyleoption_cast<const QStyleOptionGroupBox *>(opt))
5017 size += QSize(groupBoxOpt->features.testFlag(QStyleOptionFrame::Flat) ? 0 : 16, 0);
5018 break;
5019#endif // QT_CONFIG(groupbox)
5020 case CT_MdiControls:
5021 if (const auto *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
5022 const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, styleOpt, widget);
5023 int width = 1;
5024 if (styleOpt->subControls & SC_MdiMinButton)
5025 width += buttonSize + 1;
5026 if (styleOpt->subControls & SC_MdiNormalButton)
5027 width += buttonSize + 1;
5028 if (styleOpt->subControls & SC_MdiCloseButton)
5029 width += buttonSize + 1;
5030 size = QSize(width, buttonSize);
5031 } else {
5032 const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, opt, widget);
5033 size = QSize(1 + 3 * (buttonSize + 1), buttonSize);
5034 }
5035 break;
5036#if QT_CONFIG(itemviews)
5037 case CT_ItemViewItem:
5038 if (const auto *viewItemOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
5039 QRect decorationRect, displayRect, checkRect;
5040 d->viewItemLayout(viewItemOpt, &checkRect, &decorationRect, &displayRect, true);
5041 size = (decorationRect|displayRect|checkRect).size();
5042 if (decorationRect.isValid() && size.height() == decorationRect.height())
5043 size.rheight() += 2; // Prevent icons from overlapping.
5044 }
5045 break;
5046#else
5047 Q_UNUSED(d);
5048#endif // QT_CONFIG(itemviews)
5049#if QT_CONFIG(spinbox)
5050 case CT_SpinBox:
5051 if (const auto *spinBoxOpt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
5052 // Add button + frame widths
5053 const qreal dpi = QStyleHelper::dpi(opt);
5054 const bool hasButtons = (spinBoxOpt->buttonSymbols != QAbstractSpinBox::NoButtons);
5055 const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0;
5056 const int frameWidth = spinBoxOpt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth,
5057 spinBoxOpt, widget) : 0;
5058
5059 size += QSize(buttonWidth + 2 * frameWidth, 2 * frameWidth);
5060 }
5061 break;
5062#endif
5063 case CT_ScrollBar:
5064 case CT_MenuBar:
5065 case CT_Menu:
5066 case CT_MenuBarItem:
5067 case CT_Slider:
5068 case CT_ProgressBar:
5069 case CT_TabBarTab:
5070 // just return the contentsSize for now
5071 Q_FALLTHROUGH();
5072 default:
5073 break;
5074 }
5075 return size;
5076}
5077
5078
5081 QStyleHintReturn *hret) const
5082{
5083 int ret = 0;
5084
5085 switch (sh) {
5087 ret = false;
5088 break;
5091 break;
5094 break;
5096 ret = true;
5097 break;
5098#if QT_CONFIG(dialogbuttonbox)
5099 case SH_DialogButtons_DefaultButton: // This value not used anywhere.
5101 break;
5102#endif
5103#if QT_CONFIG(groupbox)
5106 break;
5107
5109 ret = opt ? int(opt->palette.color(QPalette::Text).rgba()) : 0;
5110 break;
5111#endif // QT_CONFIG(groupbox)
5112
5116 break;
5117
5118
5121 break;
5122
5125 break;
5126
5128 ret = false;
5129 break;
5130
5132 ret = 256;
5133 break;
5134
5136 ret = true;
5137 break;
5138
5140 ret = false;
5141 break;
5143 ret = 1;
5144 break;
5146 ret = true;
5147 break;
5149 ret = 1000;
5150 break;
5152 ret = false;
5153 break;
5155 ret = false;
5156 break;
5157
5160 break;
5161
5163#if defined(Q_OS_DARWIN)
5164 ret = 0;
5165#else
5166 ret = 1;
5167#endif
5168 break;
5169
5171 if (opt)
5173 else
5174 ret = -1;
5175 break;
5179 const QVariant hint = theme ? theme->themeHint(hintType) : QPlatformTheme::defaultThemeHint(hintType);
5180 ret = hint.toChar().unicode();
5181 break;
5182 }
5185 break;
5187 ret = 1;
5188 break;
5189
5190 case SH_UnderlineShortcut: {
5192 ret = theme ? theme->themeHint(QPlatformTheme::UnderlineShortcut).toInt()
5194 break;
5195 }
5196
5198 ret = 150;
5199 break;
5200
5202 ret = 500;
5203 break;
5204
5206 ret = 75;
5207 break;
5208
5210 ret = true;
5211 break;
5212
5214 ret = true;
5215 break;
5216
5218 ret = 255;
5219 break;
5220
5223 break;
5224
5226 ret = 0;
5227 break;
5228
5230 ret = 600;
5231 break;
5232
5233 case SH_FocusFrame_Mask:
5234 ret = 1;
5235 if (widget) {
5236 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5237 mask->region = widget->rect();
5238 const int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt, widget);
5239 const int hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget);
5240 mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
5241 }
5242 }
5243 break;
5244#if QT_CONFIG(rubberband)
5245 case SH_RubberBand_Mask:
5246 if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
5247 ret = 0;
5248 if (rbOpt->shape == QRubberBand::Rectangle) {
5249 ret = true;
5250 if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
5251 mask->region = opt->rect;
5252 const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget) * 2;
5253 mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
5254 }
5255 }
5256 }
5257 break;
5258#endif // QT_CONFIG(rubberband)
5260 ret = 1;
5261 break;
5262
5265 break;
5266
5269 break;
5270
5273 break;
5274
5276 ret = false;
5277 break;
5278
5280 ret = 0;
5282 ret = theme->themeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick).toBool() ? 1 : 0;
5283 break;
5285 ret = true;
5286 break;
5288 ret = false;
5289 break;
5292 break;
5293#if QT_CONFIG(dialogbuttonbox)
5297 ret = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt();
5298 break;
5299#endif
5302 break;
5305 break;
5307 ret = 0;
5309 ret = theme->themeHint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool() ? 1 : 0;
5310 break;
5312 ret = true;
5313 break;
5315 ret = true;
5316 break;
5318 ret = false;
5319 break;
5320#if QT_CONFIG(tabwidget)
5323 break;
5324#endif
5325 case SH_ToolBar_Movable:
5326 ret = true;
5327 break;
5329 ret = true;
5330 if (QStyleHintReturnVariant *vret = qstyleoption_cast<QStyleHintReturnVariant*>(hret)) {
5334 vret->variant = fmt;
5335 }
5336 break;
5337#if QT_CONFIG(wizard)
5338 case SH_WizardStyle:
5340 break;
5341#endif
5342#if QT_CONFIG(formlayout)
5345 break;
5348 break;
5349#endif
5352 break;
5355 break;
5357 ret = false;
5358 break;
5360 ret = 0;
5361 break;
5362#if QT_CONFIG(tabbar)
5365 break;
5367 ret = 500;
5368 break;
5369#endif
5371 ret = true;
5372 break;
5373 case SH_ToolButtonStyle:
5374 ret = 0;
5376 ret = theme->themeHint(QPlatformTheme::ToolButtonStyle).toInt();
5377 break;
5380 break;
5382 ret = false;
5383 break;
5385 ret = false;
5386 break;
5387#if QT_CONFIG(tooltip)
5389 ret = 700;
5390 break;
5392 ret = 2000;
5393 break;
5394#endif
5395 case SH_Widget_Animate:
5396 // TODO Qt6: move this code in the SH_Widget_Animation_Duration case
5397 // and replace false with 0 and true with 200.
5398#if QT_CONFIG(treeview)
5399 if (qobject_cast<const QTreeView*>(widget)) {
5400 ret = false;
5401 } else
5402#endif
5403 {
5404 ret = true;
5405 }
5406 break;
5408 ret = true;
5409 break;
5410#if QT_CONFIG(itemviews)
5413 break;
5414#endif
5416 ret = true;
5417 break;
5419 ret = styleHint(SH_Widget_Animate, opt, widget, hret) ? 200 : 0;
5420 break;
5422 ret = true;
5423 break;
5425 ret = true;
5426 break;
5429 break;
5431 ret = true;
5432 break;
5434 ret = true;
5435 break;
5455 case SH_ComboBox_Popup:
5459 case SH_Menu_Scrollable:
5465 case SH_ToolTip_Mask:
5466 case SH_Menu_Mask:
5472 ret = false;
5473 break;
5476 ret = theme->themeHint(QPlatformTheme::MenuBarFocusOnAltPressRelease).toBool();
5477 break;
5478 case SH_CustomBase:
5479 // Added to get compiler errors when a style hint is missing
5480 ret = false;
5481 break;
5482 }
5483
5484 return ret;
5485}
5486
5487#if QT_CONFIG(imageformat_xpm)
5488static QPixmap cachedPixmapFromXPM(const char * const *xpm)
5489{
5491 const QString tag = QString::asprintf("xpm:0x%p", static_cast<const void*>(xpm));
5492 if (!QPixmapCache::find(tag, &result)) {
5493 result = QPixmap(xpm);
5495 }
5496 return result;
5497}
5498
5499static inline QPixmap titleBarMenuCachedPixmapFromXPM() { return cachedPixmapFromXPM(qt_menu_xpm); }
5500#endif // QT_CONFIG(imageformat_xpm)
5501
5502#if QT_CONFIG(imageformat_png)
5503static constexpr QLatin1StringView iconResourcePrefix() noexcept { return ":/qt-project.org/styles/commonstyle/images/"_L1; }
5504static constexpr QLatin1StringView iconPngSuffix() noexcept { return ".png"_L1; }
5505
5506template <typename T>
5507static void addIconFiles(QStringView prefix, std::initializer_list<T> sizes, QIcon &icon,
5509{
5510 const auto fullPrefix = iconResourcePrefix() + prefix;
5511 for (int size : sizes)
5512 icon.addFile(fullPrefix + QString::number(size) + iconPngSuffix(),
5513 QSize(size, size), mode, state);
5514}
5515
5516static constexpr auto dockTitleIconSizes = {10, 16, 20, 32, 48, 64};
5517static constexpr auto titleBarSizes = {16, 32, 48};
5518static constexpr auto toolBarExtHSizes = {8, 16, 32, 128};
5519static constexpr auto toolBarExtVSizes = {5, 10, 20, 80};
5520static constexpr auto pngIconSizes = {16, 32, 128};
5521#endif // imageformat_png
5522
5525 const QWidget *widget) const
5526{
5527 Q_D(const QCommonStyle);
5528 QIcon icon;
5529
5530 icon = d->iconFromWindowsTheme(sp, option, widget);
5531 if (!icon.isNull())
5532 return icon.pixmap(QSize(16, 16), qt_getDevicePixelRatio(widget));
5533
5534 icon = d->iconFromApplicationTheme(sp, option, widget);
5535 if (!icon.isNull())
5536 return icon.pixmap(QSize(16, 16), qt_getDevicePixelRatio(widget));
5537
5538 icon = d->iconFromMacTheme(sp, option, widget);
5539 if (!icon.isNull())
5540 return icon.pixmap(QSize(16, 16), qt_getDevicePixelRatio(widget));
5541
5542 icon = d->iconFromResourceTheme(sp, option, widget);
5543 if (!icon.isNull())
5544 return icon.pixmap(QSize(16, 16), qt_getDevicePixelRatio(widget));
5545
5546#ifndef QT_NO_IMAGEFORMAT_XPM
5547 switch (sp) {
5549 if (d->rtl(option)) {
5551 return QPixmap::fromImage(std::move(im));
5552 }
5553 return cachedPixmapFromXPM(tb_extension_arrow_h_xpm);
5555 return cachedPixmapFromXPM(tb_extension_arrow_v_xpm);
5557 return cachedPixmapFromXPM(filedialog_start_xpm);
5559 return cachedPixmapFromXPM(filedialog_end_xpm);
5561 return titleBarMenuCachedPixmapFromXPM();
5563 return cachedPixmapFromXPM(qt_shade_xpm);
5565 return cachedPixmapFromXPM(qt_unshade_xpm);
5567 return cachedPixmapFromXPM(qt_normalizeup_xpm);
5569 return cachedPixmapFromXPM(qt_minimize_xpm);
5571 return cachedPixmapFromXPM(qt_maximize_xpm);
5573 return cachedPixmapFromXPM(qt_close_xpm);
5575 return cachedPixmapFromXPM(qt_help_xpm);
5577 return cachedPixmapFromXPM(dock_widget_close_xpm);
5579 return cachedPixmapFromXPM(information_xpm);
5581 return cachedPixmapFromXPM(warning_xpm);
5583 return cachedPixmapFromXPM(critical_xpm);
5585 return cachedPixmapFromXPM(question_xpm);
5586 default:
5587 break;
5588 }
5589#endif //QT_NO_IMAGEFORMAT_XPM
5590
5591 return QPixmap();
5592}
5593
5595 const QStyleOption *option,
5596 const QWidget *widget) const
5597{
5600 QIcon icon;
5601#ifdef Q_OS_WIN
5602 switch (standardIcon) {
5619 const auto dpr = qt_getDevicePixelRatio(widget);
5620 const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize>>();
5621 for (const QSize &size : sizes) {
5622 QPixmap pixmap = theme->standardPixmap(sp, size * dpr);
5625 }
5626 }
5627 break;
5628 case QStyle::SP_DirIcon:
5631 QPlatformTheme::StandardPixmap spOff = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
5634 const auto dpr = qt_getDevicePixelRatio(widget);
5635 const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize>>();
5636 for (const QSize &size : sizes) {
5637 const QSizeF pixSize = size * dpr;
5638 QPixmap pixmap = theme->standardPixmap(spOff, pixSize);
5641 pixmap = theme->standardPixmap(spOn, pixSize);
5642 pixmap.setDevicePixelRatio(dpr);
5644 }
5645 }
5646 break;
5647 default:
5648 break;
5649 }
5650#else
5651 Q_UNUSED(standardIcon)
5652#endif
5653 return icon;
5654}
5655
5657 const QStyleOption *option,
5658 const QWidget *widget) const
5659{
5661 switch (standardIcon) {
5663 return QIcon::fromTheme("user-home"_L1);
5665 return QIcon::fromTheme("dialog-information"_L1);
5667 return QIcon::fromTheme("dialog-warning"_L1);
5669 return QIcon::fromTheme("dialog-error"_L1);
5671 return QIcon::fromTheme("dialog-question"_L1);
5674 return QIcon::fromTheme("folder-open"_L1);
5676 return QIcon::fromTheme("document-save"_L1);
5678 return QIcon::fromTheme("dialog-ok-apply"_L1);
5681 return QIcon::fromTheme("dialog-ok"_L1);
5683 return QIcon::fromTheme("edit-delete"_L1);
5685 return QIcon::fromTheme("edit-clear"_L1);
5687 return QIcon::fromTheme("help-contents"_L1);
5689 return QIcon::fromTheme("text-x-generic"_L1);
5691 case QStyle::SP_DirIcon:
5692 return QIcon::fromTheme("folder"_L1);
5694 return QIcon::fromTheme("floppy_unmount"_L1);
5696 return QIcon::fromTheme("computer"_L1, QIcon::fromTheme("system"_L1));
5698 return QIcon::fromTheme("user-desktop"_L1);
5700 return QIcon::fromTheme("user-trash"_L1);
5703 return QIcon::fromTheme("media-optical"_L1);
5705 return QIcon::fromTheme("drive-harddisk"_L1);
5707 return QIcon::fromTheme("go-up"_L1);
5709 return QIcon::fromTheme("folder-new"_L1);
5710 case QStyle::SP_ArrowUp:
5711 return QIcon::fromTheme("go-up"_L1);
5713 return QIcon::fromTheme("go-down"_L1);
5715 return QIcon::fromTheme("go-next"_L1);
5717 return QIcon::fromTheme("go-previous"_L1);
5720 return QIcon::fromTheme("dialog-cancel"_L1, QIcon::fromTheme("process-stop"_L1));
5722 return QIcon::fromTheme("window-close"_L1);
5724 return QIcon::fromTheme("view-list-details"_L1);
5726 return QIcon::fromTheme("view-list-icons"_L1);
5728 return QIcon::fromTheme("view-refresh"_L1);
5730 return QIcon::fromTheme("process-stop"_L1);
5732 return QIcon::fromTheme("media-playback-start"_L1);
5734 return QIcon::fromTheme("media-playback-pause"_L1);
5736 return QIcon::fromTheme("media-playback-stop"_L1);
5738 return QIcon::fromTheme("media-seek-forward"_L1);
5740 return QIcon::fromTheme("media-seek-backward"_L1);
5742 return QIcon::fromTheme("media-skip-forward"_L1);
5744 return QIcon::fromTheme("media-skip-backward"_L1);
5746 return QIcon::fromTheme("audio-volume-medium"_L1);
5748 return QIcon::fromTheme("audio-volume-muted"_L1);
5752 option, widget);
5756 option, widget);
5759 const auto si = (standardIcon == QStyle::SP_DirLinkIcon)
5761 QIcon icon;
5762 const QIcon linkIcon = QIcon::fromTheme("emblem-symbolic-link"_L1);
5763 const QIcon baseIcon = iconFromApplicationTheme(si, option, widget);
5764 if (!linkIcon.isNull() || !baseIcon.isNull()) {
5765 const auto sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
5766 const auto dpr = qt_getDevicePixelRatio(widget);
5767 for (const auto size : sizes) {
5768 QPixmap basePixmap = baseIcon.pixmap(size, dpr);
5769 QPixmap linkPixmap = linkIcon.pixmap(size / 2, dpr);
5770 QPainter painter(&basePixmap);
5771 const auto w = size.width() / 2;
5772 painter.drawPixmap(w, w, linkPixmap);
5773 icon.addPixmap(basePixmap);
5774 }
5775 }
5776 return icon;
5777 }
5778 break;
5780 const QString directionalThemeName = rtl(option)
5781 ? QStringLiteral("edit-clear-locationbar-ltr") : QStringLiteral("edit-clear-locationbar-rtl");
5782 if (QIcon::hasThemeIcon(directionalThemeName))
5783 return QIcon::fromTheme(directionalThemeName);
5784 const QString themeName = QStringLiteral("edit-clear");
5787 break;
5788 }
5789 default:
5790 break;
5791 }
5792 } // if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty())
5793
5794 return {};
5795}
5796
5798 const QStyleOption *option,
5799 const QWidget *widget) const
5800{
5801#ifdef Q_OS_DARWIN
5802 Q_Q(const QCommonStyle);
5804 switch (standardIcon) {
5805 case QStyle::SP_DirIcon: {
5806 // A rather special case
5807 QIcon closeIcon = q->standardIcon(QStyle::SP_DirClosedIcon, option, widget);
5808 QIcon openIcon = q->standardIcon(QStyle::SP_DirOpenIcon, option, widget);
5809 closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On);
5810 closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On);
5811 closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On);
5812 closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On);
5813 return closeIcon;
5814 }
5815
5818 QIcon titleBarIcon;
5819 constexpr auto imagesPrefix = ":/qt-project.org/styles/macstyle/images/"_L1;
5820 const auto namePrefix = standardIcon == QStyle::SP_TitleBarCloseButton
5821 ? "closedock-"_L1
5822 : "dockdock-"_L1;
5823 for (const auto size : dockTitleIconSizes) {
5824 titleBarIcon.addFile(imagesPrefix + namePrefix + "macstyle-"_L1 + QString::number(size)
5825 + iconPngSuffix(), QSize(size, size), QIcon::Normal, QIcon::Off);
5826 titleBarIcon.addFile(imagesPrefix + namePrefix + "down-macstyle-"_L1 + QString::number(size)
5827 + iconPngSuffix(), QSize(size, size), QIcon::Normal, QIcon::On);
5828 }
5829 return titleBarIcon;
5830 }
5831
5851 QIcon retIcon;
5852 const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize> >();
5853 for (const QSize &size : sizes) {
5854 QPixmap mainIcon;
5855 const QString cacheKey = "qt_mac_constructQIconFromIconRef"_L1 + QString::number(standardIcon) + QString::number(size.width());
5856 if (standardIcon >= QStyle::SP_CustomBase) {
5857 mainIcon = theme->standardPixmap(sp, QSizeF(size));
5858 } else if (QPixmapCache::find(cacheKey, &mainIcon) == false) {
5859 mainIcon = theme->standardPixmap(sp, QSizeF(size));
5860 QPixmapCache::insert(cacheKey, mainIcon);
5861 }
5862
5863 retIcon.addPixmap(mainIcon);
5864 }
5865 return retIcon;
5866 }
5867
5868 default:
5869 break;
5870 }
5871 } // if (QGuiApplication::desktopSettingsAware())
5872#else // Q_OS_DARWIN
5873 Q_UNUSED(standardIcon);
5876#endif // Q_OS_DARWIN
5877 return {};
5878}
5879
5881 const QStyleOption *option,
5882 const QWidget *widget) const
5883{
5884 Q_Q(const QCommonStyle);
5885 QIcon icon;
5886#ifndef QT_NO_IMAGEFORMAT_PNG
5887 switch (standardIcon) {
5889 addIconFiles(u"information-", pngIconSizes, icon);
5890 break;
5892 addIconFiles(u"warning-", pngIconSizes, icon);
5893 break;
5895 addIconFiles(u"critical-", pngIconSizes, icon);
5896 break;
5898 addIconFiles(u"question-", pngIconSizes, icon);
5899 break;
5901 addIconFiles(u"filedialog_start-", pngIconSizes, icon);
5902 break;
5904 addIconFiles(u"filedialog_end-", pngIconSizes, icon);
5905 break;
5907 addIconFiles(u"titlebar-min-", titleBarSizes, icon);
5908 break;
5910 addIconFiles(u"titlebar-max-", titleBarSizes, icon);
5911 break;
5913 addIconFiles(u"titlebar-shade-", titleBarSizes, icon);
5914 break;
5916 addIconFiles(u"titlebar-unshade-", titleBarSizes, icon);
5917 break;
5919 addIconFiles(u"titlebar-contexthelp-", titleBarSizes, icon);
5920 break;
5922 addIconFiles(u"newdirectory-", pngIconSizes, icon);
5923 break;
5925 return q->proxy()->standardIcon(QStyle::SP_ArrowBack, option, widget);
5927 return q->proxy()->standardIcon(QStyle::SP_ArrowUp, option, widget);
5929 addIconFiles(u"viewdetailed-", pngIconSizes, icon);
5930 break;
5932 addIconFiles(u"fileinfo-", pngIconSizes, icon);
5933 break;
5935 addIconFiles(u"filecontents-", pngIconSizes, icon);
5936 break;
5938 addIconFiles(u"viewlist-", pngIconSizes, icon);
5939 break;
5941 addIconFiles(u"standardbutton-ok-", pngIconSizes, icon);
5942 break;
5944 addIconFiles(u"standardbutton-cancel-", pngIconSizes, icon);
5945 break;
5947 addIconFiles(u"standardbutton-help-", pngIconSizes, icon);
5948 break;
5950 addIconFiles(u"standardbutton-open-", pngIconSizes, icon);
5951 break;
5953 addIconFiles(u"standardbutton-save-", pngIconSizes, icon);
5954 break;
5956 addIconFiles(u"standardbutton-close-", pngIconSizes, icon);
5957 break;
5959 addIconFiles(u"standardbutton-apply-", pngIconSizes, icon);
5960 break;
5962 addIconFiles(u"standardbutton-clear-", pngIconSizes, icon);
5963 break;
5965 addIconFiles(u"standardbutton-delete-", pngIconSizes, icon);
5966 break;
5968 addIconFiles(u"standardbutton-yes-", pngIconSizes, icon);
5969 break;
5971 addIconFiles(u"standardbutton-no-", pngIconSizes, icon);
5972 break;
5975 return q->proxy()->standardIcon(rtl(option) ? QStyle::SP_ArrowLeft
5977 option, widget);
5979 return q->proxy()->standardIcon(rtl(option) ? QStyle::SP_ArrowRight
5981 option, widget);
5983 addIconFiles(u"left-", pngIconSizes, icon);
5984 break;
5986 addIconFiles(u"right-", pngIconSizes, icon);
5987 break;
5988 case QStyle::SP_ArrowUp:
5989 addIconFiles(u"up-", pngIconSizes, icon);
5990 break;
5992 addIconFiles(u"down-", pngIconSizes, icon);
5993 break;
5995 case QStyle::SP_DirIcon:
5996 addIconFiles(u"dirclosed-", pngIconSizes, icon, QIcon::Normal, QIcon::Off);
5997 addIconFiles(u"diropen-", pngIconSizes, icon, QIcon::Normal, QIcon::On);
5998 break;
6000 addIconFiles(u"diropen-", pngIconSizes, icon);
6001 break;
6003 addIconFiles(u"dirclosed-", pngIconSizes, icon);
6004 break;
6006 addIconFiles(u"dirlink-", pngIconSizes, icon);
6007 break;
6009 addIconFiles(u"cdr-", pngIconSizes, icon);
6010 break;
6012 addIconFiles(u"floppy-", pngIconSizes, icon);
6013 break;
6015 addIconFiles(u"harddrive-", pngIconSizes, icon);
6016 break;
6018 addIconFiles(u"dvd-", pngIconSizes, icon);
6019 break;
6021 addIconFiles(u"networkdrive-", pngIconSizes, icon);
6022 break;
6024 addIconFiles(u"file-", pngIconSizes, icon);
6025 break;
6027 addIconFiles(u"filelink-", pngIconSizes, icon);
6028 break;
6030 addIconFiles(u"desktop-", {16, 32}, icon);
6031 break;
6033 addIconFiles(u"trash-", pngIconSizes, icon);
6034 break;
6036 addIconFiles(u"computer-", {16, 32}, icon);
6037 break;
6039 addIconFiles(u"refresh-", {24, 32}, icon);
6040 break;
6042 addIconFiles(u"stop-", {24, 32}, icon);
6043 break;
6045 addIconFiles(u"media-play-", pngIconSizes, icon);
6046 break;
6048 addIconFiles(u"media-pause-", pngIconSizes, icon);
6049 break;
6051 addIconFiles(u"media-stop-", pngIconSizes, icon);
6052 break;
6054 addIconFiles(u"media-seek-forward-", pngIconSizes, icon);
6055 break;
6057 addIconFiles(u"media-seek-backward-", pngIconSizes, icon);
6058 break;
6060 addIconFiles(u"media-skip-forward-", pngIconSizes, icon);
6061 break;
6063 addIconFiles(u"media-skip-backward-", pngIconSizes, icon);
6064 break;
6066 addIconFiles(u"media-volume-", {16}, icon);
6067 break;
6069 addIconFiles(u"media-volume-muted-", {16}, icon);
6070 break;
6073 addIconFiles(u"closedock-", dockTitleIconSizes, icon);
6074 break;
6076# ifndef QT_NO_IMAGEFORMAT_XPM
6077 icon.addPixmap(titleBarMenuCachedPixmapFromXPM());
6078# endif
6079 icon.addFile(":/qt-project.org/qmessagebox/images/qtlogo-64.png"_L1);
6080 break;
6082 addIconFiles(u"normalizedockup-", dockTitleIconSizes, icon);
6083 break;
6085 addIconFiles(rtl(option) ? u"toolbar-ext-h-rtl-" : u"toolbar-ext-h-", toolBarExtHSizes, icon);
6086 break;
6088 addIconFiles(u"toolbar-ext-v-", toolBarExtVSizes, icon);
6089 break;
6091 addIconFiles(u"standardbutton-closetab-", pngIconSizes, icon, QIcon::Normal, QIcon::Off);
6092 addIconFiles(u"standardbutton-closetab-down-", pngIconSizes, icon, QIcon::Normal, QIcon::On);
6093 addIconFiles(u"standardbutton-closetab-hover-", pngIconSizes, icon, QIcon::Active, QIcon::Off);
6094 break;
6096 addIconFiles(u"cleartext-", pngIconSizes, icon);
6097 break;
6098 default:
6099 break;
6100 }
6101#else // QT_NO_IMAGEFORMAT_PNG
6102 Q_UNUSED(standardIcon);
6105#endif // QT_NO_IMAGEFORMAT_PNG
6106 return icon;
6107}
6108
6109
6114 const QWidget *widget) const
6115{
6116 Q_D(const QCommonStyle);
6117 QIcon icon;
6118
6119 icon = d->iconFromWindowsTheme(standardIcon, option, widget);
6120 if (!icon.isNull())
6121 return icon;
6122
6123 icon = d->iconFromApplicationTheme(standardIcon, option, widget);
6124 if (!icon.isNull())
6125 return icon;
6126
6127 icon = d->iconFromMacTheme(standardIcon, option, widget);
6128 if (!icon.isNull())
6129 return icon;
6130
6131 icon = d->iconFromResourceTheme(standardIcon, option, widget);
6132 if (!icon.isNull())
6133 return icon;
6134
6135#ifndef QT_NO_IMAGEFORMAT_XPM
6136 switch (standardIcon) {
6138 icon.addPixmap(titleBarMenuCachedPixmapFromXPM());
6139 break;
6140 default:
6141 break;
6142 }
6143 if (!icon.isNull())
6144 return icon;
6145#endif
6147 return icon;
6148}
6149
6150static inline uint qt_intensity(uint r, uint g, uint b)
6151{
6152 // 30% red, 59% green, 11% blue
6153 return (77 * r + 150 * g + 28 * b) / 255;
6154}
6155
6158 const QStyleOption *opt) const
6159{
6160 switch (iconMode) {
6161 case QIcon::Disabled: {
6163
6164 // Create a colortable based on the background (black -> bg -> white)
6166 int red = bg.red();
6167 int green = bg.green();
6168 int blue = bg.blue();
6169 uchar reds[256], greens[256], blues[256];
6170 for (int i=0; i<128; ++i) {
6171 reds[i] = uchar((red * (i<<1)) >> 8);
6172 greens[i] = uchar((green * (i<<1)) >> 8);
6173 blues[i] = uchar((blue * (i<<1)) >> 8);
6174 }
6175 for (int i=0; i<128; ++i) {
6176 reds[i+128] = uchar(qMin(red + (i << 1), 255));
6177 greens[i+128] = uchar(qMin(green + (i << 1), 255));
6178 blues[i+128] = uchar(qMin(blue + (i << 1), 255));
6179 }
6180
6181 int intensity = qt_intensity(red, green, blue);
6182 const int factor = 191;
6183
6184 // High intensity colors needs dark shifting in the color table, while
6185 // low intensity colors needs light shifting. This is to increase the
6186 // perceived contrast.
6187 if ((red - factor > green && red - factor > blue)
6188 || (green - factor > red && green - factor > blue)
6189 || (blue - factor > red && blue - factor > green))
6190 intensity = qMin(255, intensity + 91);
6191 else if (intensity <= 128)
6192 intensity -= 51;
6193
6194 for (int y=0; y<im.height(); ++y) {
6195 QRgb *scanLine = (QRgb*)im.scanLine(y);
6196 for (int x=0; x<im.width(); ++x) {
6197 QRgb pixel = *scanLine;
6198 // Calculate color table index, taking intensity adjustment
6199 // and a magic offset into account.
6200 uint ci = uint(qGray(pixel)/3 + (130 - intensity / 3));
6201 *scanLine = qRgba(reds[ci], greens[ci], blues[ci], qAlpha(pixel));
6202 ++scanLine;
6203 }
6204 }
6205
6206 return QPixmap::fromImage(std::move(im));
6207 }
6208 case QIcon::Selected: {
6211 color.setAlphaF(0.3f);
6214 painter.fillRect(0, 0, img.width(), img.height(), color);
6215 painter.end();
6216 return QPixmap::fromImage(std::move(img)); }
6217 case QIcon::Active:
6218 return pixmap;
6219 default:
6220 break;
6221 }
6222 return pixmap;
6223}
6224
6229 Qt::Orientation /* orientation */, const QStyleOption * /* option */,
6230 const QWidget * /* widget */) const
6231{
6232 return -1;
6233}
6234
6239{
6240 QStyle::polish(pal);
6241}
6242
6250
6258
6266
6271{
6272 Q_D(const QCommonStyle);
6273 d->tabBarcloseButtonIcon = QIcon();
6274 QStyle::unpolish(application);
6275}
6276
6277
6279
6280#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
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
void setAlphaF(float alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1511
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
QIcon iconFromMacTheme(QCommonStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
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
QIcon iconFromResourceTheme(QCommonStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
static bool rtl(const QStyleOption *option)
QIcon iconFromApplicationTheme(QCommonStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
QIcon iconFromWindowsTheme(QCommonStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) 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...
\reentrant
Definition qfont.h:22
@ WeightResolved
Definition qfont.h:118
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:373
uint resolveMask() const
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
static QPlatformTheme * platformTheme()
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:1401
static QString themeName()
Definition qicon.cpp:1274
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:1060
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:1019
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
qint64 cacheKey() const
Returns a number that identifies the contents of this QIcon object.
Definition qicon.cpp:819
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:1113
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:926
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:834
static QIcon fromTheme(const QString &name)
Definition qicon.cpp:1344
\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:1637
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:219
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition qimage.h:125
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
\inmodule QtGui
Definition qbrush.h:394
\inmodule QtCore
Definition qmargins.h:24
constexpr int bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:115
constexpr int left() const noexcept
Returns the left margin.
Definition qmargins.h:106
constexpr int right() const noexcept
Returns the right margin.
Definition qmargins.h:112
constexpr int top() const noexcept
Returns the top margin.
Definition qmargins.h:109
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
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 restore()
Restores the current painter state (pops a saved state off the stack).
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void save()
Saves the current painter state (pushes the state onto a stack).
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.
@ Antialiasing
Definition qpainter.h:52
bool end()
Ends painting.
@ CompositionMode_SourceAtop
Definition qpainter.h:107
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 & button() const
Returns the button brush of the current color group.
Definition qpalette.h:84
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:88
const QBrush & toolTipBase() const
Definition qpalette.h:91
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition qpalette.h:83
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition qpalette.h:86
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:748
const QBrush & toolTipText() const
Definition qpalette.h:92
const QBrush & light() const
Returns the light brush of the current color group.
Definition qpalette.h:85
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
Definition qpalette.h:65
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:67
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition qpalette.h:87
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:151
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:49
@ Inactive
Definition qpalette.h:49
@ Disabled
Definition qpalette.h:49
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:146
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition qpalette.h:93
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:89
@ HighlightedText
Definition qpalette.h:53
@ AlternateBase
Definition qpalette.h:55
@ ButtonText
Definition qpalette.h:52
@ WindowText
Definition qpalette.h:51
@ Highlight
Definition qpalette.h:53
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition qpalette.h:96
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition qpalette.h:99
\inmodule QtGui
Definition qpen.h:28
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition qpen.cpp:592
void setColor(const QColor &color)
Sets the color of this pen's brush to the given color.
Definition qpen.cpp:705
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:480
QSize size() const
Returns the size of the pixmap.
Definition qpixmap.cpp:493
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:456
int width() const
Returns the width of the pixmap.
Definition qpixmap.cpp:468
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
Definition qpixmap.cpp:604
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
Definition qpixmap.cpp:576
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:1437
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:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QPolygon class provides a list of points using integer precision.
Definition qpolygon.h:23
\inmodule QtCore\reentrant
Definition qrect.h:484
\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:167
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:373
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:338
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
Definition qrect.h:170
QRect intersected(const QRect &other) const noexcept
Definition qrect.h:415
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:182
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
Definition qrect.h:197
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:221
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:370
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:176
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
Definition qrect.h:191
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:173
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:346
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:185
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
Definition qrect.h:381
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:245
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:362
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Definition qrect.h:224
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
QRect united(const QRect &other) const noexcept
Definition qrect.h:420
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:188
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
Definition qrect.h:384
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:179
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
Definition qrect.h:194
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr QSize transposed() const noexcept
Definition qsize.h:142
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
Definition qsize.h:139
@ TicksAbove
Definition qslider.h:27
@ TicksBelow
Definition qslider.h:29
@ TicksBothSides
Definition qslider.h:31
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString & replace(qsizetype i, qsizetype len, QChar after)
Definition qstring.cpp:3824
void chop(qsizetype n)
Removes n characters from the end of the string.
Definition qstring.cpp:6340
QString mid(qsizetype position, qsizetype n=-1) const &
Definition qstring.cpp:5300
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
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:5506
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:8084
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
Definition qstring.cpp:7263
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
\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
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:34
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:546
@ CT_Menu
Definition qstyle.h:557
@ CT_ProgressBar
Definition qstyle.h:553
@ CT_CheckBox
Definition qstyle.h:548
@ CT_ItemViewItem
Definition qstyle.h:569
@ CT_SpinBox
Definition qstyle.h:562
@ CT_ToolButton
Definition qstyle.h:550
@ CT_MenuBar
Definition qstyle.h:556
@ CT_PushButton
Definition qstyle.h:547
@ CT_MenuItem
Definition qstyle.h:554
@ CT_RadioButton
Definition qstyle.h:549
@ CT_MenuBarItem
Definition qstyle.h:555
@ CT_MdiControls
Definition qstyle.h:568
@ CT_TabBarTab
Definition qstyle.h:558
@ CT_LineEdit
Definition qstyle.h:561
@ CT_ScrollBar
Definition qstyle.h:560
@ CT_HeaderSection
Definition qstyle.h:566
@ CT_TabWidget
Definition qstyle.h:564
@ CT_Slider
Definition qstyle.h:559
@ CT_ComboBox
Definition qstyle.h:551
@ CT_GroupBox
Definition qstyle.h:567
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:2202
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:584
@ SH_TitleBar_ShowToolTipsOnButtons
Definition qstyle.h:699
@ SH_ToolBar_Movable
Definition qstyle.h:672
@ SH_TabBar_ElideMode
Definition qstyle.h:652
@ SH_ComboBox_ListMouseTracking
Definition qstyle.h:604
@ SH_GroupBox_TextLabelColor
Definition qstyle.h:617
@ SH_TabBar_CloseButtonPosition
Definition qstyle.h:677
@ SH_Slider_PageSetButtons
Definition qstyle.h:650
@ SH_TitleBar_NoBorder
Definition qstyle.h:611
@ SH_Menu_Scrollable
Definition qstyle.h:615
@ SH_ScrollView_FrameOnlyAroundContents
Definition qstyle.h:602
@ SH_Splitter_OpaqueResize
Definition qstyle.h:686
@ SH_MainWindow_SpaceBelowMenuBar
Definition qstyle.h:597
@ SH_ProgressDialog_CenterCancelButton
Definition qstyle.h:594
@ SH_Menu_Mask
Definition qstyle.h:665
@ SH_ComboBox_Popup
Definition qstyle.h:610
@ SH_EtchDisabledText
Definition qstyle.h:585
@ SH_SpinBox_AnimateButton
Definition qstyle.h:627
@ SH_Menu_SubMenuUniDirectionFailCount
Definition qstyle.h:693
@ SH_TextControl_FocusIndicatorTextCharFormat
Definition qstyle.h:662
@ SH_MessageBox_UseBorderForButtonSpacing
Definition qstyle.h:635
@ SH_SpinBox_ClickAutoRepeatRate
Definition qstyle.h:629
@ SH_TabBar_Alignment
Definition qstyle.h:590
@ SH_ItemView_PaintAlternatingRowColorsForEmptyArea
Definition qstyle.h:669
@ SH_ComboBox_UseNativePopup
Definition qstyle.h:689
@ SH_ItemView_ChangeHighlightOnFocus
Definition qstyle.h:607
@ SH_SpinBox_KeyPressAutoRepeatRate
Definition qstyle.h:628
@ SH_ItemView_MovementWithoutUpdatingSelection
Definition qstyle.h:659
@ SH_MenuBar_AltKeyNavigation
Definition qstyle.h:603
@ SH_Menu_SubMenuUniDirection
Definition qstyle.h:692
@ SH_CustomBase
Definition qstyle.h:709
@ SH_ScrollBar_RollBetweenButtons
Definition qstyle.h:648
@ SH_Menu_MouseTracking
Definition qstyle.h:605
@ SH_ScrollBar_Transient
Definition qstyle.h:681
@ SH_Table_GridLineColor
Definition qstyle.h:619
@ SH_TabBar_AllowWheelScrolling
Definition qstyle.h:704
@ SH_SpinControls_DisableOnBounds
Definition qstyle.h:641
@ SH_ScrollBar_MiddleClickAbsolutePosition
Definition qstyle.h:587
@ SH_Menu_FlashTriggeredItem
Definition qstyle.h:666
@ SH_Menu_SubMenuPopupDelay
Definition qstyle.h:601
@ SH_ItemView_ArrowKeysNavigateIntoChildren
Definition qstyle.h:664
@ SH_Slider_AbsoluteSetButtons
Definition qstyle.h:649
@ SH_Widget_Animation_Duration
Definition qstyle.h:700
@ SH_Menu_SubMenuResetWhenReenteringParent
Definition qstyle.h:696
@ SH_ComboBox_PopupFrameStyle
Definition qstyle.h:654
@ SH_Slider_SloppyKeyEvents
Definition qstyle.h:593
@ SH_TabWidget_DefaultTabPosition
Definition qstyle.h:671
@ SH_DitherDisabledText
Definition qstyle.h:586
@ SH_TabBar_ChangeCurrentDelay
Definition qstyle.h:691
@ SH_Header_ArrowAlignment
Definition qstyle.h:591
@ SH_Widget_Animate
Definition qstyle.h:685
@ SH_ToolBox_SelectedPageTitleBold
Definition qstyle.h:622
@ SH_LineEdit_PasswordMaskDelay
Definition qstyle.h:690
@ SH_SpinBox_SelectOnStep
Definition qstyle.h:706
@ SH_ToolButtonStyle
Definition qstyle.h:679
@ SH_TabBar_PreferNoArrows
Definition qstyle.h:623
@ SH_Menu_KeyboardSearch
Definition qstyle.h:651
@ SH_Button_FocusPolicy
Definition qstyle.h:634
@ SH_Menu_SupportsSections
Definition qstyle.h:682
@ SH_Menu_SubMenuSloppySelectOtherActions
Definition qstyle.h:694
@ SH_Menu_SelectionWrap
Definition qstyle.h:658
@ SH_FormLayoutWrapPolicy
Definition qstyle.h:670
@ SH_Widget_ShareActivation
Definition qstyle.h:608
@ SH_ComboBox_LayoutDirection
Definition qstyle.h:643
@ SH_DialogButtons_DefaultButton
Definition qstyle.h:621
@ SH_ComboBox_AllowWheelScrolling
Definition qstyle.h:701
@ SH_ToolButton_PopupDelay
Definition qstyle.h:637
@ SH_Menu_AllowActiveAndDisabled
Definition qstyle.h:599
@ SH_SpinBox_StepModifier
Definition qstyle.h:703
@ SH_TabBar_SelectMouseType
Definition qstyle.h:589
@ SH_Menu_FillScreenWithScroll
Definition qstyle.h:630
@ SH_Table_AlwaysDrawLeftTopGridLines
Definition qstyle.h:705
@ SH_FontDialog_SelectAssociatedText
Definition qstyle.h:598
@ SH_ToolTipLabel_Opacity
Definition qstyle.h:631
@ SH_ScrollBar_LeftClickAbsolutePosition
Definition qstyle.h:624
@ SH_DialogButtonBox_ButtonsHaveIcons
Definition qstyle.h:656
@ SH_MenuBar_MouseTracking
Definition qstyle.h:606
@ SH_FormLayoutFieldGrowthPolicy
Definition qstyle.h:673
@ SH_UnderlineShortcut
Definition qstyle.h:626
@ SH_SpinBox_ClickAutoRepeatThreshold
Definition qstyle.h:668
@ SH_ScrollBar_ContextMenu
Definition qstyle.h:647
@ SH_FormLayoutFormAlignment
Definition qstyle.h:674
@ SH_Menu_SubMenuDontStartSloppyOnLeave
Definition qstyle.h:697
@ SH_MessageBox_CenterButtons
Definition qstyle.h:657
@ SH_TitleBar_ModifyNotification
Definition qstyle.h:633
@ SH_Slider_StopMouseOverSlider
Definition qstyle.h:612
@ SH_DrawMenuBarSeparator
Definition qstyle.h:632
@ SH_RequestSoftwareInputPanel
Definition qstyle.h:680
@ SH_ToolTip_Mask
Definition qstyle.h:660
@ SH_Slider_SnapToValue
Definition qstyle.h:592
@ SH_LineEdit_PasswordCharacter
Definition qstyle.h:620
@ SH_SpinBox_ButtonsInsideFrame
Definition qstyle.h:702
@ SH_ItemView_DrawDelegateFrame
Definition qstyle.h:676
@ SH_Menu_FadeOutOnHide
Definition qstyle.h:667
@ SH_GroupBox_TextLabelVerticalAlignment
Definition qstyle.h:616
@ SH_ItemView_ScrollMode
Definition qstyle.h:698
@ SH_ScrollBar_ScrollWhenPointerLeavesControl
Definition qstyle.h:588
@ SH_ToolTip_FallAsleepDelay
Definition qstyle.h:684
@ SH_PrintDialog_RightAlignButtons
Definition qstyle.h:596
@ SH_BlinkCursorWhenTextSelected
Definition qstyle.h:613
@ SH_DialogButtonLayout
Definition qstyle.h:653
@ SH_TitleBar_AutoRaise
Definition qstyle.h:636
@ SH_ListViewExpand_SelectMouseType
Definition qstyle.h:625
@ SH_ItemView_EllipsisLocation
Definition qstyle.h:644
@ SH_ItemView_ActivateItemOnSingleClick
Definition qstyle.h:646
@ SH_MessageBox_TextInteractionFlags
Definition qstyle.h:655
@ SH_WindowFrame_Mask
Definition qstyle.h:640
@ SH_RichText_FullWidthSelection
Definition qstyle.h:614
@ SH_Menu_SloppySubMenus
Definition qstyle.h:618
@ SH_RubberBand_Mask
Definition qstyle.h:639
@ SH_FormLayoutLabelAlignment
Definition qstyle.h:675
@ SH_ItemView_ShowDecorationSelected
Definition qstyle.h:645
@ SH_DockWidget_ButtonsHaveFrame
Definition qstyle.h:678
@ SH_WizardStyle
Definition qstyle.h:663
@ SH_Menu_SpaceActivatesItem
Definition qstyle.h:600
@ SH_ToolTip_WakeUpDelay
Definition qstyle.h:683
@ SH_FocusFrame_AboveWidget
Definition qstyle.h:661
@ SH_FocusFrame_Mask
Definition qstyle.h:638
@ SH_ProgressDialog_TextLabelAlignment
Definition qstyle.h:595
@ SH_Dial_BackgroundRole
Definition qstyle.h:642
@ SH_Menu_SubMenuSloppyCloseTimeout
Definition qstyle.h:695
@ SH_Workspace_FillSpaceOnMaximize
Definition qstyle.h:609
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:716
@ SP_DockWidgetCloseButton
Definition qstyle.h:725
@ SP_DirIcon
Definition qstyle.h:755
@ SP_FileIcon
Definition qstyle.h:742
@ SP_ArrowForward
Definition qstyle.h:772
@ SP_DirLinkIcon
Definition qstyle.h:740
@ SP_MediaVolume
Definition qstyle.h:785
@ SP_DriveNetIcon
Definition qstyle.h:737
@ SP_TitleBarCloseButton
Definition qstyle.h:720
@ SP_BrowserStop
Definition qstyle.h:777
@ SP_ComputerIcon
Definition qstyle.h:732
@ SP_MediaPlay
Definition qstyle.h:778
@ SP_FileDialogBack
Definition qstyle.h:754
@ SP_DialogDiscardButton
Definition qstyle.h:764
@ SP_MediaSkipBackward
Definition qstyle.h:782
@ SP_TitleBarMenuButton
Definition qstyle.h:717
@ SP_DesktopIcon
Definition qstyle.h:730
@ SP_DriveCDIcon
Definition qstyle.h:735
@ SP_TrashIcon
Definition qstyle.h:731
@ SP_DialogNoButton
Definition qstyle.h:766
@ SP_TitleBarMinButton
Definition qstyle.h:718
@ SP_MediaSeekBackward
Definition qstyle.h:784
@ SP_DialogCloseButton
Definition qstyle.h:761
@ SP_TitleBarMaxButton
Definition qstyle.h:719
@ SP_FileDialogListView
Definition qstyle.h:753
@ SP_MediaStop
Definition qstyle.h:779
@ SP_TitleBarContextHelpButton
Definition qstyle.h:724
@ SP_DirHomeIcon
Definition qstyle.h:773
@ SP_MediaSeekForward
Definition qstyle.h:783
@ SP_MediaVolumeMuted
Definition qstyle.h:786
@ SP_DialogOpenButton
Definition qstyle.h:759
@ SP_TitleBarNormalButton
Definition qstyle.h:721
@ SP_MessageBoxQuestion
Definition qstyle.h:729
@ SP_LineEditClearButton
Definition qstyle.h:787
@ SP_CommandLink
Definition qstyle.h:774
@ SP_ArrowBack
Definition qstyle.h:771
@ SP_ArrowDown
Definition qstyle.h:768
@ SP_TitleBarShadeButton
Definition qstyle.h:722
@ SP_TabCloseButton
Definition qstyle.h:795
@ SP_VistaShield
Definition qstyle.h:775
@ SP_FileDialogNewFolder
Definition qstyle.h:749
@ SP_FileDialogEnd
Definition qstyle.h:747
@ SP_CustomBase
Definition qstyle.h:798
@ SP_FileDialogInfoView
Definition qstyle.h:751
@ SP_ArrowLeft
Definition qstyle.h:769
@ SP_DialogCancelButton
Definition qstyle.h:757
@ SP_FileDialogStart
Definition qstyle.h:746
@ SP_MediaPause
Definition qstyle.h:780
@ SP_DriveHDIcon
Definition qstyle.h:734
@ SP_DriveDVDIcon
Definition qstyle.h:736
@ SP_DriveFDIcon
Definition qstyle.h:733
@ SP_BrowserReload
Definition qstyle.h:776
@ SP_DialogHelpButton
Definition qstyle.h:758
@ SP_DialogSaveButton
Definition qstyle.h:760
@ SP_FileDialogDetailedView
Definition qstyle.h:750
@ SP_MessageBoxCritical
Definition qstyle.h:728
@ SP_MediaSkipForward
Definition qstyle.h:781
@ SP_MessageBoxInformation
Definition qstyle.h:726
@ SP_DialogResetButton
Definition qstyle.h:763
@ SP_DialogOkButton
Definition qstyle.h:756
@ SP_ArrowUp
Definition qstyle.h:767
@ SP_FileDialogContentsView
Definition qstyle.h:752
@ SP_TitleBarUnshadeButton
Definition qstyle.h:723
@ SP_DialogYesButton
Definition qstyle.h:765
@ SP_FileDialogToParent
Definition qstyle.h:748
@ SP_FileLinkIcon
Definition qstyle.h:743
@ SP_ToolBarVerticalExtensionButton
Definition qstyle.h:745
@ SP_DialogApplyButton
Definition qstyle.h:762
@ SP_ToolBarHorizontalExtensionButton
Definition qstyle.h:744
@ SP_MessageBoxWarning
Definition qstyle.h:727
@ SP_ArrowRight
Definition qstyle.h:770
@ SP_DirOpenIcon
Definition qstyle.h:738
@ SP_DirClosedIcon
Definition qstyle.h:739
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:2173
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:2222
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:2143
PixelMetric
This enum describes the various available pixel metrics.
Definition qstyle.h:413
@ PM_MenuVMargin
Definition qstyle.h:452
@ PM_LayoutBottomMargin
Definition qstyle.h:515
@ PM_MenuBarHMargin
Definition qstyle.h:460
@ PM_FocusFrameVMargin
Definition qstyle.h:498
@ PM_MenuPanelWidth
Definition qstyle.h:453
@ PM_TabBar_ScrollButtonOverlap
Definition qstyle.h:518
@ PM_TextCursorWidth
Definition qstyle.h:520
@ PM_ScrollBarExtent
Definition qstyle.h:426
@ PM_TitleBarButtonIconSize
Definition qstyle.h:533
@ PM_DockWidgetFrameWidth
Definition qstyle.h:437
@ PM_TitleBarButtonSize
Definition qstyle.h:534
@ PM_TitleBarHeight
Definition qstyle.h:448
@ PM_SizeGripSize
Definition qstyle.h:504
@ PM_DockWidgetTitleMargin
Definition qstyle.h:505
@ PM_ExclusiveIndicatorHeight
Definition qstyle.h:465
@ PM_TabBarTabHSpace
Definition qstyle.h:440
@ PM_LayoutLeftMargin
Definition qstyle.h:512
@ PM_LineEditIconMargin
Definition qstyle.h:537
@ PM_DefaultFrameWidth
Definition qstyle.h:420
@ PM_MaximumDragDistance
Definition qstyle.h:424
@ PM_ToolBarHandleExtent
Definition qstyle.h:484
@ PM_ButtonShiftHorizontal
Definition qstyle.h:417
@ PM_MdiSubWindowFrameWidth
Definition qstyle.h:473
@ PM_ToolBarItemSpacing
Definition qstyle.h:485
@ PM_DockWidgetTitleBarButtonMargin
Definition qstyle.h:509
@ PM_ToolBarSeparatorExtent
Definition qstyle.h:487
@ PM_IndicatorWidth
Definition qstyle.h:462
@ PM_TabBarBaseOverlap
Definition qstyle.h:443
@ PM_HeaderDefaultSectionSizeHorizontal
Definition qstyle.h:530
@ PM_ScrollView_ScrollBarOverlap
Definition qstyle.h:526
@ PM_DockWidgetSeparatorExtent
Definition qstyle.h:435
@ PM_TabCloseIndicatorWidth
Definition qstyle.h:522
@ PM_MenuTearoffHeight
Definition qstyle.h:454
@ PM_CheckBoxLabelSpacing
Definition qstyle.h:502
@ PM_LayoutVerticalSpacing
Definition qstyle.h:517
@ PM_TabBarTabShiftVertical
Definition qstyle.h:480
@ PM_LayoutHorizontalSpacing
Definition qstyle.h:516
@ PM_TabBarBaseHeight
Definition qstyle.h:442
@ PM_SliderTickmarkOffset
Definition qstyle.h:432
@ PM_ButtonShiftVertical
Definition qstyle.h:418
@ PM_MessageBoxIconSize
Definition qstyle.h:506
@ PM_IndicatorHeight
Definition qstyle.h:463
@ PM_ButtonDefaultIndicator
Definition qstyle.h:415
@ PM_LayoutTopMargin
Definition qstyle.h:513
@ PM_SliderControlThickness
Definition qstyle.h:430
@ PM_ComboBoxFrameWidth
Definition qstyle.h:422
@ PM_MenuBarPanelWidth
Definition qstyle.h:457
@ PM_ToolBarItemMargin
Definition qstyle.h:486
@ PM_SliderSpaceAvailable
Definition qstyle.h:433
@ PM_ToolBarIconSize
Definition qstyle.h:492
@ PM_MenuButtonIndicator
Definition qstyle.h:416
@ PM_MenuDesktopFrameWidth
Definition qstyle.h:455
@ PM_HeaderMargin
Definition qstyle.h:476
@ PM_TabBarIconSize
Definition qstyle.h:503
@ PM_LineEditIconSize
Definition qstyle.h:536
@ PM_TabBarTabVSpace
Definition qstyle.h:441
@ PM_MenuHMargin
Definition qstyle.h:451
@ PM_SmallIconSize
Definition qstyle.h:495
@ PM_HeaderMarkSize
Definition qstyle.h:477
@ PM_ProgressBarChunkWidth
Definition qstyle.h:445
@ PM_LargeIconSize
Definition qstyle.h:496
@ PM_MenuBarItemSpacing
Definition qstyle.h:458
@ PM_IconViewIconSize
Definition qstyle.h:494
@ PM_ListViewIconSize
Definition qstyle.h:493
@ PM_SubMenuOverlap
Definition qstyle.h:527
@ PM_TabBarScrollButtonWidth
Definition qstyle.h:481
@ PM_DockWidgetHandleExtent
Definition qstyle.h:436
@ PM_SpinBoxSliderHeight
Definition qstyle.h:490
@ PM_ButtonMargin
Definition qstyle.h:414
@ PM_ToolBarExtensionExtent
Definition qstyle.h:488
@ PM_TabCloseIndicatorHeight
Definition qstyle.h:523
@ PM_SliderThickness
Definition qstyle.h:429
@ PM_HeaderDefaultSectionSizeVertical
Definition qstyle.h:531
@ PM_SliderLength
Definition qstyle.h:431
@ PM_TreeViewIndentation
Definition qstyle.h:528
@ PM_RadioButtonLabelSpacing
Definition qstyle.h:511
@ PM_TabBarTabShiftHorizontal
Definition qstyle.h:479
@ PM_ScrollView_ScrollBarSpacing
Definition qstyle.h:525
@ PM_MdiSubWindowMinimizedWidth
Definition qstyle.h:474
@ PM_SpinBoxFrameWidth
Definition qstyle.h:421
@ PM_LayoutRightMargin
Definition qstyle.h:514
@ PM_FocusFrameHMargin
Definition qstyle.h:499
@ PM_ExclusiveIndicatorWidth
Definition qstyle.h:464
@ PM_ToolTipLabelFrameWidth
Definition qstyle.h:501
@ 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:507
@ PM_ToolBarFrameWidth
Definition qstyle.h:483
@ PM_HeaderGripMargin
Definition qstyle.h:478
@ RSIP_OnMouseClick
Definition qstyle.h:580
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:2400
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
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
\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:65
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
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:2600
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:4411
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]
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)
Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option)
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size, qreal dpr)
Combined button and popup list for selecting options.
@ WindowMinimized
Definition qnamespace.h:253
@ WindowMaximized
Definition qnamespace.h:254
@ BottomLeftCorner
@ TopRightCorner
@ TopLeftCorner
@ BottomRightCorner
@ Unchecked
@ Checked
@ PartiallyChecked
@ AlignRight
Definition qnamespace.h:146
@ AlignVCenter
Definition qnamespace.h:155
@ AlignTop
Definition qnamespace.h:153
@ AlignTrailing
Definition qnamespace.h:147
@ AlignHCenter
Definition qnamespace.h:148
@ AlignCenter
Definition qnamespace.h:163
@ AlignAbsolute
Definition qnamespace.h:150
@ AlignLeft
Definition qnamespace.h:144
@ LeftButton
Definition qnamespace.h:58
@ MiddleButton
Definition qnamespace.h:60
@ LinksAccessibleByMouse
@ WA_NoSystemBackground
Definition qnamespace.h:291
LayoutDirection
@ LeftToRight
@ LayoutDirectionAuto
@ RightToLeft
@ StrongFocus
Definition qnamespace.h:110
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ UpArrow
@ RightArrow
@ LeftArrow
@ DownArrow
@ TextSingleLine
Definition qnamespace.h:170
@ TextDontClip
Definition qnamespace.h:171
@ TextHideMnemonic
Definition qnamespace.h:178
@ TextShowMnemonic
Definition qnamespace.h:173
@ OpaqueMode
Definition qnamespace.h:508
@ white
Definition qnamespace.h:31
@ black
Definition qnamespace.h:30
@ DotLine
@ DashLine
@ NoPen
@ DecorationRole
@ CheckStateRole
@ DisplayRole
@ ControlModifier
@ Dense4Pattern
@ NoBrush
@ WindowContextHelpButtonHint
Definition qnamespace.h:231
@ WindowType_Mask
Definition qnamespace.h:220
@ WindowMaximizeButtonHint
Definition qnamespace.h:229
@ WindowMinimizeButtonHint
Definition qnamespace.h:228
@ WindowShadeButtonHint
Definition qnamespace.h:232
@ Tool
Definition qnamespace.h:212
@ WindowTitleHint
Definition qnamespace.h:226
@ WindowSystemMenuHint
Definition qnamespace.h:227
TextElideMode
Definition qnamespace.h:188
@ ElideMiddle
Definition qnamespace.h:191
@ ElideRight
Definition qnamespace.h:190
@ ElideNone
Definition qnamespace.h:192
@ ToolButtonTextOnly
@ ToolButtonTextUnderIcon
@ ToolButtonIconOnly
Definition brush.cpp:5
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 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:333
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
static QByteArray cacheKey(Args &&...args)
#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
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 GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat f
GLsizei range
GLint GLsizei width
GLuint color
[2]
GLint left
GLuint GLsizei const GLchar * label
[43]
GLint GLint bottom
GLuint GLfloat x0
GLenum target
GLbitfield flags
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
GLdouble s
[6]
Definition qopenglext.h:235
GLbyte GLbyte blue
Definition qopenglext.h:385
GLint void * img
Definition qopenglext.h:233
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLfixed GLfixed x2
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
GLuint GLenum option
GLenum GLsizei len
GLbyte green
Definition qopenglext.h:385
static const QRectF boundingRect(const QPointF *points, int pointCount)
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
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)
QPixmap styleCachePixmap(const QSize &size, qreal pixelRatio)
Definition qstyle_p.h:38
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
Definition qswap.h:20
#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:32
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
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
QPainterStateSaver(QPainter *p, bool bSaveRestore=true)