86 Q_D(
const QCommonStyle);
88 case PE_FrameButtonBevel:
89 case PE_FrameButtonTool:
90 qDrawShadeRect(p, opt->rect, opt->palette,
93 case PE_PanelButtonCommand:
94 case PE_PanelButtonBevel:
95 case PE_PanelButtonTool:
96 case PE_IndicatorButtonDropDown:
97 qDrawShadePanel(p, opt->rect, opt->palette,
98 opt->state & (State_Sunken | State_On), 1,
99 &opt->palette.brush(QPalette::Button));
101 case PE_IndicatorItemViewItemCheck:
102 proxy()->drawPrimitive(PE_IndicatorCheckBox, opt, p);
104 case PE_IndicatorCheckBox:
106 p->setPen(opt->palette.windowText().color());
107 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
108 p->drawRect(opt->rect);
109 p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight());
111 qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
112 opt->palette, opt->state & (State_Sunken | State_On), 1,
113 &opt->palette.brush(QPalette::Button));
116 case PE_IndicatorRadioButton: {
117 QRect ir = opt->rect;
118 p->setPen(opt->palette.dark().color());
119 p->drawArc(opt->rect, 0, 5760);
121 ir.adjust(2, 2, -2, -2);
122 p->setBrush(opt->palette.windowText());
126 case PE_FrameFocusRect:
128 QColor bg = fropt->backgroundColor;
129 QPen oldPen = p->pen();
132 bg.getHsv(&h, &s, &v);
134 p->setPen(Qt::black);
136 p->setPen(Qt::white);
138 p->setPen(opt->palette.windowText().color());
140 QRect focusRect = opt->rect.adjusted(1, 1, -1, -1);
141 p->drawRect(focusRect.adjusted(0, 0, -1, -1));
145 case PE_IndicatorMenuCheckMark: {
146 const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width();
147 const int markH = markW;
148 int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1;
149 int posY = opt->rect.y() + (opt->rect.height() - markH)/2;
157 for (i = 0; i < markW/2; ++i) {
158 a << QLineF(xx, yy, xx, yy + 2);
163 for (; i < markH; ++i) {
164 a << QLineF(xx, yy, xx, yy + 2);
171 p->setPen(opt->palette.light().color());
175 p->setPen((opt->state &
State_On) ? opt->palette.highlightedText().color() : opt->palette.text().color());
180 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
181 if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) {
182 qDrawShadePanel(p, frame->rect, frame->palette, frame->state &
State_Sunken,
185 qDrawPlainRect(p, frame->rect, frame->palette.windowText().color(), frame->lineWidth);
189 case PE_PanelMenuBar:
190 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)){
191 qDrawShadePanel(p, frame->rect, frame->palette,
false, frame->lineWidth,
192 &frame->palette.brush(QPalette::Button));
196 qDrawShadePanel(p, frame->rect, frame->palette,
false, frame->lineWidth,
197 &frame->palette.brush(QPalette::Button));
203 case PE_PanelToolBar:
205 case PE_IndicatorProgressChunk:
207 p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6,
208 opt->palette.brush(QPalette::Highlight));
211 case PE_IndicatorBranch: {
212 static const int decoration_size = 9;
213 int mid_h = opt->rect.x() + opt->rect.width() / 2;
214 int mid_v = opt->rect.y() + opt->rect.height() / 2;
220 int delta = decoration_size / 2;
225 p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
227 p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
228 QPen oldPen = p->pen();
229 p->setPen(opt->palette.dark().color());
230 p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
233 QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
235 if (opt->direction == Qt::RightToLeft)
236 p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
238 p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
241 p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
243 p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
245 case PE_FrameStatusBarItem:
246 qDrawShadeRect(p, opt->rect, opt->palette,
true, 1, 0,
nullptr);
248 case PE_IndicatorHeaderArrow:
250 QPen oldPen = p->pen();
252 p->setPen(QPen(opt->palette.light(), 0));
253 p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),
254 opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
255 p->setPen(QPen(opt->palette.dark(), 0));
257 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()),
258 QPoint(opt->rect.x(), opt->rect.y()),
259 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y()),
261 p->drawPolyline(points,
sizeof points /
sizeof *points);
263 p->setPen(QPen(opt->palette.light(), 0));
265 QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height()),
266 QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()),
267 QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y()),
269 p->drawPolyline(points,
sizeof points /
sizeof *points);
270 p->setPen(QPen(opt->palette.dark(), 0));
271 p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),
272 opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
277 case PE_FrameTabBarBase:
282 case QStyleOptionTab::RoundedNorth:
283 case QStyleOptionTab::TriangularNorth:
284 p->setPen(QPen(tbb->palette.light(), 0));
285 p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
287 case QStyleOptionTab::RoundedWest:
288 case QStyleOptionTab::TriangularWest:
289 p->setPen(QPen(tbb->palette.light(), 0));
290 p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
292 case QStyleOptionTab::RoundedSouth:
293 case QStyleOptionTab::TriangularSouth:
294 p->setPen(QPen(tbb->palette.shadow(), 0));
295 p->drawLine(tbb->rect.left(), tbb->rect.bottom(),
296 tbb->rect.right(), tbb->rect.bottom());
297 p->setPen(QPen(tbb->palette.dark(), 0));
298 p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1,
299 tbb->rect.right() - 1, tbb->rect.bottom() - 1);
301 case QStyleOptionTab::RoundedEast:
302 case QStyleOptionTab::TriangularEast:
303 p->setPen(QPen(tbb->palette.dark(), 0));
304 p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight());
310 case PE_IndicatorTabClose: {
311 if (d->tabBarcloseButtonIcon.isNull()) {
312 d->tabBarcloseButtonIcon.addPixmap(QPixmap(
313 QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-16.png")),
314 QIcon::Normal, QIcon::Off);
315 d->tabBarcloseButtonIcon.addPixmap(QPixmap(
316 QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-down-16.png")),
317 QIcon::Normal, QIcon::On);
318 d->tabBarcloseButtonIcon.addPixmap(QPixmap(
319 QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-closetab-hover-16.png")),
320 QIcon::Active, QIcon::Off);
323 int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize);
324 QIcon::Mode mode = opt->state & State_Enabled ?
325 (opt->state & State_Raised ? QIcon::Active : QIcon::Normal)
327 if (!(opt->state & State_Raised)
328 && !(opt->state & State_Sunken)
329 && !(opt->state & QStyle::State_Selected))
330 mode = QIcon::Disabled;
332 QIcon::State state = opt->state & State_Sunken ? QIcon::On : QIcon::Off;
333 QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(size, size), dpr(opt->window), mode, state);
334 proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap);
337 case PE_FrameTabWidget:
339 qDrawWinPanel(p, opt->rect, opt->palette,
false,
nullptr);
341 case PE_FrameLineEdit:
342 proxy()->drawPrimitive(PE_Frame, opt, p);
344 case PE_FrameGroupBox:
345 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
346 if (frame->features & QStyleOptionFrame::Flat) {
347 QRect fr = frame->rect;
348 QPoint p1(fr.x(), fr.y() + 1);
349 QPoint p2(fr.x() + fr.width(), p1.y());
350 qDrawShadeLine(p, p1, p2, frame->palette,
true,
351 frame->lineWidth, frame->midLineWidth);
353 qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(),
354 frame->rect.height(), frame->palette,
true,
355 frame->lineWidth, frame->midLineWidth);
359 case PE_FrameDockWidget:
360 if (
const QStyleOptionFrame *frame = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
361 int lw = frame->lineWidth;
363 lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth);
365 qDrawShadePanel(p, frame->rect, frame->palette,
false, lw);
368 case PE_IndicatorToolBarHandle:
370 p->translate(opt->rect.x(), opt->rect.y());
372 int x = opt->rect.width() / 3;
373 if (opt->direction == Qt::RightToLeft)
375 if (opt->rect.height() > 4) {
376 qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
377 opt->palette,
false, 1,
nullptr);
378 qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4,
379 opt->palette,
false, 1,
nullptr);
382 if (opt->rect.width() > 4) {
383 int y = opt->rect.height() / 3;
384 qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
385 opt->palette,
false, 1,
nullptr);
386 qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3,
387 opt->palette,
false, 1,
nullptr);
392 case PE_IndicatorToolBarSeparator:
396 p1 =
QPoint(opt->rect.width()/2, 0);
397 p2 =
QPoint(p1.x(), opt->rect.height());
399 p1 =
QPoint(0, opt->rect.height()/2);
400 p2 =
QPoint(opt->rect.width(), p1.y());
402 qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0);
405 case PE_IndicatorSpinPlus:
406 case PE_IndicatorSpinMinus: {
408 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt);
409 QRect br = r.adjusted(fw, fw, -fw, -fw);
412 int step = (br.width() + 4) / 5;
413 p->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
415 opt->palette.buttonText());
416 if (pe == PE_IndicatorSpinPlus)
417 p->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset,
419 opt->palette.buttonText());
422 case PE_IndicatorSpinUp:
423 case PE_IndicatorSpinDown: {
425 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt);
427 int x = r.x(), y = r.y(), w = r.width(), h = r.height();
436 int sx = x + w / 2 - sw / 2;
437 int sy = y + h / 2 - sh / 2;
439 if (pe == PE_IndicatorSpinUp && fw)
445 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
446 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
449 p->translate(sx + bsx, sy + bsy);
450 p->setPen(opt->palette.buttonText().color());
451 p->setBrush(opt->palette.buttonText());
452 if (pe == PE_IndicatorSpinDown) {
453 const QPoint points[] = { QPoint(0, 1), QPoint(sw-1, 1), QPoint(sh-2, sh-1) };
454 p->drawPolygon(points,
sizeof points /
sizeof *points);
456 const QPoint points[] = { QPoint(0, sh-1), QPoint(sw-1, sh-1), QPoint(sh-2, 1) };
457 p->drawPolygon(points,
sizeof points /
sizeof *points);
461 case PE_PanelTipLabel: {
462 const QBrush brush(opt->palette.toolTipBase());
463 qDrawPlainRect(p, opt->rect, opt->palette.toolTipText().color(), 1, &brush);
466 case PE_IndicatorTabTear:
467 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
468 bool rtl = tab->direction == Qt::RightToLeft;
469 const bool horizontal = tab->rect.height() > tab->rect.width();
470 const int margin = 4;
474 QRect rect = tab->rect.adjusted(rtl ? margin : 0, 0, rtl ? 1 : -margin, 0);
475 rect.setTop(rect.top() + ((tab->state &
State_Selected) ? 1 : 3));
476 rect.setBottom(rect.bottom() - ((tab->state &
State_Selected) ? 0 : 2));
478 path.moveTo(
QPoint(rtl ? rect.right() : rect.left(), rect.top()));
480 for (
int jags = 1; jags <= count; ++jags, rtl = !rtl)
481 path.lineTo(
QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
483 QRect rect = tab->rect.adjusted(0, 0, 0, -margin);
484 rect.setLeft(rect.left() + ((tab->state &
State_Selected) ? 1 : 3));
485 rect.setRight(rect.right() - ((tab->state &
State_Selected) ? 0 : 2));
487 path.moveTo(
QPoint(rect.left(), rect.top()));
489 for (
int jags = 1; jags <= count; ++jags, rtl = !rtl)
490 path.lineTo(
QPoint(rect.left() + jags * rect.width()/count, rtl ? rect.top() : rect.bottom()));
493 p->setPen(QPen(tab->palette.dark(), qreal(.8)));
494 p->setBrush(tab->palette.window());
495 p->setRenderHint(QPainter::Antialiasing);
499 case PE_PanelLineEdit:
500 if (
const QStyleOptionFrame *panel = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
501 p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth),
502 panel->palette.brush(QPalette::Base));
504 if (panel->lineWidth > 0)
505 proxy()->drawPrimitive(PE_FrameLineEdit, panel, p);
508#if QT_CONFIG(quick_itemview)
509 case PE_IndicatorColumnViewArrow: {
510 if (
const QStyleOptionViewItem *viewOpt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
511 bool reverse = (viewOpt->direction == Qt::RightToLeft);
514 int x = viewOpt->rect.x() + 1;
515 int offset = (viewOpt->rect.height() / 3);
516 int height = (viewOpt->rect.height()) - offset * 2;
519 int x2 = x + height - 1;
521 x = viewOpt->rect.x() + viewOpt->rect.width() - 1;
524 path.moveTo(x, viewOpt->rect.y() + offset);
525 path.lineTo(x, viewOpt->rect.y() + offset + height);
526 path.lineTo(x2, viewOpt->rect.y() + offset+height/2);
528 if (viewOpt->state & QStyle::State_Selected ) {
529 if (viewOpt->showDecorationSelected) {
530 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::HighlightedText);
534 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::WindowText);
540 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Mid);
547 if (!(viewOpt->state & QStyle::State_Selected)) {
549 lines.moveTo(x, viewOpt->rect.y() + offset);
550 lines.lineTo(x, viewOpt->rect.y() + offset + height);
551 lines.moveTo(x, viewOpt->rect.y() + offset);
552 lines.lineTo(x2, viewOpt->rect.y() + offset+height/2);
553 QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Dark);
560 case PE_IndicatorItemViewItemDrop: {
561 QRect rect = opt->rect;
562 if (opt->rect.height() == 0)
563 p->drawLine(rect.topLeft(), rect.topRight());
567 case PE_PanelItemViewRow:
568 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
569 QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
570 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
571 cg = QPalette::Inactive;
573 if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt))
574 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
575 else if (vopt->features & QStyleOptionViewItem::Alternate)
576 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
579 case PE_PanelItemViewItem:
580 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
581 QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
582 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
583 cg = QPalette::Inactive;
585 if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) {
586 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight));
588 if (vopt->backgroundBrush.style() != Qt::NoBrush) {
589 QPointF oldBO = p->brushOrigin();
590 p->setBrushOrigin(vopt->rect.topLeft());
591 p->fillRect(vopt->rect, vopt->backgroundBrush);
592 p->setBrushOrigin(oldBO);
595 if (vopt->state & QStyle::State_Selected) {
596 QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, opt);
597 p->fillRect(textRect, vopt->palette.brush(cg, QPalette::Highlight));
603 case PE_PanelScrollAreaCorner: {
604 const QBrush brush(opt->palette.brush(QPalette::Window));
605 p->fillRect(opt->rect, brush);
607 case PE_IndicatorArrowUp:
608 case PE_IndicatorArrowDown:
609 case PE_IndicatorArrowRight:
610 case PE_IndicatorArrowLeft:
612 if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
615 int size = qMin(r.height(), r.width());
617 QString pixmapName = QStyleHelper::uniqueName(QLatin1String(
"$qt_ia-")
618 % QLatin1String(metaObject()->className()), opt, QSize(size, size))
619 % HexString<uint>(pe);
620 if (!QPixmapCache::find(pixmapName, &pixmap)) {
621 qreal pixelRatio = p->device()->devicePixelRatioF();
622 int border = qRound(pixelRatio*(size/5));
623 int sqsize = qRound(pixelRatio*(2*(size/2)));
624 QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
626 QPainter imagePainter(&image);
630 case PE_IndicatorArrowUp:
631 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
633 case PE_IndicatorArrowDown:
634 a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
636 case PE_IndicatorArrowRight:
637 a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
639 case PE_IndicatorArrowLeft:
640 a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
650 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
651 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
654 QRect bounds = a.boundingRect();
655 int sx = sqsize / 2 - bounds.center().x() - 1;
656 int sy = sqsize / 2 - bounds.center().y() - 1;
657 imagePainter.translate(sx + bsx, sy + bsy);
658 imagePainter.setPen(opt->palette.buttonText().color());
659 imagePainter.setBrush(opt->palette.buttonText());
662 imagePainter.translate(1, 1);
663 imagePainter.setBrush(opt->palette.light());
664 imagePainter.setPen(opt->palette.light().color());
665 imagePainter.drawPolygon(a);
666 imagePainter.translate(-1, -1);
667 imagePainter.setBrush(opt->palette.mid());
668 imagePainter.setPen(opt->palette.mid().color());
671 imagePainter.drawPolygon(a);
673 pixmap = QPixmap::fromImage(std::move(image));
674 pixmap.setDevicePixelRatio(pixelRatio);
675 QPixmapCache::insert(pixmapName, pixmap);
677 int xOffset = r.x() + (r.width() - size)/2;
678 int yOffset = r.y() + (r.height() - size)/2;
679 p->drawPixmap(xOffset, yOffset, pixmap);
1130 Q_D(
const QCommonStyle);
1135 Q_ASSERT(opt->window);
1141 proxy()->drawControl(CE_PushButtonBevel, btn, p);
1143 subopt.rect = subElementRect(SE_PushButtonContents, btn);
1144 proxy()->drawControl(CE_PushButtonLabel, &subopt, p);
1147 case CE_PushButtonBevel:
1149 QRect br = btn->rect;
1150 int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn);
1151 if (btn->features & QStyleOptionButton::DefaultButton)
1152 proxy()->drawPrimitive(PE_FrameDefaultButton, opt, p);
1154 br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
1160 proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p);
1163 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn);
1164 QRect ir = btn->rect;
1166 newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6);
1167 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p);
1172 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn);
1173 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1177 case CE_PushButtonLabel:
1179 QRect textRect = button->rect;
1180 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
1181 if (!proxy()->styleHint(SH_UnderlineShortcut, button))
1182 tf |= Qt::TextHideMnemonic;
1184 if (!button->icon.isNull()) {
1186 QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
1187 if (mode == QIcon::Normal && button->state & State_HasFocus)
1188 mode = QIcon::Active;
1189 QIcon::State state = QIcon::Off;
1190 if (button->state & State_On)
1193 QPixmap pixmap = button->icon.pixmap(button->iconSize, dpr(opt->window), mode, state);
1194 int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
1195 int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
1196 int labelWidth = pixmapWidth;
1197 int labelHeight = pixmapHeight;
1198 int iconSpacing = 4;
1199 if (!button->text.isEmpty()) {
1200 int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
1201 labelWidth += (textWidth + iconSpacing);
1204 QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
1205 textRect.y() + (textRect.height() - labelHeight) / 2,
1206 pixmapWidth, pixmapHeight);
1208 iconRect = visualRect(button->direction, textRect, iconRect);
1210 if (button->direction == Qt::RightToLeft) {
1211 tf |= Qt::AlignRight;
1212 textRect.setRight(iconRect.left() - iconSpacing);
1214 tf |= Qt::AlignLeft;
1215 textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
1218 if (button->state & (State_On | State_Sunken))
1219 iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt),
1220 proxy()->pixelMetric(PM_ButtonShiftVertical, opt));
1221 p->drawPixmap(iconRect, pixmap);
1223 tf |= Qt::AlignHCenter;
1225 if (button->state & (State_On | State_Sunken))
1226 textRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt),
1227 proxy()->pixelMetric(PM_ButtonShiftVertical, opt));
1230 int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button);
1231 if (button->direction == Qt::LeftToRight)
1232 textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
1234 textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
1236 proxy()->drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled),
1237 button->text, QPalette::ButtonText);
1240 case CE_RadioButton:
1243 bool isRadio = (element == CE_RadioButton);
1245 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
1246 : SE_CheckBoxIndicator, btn);
1247 proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
1249 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
1250 : SE_CheckBoxContents, btn);
1251 proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p);
1255 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
1256 : SE_CheckBoxFocusRect, btn);
1257 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
1261 case CE_RadioButtonLabel:
1262 case CE_CheckBoxLabel:
1264 uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter);
1266 if (!proxy()->styleHint(SH_UnderlineShortcut, btn))
1267 alignment |= Qt::TextHideMnemonic;
1269 QRect textRect = btn->rect;
1270 if (!btn->icon.isNull()) {
1271 pix = btn->icon.pixmap(btn->iconSize, dpr(opt->window), btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
1272 proxy()->drawItemPixmap(p, btn->rect, alignment, pix);
1273 if (btn->direction == Qt::RightToLeft)
1274 textRect.setRight(textRect.right() - btn->iconSize.width() - 4);
1276 textRect.setLeft(textRect.left() + btn->iconSize.width() + 4);
1278 if (!btn->text.isEmpty()){
1279 proxy()->drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,
1280 btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
1284 case CE_MenuScroller: {
1287 proxy()->drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), &arrowOpt, p);
1289 case CE_MenuTearoff:
1290 if (opt->state & State_Selected)
1291 p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight));
1293 p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1294 p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
1295 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1,
1296 opt->rect.x() + opt->rect.width() - 4,
1297 opt->rect.y() + opt->rect.height() / 2 - 1);
1298 p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
1299 p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2,
1300 opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
1302 case CE_MenuBarItem:
1304 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip
1305 | Qt::TextSingleLine;
1306 if (!proxy()->styleHint(SH_UnderlineShortcut, mbi))
1307 alignment |= Qt::TextHideMnemonic;
1308 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
1309 QPixmap pix = mbi->icon.pixmap(QSize(iconExtent, iconExtent), dpr(opt->window),
1310 mbi->state.testFlag(State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1312 proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
1314 proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
1315 mbi->text, QPalette::ButtonText);
1318 case CE_MenuBarEmptyArea:
1320 case CE_ProgressBar:
1324 subopt.rect = subElementRect(SE_ProgressBarGroove, pb);
1325 proxy()->drawControl(CE_ProgressBarGroove, &subopt, p);
1326 subopt.rect = subElementRect(SE_ProgressBarContents, pb);
1327 proxy()->drawControl(CE_ProgressBarContents, &subopt, p);
1329 subopt.rect = subElementRect(SE_ProgressBarLabel, pb);
1330 proxy()->drawControl(CE_ProgressBarLabel, &subopt, p);
1334 case CE_ProgressBarGroove:
1335 if (opt->rect.isValid())
1336 qDrawShadePanel(p, opt->rect, opt->palette,
true, 1,
1337 &opt->palette.brush(QPalette::Window));
1339 case CE_ProgressBarLabel:
1341 QPalette::ColorRole textRole = QPalette::NoRole;
1342 if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible
1343 && ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) {
1344 textRole = QPalette::HighlightedText;
1346 QRect shadowRect(pb->rect);
1347 shadowRect.translate(1,1);
1348 QColor shadowColor = (pb->palette.color(textRole).value() <= 128)
1349 ? QColor(255,255,255,160) : QColor(0,0,0,160);
1350 QPalette shadowPalette = pb->palette;
1351 shadowPalette.setColor(textRole, shadowColor);
1352 proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette,
1353 pb->state & State_Enabled, pb->text, textRole);
1355 proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette,
1356 pb->state & State_Enabled, pb->text, textRole);
1359 case CE_ProgressBarContents:
1362 QRect rect = pb->rect;
1368 QPalette pal2 = pb->palette;
1370 if (pal2.highlight() == pal2.window())
1371 pal2.setBrush(QPalette::Highlight, pb->palette.brush(QPalette::Active,
1372 QPalette::Highlight));
1373 bool reverse = pb->direction == Qt::RightToLeft;
1376 int w = rect.width();
1379 int x = (progress - minimum) % (w * 2);
1382 x = reverse ? rect.right() - x : x + rect.x();
1383 p->setPen(QPen(pal2.highlight().color(), 4));
1384 p->drawLine(x, rect.y(), x, rect.height());
1386 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb);
1392 u = ((rect.width() + unit_width) / unit_width);
1395 qint64 p_v = progress - minimum;
1396 qint64 t_s = (maximum - minimum) ? (maximum - minimum) : qint64(1);
1398 if (u > 0 && p_v >= INT_MAX / u && t_s >= u) {
1406 tnu = nu = p_v * u / t_s;
1408 if (nu * unit_width > w)
1416 int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0)
1421 pbBits.palette = pal2;
1422 int myY = pbBits.rect.y();
1423 int myHeight = pbBits.rect.height();
1425 for (
int i = 0; i < nu; ++i) {
1426 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight);
1427 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1428 x += reverse ? -unit_width : unit_width;
1434 int pixels_left = w - (nu * unit_width);
1435 int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x;
1436 pbBits.rect.setRect(offset, myY, pixels_left, myHeight);
1437 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p);
1442 case CE_HeaderLabel:
1444 QRect rect = header->rect;
1445 if (!header->icon.isNull()) {
1446 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
1448 = header->icon.pixmap(QSize(iconExtent, iconExtent), dpr(opt->window),
1449 header->state.testFlag(State_Enabled) ? QIcon::Normal : QIcon::Disabled);
1450 int pixw = pixmap.width() / pixmap.devicePixelRatio();
1452 QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect);
1453 QRect inter = aligned.intersected(rect);
1454 p->drawPixmap(inter.x(), inter.y(), pixmap,
1455 inter.x() - aligned.x(), inter.y() - aligned.y(),
1456 aligned.width() * pixmap.devicePixelRatio(),
1457 pixmap.height() * pixmap.devicePixelRatio());
1459 const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt);
1460 if (header->direction == Qt::LeftToRight)
1461 rect.setLeft(rect.left() + pixw + margin);
1463 rect.setRight(rect.right() - pixw - margin);
1466 QFont fnt = p->font();
1470 proxy()->drawItemText(p, rect, header->textAlignment, header->palette,
1471 (header->state & State_Enabled), header->text, QPalette::ButtonText);
1474 case CE_ToolButtonLabel:
1477 QRect rect = toolbutton->rect;
1481 shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton);
1482 shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton);
1486 if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty())
1487 || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) {
1488 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
1489 if (!proxy()->styleHint(SH_UnderlineShortcut, opt))
1490 alignment |= Qt::TextHideMnemonic;
1491 rect.translate(shiftX, shiftY);
1492 p->setFont(toolbutton->font);
1493 proxy()->drawItemText(p, rect, alignment, toolbutton->palette,
1494 opt->state & State_Enabled, toolbutton->text,
1495 QPalette::ButtonText);
1498 QSize pmSize = toolbutton->iconSize;
1499 if (!toolbutton->icon.isNull()) {
1500 QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off;
1502 if (!(toolbutton->state & State_Enabled))
1503 mode = QIcon::Disabled;
1504 else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise))
1505 mode = QIcon::Active;
1507 mode = QIcon::Normal;
1508 pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize),
1509 dpr(opt->window), mode, state);
1510 pmSize = pm.size() / pm.devicePixelRatio();
1513 if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) {
1514 p->setFont(toolbutton->font);
1517 int alignment = Qt::TextShowMnemonic;
1518 if (!proxy()->styleHint(SH_UnderlineShortcut, opt))
1519 alignment |= Qt::TextHideMnemonic;
1521 if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
1522 pr.setHeight(pmSize.height() + 4);
1523 tr.adjust(0, pr.height() - 1, 0, -1);
1524 pr.translate(shiftX, shiftY);
1526 proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm);
1528 drawArrow(
proxy(), toolbutton, pr, p);
1530 alignment |= Qt::AlignCenter;
1532 pr.setWidth(pmSize.width() + 4);
1533 tr.adjust(pr.width(), 0, 0, 0);
1534 pr.translate(shiftX, shiftY);
1536 proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm);
1538 drawArrow(
proxy(), toolbutton, pr, p);
1540 alignment |= Qt::AlignLeft | Qt::AlignVCenter;
1542 tr.translate(shiftX, shiftY);
1543 const QString text = d->toolButtonElideText(toolbutton, tr, alignment);
1544 proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette,
1545 toolbutton->state & State_Enabled, text,
1546 QPalette::ButtonText);
1548 rect.translate(shiftX, shiftY);
1550 drawArrow(
proxy(), toolbutton, rect, p);
1552 proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm);
1559 if (
const QStyleOptionToolBox *tb = qstyleoption_cast<
const QStyleOptionToolBox *>(opt)) {
1560 proxy()->drawControl(CE_ToolBoxTabShape, tb, p);
1561 proxy()->drawControl(CE_ToolBoxTabLabel, tb, p);
1564 case CE_ToolBoxTabShape:
1565 if (
const QStyleOptionToolBox *tb = qstyleoption_cast<
const QStyleOptionToolBox *>(opt)) {
1566 p->setPen(tb->palette.mid().color().darker(150));
1567 int d = 20 + tb->rect.height() - 3;
1568 if (tb->direction != Qt::RightToLeft) {
1569 const QPoint points[] = {
1570 QPoint(-1, tb->rect.height() + 1),
1572 QPoint(tb->rect.width() - d, 1),
1573 QPoint(tb->rect.width() - 20, tb->rect.height() - 2),
1574 QPoint(tb->rect.width() - 1, tb->rect.height() - 2),
1575 QPoint(tb->rect.width() - 1, tb->rect.height() + 1),
1576 QPoint(-1, tb->rect.height() + 1),
1578 p->drawPolygon(points,
sizeof points /
sizeof *points);
1580 const QPoint points[] = {
1581 QPoint(tb->rect.width(), tb->rect.height() + 1),
1582 QPoint(tb->rect.width(), 1),
1584 QPoint(20 - 1, tb->rect.height() - 2),
1585 QPoint(0, tb->rect.height() - 2),
1586 QPoint(0, tb->rect.height() + 1),
1587 QPoint(tb->rect.width(), tb->rect.height() + 1),
1589 p->drawPolygon(points,
sizeof points /
sizeof *points);
1591 p->setPen(tb->palette.light().color());
1592 if (tb->direction != Qt::RightToLeft) {
1593 p->drawLine(0, 2, tb->rect.width() - d, 2);
1594 p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1);
1595 p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1,
1596 tb->rect.width(), tb->rect.height() - 1);
1598 p->drawLine(tb->rect.width() - 1, 2, d - 1, 2);
1599 p->drawLine(d, 2, 20, tb->rect.height() - 1);
1600 p->drawLine(19, tb->rect.height() - 1,
1601 -1, tb->rect.height() - 1);
1603 p->setBrush(Qt::NoBrush);
1607 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1608 proxy()->drawControl(CE_TabBarTabShape, tab, p);
1609 proxy()->drawControl(CE_TabBarTabLabel, tab, p);
1612 case CE_TabBarTabShape:
1613 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1616 QRect rect(tab->rect);
1618 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
1619 int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt);
1622 switch (tab->shape) {
1623 case QStyleOptionTab::TriangularNorth:
1624 rect.adjust(0, 0, 0, -tabOverlap);
1626 rect.adjust(1, 1, -1, 0);
1628 case QStyleOptionTab::TriangularSouth:
1629 rect.adjust(0, tabOverlap, 0, 0);
1631 rect.adjust(1, 0, -1, -1);
1633 case QStyleOptionTab::TriangularEast:
1634 rect.adjust(tabOverlap, 0, 0, 0);
1636 rect.adjust(0, 1, -1, -1);
1638 case QStyleOptionTab::TriangularWest:
1639 rect.adjust(0, 0, -tabOverlap, 0);
1641 rect.adjust(1, 1, 0, -1);
1648 p->setPen(QPen(tab->palette.windowText(), 0));
1650 p->setBrush(tab->palette.base());
1652 p->setBrush(tab->palette.window());
1658 switch (tab->shape) {
1659 case QStyleOptionTab::TriangularNorth:
1660 case QStyleOptionTab::TriangularSouth: {
1661 a.setPoint(0, 0, -1);
1662 a.setPoint(1, 0, 0);
1663 y = rect.height() - 2;
1665 a.setPoint(2, x++, y - 1);
1667 a.setPoint(3, x++, y++);
1668 a.setPoint(4, x, y);
1671 int right = rect.width() - 1;
1672 for (i = 0; i < 5; ++i)
1673 a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y());
1674 if (tab->shape == QStyleOptionTab::TriangularNorth)
1675 for (i = 0; i < 10; ++i)
1676 a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y());
1678 a.translate(rect.left(), rect.top());
1679 p->setRenderHint(QPainter::Antialiasing);
1680 p->translate(0, 0.5);
1686 case QStyleOptionTab::TriangularEast:
1687 case QStyleOptionTab::TriangularWest: {
1688 a.setPoint(0, -1, 0);
1689 a.setPoint(1, 0, 0);
1690 x = rect.width() - 2;
1692 a.setPoint(2, x - 1, y++);
1694 a.setPoint(3, x++, y++);
1695 a.setPoint(4, x, y);
1697 int bottom = rect.height() - 1;
1698 for (i = 0; i < 5; ++i)
1699 a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y());
1700 if (tab->shape == QStyleOptionTab::TriangularWest)
1701 for (i = 0; i < 10; ++i)
1702 a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y());
1703 a.translate(rect.left(), rect.top());
1704 p->setRenderHint(QPainter::Antialiasing);
1705 p->translate(0.5, 0);
1716 case CE_ToolBoxTabLabel:
1717 if (
const QStyleOptionToolBox *tb = qstyleoption_cast<
const QStyleOptionToolBox *>(opt)) {
1720 int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb);
1721 QPixmap pm = tb->icon.pixmap(QSize(iconExtent, iconExtent), dpr(opt->window),
1722 enabled ? QIcon::Normal : QIcon::Disabled);
1724 QRect cr = subElementRect(QStyle::SE_ToolBoxTabContents, tb);
1729 tr.adjust(4, 0, -8, 0);
1731 int iw = pm.width() / pm.devicePixelRatio() + 4;
1732 ih = pm.height()/ pm.devicePixelRatio();
1733 ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih);
1734 tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height());
1737 if (selected && proxy()->styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb)) {
1743 QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width());
1746 p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm);
1748 int alignment = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic;
1749 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, tb))
1750 alignment |= Qt::TextHideMnemonic;
1751 proxy()->drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText);
1756 opt.palette = tb->palette;
1758 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p);
1762 case CE_TabBarTabLabel:
1763 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
1764 QRect tr = tab->rect;
1765 bool verticalTabs = tab->shape == QStyleOptionTab::RoundedEast
1766 || tab->shape == QStyleOptionTab::RoundedWest
1767 || tab->shape == QStyleOptionTab::TriangularEast
1768 || tab->shape == QStyleOptionTab::TriangularWest;
1770 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic;
1771 if (!proxy()->styleHint(SH_UnderlineShortcut, opt))
1772 alignment |= Qt::TextHideMnemonic;
1776 int newX, newY, newRot;
1777 if (tab->shape == QStyleOptionTab::RoundedEast || tab->shape == QStyleOptionTab::TriangularEast) {
1778 newX = tr.width() + tr.x();
1783 newY = tr.y() + tr.height();
1786 QTransform m = QTransform::fromTranslate(newX, newY);
1788 p->setTransform(m,
true);
1791 d->tabLayout(tab, &tr, &iconRect);
1792 tr = proxy()->subElementRect(SE_TabBarTabText, opt);
1794 if (!tab->icon.isNull()) {
1795 QPixmap tabIcon = tab->icon.pixmap(tab->iconSize, dpr(opt->window),
1796 (tab->state & State_Enabled) ? QIcon::Normal
1798 (tab->state & State_Selected) ? QIcon::On
1800 p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
1803 proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText);
1808 const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
1811 x1 = tab->rect.left();
1812 x2 = tab->rect.right() - 1;
1816 fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET,
1817 x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET);
1818 drawPrimitive(PE_FrameFocusRect, &fropt, p);
1825 opt->rect.getRect(&x, &y, &w, &h);
1827 int sw = qMin(h, w);
1829 p->translate(0, h - w);
1831 p->translate(w - h, 0);
1839 corner = sgOpt->corner;
1840 else if (opt->direction == Qt::RightToLeft)
1841 corner = Qt::BottomLeftCorner;
1843 corner = Qt::BottomRightCorner;
1845 if (corner == Qt::BottomLeftCorner) {
1847 for (
int i = 0; i < 4; ++i) {
1848 p->setPen(QPen(opt->palette.light().color(), 1));
1849 p->drawLine(x, sy - 1 , sx + 1, sw);
1850 p->setPen(QPen(opt->palette.dark().color(), 1));
1851 p->drawLine(x, sy, sx, sw);
1852 p->setPen(QPen(opt->palette.dark().color(), 1));
1853 p->drawLine(x, sy + 1, sx - 1, sw);
1857 }
else if (corner == Qt::BottomRightCorner) {
1858 for (
int i = 0; i < 4; ++i) {
1859 p->setPen(QPen(opt->palette.light().color(), 1));
1860 p->drawLine(sx - 1, sw, sw, sy - 1);
1861 p->setPen(QPen(opt->palette.dark().color(), 1));
1862 p->drawLine(sx, sw, sw, sy);
1863 p->setPen(QPen(opt->palette.dark().color(), 1));
1864 p->drawLine(sx + 1, sw, sw, sy + 1);
1868 }
else if (corner == Qt::TopRightCorner) {
1870 for (
int i = 0; i < 4; ++i) {
1871 p->setPen(QPen(opt->palette.light().color(), 1));
1872 p->drawLine(sx - 1, y, sw, sy + 1);
1873 p->setPen(QPen(opt->palette.dark().color(), 1));
1874 p->drawLine(sx, y, sw, sy);
1875 p->setPen(QPen(opt->palette.dark().color(), 1));
1876 p->drawLine(sx + 1, y, sw, sy - 1);
1880 }
else if (corner == Qt::TopLeftCorner) {
1881 for (
int i = 0; i < 4; ++i) {
1882 p->setPen(QPen(opt->palette.light().color(), 1));
1883 p->drawLine(x, sy - 1, sx - 1, y);
1884 p->setPen(QPen(opt->palette.dark().color(), 1));
1885 p->drawLine(x, sy, sx, y);
1886 p->setPen(QPen(opt->palette.dark().color(), 1));
1887 p->drawLine(x, sy + 1, sx + 1, y);
1894 case CE_RubberBand: {
1896 QPixmap tiledPixmap(16, 16);
1897 QPainter pixmapPainter(&tiledPixmap);
1898 pixmapPainter.setPen(Qt::NoPen);
1899 pixmapPainter.setBrush(Qt::Dense4Pattern);
1900 pixmapPainter.setBackground(QBrush(opt->palette.base()));
1901 pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
1902 pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
1903 pixmapPainter.end();
1905 tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
1908 QRect r = opt->rect;
1910 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, &mask))
1911 p->setClipRegion(mask.region);
1912 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1913 p->setPen(opt->palette.color(QPalette::Active, QPalette::WindowText));
1914 p->setBrush(Qt::NoBrush);
1915 p->drawRect(r.adjusted(0, 0, -1, -1));
1917 p->drawRect(r.adjusted(3, 3, -4, -4));
1921 case CE_DockWidgetTitle:
1922 if (
const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<
const QStyleOptionDockWidget *>(opt)) {
1923 QRect r = dwOpt->rect.adjusted(0, 0, -1, -1);
1924 if (dwOpt->movable) {
1925 p->setPen(dwOpt->palette.color(QPalette::Dark));
1929 if (!dwOpt->title.isEmpty()) {
1930 const bool verticalTitleBar = dwOpt->verticalTitleBar;
1932 if (verticalTitleBar) {
1936 p->translate(r.left(), r.top() + r.width());
1938 p->translate(-r.left(), -r.top());
1941 const int indent = p->fontMetrics().descent();
1942 proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),
1943 Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
1944 dwOpt->state & State_Enabled, dwOpt->title,
1945 QPalette::WindowText);
1947 if (verticalTitleBar)
1954 QRegion clipRegion = p->clipRegion();
1955 p->setClipRect(opt->rect);
1956 proxy()->drawControl(CE_HeaderSection, header, p);
1958 subopt.rect = subElementRect(SE_HeaderLabel, header);
1959 if (subopt.rect.isValid())
1960 proxy()->drawControl(CE_HeaderLabel, &subopt, p);
1962 subopt.rect = subElementRect(SE_HeaderArrow, opt);
1963 proxy()->drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p);
1965 p->setClipRegion(clipRegion);
1969 p->fillRect(opt->rect, opt->palette.windowText());
1971 case CE_HeaderSection:
1972 qDrawShadePanel(p, opt->rect, opt->palette,
1973 opt->state & State_Sunken, 1,
1974 &opt->palette.brush(QPalette::Button));
1976 case CE_HeaderEmptyArea:
1977 p->fillRect(opt->rect, opt->palette.window());
1979 case CE_ComboBoxLabel:
1981 QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField);
1983 p->setClipRect(editRect);
1984 if (!cb->currentIcon.isNull()) {
1985 QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
1987 QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, dpr(opt->window), mode);
1988 QRect iconRect(editRect);
1989 iconRect.setWidth(cb->iconSize.width() + 4);
1990 iconRect = alignedRect(cb->direction,
1991 Qt::AlignLeft | Qt::AlignVCenter,
1992 iconRect.size(), editRect);
1994 p->fillRect(iconRect, opt->palette.brush(QPalette::Base));
1995 proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
1997 if (cb->direction == Qt::RightToLeft)
1998 editRect.translate(-4 - cb->iconSize.width(), 0);
2000 editRect.translate(cb->iconSize.width() + 4, 0);
2002 if (!cb->currentText.isEmpty() && !cb
->editable) {
2003 proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0),
2004 visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
2005 cb->palette, cb->state & State_Enabled, cb->currentText);
2013 QStyleOptionFrame frame;
2014 frame.QStyleOption::operator=(*toolBar);
2017 proxy()->drawPrimitive(PE_PanelToolBar, opt, p);
2019 qDrawShadePanel(p, toolBar->rect, toolBar->palette,
false, toolBar->lineWidth,
2020 &toolBar->palette.brush(QPalette::Button));
2023 case CE_ColumnViewGrip: {
2025 QLinearGradient g(0, 0, opt->rect.width(), 0);
2026 g.setColorAt(0, opt->palette.color(QPalette::Active, QPalette::Mid));
2027 g.setColorAt(0.5, Qt::white);
2028 p->fillRect(QRect(0, 0, opt->rect.width(), opt->rect.height()), g);
2032 pen.setWidth(opt->rect.width()/20);
2033 pen.setColor(opt->palette.color(QPalette::Active, QPalette::Dark));
2036 int line1starting = opt->rect.width()*8 / 20;
2037 int line2starting = opt->rect.width()*13 / 20;
2038 int top = opt->rect.height()*20/75;
2039 int bottom = opt->rect.height() - 1 - top;
2040 p->drawLine(line1starting, top, line1starting, bottom);
2041 p->drawLine(line2starting, top, line2starting, bottom);
2044#if QT_CONFIG(quick_itemview)
2045 case CE_ItemViewItem:
2046 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
2048 p->setClipRect(opt->rect);
2050 QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt);
2051 QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt);
2052 QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt);
2055 proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p);
2058 if (vopt->features & QStyleOptionViewItem::HasCheckIndicator) {
2059 QStyleOptionViewItem option(*vopt);
2060 option.rect = checkRect;
2061 option.state = option.state & ~QStyle::State_HasFocus;
2063 switch (vopt->checkState) {
2065 option.state |= QStyle::State_Off;
2067 case Qt::PartiallyChecked:
2068 option.state |= QStyle::State_NoChange;
2071 option.state |= QStyle::State_On;
2074 proxy()->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &option, p);
2078 QIcon::Mode mode = QIcon::Normal;
2079 if (!(vopt->state & QStyle::State_Enabled))
2080 mode = QIcon::Disabled;
2081 else if (vopt->state & QStyle::State_Selected)
2082 mode = QIcon::Selected;
2083 QIcon::State state = vopt->state & QStyle::State_Open ? QIcon::On : QIcon::Off;
2084 vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state);
2087 if (!vopt->text.isEmpty()) {
2088 QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
2089 ? QPalette::Normal : QPalette::Disabled;
2090 if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
2091 cg = QPalette::Inactive;
2093 if (vopt->state & QStyle::State_Selected) {
2094 p->setPen(vopt->palette.color(cg, QPalette::HighlightedText));
2096 p->setPen(vopt->palette.color(cg, QPalette::Text));
2098 if (vopt->state & QStyle::State_Editing) {
2099 p->setPen(vopt->palette.color(cg, QPalette::Text));
2100 p->drawRect(textRect.adjusted(0, 0, -1, -1));
2103 d->viewItemDrawText(p, vopt, textRect);
2107 if (vopt->state & QStyle::State_HasFocus) {
2108 QStyleOptionFocusRect o;
2109 o.QStyleOption::operator=(*vopt);
2110 o.rect = proxy()->subElementRect(SE_ItemViewItemFocusRect, vopt);
2111 o.state |= QStyle::State_KeyboardFocusChange;
2112 o.state |= QStyle::State_Item;
2113 QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled)
2114 ? QPalette::Normal : QPalette::Disabled;
2115 o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected)
2116 ? QPalette::Highlight : QPalette::Window);
2117 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, p);
2124 case CE_ShapedFrame:
2125 if (
const QStyleOptionFrame *f = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
2126 int frameShape = f->frameShape;
2127 int frameShadow = QStyleOptionFrame::Plain;
2129 frameShadow = QStyleOptionFrame::Sunken;
2131 frameShadow = QStyleOptionFrame::Raised;
2134 int lw = f->lineWidth;
2135 int mlw = f->midLineWidth;
2136 QPalette::ColorRole foregroundRole = QPalette::WindowText;
2138 switch (frameShape) {
2139 case QStyleOptionFrame::Box:
2140 if (frameShadow == QStyleOptionFrame::Plain) {
2141 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2143 qDrawShadeRect(p, f->rect, f->palette, frameShadow == QStyleOptionFrame::Sunken, lw, mlw);
2146 case QStyleOptionFrame::StyledPanel:
2147 proxy()->drawPrimitive(QStyle::PE_Frame, opt, p);
2149 case QStyleOptionFrame::Panel:
2150 if (frameShadow == QStyleOptionFrame::Plain) {
2151 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2153 qDrawShadePanel(p, f->rect, f->palette, frameShadow == QStyleOptionFrame::Sunken, lw);
2156 case QStyleOptionFrame::WinPanel:
2157 if (frameShadow == QStyleOptionFrame::Plain) {
2158 qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw);
2160 qDrawWinPanel(p, f->rect, f->palette, frameShadow == QStyleOptionFrame::Sunken);
2163 case QStyleOptionFrame::HLine:
2164 case QStyleOptionFrame::VLine: {
2166 if (frameShape == QStyleOptionFrame::HLine) {
2167 p1 =
QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height() / 2);
2168 p2 =
QPoint(opt->rect.x() + opt->rect.width(), p1.y());
2170 p1 =
QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
2171 p2 =
QPoint(p1.x(), p1.y() + opt->rect.height());
2173 if (frameShadow == QStyleOptionFrame::Plain) {
2174 QPen oldPen = p->pen();
2175 p->setPen(QPen(opt->palette.brush(foregroundRole), lw));
2176 p->drawLine(p1, p2);
2179 qDrawShadeLine(p, p1, p2, f->palette, frameShadow == QStyleOptionFrame::Sunken, lw, mlw);
2193 Q_D(
const QCommonStyle);
2196 case SE_PushButtonContents:
2199 dx1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn);
2200 if (btn->features & QStyleOptionButton::AutoDefaultButton)
2201 dx1 += proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn);
2203 r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2,
2204 opt->rect.height() - dx2);
2205 r = visualRect(opt->direction, opt->rect, r);
2208 case SE_PushButtonFocusRect:
2210 int dbw1 = 0, dbw2 = 0;
2212 dbw1 = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn);
2216 int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn) + 1,
2219 r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1,
2220 btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2);
2221 r = visualRect(opt->direction, opt->rect, r);
2224 case SE_CheckBoxIndicator:
2226 int h = proxy()->pixelMetric(PM_IndicatorHeight, opt);
2227 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2228 proxy()->pixelMetric(PM_IndicatorWidth, opt), h);
2229 r = visualRect(opt->direction, opt->rect, r);
2233 case SE_CheckBoxContents:
2236 QRect ir = visualRect(opt->direction, opt->rect,
2237 subElementRect(SE_CheckBoxIndicator, opt));
2238 int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt);
2239 r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2240 opt->rect.height());
2241 r = visualRect(opt->direction, opt->rect, r);
2245 case SE_CheckBoxFocusRect:
2247 if (btn->icon.isNull() && btn->text.isEmpty()) {
2248 r = subElementRect(SE_CheckBoxIndicator, opt);
2249 r.adjust(1, 1, -1, -1);
2253 QRect cr = visualRect(btn->direction, btn->rect, subElementRect(SE_CheckBoxContents, btn));
2255 QRect iconRect, textRect;
2256 if (!btn->text.isEmpty()) {
2257 textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft
2258 | Qt::AlignVCenter | Qt::TextShowMnemonic,
2259 btn->state & State_Enabled, btn->text);
2261 if (!btn->icon.isNull()) {
2262 iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter
2263 | Qt::TextShowMnemonic,
2264 btn->icon.pixmap(btn->iconSize, dpr(opt->window), QIcon::Normal));
2265 if (!textRect.isEmpty())
2266 textRect.translate(iconRect.right() + 4, 0);
2268 r = iconRect | textRect;
2269 r.adjust(-3, -2, 3, 2);
2270 r = r.intersected(btn->rect);
2271 r = visualRect(btn->direction, btn->rect, r);
2275 case SE_RadioButtonIndicator:
2277 int h = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight, opt);
2278 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2),
2279 proxy()->pixelMetric(PM_ExclusiveIndicatorWidth, opt), h);
2280 r = visualRect(opt->direction, opt->rect, r);
2284 case SE_RadioButtonContents:
2286 QRect ir = visualRect(opt->direction, opt->rect,
2287 subElementRect(SE_RadioButtonIndicator, opt));
2288 int spacing = proxy()->pixelMetric(PM_RadioButtonLabelSpacing, opt);
2289 r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing,
2290 opt->rect.height());
2291 r = visualRect(opt->direction, opt->rect, r);
2295 case SE_RadioButtonFocusRect:
2297 if (btn->icon.isNull() && btn->text.isEmpty()) {
2298 r = subElementRect(SE_RadioButtonIndicator, opt);
2299 r.adjust(1, 1, -1, -1);
2302 QRect cr = visualRect(btn->direction, btn->rect, subElementRect(SE_RadioButtonContents, opt));
2304 QRect iconRect, textRect;
2305 if (!btn->text.isEmpty()){
2306 textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter
2307 | Qt::TextShowMnemonic, btn->state & State_Enabled, btn->text);
2309 if (!btn->icon.isNull()) {
2310 iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic,
2311 btn->icon.pixmap(btn->iconSize, dpr(opt->window), QIcon::Normal));
2312 if (!textRect.isEmpty())
2313 textRect.translate(iconRect.right() + 4, 0);
2315 r = iconRect | textRect;
2316 r.adjust(-3, -2, 3, 2);
2317 r = r.intersected(btn->rect);
2318 r = visualRect(btn->direction, btn->rect, r);
2321 case SE_SliderFocusRect:
2323 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider);
2324 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
2325 if (slider->orientation == Qt::Horizontal)
2326 r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2);
2328 r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height());
2329 r = r.intersected(slider->rect);
2330 r = visualRect(opt->direction, opt->rect, r);
2333 case SE_ProgressBarGroove:
2334 case SE_ProgressBarContents:
2335 case SE_ProgressBarLabel:
2339 textw = qMax(pb->fontMetrics.horizontalAdvance(pb->text), pb->fontMetrics.horizontalAdvance(QLatin1String(
"100%"))) + 6;
2341 if ((pb->textAlignment & Qt::AlignCenter) == 0) {
2342 if (sr != SE_ProgressBarLabel)
2343 r.setCoords(pb->rect.left(), pb->rect.top(),
2344 pb->rect.right() - textw, pb->rect.bottom());
2346 r.setCoords(pb->rect.right() - textw, pb->rect.top(),
2347 pb->rect.right(), pb->rect.bottom());
2351 r = visualRect(pb->direction, pb->rect, r);
2354 case SE_ComboBoxFocusRect:
2356 int margin = cb
->frame ? 3 : 0;
2357 r.setRect(opt->rect.left() + margin, opt->rect.top() + margin,
2358 opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin);
2359 r = visualRect(opt->direction, opt->rect, r);
2362 case SE_ToolBoxTabContents:
2364 r.adjust(0, 0, -30, 0);
2366 case SE_HeaderLabel: {
2367 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt);
2368 r.setRect(opt->rect.x() + margin, opt->rect.y() + margin,
2369 opt->rect.width() - margin * 2, opt->rect.height() - margin * 2);
2375 r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
2377 r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2));
2380 r = visualRect(opt->direction, opt->rect, r);
2382 case SE_HeaderArrow: {
2383 int h = opt->rect.height();
2384 int w = opt->rect.width();
2385 int x = opt->rect.x();
2386 int y = opt->rect.y();
2387 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt);
2390 int horiz_size = h / 2;
2391 r.setRect(x + w - margin * 2 - horiz_size, y + 5,
2392 horiz_size, h - margin * 2 - 5);
2394 int vert_size = w / 2;
2395 r.setRect(x + 5, y + h - margin * 2 - vert_size,
2396 w - margin * 2 - 5, vert_size);
2398 r = visualRect(opt->direction, opt->rect, r);
2401 case SE_RadioButtonClickRect:
2402 r = subElementRect(SE_RadioButtonFocusRect, opt);
2403 r |= subElementRect(SE_RadioButtonIndicator, opt);
2405 case SE_CheckBoxClickRect:
2406 r = subElementRect(SE_CheckBoxFocusRect, opt);
2407 r |= subElementRect(SE_CheckBoxIndicator, opt);
2409 case SE_TabWidgetTabBar:
2410 if (
const QStyleOptionTabWidgetFrame *twf
2411 = qstyleoption_cast<
const QStyleOptionTabWidgetFrame *>(opt)) {
2412 r.setSize(twf->tabBarSize);
2413 const uint alingMask = Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter;
2414 switch (twf->shape) {
2415 case QStyleOptionTab::RoundedNorth:
2416 case QStyleOptionTab::TriangularNorth:
2419 r.setWidth(qMin(r.width(), twf->rect.width()
2420 - twf->leftCornerWidgetSize.width()
2421 - twf->rightCornerWidgetSize.width()));
2422 switch (proxy()->styleHint(SH_TabBar_Alignment, twf) & alingMask) {
2425 r.moveTopLeft(
QPoint(twf->leftCornerWidgetSize.width(), 0));
2427 case Qt::AlignHCenter:
2428 r.moveTopLeft(
QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2429 + (twf->leftCornerWidgetSize.width() / 2)
2430 - (twf->rightCornerWidgetSize.width() / 2), 0));
2432 case Qt::AlignRight:
2433 r.moveTopLeft(
QPoint(twf->rect.width() - twf->tabBarSize.width()
2434 - twf->rightCornerWidgetSize.width(), 0));
2437 r = visualRect(twf->direction, twf->rect, r);
2439 case QStyleOptionTab::RoundedSouth:
2440 case QStyleOptionTab::TriangularSouth:
2441 r.setWidth(qMin(r.width(), twf->rect.width()
2442 - twf->leftCornerWidgetSize.width()
2443 - twf->rightCornerWidgetSize.width()));
2444 switch (proxy()->styleHint(SH_TabBar_Alignment, twf) & alingMask) {
2447 r.moveTopLeft(
QPoint(twf->leftCornerWidgetSize.width(),
2448 twf->rect.height() - twf->tabBarSize.height()));
2450 case Qt::AlignHCenter:
2451 r.moveTopLeft(
QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f)
2452 + (twf->leftCornerWidgetSize.width() / 2)
2453 - (twf->rightCornerWidgetSize.width() / 2),
2454 twf->rect.height() - twf->tabBarSize.height()));
2456 case Qt::AlignRight:
2457 r.moveTopLeft(
QPoint(twf->rect.width() - twf->tabBarSize.width()
2458 - twf->rightCornerWidgetSize.width(),
2459 twf->rect.height() - twf->tabBarSize.height()));
2462 r = visualRect(twf->direction, twf->rect, r);
2464 case QStyleOptionTab::RoundedEast:
2465 case QStyleOptionTab::TriangularEast:
2466 r.setHeight(qMin(r.height(), twf->rect.height()
2467 - twf->leftCornerWidgetSize.height()
2468 - twf->rightCornerWidgetSize.height()));
2469 switch (proxy()->styleHint(SH_TabBar_Alignment, twf) & alingMask) {
2472 r.moveTopLeft(
QPoint(twf->rect.width() - twf->tabBarSize.width(),
2473 twf->leftCornerWidgetSize.height()));
2475 case Qt::AlignHCenter:
2476 r.moveTopLeft(
QPoint(twf->rect.width() - twf->tabBarSize.width(),
2477 twf->rect.center().y() - r.height() / 2));
2479 case Qt::AlignRight:
2480 r.moveTopLeft(
QPoint(twf->rect.width() - twf->tabBarSize.width(),
2481 twf->rect.height() - twf->tabBarSize.height()
2482 - twf->rightCornerWidgetSize.height()));
2486 case QStyleOptionTab::RoundedWest:
2487 case QStyleOptionTab::TriangularWest:
2488 r.setHeight(qMin(r.height(), twf->rect.height()
2489 - twf->leftCornerWidgetSize.height()
2490 - twf->rightCornerWidgetSize.height()));
2491 switch (proxy()->styleHint(SH_TabBar_Alignment, twf) & alingMask) {
2494 r.moveTopLeft(
QPoint(0, twf->leftCornerWidgetSize.height()));
2496 case Qt::AlignHCenter:
2497 r.moveTopLeft(
QPoint(0, twf->rect.center().y() - r.height() / 2));
2499 case Qt::AlignRight:
2500 r.moveTopLeft(
QPoint(0, twf->rect.height() - twf->tabBarSize.height()
2501 - twf->rightCornerWidgetSize.height()));
2508 case SE_TabWidgetTabPane:
2509 case SE_TabWidgetTabContents:
2510 if (
const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<
const QStyleOptionTabWidgetFrame *>(opt)) {
2511 QStyleOptionTab tabopt;
2512 tabopt.shape = twf->shape;
2513 int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt);
2514 if (twf->lineWidth == 0)
2516 switch (twf->shape) {
2517 case QStyleOptionTab::RoundedNorth:
2518 case QStyleOptionTab::TriangularNorth:
2519 r = QRect(
QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)),
2520 QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2522 case QStyleOptionTab::RoundedSouth:
2523 case QStyleOptionTab::TriangularSouth:
2524 r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
2526 case QStyleOptionTab::RoundedEast:
2527 case QStyleOptionTab::TriangularEast:
2528 r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2530 case QStyleOptionTab::RoundedWest:
2531 case QStyleOptionTab::TriangularWest:
2532 r = QRect(
QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0),
2533 QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
2536 if (sr == SE_TabWidgetTabContents && twf->lineWidth > 0)
2537 r.adjust(2, 2, -2, -2);
2540 case SE_TabWidgetLeftCorner:
2541 if (
const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<
const QStyleOptionTabWidgetFrame *>(opt)) {
2542 QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf);
2543 switch (twf->shape) {
2544 case QStyleOptionTab::RoundedNorth:
2545 case QStyleOptionTab::TriangularNorth:
2546 r = QRect(
QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()),
2547 twf->leftCornerWidgetSize);
2549 case QStyleOptionTab::RoundedSouth:
2550 case QStyleOptionTab::TriangularSouth:
2551 r = QRect(
QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize);
2556 r = visualRect(twf->direction, twf->rect, r);
2559 case SE_TabWidgetRightCorner:
2560 if (
const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<
const QStyleOptionTabWidgetFrame *>(opt)) {
2561 QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf);
2562 switch (twf->shape) {
2563 case QStyleOptionTab::RoundedNorth:
2564 case QStyleOptionTab::TriangularNorth:
2565 r = QRect(
QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2566 paneRect.y() - twf->rightCornerWidgetSize.height()),
2567 twf->rightCornerWidgetSize);
2569 case QStyleOptionTab::RoundedSouth:
2570 case QStyleOptionTab::TriangularSouth:
2571 r = QRect(
QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(),
2572 paneRect.height()), twf->rightCornerWidgetSize);
2577 r = visualRect(twf->direction, twf->rect, r);
2580 case SE_TabBarTabText:
2581 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
2582 QRect dummyIconRect;
2583 d->tabLayout(tab, &r, &dummyIconRect);
2586 case SE_TabBarTabLeftButton:
2587 case SE_TabBarTabRightButton:
2588 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
2590 int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab);
2591 int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab);
2592 int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt) / 2;
2593 hpadding = qMax(hpadding, 4);
2595 bool verticalTabs = tab->shape == QStyleOptionTab::RoundedEast
2596 || tab->shape == QStyleOptionTab::RoundedWest
2597 || tab->shape == QStyleOptionTab::TriangularEast
2598 || tab->shape == QStyleOptionTab::TriangularWest;
2600 QRect tr = tab->rect;
2601 if (tab->shape == QStyleOptionTab::RoundedSouth || tab->shape == QStyleOptionTab::TriangularSouth)
2602 verticalShift = -verticalShift;
2604 qSwap(horizontalShift, verticalShift);
2605 horizontalShift *= -1;
2606 verticalShift *= -1;
2608 if (tab->shape == QStyleOptionTab::RoundedWest || tab->shape == QStyleOptionTab::TriangularWest)
2609 horizontalShift = -horizontalShift;
2611 tr.adjust(0, 0, horizontalShift, verticalShift);
2614 tr.setBottom(tr.bottom() - verticalShift);
2615 tr.setRight(tr.right() - horizontalShift);
2618 QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize;
2619 int w = size.width();
2620 int h = size.height();
2621 int midHeight =
static_cast<
int>(qCeil(
float(tr.height() - h) / 2));
2622 int midWidth = ((tr.width() - w) / 2);
2624 bool atTheTop =
true;
2625 switch (tab->shape) {
2626 case QStyleOptionTab::RoundedWest:
2627 case QStyleOptionTab::TriangularWest:
2628 atTheTop = (sr == SE_TabBarTabLeftButton);
2630 case QStyleOptionTab::RoundedEast:
2631 case QStyleOptionTab::TriangularEast:
2632 atTheTop = (sr == SE_TabBarTabRightButton);
2635 if (sr == SE_TabBarTabLeftButton)
2636 r = QRect(tab->rect.x() + hpadding, midHeight, w, h);
2638 r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h);
2639 r = visualRect(tab->direction, tab->rect, r);
2643 r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h);
2645 r = QRect(midWidth, tr.y() + hpadding, w, h);
2650 case SE_TabBarTearIndicator:
2651 if (
const QStyleOptionTab *tab = qstyleoption_cast<
const QStyleOptionTab *>(opt)) {
2652 switch (tab->shape) {
2653 case QStyleOptionTab::RoundedNorth:
2654 case QStyleOptionTab::TriangularNorth:
2655 case QStyleOptionTab::RoundedSouth:
2656 case QStyleOptionTab::TriangularSouth:
2657 r.setRect(tab->rect.left(), tab->rect.top(), 8, opt->rect.height());
2659 case QStyleOptionTab::RoundedWest:
2660 case QStyleOptionTab::TriangularWest:
2661 case QStyleOptionTab::RoundedEast:
2662 case QStyleOptionTab::TriangularEast:
2663 r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 8);
2668 r = visualRect(opt->direction, opt->rect, r);
2671 case SE_TabBarScrollLeftButton: {
2672 const bool vertical = opt->rect.width() < opt->rect.height();
2673 const Qt::LayoutDirection ld = opt->direction;
2674 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth,
nullptr);
2675 const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap,
nullptr);
2677 r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth)
2678 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height()));
2680 case SE_TabBarScrollRightButton: {
2681 const bool vertical = opt->rect.width() < opt->rect.height();
2682 const Qt::LayoutDirection ld = opt->direction;
2683 const int buttonWidth = proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth,
nullptr);
2685 r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth)
2686 : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height()));
2688 case SE_TreeViewDisclosureItem:
2691 case SE_LineEditContents:
2692 if (
const QStyleOptionFrame *f = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
2693 r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth);
2694 r = visualRect(opt->direction, opt->rect, r);
2697 case SE_FrameContents:
2698 if (
const QStyleOptionFrame *f = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
2699 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, f);
2700 r = opt->rect.adjusted(fw, fw, -fw, -fw);
2701 r = visualRect(opt->direction, opt->rect, r);
2704 case SE_ShapedFrameContents:
2705 if (
const QStyleOptionFrame *f = qstyleoption_cast<
const QStyleOptionFrame *>(opt)) {
2706 int frameShape = f->frameShape;
2707 int frameShadow = QStyleOptionFrame::Plain;
2709 frameShadow = QStyleOptionFrame::Sunken;
2711 frameShadow = QStyleOptionFrame::Raised;
2716 switch (frameShape) {
2717 case QStyleOptionFrame::NoFrame:
2721 case QStyleOptionFrame::Box:
2722 case QStyleOptionFrame::HLine:
2723 case QStyleOptionFrame::VLine:
2724 switch (frameShadow) {
2725 case QStyleOptionFrame::Plain:
2726 frameWidth = f->lineWidth;
2728 case QStyleOptionFrame::Raised:
2729 case QStyleOptionFrame::Sunken:
2730 frameWidth = (
short)(f->lineWidth*2 + f->midLineWidth);
2735 case QStyleOptionFrame::StyledPanel:
2738 return subElementRect(QStyle::SE_FrameContents, opt);
2740 case QStyleOptionFrame::WinPanel:
2744 case QStyleOptionFrame::Panel:
2745 switch (frameShadow) {
2746 case QStyleOptionFrame::Plain:
2747 case QStyleOptionFrame::Raised:
2748 case QStyleOptionFrame::Sunken:
2749 frameWidth = f->lineWidth;
2754 r = f->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
2757 case SE_DockWidgetCloseButton:
2758 case SE_DockWidgetFloatButton:
2759 case SE_DockWidgetTitleBarText:
2760 case SE_DockWidgetIcon: {
2761 int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt);
2762 int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt);
2763 QRect rect = opt->rect;
2765 const QStyleOptionDockWidget *dwOpt
2766 = qstyleoption_cast<
const QStyleOptionDockWidget*>(opt);
2767 bool canClose = dwOpt ==
nullptr ?
true : dwOpt->closable;
2768 bool canFloat = dwOpt ==
nullptr ?
false : dwOpt->floatable;
2770 const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar;
2775 if (verticalTitleBar)
2776 rect = rect.transposed();
2779 int right = rect.right();
2780 int left = rect.left();
2784 QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton,
2785 opt).actualSize(QSize(iconSize, iconSize));
2786 sz += QSize(buttonMargin, buttonMargin);
2787 if (verticalTitleBar)
2788 sz = sz.transposed();
2789 closeRect = QRect(right - sz.width(),
2790 rect.center().y() - sz.height()/2,
2791 sz.width(), sz.height());
2792 right = closeRect.left() - 1;
2794 if (sr == SE_DockWidgetCloseButton) {
2801 QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarNormalButton,
2802 opt).actualSize(QSize(iconSize, iconSize));
2803 sz += QSize(buttonMargin, buttonMargin);
2804 if (verticalTitleBar)
2805 sz = sz.transposed();
2806 floatRect = QRect(right - sz.width(),
2807 rect.center().y() - sz.height()/2,
2808 sz.width(), sz.height());
2809 right = floatRect.left() - 1;
2811 if (sr == SE_DockWidgetFloatButton) {
2817 if (sr == SE_DockWidgetIcon) {
2822 QRect textRect = QRect(left, rect.top(),
2823 right - left, rect.height());
2824 if (sr == SE_DockWidgetTitleBarText) {
2831 if (verticalTitleBar) {
2832 r = QRect(rect.left() + r.top() - rect.top(),
2833 rect.top() + rect.right() - r.right(),
2834 r.height(), r.width());
2836 r = visualRect(opt->direction, rect, r);
2840#if QT_CONFIG(quick_itemview)
2841 case SE_ItemViewItemCheckIndicator:
2842 if (!qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
2843 r = subElementRect(SE_CheckBoxIndicator, opt);
2847 case SE_ItemViewItemDecoration:
2848 case SE_ItemViewItemText:
2849 case SE_ItemViewItemFocusRect:
2850 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<
const QStyleOptionViewItem *>(opt)) {
2851 if (!d->isViewItemCached(*vopt)) {
2852 d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect,
false);
2853 if (d->cachedOption) {
2854 delete d->cachedOption;
2855 d->cachedOption =
nullptr;
2857 d->cachedOption =
new QStyleOptionViewItem(*vopt);
2859 if (sr == SE_ItemViewItemCheckIndicator)
2861 else if (sr == SE_ItemViewItemDecoration)
2862 r = d->decorationRect;
2863 else if (sr == SE_ItemViewItemText || sr == SE_ItemViewItemFocusRect)
2868 case SE_ToolBarHandle:
2873 const QMargins margins(2, 2, 2, 2);
2874 const int handleExtent = proxy()->pixelMetric(QStyle::PM_ToolBarHandleExtent, opt);
2876 r = QRect(margins.left(), margins.top(),
2878 tbopt->rect.height() - (margins.top() + margins.bottom()));
2879 r = QStyle::visualRect(tbopt->direction, tbopt->rect, r);
2881 r = QRect(margins.left(), margins.top(),
2882 tbopt->rect.width() - (margins.left() + margins.right()),
2944 if (slider->subControls == SC_SliderTickmarks) {
2945 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider);
2947 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
2948 int len = proxy()->pixelMetric(PM_SliderLength, slider);
2949 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider);
2951 if (interval <= 0) {
2961 int fudge = len / 2;
2965 p->translate(slider->rect.x(), slider->rect.y());
2966 p->setPen(slider->palette.windowText().color());
2969 if (v == slider
->maximum + 1 && interval == 1)
2971 const int v_ = qMin(v, slider
->maximum);
2973 v_
, available
) + fudge;
2974 if (slider->orientation == Qt::Horizontal) {
2976 p->drawLine(pos, 0, pos, tickOffset - 2);
2978 p->drawLine(pos, tickOffset + thickness + 1, pos,
2979 slider->rect.height()-1);
2982 p->drawLine(0, pos, tickOffset - 2, pos);
2984 p->drawLine(tickOffset + thickness + 1, pos,
2985 slider->rect.width()-1, pos);
2988 int nextInterval = v + interval;
2989 if (nextInterval < v)
3001 State saveFlags = scrollbar->state;
3003 if (scrollbar->subControls & SC_ScrollBarSubLine) {
3004 newScrollbar.state = saveFlags;
3005 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine);
3006 if (newScrollbar.rect.isValid()) {
3007 if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
3009 proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p);
3012 if (scrollbar->subControls & SC_ScrollBarAddLine) {
3013 newScrollbar.rect = scrollbar->rect;
3014 newScrollbar.state = saveFlags;
3015 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine);
3016 if (newScrollbar.rect.isValid()) {
3017 if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
3019 proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p);
3022 if (scrollbar->subControls & SC_ScrollBarSubPage) {
3023 newScrollbar.rect = scrollbar->rect;
3024 newScrollbar.state = saveFlags;
3025 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage);
3026 if (newScrollbar.rect.isValid()) {
3027 if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage))
3029 proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p);
3032 if (scrollbar->subControls & SC_ScrollBarAddPage) {
3033 newScrollbar.rect = scrollbar->rect;
3034 newScrollbar.state = saveFlags;
3035 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage);
3036 if (newScrollbar.rect.isValid()) {
3037 if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage))
3039 proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p);
3042 if (scrollbar->subControls & SC_ScrollBarFirst) {
3043 newScrollbar.rect = scrollbar->rect;
3044 newScrollbar.state = saveFlags;
3045 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst);
3046 if (newScrollbar.rect.isValid()) {
3047 if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
3049 proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p);
3052 if (scrollbar->subControls & SC_ScrollBarLast) {
3053 newScrollbar.rect = scrollbar->rect;
3054 newScrollbar.state = saveFlags;
3055 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast);
3056 if (newScrollbar.rect.isValid()) {
3057 if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
3059 proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p);
3062 if (scrollbar->subControls & SC_ScrollBarSlider) {
3063 newScrollbar.rect = scrollbar->rect;
3064 newScrollbar.state = saveFlags;
3065 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider);
3066 if (newScrollbar.rect.isValid()) {
3067 if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
3069 proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p);
3074 fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2,
3075 newScrollbar.rect.width() - 5,
3076 newScrollbar.rect.height() - 5);
3077 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
3086 PrimitiveElement pe;
3088 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
3089 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame);
3090 qDrawWinPanel(p, r, sb->palette,
true);
3093 if (sb->subControls & SC_SpinBoxUp) {
3094 copy.subControls = SC_SpinBoxUp;
3095 QPalette pal2 = sb->palette;
3097 pal2.setCurrentColorGroup(QPalette::Disabled);
3101 copy.palette = pal2;
3103 if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
3110 pe = (sb->buttonSymbols == QStyleOptionSpinBox::PlusMinus ? PE_IndicatorSpinPlus
3111 : PE_IndicatorSpinUp);
3113 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp);
3114 proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p);
3115 copy.rect.adjust(3, 0, -4, 0);
3116 proxy()->drawPrimitive(pe, ©, p);
3119 if (sb->subControls & SC_SpinBoxDown) {
3120 copy.subControls = SC_SpinBoxDown;
3121 copy.state = sb->state;
3122 QPalette pal2 = sb->palette;
3124 pal2.setCurrentColorGroup(QPalette::Disabled);
3127 copy.palette = pal2;
3129 if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
3136 pe = (sb->buttonSymbols == QStyleOptionSpinBox::PlusMinus ? PE_IndicatorSpinMinus
3137 : PE_IndicatorSpinDown);
3139 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown);
3140 proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p);
3141 copy.rect.adjust(3, 0, -4, 0);
3142 proxy()->drawPrimitive(pe, ©, p);
3149 QRect button, menuarea;
3150 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton);
3151 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu);
3153 State bflags = toolbutton->state & ~State_Sunken;
3155 if (bflags & State_AutoRaise) {
3156 if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
3157 bflags &= ~State_Raised;
3160 State mflags = bflags;
3162 if (toolbutton->activeSubControls & SC_ToolButton)
3163 bflags |= State_Sunken;
3164 mflags |= State_Sunken;
3168 if (toolbutton->subControls & SC_ToolButton) {
3169 if (bflags & (State_Sunken | State_On | State_Raised)) {
3171 tool.state = bflags;
3172 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3179 fr.rect.adjust(3, 3, -3, -3);
3180 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
3181 fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator,
3183 proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p);
3186 label.state = bflags;
3187 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt);
3188 label.rect = button.adjusted(fw, fw, -fw, -fw);
3189 proxy()->drawControl(CE_ToolButtonLabel, &label, p);
3191 if (toolbutton->subControls & SC_ToolButtonMenu) {
3192 tool.rect = menuarea;
3193 tool.state = mflags;
3194 if (mflags & (State_Sunken | State_On | State_Raised))
3195 proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p);
3196 proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p);
3198 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton);
3199 QRect ir = toolbutton->rect;
3201 newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6);
3202 newBtn.rect = visualRect(toolbutton->direction, button, newBtn.rect);
3203 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p);
3210 if (opt->subControls & SC_TitleBarLabel) {
3211 QColor left = tb->palette.highlight().color();
3212 QColor right = tb->palette.base().color();
3214 QBrush fillBrush(left);
3215 if (left != right) {
3216 QPoint p1(tb->rect.x(), tb->rect.top() + tb->rect.height()/2);
3217 QPoint p2(tb->rect.right(), tb->rect.top() + tb->rect.height()/2);
3218 QLinearGradient lg(p1, p2);
3219 lg.setColorAt(0, left);
3220 lg.setColorAt(1, right);
3224 p->fillRect(opt->rect, fillBrush);
3226 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel);
3228 p->setPen(tb->palette.highlightedText().color());
3229 p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(),
3230 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
3237 if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3238 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton);
3239 down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken);
3240 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool)
3241 pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3243 pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3246 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3250 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3251 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3252 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3256 if (tb->subControls & SC_TitleBarMaxButton
3257 && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
3258 && !(tb->titleBarState & Qt::WindowMaximized)) {
3259 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton);
3261 down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
3262 pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3265 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3269 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3270 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3271 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3275 if (tb->subControls & SC_TitleBarMinButton
3276 && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
3277 && !(tb->titleBarState & Qt::WindowMinimized)) {
3278 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton);
3279 down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
3280 pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3283 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3287 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3288 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3289 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3293 bool drawNormalButton = (tb->subControls & SC_TitleBarNormalButton)
3294 && (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3295 && (tb->titleBarState & Qt::WindowMinimized))
3296 || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3297 && (tb->titleBarState & Qt::WindowMaximized)));
3299 if (drawNormalButton) {
3300 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton);
3301 down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
3302 pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3305 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3309 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3310 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3311 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3315 if (tb->subControls & SC_TitleBarShadeButton
3316 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3317 && !(tb->titleBarState & Qt::WindowMinimized)) {
3318 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton);
3319 down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
3320 pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3323 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3326 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3327 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3328 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3332 if (tb->subControls & SC_TitleBarUnshadeButton
3333 && tb->titleBarFlags & Qt::WindowShadeButtonHint
3334 && tb->titleBarState & Qt::WindowMinimized) {
3335 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton);
3337 down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
3338 pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3341 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3344 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3345 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3346 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3349 if (tb->subControls & SC_TitleBarContextHelpButton
3350 && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) {
3351 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton);
3353 down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken);
3354 pm = proxy()->standardIcon(SP_TitleBarContextHelpButton, &tool).pixmap(QSize(10, 10), dpr(opt->window));
3357 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p);
3360 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb),
3361 proxy()->pixelMetric(PM_ButtonShiftVertical, tb));
3362 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3365 if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
3366 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu);
3367 if (!tb->icon.isNull()) {
3368 tb->icon.paint(p, ir);
3370 int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb);
3371 pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool).pixmap(QSize(iconSize, iconSize), dpr(opt->window));
3374 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
3386 if (p->paintEngine()->hasFeature(QPaintEngine::Antialiasing))
3387 p->setRenderHint(QPainter::Antialiasing);
3389 int width = dial->rect.width();
3390 int height = dial->rect.height();
3391 qreal r = qMin(width, height) / 2;
3393 qreal dx = dial->rect.x() + d_ + (width - 2 * r) / 2 + 1;
3394 qreal dy = dial->rect.y() + d_ + (height - 2 * r) / 2 + 1;
3395 QRect br = QRect(
int(dx),
int(dy),
int(r * 2 - 2 * d_ - 2),
int(r * 2 - 2 * d_ - 2));
3397 QPalette pal = opt->palette;
3399 if (dial->subControls & QStyle::SC_DialTickmarks) {
3400 p->setPen(pal.windowText().color());
3401 p->drawLines(QStyleHelper::calcLines(dial));
3405 p->setBrush(pal.brush(QPalette::ColorRole(proxy()->styleHint(SH_Dial_BackgroundRole, dial))));
3406 p->setPen(Qt::NoPen);
3408 p->setBrush(Qt::NoBrush);
3410 p->setPen(QPen(pal.dark().color()));
3411 p->drawArc(br, 60 * 16, 180 * 16);
3412 p->setPen(QPen(pal.light().color()));
3413 p->drawArc(br, 240 * 16, 180 * 16);
3418 p->setPen(Qt::NoPen);
3419 p->setBrush(pal.button());
3420 p->drawPolygon(arrow.cbegin(), arrow.size());
3422 a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]);
3423 p->setBrush(Qt::NoBrush);
3425 if (a <= 0 || a > 200) {
3426 p->setPen(pal.light().color());
3427 p->drawLine(arrow[2], arrow[0]);
3428 p->drawLine(arrow[1], arrow[2]);
3429 p->setPen(pal.dark().color());
3430 p->drawLine(arrow[0], arrow[1]);
3431 }
else if (a > 0 && a < 45) {
3432 p->setPen(pal.light().color());
3433 p->drawLine(arrow[2], arrow[0]);
3434 p->setPen(pal.dark().color());
3435 p->drawLine(arrow[1], arrow[2]);
3436 p->drawLine(arrow[0], arrow[1]);
3437 }
else if (a >= 45 && a < 135) {
3438 p->setPen(pal.dark().color());
3439 p->drawLine(arrow[2], arrow[0]);
3440 p->drawLine(arrow[1], arrow[2]);
3441 p->setPen(pal.light().color());
3442 p->drawLine(arrow[0], arrow[1]);
3443 }
else if (a >= 135 && a < 200) {
3444 p->setPen(pal.dark().color());
3445 p->drawLine(arrow[2], arrow[0]);
3446 p->setPen(pal.light().color());
3447 p->drawLine(arrow[0], arrow[1]);
3448 p->drawLine(arrow[1], arrow[2]);
3453 fropt.rect = dial->rect;
3454 fropt.state = dial->state;
3455 fropt.palette = dial->palette;
3457 br.adjust(0, 0, 2, 2);
3458 if (dial->subControls & SC_DialTickmarks) {
3459 int r = qMin(width, height) / 2;
3460 br.translate(-r / 6, - r / 6);
3461 br.setWidth(br.width() + r / 3);
3462 br.setHeight(br.height() + r / 3);
3464 fropt.rect = br.adjusted(-2, -2, 2, 2);
3465 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p);
3473 QRect textRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel);
3474 QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox);
3475 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
3476 QStyleOptionFrame frame;
3477 frame.QStyleOption::operator=(*groupBox);
3478 frame.features = groupBox->features;
3481 frame.rect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame);
3483 QRegion region(groupBox->rect);
3484 if (!groupBox->text.isEmpty()) {
3485 bool ltr = groupBox->direction == Qt::LeftToRight;
3487 if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
3488 finalRect = checkBoxRect.united(textRect);
3489 finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
3491 finalRect = textRect;
3493 region -= finalRect;
3495 p->setClipRegion(region);
3496 proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p);
3501 if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
3502 QColor textColor = groupBox->textColor;
3503 if (textColor.isValid())
3504 p->setPen(textColor);
3505 int alignment =
int(groupBox->textAlignment);
3506 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, opt))
3507 alignment |= Qt::TextHideMnemonic;
3509 proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
3510 groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
3511 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
3516 fropt.rect = textRect;
3517 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p);
3522 if (groupBox->subControls & SC_GroupBoxCheckBox) {
3525 box.rect = checkBoxRect;
3526 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, p);
3530 case CC_MdiControls:
3537 const int buttonIconMetric = proxy()->pixelMetric(PM_TitleBarButtonIconSize, &btnOpt);
3538 const QSize buttonIconSize(buttonIconMetric, buttonIconMetric);
3539 if (opt->subControls & QStyle::SC_MdiCloseButton) {
3540 if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
3543 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
3544 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
3551 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton);
3552 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p);
3553 QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(buttonIconSize, dpr(opt->window));
3554 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3556 if (opt->subControls & QStyle::SC_MdiNormalButton) {
3557 if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
3560 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
3561 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
3568 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton);
3569 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p);
3570 QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(buttonIconSize, dpr(opt->window));
3571 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3573 if (opt->subControls & QStyle::SC_MdiMinButton) {
3574 if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
3577 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
3578 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
3585 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton);
3586 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p);
3587 QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(buttonIconSize, dpr(opt->window));
3588 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
3593 qWarning(
"QCommonStyle::drawComplexControl: Control %d not handled", cc);
3744 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider);
3745 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider);
3748 case SC_SliderHandle: {
3750 int len = proxy()->pixelMetric(PM_SliderLength, slider);
3751 bool horizontal = slider->orientation == Qt::Horizontal;
3754 (horizontal ? slider->rect.width()
3755 : slider->rect.height()) - len
,
3758 ret.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
3760 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
3762 case SC_SliderGroove:
3763 if (slider->orientation == Qt::Horizontal)
3764 ret.setRect(slider->rect.x(), slider->rect.y() + tickOffset,
3765 slider->rect.width(), thickness);
3767 ret.setRect(slider->rect.x() + tickOffset, slider->rect.y(),
3768 thickness, slider->rect.height());
3773 ret = visualRect(slider->direction, slider->rect, ret);
3778 const QRect scrollBarRect = scrollbar->rect;
3780 if (!proxy()->styleHint(SH_ScrollBar_Transient, scrollbar))
3781 sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar);
3782 int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
3783 scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2);
3791 int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar);
3792 if (sliderlen < slidermin || range > INT_MAX / 2)
3793 sliderlen = slidermin;
3794 if (sliderlen > maxlen)
3807 case SC_ScrollBarSubLine:
3808 if (scrollbar->orientation == Qt::Horizontal) {
3809 int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent);
3810 ret.setRect(0, 0, buttonWidth, scrollBarRect.height());
3812 int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent);
3813 ret.setRect(0, 0, scrollBarRect.width(), buttonHeight);
3816 case SC_ScrollBarAddLine:
3817 if (scrollbar->orientation == Qt::Horizontal) {
3818 int buttonWidth = qMin(scrollBarRect.width()/2, sbextent);
3819 ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height());
3821 int buttonHeight = qMin(scrollBarRect.height()/2, sbextent);
3822 ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight);
3825 case SC_ScrollBarSubPage:
3826 if (scrollbar->orientation == Qt::Horizontal)
3827 ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height());
3829 ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent);
3831 case SC_ScrollBarAddPage:
3832 if (scrollbar->orientation == Qt::Horizontal)
3833 ret.setRect(sliderstart + sliderlen, 0,
3834 maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height());
3836 ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(),
3837 maxlen - sliderstart - sliderlen + sbextent);
3839 case SC_ScrollBarGroove:
3840 if (scrollbar->orientation == Qt::Horizontal)
3841 ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2,
3842 scrollBarRect.height());
3844 ret.setRect(0, sbextent, scrollBarRect.width(),
3845 scrollBarRect.height() - sbextent * 2);
3847 case SC_ScrollBarSlider:
3848 if (scrollbar->orientation == Qt::Horizontal)
3849 ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
3851 ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
3856 ret = visualRect(scrollbar->direction, scrollBarRect, ret);
3862 int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox) : 0;
3863 bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw));
3865 bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4)));
3866 int y = fw + spinbox->rect.y();
3868 x = spinbox->rect.x() + spinbox->rect.width() - fw - bs.width();
3875 ret = QRect(x, y, bs.width(), bs.height());
3877 case SC_SpinBoxDown:
3881 ret = QRect(x, y + bs.height(), bs.width(), bs.height());
3883 case SC_SpinBoxEditField:
3885 ret = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw);
3887 ret = QRect(lx, fw, rx, spinbox->rect.height() - 2*fw);
3890 case SC_SpinBoxFrame:
3891 ret = spinbox->rect;
3896 ret = visualRect(spinbox->direction, spinbox->rect, ret);
3901 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb);
3908 ret.adjust(0, 0, -mbi, 0);
3910 case SC_ToolButtonMenu:
3914 ret.adjust(ret.width() - mbi, 0, 0, 0);
3919 ret = visualRect(tb->direction, tb->rect, ret);
3924 const qreal dpi = QStyleHelper::dpi(opt);
3925 const int x = cb->rect.x(), y = cb->rect.y(), wi = cb->rect.width(), he = cb->rect.height();
3926 const int margin = cb->frame ? qRound(QStyleHelper::dpiScaled(3, dpi)) : 0;
3927 const int bmarg = cb->frame ? qRound(QStyleHelper::dpiScaled(2, dpi)) : 0;
3928 const int xpos = x + wi - bmarg - qRound(QStyleHelper::dpiScaled(16, dpi));
3932 case SC_ComboBoxFrame:
3935 case SC_ComboBoxArrow:
3936 ret.setRect(xpos, y + bmarg, qRound(QStyleHelper::dpiScaled(16, opt)), he - 2*bmarg);
3938 case SC_ComboBoxEditField:
3939 ret.setRect(x + margin, y + margin, wi - 2 * margin - qRound(QStyleHelper::dpiScaled(16, dpi)), he - 2 * margin);
3941 case SC_ComboBoxListBoxPopup:
3947 ret = visualRect(cb->direction, cb->rect, ret);
3950 case CC_SearchField:
3952 const qreal dpi = QStyleHelper::dpi(opt);
3953 const int x = sf->rect.x(), y = sf->rect.y(), wi = sf->rect.width(), he = sf->rect.height();
3954 const int margin = qRound(QStyleHelper::dpiScaled(3, dpi));
3955 const int buttonSize = qRound(QStyleHelper::dpiScaled(16, dpi));
3956 const int spacing = qRound(QStyleHelper::dpiScaled(2, dpi));
3959 case SC_SearchFieldFrame:
3962 case SC_SearchFieldSearch:
3963 ret.setRect(x + margin, y + (he - buttonSize) / 2, buttonSize, buttonSize);
3965 case SC_SearchFieldClear:
3966 ret.setRect(x + wi - margin - buttonSize, y + (he - buttonSize) / 2, buttonSize, buttonSize);
3968 case SC_SearchFieldEditField:
3969 ret.setRect(x + margin + buttonSize + spacing, y + margin, wi - (margin + buttonSize + spacing) * 2, he - 2 * margin);
3971 case SC_SearchFieldPopup:
3977 ret = visualRect(sf->direction, sf->rect, ret);
3982 const int controlMargin = 2;
3983 const int controlHeight = tb->rect.height() - controlMargin *2;
3984 const int delta = controlHeight + controlMargin;
3987 bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
3988 bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
3991 case SC_TitleBarLabel:
3992 if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
3994 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
3995 ret.adjust(delta, 0, -delta, 0);
3996 if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
3997 ret.adjust(0, 0, -delta, 0);
3998 if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
3999 ret.adjust(0, 0, -delta, 0);
4000 if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
4001 ret.adjust(0, 0, -delta, 0);
4002 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4003 ret.adjust(0, 0, -delta, 0);
4006 case SC_TitleBarContextHelpButton:
4007 if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
4010 case SC_TitleBarMinButton:
4011 if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4013 else if (sc == SC_TitleBarMinButton)
4016 case SC_TitleBarNormalButton:
4017 if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
4019 else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4021 else if (sc == SC_TitleBarNormalButton)
4024 case SC_TitleBarMaxButton:
4025 if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
4027 else if (sc == SC_TitleBarMaxButton)
4030 case SC_TitleBarShadeButton:
4031 if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4033 else if (sc == SC_TitleBarShadeButton)
4036 case SC_TitleBarUnshadeButton:
4037 if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
4039 else if (sc == SC_TitleBarUnshadeButton)
4042 case SC_TitleBarCloseButton:
4043 if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
4045 else if (sc == SC_TitleBarCloseButton)
4047 ret.setRect(tb->rect.right() - offset, tb->rect.top() + controlMargin,
4048 controlHeight, controlHeight);
4050 case SC_TitleBarSysMenu:
4051 if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
4052 ret.setRect(tb->rect.left() + controlMargin, tb->rect.top() + controlMargin,
4053 controlHeight, controlHeight);
4059 ret = visualRect(tb->direction, tb->rect, ret);
4065 case SC_GroupBoxFrame:
4066 case SC_GroupBoxContents: {
4069 int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox);
4070 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4071 if (groupBox->text.size() || hasCheckBox) {
4072 int checkBoxHeight = hasCheckBox ? proxy()->pixelMetric(PM_IndicatorHeight, groupBox) : 0;
4073 topHeight = qMax(groupBox->fontMetrics.height(), checkBoxHeight);
4074 if (verticalAlignment & Qt::AlignVCenter)
4075 topMargin = topHeight / 2;
4076 else if (verticalAlignment & Qt::AlignTop)
4077 topMargin = topHeight;
4080 QRect frameRect = groupBox->rect;
4081 frameRect.setTop(topMargin);
4083 if (sc == SC_GroupBoxFrame) {
4089 if ((groupBox->features & QStyleOptionFrame::Flat) == 0)
4090 frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox);
4091 ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin,
4092 -frameWidth, -frameWidth);
4095 case SC_GroupBoxCheckBox:
4096 case SC_GroupBoxLabel: {
4097 QFontMetrics fontMetrics = groupBox->fontMetrics;
4098 int th = fontMetrics.height();
4099 int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(
' ')).width();
4100 int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
4101 ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
4103 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt);
4104 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt);
4105 int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt) - 1;
4106 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
4107 int checkBoxWidth = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
4108 int checkBoxHeight = hasCheckBox ? indicatorHeight : 0;
4110 int h = qMax(th, checkBoxHeight);
4114 QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
4115 QSize(tw + checkBoxWidth, h), ret);
4119 bool ltr = groupBox->direction == Qt::LeftToRight;
4122 if (sc == SC_GroupBoxCheckBox) {
4123 left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
4124 int top = totalRect.top() + (h - checkBoxHeight) / 2;
4125 totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
4128 left = ltr ? (totalRect.left() + checkBoxWidth - 2) : totalRect.left();
4129 int top = totalRect.top() + (h - th) / 2;
4130 totalRect.setRect(left, top, totalRect.width() - checkBoxWidth, th);
4142 case CC_MdiControls:
4144 int numSubControls = 0;
4145 if (opt->subControls & SC_MdiCloseButton)
4147 if (opt->subControls & SC_MdiMinButton)
4149 if (opt->subControls & SC_MdiNormalButton)
4151 if (numSubControls == 0)
4154 int buttonWidth = opt->rect.width() / numSubControls - 1;
4157 case SC_MdiCloseButton:
4159 if (numSubControls == 1)
4161 offset += buttonWidth + 2;
4163 case SC_MdiNormalButton:
4167 if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton)))
4169 if (opt->subControls & SC_MdiNormalButton)
4170 offset += buttonWidth;
4179 if (numSubControls == 1)
4181 ret = QRect(offset, 0, buttonWidth, opt->rect.height());
4184 qWarning(
"QCommonStyle::subControlRect: Case %d not handled", cc);
5496 const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QGuiApplication::isRightToLeft());
5499 switch (standardIcon) {
5500 case SP_DriveCDIcon:
5501 case SP_DriveDVDIcon:
5502 case SP_DriveNetIcon:
5503 case SP_DriveHDIcon:
5504 case SP_DriveFDIcon:
5506 case SP_FileLinkIcon:
5507 case SP_DesktopIcon:
5508 case SP_ComputerIcon:
5509 case SP_VistaShield:
5510 case SP_MessageBoxInformation:
5511 case SP_MessageBoxWarning:
5512 case SP_MessageBoxCritical:
5513 case SP_MessageBoxQuestion:
5514 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
5515 QPlatformTheme::StandardPixmap sp =
static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
5516 for (
int size = 16 ; size <= 32 ; size += 16) {
5517 QPixmap pixmap = theme->standardPixmap(sp, QSizeF(size, size));
5518 icon.addPixmap(pixmap, QIcon::Normal);
5523 case SP_DirLinkIcon:
5524 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
5525 QPlatformTheme::StandardPixmap spOff =
static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
5526 QPlatformTheme::StandardPixmap spOn = standardIcon == SP_DirIcon ? QPlatformTheme::DirOpenIcon :
5527 QPlatformTheme::DirLinkOpenIcon;
5528 for (
int size = 16 ; size <= 32 ; size += 16) {
5529 QSizeF pixSize(size, size);
5530 QPixmap pixmap = theme->standardPixmap(spOff, pixSize);
5531 icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
5532 pixmap = theme->standardPixmap(spOn, pixSize);
5533 icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
5537 case SP_LineEditClearButton:
5538 icon = clearTextIcon(rtl);
5548 if (QGuiApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) {
5549 switch (standardIcon) {
5550 case SP_DirHomeIcon:
5551 icon = QIcon::fromTheme(QLatin1String(
"user-home"));
5553 case SP_MessageBoxInformation:
5554 icon = QIcon::fromTheme(QLatin1String(
"dialog-information"));
5556 case SP_MessageBoxWarning:
5557 icon = QIcon::fromTheme(QLatin1String(
"dialog-warning"));
5559 case SP_MessageBoxCritical:
5560 icon = QIcon::fromTheme(QLatin1String(
"dialog-error"));
5562 case SP_MessageBoxQuestion:
5563 icon = QIcon::fromTheme(QLatin1String(
"dialog-question"));
5565 case SP_DialogOpenButton:
5566 case SP_DirOpenIcon:
5567 icon = QIcon::fromTheme(QLatin1String(
"folder-open"));
5569 case SP_DialogSaveButton:
5570 icon = QIcon::fromTheme(QLatin1String(
"document-save"));
5572 case SP_DialogApplyButton:
5573 icon = QIcon::fromTheme(QLatin1String(
"dialog-ok-apply"));
5575 case SP_DialogYesButton:
5576 case SP_DialogOkButton:
5577 icon = QIcon::fromTheme(QLatin1String(
"dialog-ok"));
5579 case SP_DialogDiscardButton:
5580 icon = QIcon::fromTheme(QLatin1String(
"edit-delete"));
5582 case SP_DialogResetButton:
5583 icon = QIcon::fromTheme(QLatin1String(
"edit-clear"));
5585 case SP_DialogHelpButton:
5586 icon = QIcon::fromTheme(QLatin1String(
"help-contents"));
5589 icon = QIcon::fromTheme(QLatin1String(
"text-x-generic"));
5591 case SP_DirClosedIcon:
5593 icon = QIcon::fromTheme(QLatin1String(
"folder"));
5595 case SP_DriveFDIcon:
5596 icon = QIcon::fromTheme(QLatin1String(
"floppy_unmount"));
5598 case SP_ComputerIcon:
5599 icon = QIcon::fromTheme(QLatin1String(
"computer"),
5600 QIcon::fromTheme(QLatin1String(
"system")));
5602 case SP_DesktopIcon:
5603 icon = QIcon::fromTheme(QLatin1String(
"user-desktop"));
5606 icon = QIcon::fromTheme(QLatin1String(
"user-trash"));
5608 case SP_DriveCDIcon:
5609 case SP_DriveDVDIcon:
5610 icon = QIcon::fromTheme(QLatin1String(
"media-optical"));
5612 case SP_DriveHDIcon:
5613 icon = QIcon::fromTheme(QLatin1String(
"drive-harddisk"));
5615 case SP_FileDialogToParent:
5616 icon = QIcon::fromTheme(QLatin1String(
"go-up"));
5618 case SP_FileDialogNewFolder:
5619 icon = QIcon::fromTheme(QLatin1String(
"folder-new"));
5622 icon = QIcon::fromTheme(QLatin1String(
"go-up"));
5625 icon = QIcon::fromTheme(QLatin1String(
"go-down"));
5628 icon = QIcon::fromTheme(QLatin1String(
"go-next"));
5631 icon = QIcon::fromTheme(QLatin1String(
"go-previous"));
5633 case SP_DialogNoButton:
5634 case SP_DialogCancelButton:
5635 icon = QIcon::fromTheme(QLatin1String(
"dialog-cancel"),
5636 QIcon::fromTheme(QLatin1String(
"process-stop")));
5638 case SP_DialogCloseButton:
5639 icon = QIcon::fromTheme(QLatin1String(
"window-close"));
5641 case SP_FileDialogDetailedView:
5642 icon = QIcon::fromTheme(QLatin1String(
"view-list-details"));
5644 case SP_FileDialogListView:
5645 icon = QIcon::fromTheme(QLatin1String(
"view-list-icons"));
5647 case SP_BrowserReload:
5648 icon = QIcon::fromTheme(QLatin1String(
"view-refresh"));
5650 case SP_BrowserStop:
5651 icon = QIcon::fromTheme(QLatin1String(
"process-stop"));
5654 icon = QIcon::fromTheme(QLatin1String(
"media-playback-start"));
5657 icon = QIcon::fromTheme(QLatin1String(
"media-playback-pause"));
5660 icon = QIcon::fromTheme(QLatin1String(
"media-playback-stop"));
5662 case SP_MediaSeekForward:
5663 icon = QIcon::fromTheme(QLatin1String(
"media-seek-forward"));
5665 case SP_MediaSeekBackward:
5666 icon = QIcon::fromTheme(QLatin1String(
"media-seek-backward"));
5668 case SP_MediaSkipForward:
5669 icon = QIcon::fromTheme(QLatin1String(
"media-skip-forward"));
5671 case SP_MediaSkipBackward:
5672 icon = QIcon::fromTheme(QLatin1String(
"media-skip-backward"));
5674 case SP_MediaVolume:
5675 icon = QIcon::fromTheme(QLatin1String(
"audio-volume-medium"));
5677 case SP_MediaVolumeMuted:
5678 icon = QIcon::fromTheme(QLatin1String(
"audio-volume-muted"));
5680 case SP_ArrowForward:
5682 return QCommonStyle::standardIcon(SP_ArrowLeft, option);
5683 return QCommonStyle::standardIcon(SP_ArrowRight, option);
5686 return QCommonStyle::standardIcon(SP_ArrowRight, option);
5687 return QCommonStyle::standardIcon(SP_ArrowLeft, option);
5688 case SP_FileLinkIcon:
5690 QIcon linkIcon = QIcon::fromTheme(QLatin1String(
"emblem-symbolic-link"));
5691 if (!linkIcon.isNull()) {
5692 QIcon baseIcon = QCommonStyle::standardIcon(SP_FileIcon, option);
5693 const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
5694 const qreal devicePixelRatio = option ? dpr(option->window) : 1.;
5695 for (
int i = 0 ; i < sizes.size() ; ++i) {
5696 int size = sizes[i].width();
5697 QPixmap basePixmap = baseIcon.pixmap(QSize(size, size), devicePixelRatio);
5698 QPixmap linkPixmap = linkIcon.pixmap(QSize(size / 2, size / 2), devicePixelRatio);
5699 QPainter painter(&basePixmap);
5700 painter.drawPixmap(size/2, size/2, linkPixmap);
5701 icon.addPixmap(basePixmap);
5706 case SP_DirLinkIcon:
5708 QIcon linkIcon = QIcon::fromTheme(QLatin1String(
"emblem-symbolic-link"));
5709 if (!linkIcon.isNull()) {
5710 QIcon baseIcon = QCommonStyle::standardIcon(SP_DirIcon, option);
5711 const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
5712 const qreal devicePixelRatio = option ? dpr(option->window) : 1.;
5713 for (
int i = 0 ; i < sizes.size() ; ++i) {
5714 int size = sizes[i].width();
5715 QPixmap basePixmap = baseIcon.pixmap(QSize(size, size), devicePixelRatio);
5716 QPixmap linkPixmap = linkIcon.pixmap(QSize(size / 2, size / 2), devicePixelRatio);
5717 QPainter painter(&basePixmap);
5718 painter.drawPixmap(size/2, size/2, linkPixmap);
5719 icon.addPixmap(basePixmap);
5732#if defined(Q_OS_MACOS)
5733 if (QGuiApplication::desktopSettingsAware()) {
5734 switch (standardIcon) {
5737 QIcon closeIcon = QCommonStyle::standardIcon(SP_DirClosedIcon, option);
5738 QIcon openIcon = QCommonStyle::standardIcon(SP_DirOpenIcon, option);
5739 closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On);
5740 closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On);
5741 closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On);
5742 closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On);
5746 case SP_TitleBarNormalButton:
5747 case SP_TitleBarCloseButton: {
5749 if (standardIcon == SP_TitleBarCloseButton) {
5750 titleBarIcon.addFile(QLatin1String(
":/qt-project.org/styles/macstyle/images/closedock-16.png"));
5751 titleBarIcon.addFile(QLatin1String(
":/qt-project.org/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
5753 titleBarIcon.addFile(QLatin1String(
":/qt-project.org/styles/macstyle/images/dockdock-16.png"));
5754 titleBarIcon.addFile(QLatin1String(
":/qt-project.org/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On);
5756 return titleBarIcon;
5759 case SP_MessageBoxQuestion:
5760 case SP_MessageBoxInformation:
5761 case SP_MessageBoxWarning:
5762 case SP_MessageBoxCritical:
5763 case SP_DesktopIcon:
5765 case SP_ComputerIcon:
5766 case SP_DriveFDIcon:
5767 case SP_DriveHDIcon:
5768 case SP_DriveCDIcon:
5769 case SP_DriveDVDIcon:
5770 case SP_DriveNetIcon:
5771 case SP_DirOpenIcon:
5772 case SP_DirClosedIcon:
5773 case SP_DirLinkIcon:
5774 case SP_FileLinkIcon:
5776 if (
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
5777 QPlatformTheme::StandardPixmap sp =
static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
5779 const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize> >();
5780 for (
const QSize &size : sizes) {
5782 const QString cacheKey = QLatin1String(
"qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size.width());
5783 if (standardIcon >= QStyle::SP_CustomBase) {
5784 mainIcon = theme->standardPixmap(sp, QSizeF(size));
5785 }
else if (QPixmapCache::find(cacheKey, &mainIcon) ==
false) {
5786 mainIcon = theme->standardPixmap(sp, QSizeF(size));
5787 QPixmapCache::insert(cacheKey, mainIcon);
5790 retIcon.addPixmap(mainIcon);
5792 if (!retIcon.isNull())
5802 switch (standardIcon) {
5803#ifndef QT_NO_IMAGEFORMAT_PNG
5804 case SP_TitleBarMinButton:
5805 addIconFiles(iconResourcePrefix() + QStringLiteral(
"titlebar-min-"),
5806 titleBarSizes,
sizeof(titleBarSizes)/
sizeof(titleBarSizes[0]), icon);
5808 case SP_TitleBarMaxButton:
5809 addIconFiles(iconResourcePrefix() + QStringLiteral(
"titlebar-max-"),
5810 titleBarSizes,
sizeof(titleBarSizes)/
sizeof(titleBarSizes[0]), icon);
5812 case SP_TitleBarShadeButton:
5813 addIconFiles(iconResourcePrefix() + QStringLiteral(
"titlebar-shade-"),
5814 titleBarSizes,
sizeof(titleBarSizes)/
sizeof(titleBarSizes[0]), icon);
5817 case SP_TitleBarUnshadeButton:
5818 addIconFiles(iconResourcePrefix() + QStringLiteral(
"titlebar-unshade-"),
5819 titleBarSizes,
sizeof(titleBarSizes)/
sizeof(titleBarSizes[0]), icon);
5821 case SP_TitleBarContextHelpButton:
5822 addIconFiles(iconResourcePrefix() + QStringLiteral(
"titlebar-contexthelp-"),
5823 titleBarSizes,
sizeof(titleBarSizes)/
sizeof(titleBarSizes[0]), icon);
5825 case SP_FileDialogNewFolder:
5826 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/newdirectory-16.png"), QSize(16, 16));
5827 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/newdirectory-32.png"), QSize(32, 32));
5828 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/newdirectory-128.png"), QSize(128, 128));
5830 case SP_FileDialogBack:
5831 return QCommonStyle::standardIcon(SP_ArrowBack, option);
5832 case SP_FileDialogToParent:
5833 return QCommonStyle::standardIcon(SP_ArrowUp, option);
5834 case SP_FileDialogDetailedView:
5835 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewdetailed-16.png"), QSize(16, 16));
5836 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewdetailed-32.png"), QSize(32, 32));
5837 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewdetailed-128.png"), QSize(128, 128));
5839 case SP_FileDialogInfoView:
5840 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/fileinfo-16.png"), QSize(16, 16));
5841 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/fileinfo-32.png"), QSize(32, 32));
5842 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/fileinfo-128.png"), QSize(128, 128));
5844 case SP_FileDialogContentsView:
5845 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filecontents-16.png"), QSize(16, 16));
5846 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filecontents-32.png"), QSize(32, 32));
5847 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filecontents-128.png"), QSize(128, 128));
5849 case SP_FileDialogListView:
5850 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewlist-16.png"), QSize(16, 16));
5851 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewlist-32.png"), QSize(32, 32));
5852 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/viewlist-128.png"), QSize(128, 128));
5854 case SP_DialogOkButton:
5855 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-ok-16.png"), QSize(16, 16));
5856 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-ok-32.png"), QSize(32, 32));
5857 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-ok-128.png"), QSize(128, 128));
5859 case SP_DialogCancelButton:
5860 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-16.png"), QSize(16, 16));
5861 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-32.png"), QSize(32, 32));
5862 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-cancel-128.png"), QSize(128, 128));
5864 case SP_DialogHelpButton:
5865 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-help-16.png"), QSize(16, 16));
5866 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-help-32.png"), QSize(32, 32));
5867 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-help-128.png"), QSize(128, 128));
5869 case SP_DialogOpenButton:
5870 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-open-16.png"), QSize(16, 16));
5871 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-open-32.png"), QSize(32, 32));
5872 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-open-128.png"), QSize(128, 128));
5874 case SP_DialogSaveButton:
5875 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-save-16.png"), QSize(16, 16));
5876 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-save-32.png"), QSize(32, 32));
5877 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-save-128.png"), QSize(128, 128));
5879 case SP_DialogCloseButton:
5880 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-close-16.png"), QSize(16, 16));
5881 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-close-32.png"), QSize(32, 32));
5882 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-close-128.png"), QSize(128, 128));
5884 case SP_DialogApplyButton:
5885 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-apply-16.png"), QSize(16, 16));
5886 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-apply-32.png"), QSize(32, 32));
5887 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-apply-128.png"), QSize(128, 128));
5889 case SP_DialogResetButton:
5890 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-clear-16.png"), QSize(16, 16));
5891 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-clear-32.png"), QSize(32, 32));
5892 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-clear-128.png"), QSize(128, 128));
5894 case SP_DialogDiscardButton:
5895 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-delete-16.png"), QSize(16, 16));
5896 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-delete-32.png"), QSize(32, 32));
5897 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-delete-128.png"), QSize(128, 128));
5899 case SP_DialogYesButton:
5900 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-yes-16.png"), QSize(16, 16));
5901 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-yes-32.png"), QSize(32, 32));
5902 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-yes-128.png"), QSize(128, 128));
5904 case SP_DialogNoButton:
5905 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-no-16.png"), QSize(16, 16));
5906 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-no-32.png"), QSize(32, 32));
5907 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/standardbutton-no-128.png"), QSize(128, 128));
5909 case SP_ArrowForward:
5911 return QCommonStyle::standardIcon(SP_ArrowLeft, option);
5912 return QCommonStyle::standardIcon(SP_ArrowRight, option);
5915 return QCommonStyle::standardIcon(SP_ArrowRight, option);
5916 return QCommonStyle::standardIcon(SP_ArrowLeft, option);
5918 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/left-16.png"), QSize(16, 16));
5919 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/left-32.png"), QSize(32, 32));
5920 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/left-128.png"), QSize(128, 128));
5923 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/right-16.png"), QSize(16, 16));
5924 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/right-32.png"), QSize(32, 32));
5925 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/right-128.png"), QSize(128, 128));
5928 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/up-16.png"), QSize(16, 16));
5929 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/up-32.png"), QSize(32, 32));
5930 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/up-128.png"), QSize(128, 128));
5933 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/down-16.png"), QSize(16, 16));
5934 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/down-32.png"), QSize(32, 32));
5935 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/down-128.png"), QSize(128, 128));
5937 case SP_DirHomeIcon:
5939 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dirclosed-16.png"),
5940 QSize(), QIcon::Normal, QIcon::Off);
5941 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/diropen-16.png"),
5942 QSize(), QIcon::Normal, QIcon::On);
5943 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dirclosed-32.png"),
5944 QSize(32, 32), QIcon::Normal, QIcon::Off);
5945 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/diropen-32.png"),
5946 QSize(32, 32), QIcon::Normal, QIcon::On);
5947 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dirclosed-128.png"),
5948 QSize(128, 128), QIcon::Normal, QIcon::Off);
5949 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/diropen-128.png"),
5950 QSize(128, 128), QIcon::Normal, QIcon::On);
5952 case SP_DriveCDIcon:
5953 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/cdr-16.png"), QSize(16, 16));
5954 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/cdr-32.png"), QSize(32, 32));
5955 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/cdr-128.png"), QSize(128, 128));
5957 case SP_DriveDVDIcon:
5958 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dvd-16.png"), QSize(16, 16));
5959 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dvd-32.png"), QSize(32, 32));
5960 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/dvd-128.png"), QSize(128, 128));
5963 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/file-16.png"), QSize(16, 16));
5964 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/file-32.png"), QSize(32, 32));
5965 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/file-128.png"), QSize(128, 128));
5967 case SP_FileLinkIcon:
5968 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filelink-16.png"), QSize(16, 16));
5969 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filelink-32.png"), QSize(32, 32));
5970 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/filelink-128.png"), QSize(128, 128));
5973 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/trash-16.png"), QSize(16, 16));
5974 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/trash-32.png"), QSize(32, 32));
5975 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/trash-128.png"), QSize(128, 128));
5977 case SP_BrowserReload:
5978 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/refresh-24.png"), QSize(24, 24));
5979 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/refresh-32.png"), QSize(32, 32));
5981 case SP_BrowserStop:
5982 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/stop-24.png"), QSize(24, 24));
5983 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/stop-32.png"), QSize(32, 32));
5986 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-play-16.png"), QSize(16, 16));
5987 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-play-32.png"), QSize(32, 32));
5990 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-pause-16.png"), QSize(16, 16));
5991 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-pause-32.png"), QSize(32, 32));
5994 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-stop-16.png"), QSize(16, 16));
5995 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-stop-32.png"), QSize(32, 32));
5997 case SP_MediaSeekForward:
5998 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-seek-forward-16.png"), QSize(16, 16));
5999 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-seek-forward-32.png"), QSize(32, 32));
6001 case SP_MediaSeekBackward:
6002 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-seek-backward-16.png"), QSize(16, 16));
6003 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-seek-backward-32.png"), QSize(32, 32));
6005 case SP_MediaSkipForward:
6006 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-skip-forward-16.png"), QSize(16, 16));
6007 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-skip-forward-32.png"), QSize(32, 32));
6009 case SP_MediaSkipBackward:
6010 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-skip-backward-16.png"), QSize(16, 16));
6011 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-skip-backward-32.png"), QSize(32, 32));
6013 case SP_MediaVolume:
6014 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-volume-16.png"), QSize(16, 16));
6016 case SP_MediaVolumeMuted:
6017 icon.addFile(QLatin1String(
":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"), QSize(16, 16));
6019 case SP_TitleBarCloseButton:
6020 addIconFiles(iconResourcePrefix() + QStringLiteral(
"closedock-"),
6021 dockTitleIconSizes,
sizeof(dockTitleIconSizes)/
sizeof(dockTitleIconSizes[0]), icon);
6023 case SP_TitleBarMenuButton:
6024# ifndef QT_NO_IMAGEFORMAT_XPM
6025 icon.addPixmap(titleBarMenuCachedPixmapFromXPM());
6027 icon.addFile(QLatin1String(
":/qt-project.org/qmessagebox/images/qtlogo-64.png"));
6029 case SP_TitleBarNormalButton:
6030 addIconFiles(iconResourcePrefix() + QStringLiteral(
"normalizedockup-"),
6031 dockTitleIconSizes,
sizeof(dockTitleIconSizes)/
sizeof(dockTitleIconSizes[0]), icon);
6033 case SP_ToolBarHorizontalExtensionButton: {
6034 QString prefix = iconResourcePrefix() + QStringLiteral(
"toolbar-ext-h-");
6036 prefix += QStringLiteral(
"rtl-");
6037 addIconFiles(prefix, toolBarExtHSizes,
sizeof(toolBarExtHSizes)/
sizeof(toolBarExtHSizes[0]), icon);
6040 case SP_ToolBarVerticalExtensionButton:
6041 addIconFiles(iconResourcePrefix() + QStringLiteral(
"toolbar-ext-v-"),
6042 toolBarExtVSizes,
sizeof(toolBarExtVSizes)/
sizeof(toolBarExtVSizes[0]), icon);
6046 icon.addPixmap(
proxy()->standardPixmap(standardIcon, option));