7#if QT_CONFIG(style_stylesheet)
9#include "private/qcssutil_p.h"
21#if QT_CONFIG(lineedit)
24#if QT_CONFIG(textedit)
28#include <private/qwindowsstyle_p.h>
29#if QT_CONFIG(combobox)
32#include "private/qcssparser_p.h"
33#include "private/qmath_p.h"
35#include "private/qabstractscrollarea_p.h"
40#if QT_CONFIG(toolbutton)
43#if QT_CONFIG(scrollbar)
46#if QT_CONFIG(abstractslider)
51#if QT_CONFIG(checkbox)
54#if QT_CONFIG(itemviews)
57#include <private/qwindowsstyle_p_p.h>
58#if QT_CONFIG(animation)
59#include <private/qstyleanimation_p.h>
62#include <private/qtabbar_p.h>
64#include <QMetaProperty>
65#if QT_CONFIG(mainwindow)
68#if QT_CONFIG(dockwidget)
77#include <private/qwidget_p.h>
79#include <QAbstractSpinBox>
88#include <QtWidgets/qtoolbar.h>
90#if QT_CONFIG(pushbutton)
91#include <QtWidgets/qpushbutton.h>
94#include <QtGui/qpainterpath.h>
95#include <QtGui/qscreen.h>
97#include <QtCore/private/qduplicatetracker_p.h>
106class QStyleSheetStylePrivate :
public QWindowsStylePrivate
110 QStyleSheetStylePrivate() { }
126class QStyleSheetStyleRecursionGuard
130 : guarded(globalStyleSheetStyle ==
nullptr)
132 if (guarded) globalStyleSheetStyle = that;
134 ~QStyleSheetStyleRecursionGuard() {
if (guarded) globalStyleSheetStyle =
nullptr; }
137#define RECURSION_GUARD(RETURN) \
138 if (globalStyleSheetStyle != 0 && globalStyleSheetStyle != this) { RETURN; } \
139 QStyleSheetStyleRecursionGuard recursion_guard(this);
143 PseudoElement_DownArrow,
144 PseudoElement_UpArrow,
145 PseudoElement_LeftArrow,
146 PseudoElement_RightArrow,
147 PseudoElement_Indicator,
148 PseudoElement_ExclusiveIndicator,
149 PseudoElement_PushButtonMenuIndicator,
150 PseudoElement_ComboBoxDropDown,
151 PseudoElement_ComboBoxArrow,
153 PseudoElement_SpinBoxUpButton,
154 PseudoElement_SpinBoxUpArrow,
155 PseudoElement_SpinBoxDownButton,
156 PseudoElement_SpinBoxDownArrow,
157 PseudoElement_GroupBoxTitle,
158 PseudoElement_GroupBoxIndicator,
159 PseudoElement_ToolButtonMenu,
160 PseudoElement_ToolButtonMenuArrow,
161 PseudoElement_ToolButtonMenuIndicator,
162 PseudoElement_ToolBoxTab,
163 PseudoElement_ScrollBarSlider,
164 PseudoElement_ScrollBarAddPage,
165 PseudoElement_ScrollBarSubPage,
166 PseudoElement_ScrollBarAddLine,
167 PseudoElement_ScrollBarSubLine,
168 PseudoElement_ScrollBarFirst,
169 PseudoElement_ScrollBarLast,
170 PseudoElement_ScrollBarUpArrow,
171 PseudoElement_ScrollBarDownArrow,
172 PseudoElement_ScrollBarLeftArrow,
173 PseudoElement_ScrollBarRightArrow,
174 PseudoElement_SplitterHandle,
175 PseudoElement_ToolBarHandle,
176 PseudoElement_ToolBarSeparator,
177 PseudoElement_MenuScroller,
178 PseudoElement_MenuTearoff,
179 PseudoElement_MenuCheckMark,
180 PseudoElement_MenuSeparator,
181 PseudoElement_MenuIcon,
182 PseudoElement_MenuRightArrow,
183 PseudoElement_TreeViewBranch,
184 PseudoElement_HeaderViewSection,
185 PseudoElement_HeaderViewUpArrow,
186 PseudoElement_HeaderViewDownArrow,
187 PseudoElement_ProgressBarChunk,
188 PseudoElement_TabBarTab,
189 PseudoElement_TabBarScroller,
190 PseudoElement_TabBarTear,
191 PseudoElement_SliderGroove,
192 PseudoElement_SliderHandle,
193 PseudoElement_SliderAddPage,
194 PseudoElement_SliderSubPage,
195 PseudoElement_SliderTickmark,
196 PseudoElement_TabWidgetPane,
197 PseudoElement_TabWidgetTabBar,
198 PseudoElement_TabWidgetLeftCorner,
199 PseudoElement_TabWidgetRightCorner,
200 PseudoElement_DockWidgetTitle,
201 PseudoElement_DockWidgetCloseButton,
202 PseudoElement_DockWidgetFloatButton,
203 PseudoElement_DockWidgetSeparator,
204 PseudoElement_MdiCloseButton,
205 PseudoElement_MdiMinButton,
206 PseudoElement_MdiNormalButton,
207 PseudoElement_TitleBar,
208 PseudoElement_TitleBarCloseButton,
209 PseudoElement_TitleBarMinButton,
210 PseudoElement_TitleBarMaxButton,
211 PseudoElement_TitleBarShadeButton,
212 PseudoElement_TitleBarUnshadeButton,
213 PseudoElement_TitleBarNormalButton,
214 PseudoElement_TitleBarContextHelpButton,
215 PseudoElement_TitleBarSysMenu,
216 PseudoElement_ViewItem,
217 PseudoElement_ViewItemIcon,
218 PseudoElement_ViewItemText,
219 PseudoElement_ViewItemIndicator,
220 PseudoElement_ScrollAreaCorner,
221 PseudoElement_TabBarTabCloseButton,
225struct PseudoElementInfo {
230static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = {
314struct QStyleSheetBorderImageData :
public QSharedData
316 QStyleSheetBorderImageData()
319 for (
int i = 0;
i < 4;
i++)
328struct QStyleSheetBackgroundData :
public QSharedData
334 bool isTransparent()
const {
336 return !
brush.isOpaque();
350 QStyleSheetBorderData() : bi(
nullptr)
352 for (
int i = 0;
i < 4;
i++) {
360 for (
int i = 0;
i < 4;
i++) {
373 const QStyleSheetBorderImageData *borderImage()
const
375 bool hasBorderImage()
const {
return bi!=
nullptr; }
377 QSharedDataPointer<QStyleSheetBorderImageData> bi;
379 bool isOpaque()
const
381 for (
int i = 0;
i < 4;
i++) {
385 && styles[
i] != BorderStyle_Solid)
389 if (!radii[
i].isEmpty())
392 if (bi !=
nullptr && bi->pixmap.hasAlpha())
399struct QStyleSheetOutlineData :
public QStyleSheetBorderData
401 QStyleSheetOutlineData()
403 for (
int i = 0;
i < 4;
i++) {
409 : QStyleSheetBorderData(
b,
c,
s,
r)
411 for (
int i = 0;
i < 4;
i++) {
421 QStyleSheetBoxData(
int *
m,
int *
p,
int s) :
spacing(
s)
423 for (
int i = 0;
i < 4;
i++) {
437 QStyleSheetPaletteData(
const QBrush &foreground,
438 const QBrush &selectedForeground,
439 const QBrush &selectedBackground,
440 const QBrush &alternateBackground,
441 const QBrush &placeHolderTextForeground,
443 : foreground(foreground)
444 , selectionForeground(selectedForeground)
445 , selectionBackground(selectedBackground)
446 , alternateBackground(alternateBackground)
447 , placeholderForeground(placeHolderTextForeground)
452 QBrush selectionForeground;
453 QBrush selectionBackground;
454 QBrush alternateBackground;
455 QBrush placeholderForeground;
461 QStyleSheetGeometryData(
int w,
int h,
int minw,
int minh,
int maxw,
int maxh)
462 : minWidth(minw), minHeight(minh),
width(
w),
height(
h), maxWidth(maxw), maxHeight(maxh) { }
464 int minWidth, minHeight,
width,
height, maxWidth, maxHeight;
476 Qt::Alignment textAlignment;
481 QStyleSheetImageData(
const QIcon &
i, Qt::Alignment
a,
const QSize &sz)
492 QRenderRule() : features(0), hasFont(
false), pal(
nullptr),
b(
nullptr), bg(
nullptr), bd(
nullptr), ou(
nullptr), geo(
nullptr),
p(
nullptr),
img(
nullptr), clipset(0) { }
493 QRenderRule(
const QList<QCss::Declaration> &,
const QObject *);
517 const QStyleSheetPaletteData *
palette()
const {
return pal; }
518 const QStyleSheetBoxData *
box()
const {
return b; }
519 const QStyleSheetBackgroundData *background()
const {
return bg; }
520 const QStyleSheetBorderData *
border()
const {
return bd; }
521 const QStyleSheetOutlineData *outline()
const {
return ou; }
522 const QStyleSheetGeometryData *geometry()
const {
return geo; }
523 const QStyleSheetPositionData *
position()
const {
return p; }
524 const QStyleSheetImageData *
icon()
const {
return iconPtr; }
526 bool hasModification()
const;
528 bool hasPalette()
const {
return pal !=
nullptr; }
529 bool hasBackground()
const {
return bg !=
nullptr && (!bg->pixmap.isNull() || bg->brush.style() !=
Qt::NoBrush); }
533 bool hasNativeBorder()
const {
538 bool hasNativeOutline()
const {
539 return (ou ==
nullptr
540 || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native));
543 bool baseStyleCanDraw()
const {
544 if (!hasBackground() || (background()->
brush.style() ==
Qt::NoBrush && bg->pixmap.isNull()))
546 if (bg && !bg->pixmap.isNull())
548 if (hasGradientBackground())
553 bool hasBox()
const {
return b !=
nullptr; }
554 bool hasBorder()
const {
return bd !=
nullptr; }
555 bool hasOutline()
const {
return ou !=
nullptr; }
556 bool hasPosition()
const {
return p !=
nullptr; }
557 bool hasGeometry()
const {
return geo !=
nullptr; }
558 bool hasDrawable()
const {
return !hasNativeBorder() || hasBackground() || hasImage(); }
559 bool hasImage()
const {
return img !=
nullptr; }
560 bool hasIcon()
const {
return iconPtr !=
nullptr; }
562 QSize minimumContentsSize()
const
563 {
return geo ?
QSize(geo->minWidth, geo->minHeight) :
QSize(0, 0); }
564 QSize minimumSize()
const
565 {
return boxSize(minimumContentsSize()); }
567 QSize contentsSize()
const
568 {
return geo ?
QSize(geo->width, geo->height)
572 QSize csz = contentsSize();
573 if (csz.width() == -1) csz.setWidth(sz.
width());
574 if (csz.height() == -1) csz.setHeight(sz.
height());
577 bool hasContentsSize()
const
578 {
return (geo && (geo->width != -1 || geo->height != -1)) || (
img &&
img->size.isValid()); }
580 QSize size()
const {
return boxSize(contentsSize()); }
581 QSize size(
const QSize &sz)
const {
return boxSize(contentsSize(sz)); }
586 QSize csz = contentsSize();
587 if (csz.width() == -1) csz.setWidth(sz.
width());
588 if (csz.height() == -1) csz.setHeight(sz.
height());
589 if (geo->maxWidth != -1 && csz.width() > geo->maxWidth) csz.setWidth(geo->maxWidth);
590 if (geo->maxHeight != -1 && csz.height() > geo->maxHeight) csz.setHeight(geo->maxHeight);
591 csz=csz.expandedTo(
QSize(geo->minWidth, geo->minHeight));
595 bool hasStyleHint(
const QString &sh)
const {
return styleHints.contains(sh); }
598 void fixupBorder(
int);
610 QHash<QString, QVariant> styleHints;
612 QSharedDataPointer<QStyleSheetPaletteData> pal;
613 QSharedDataPointer<QStyleSheetBoxData>
b;
614 QSharedDataPointer<QStyleSheetBackgroundData> bg;
615 QSharedDataPointer<QStyleSheetBorderData> bd;
616 QSharedDataPointer<QStyleSheetOutlineData> ou;
617 QSharedDataPointer<QStyleSheetGeometryData> geo;
618 QSharedDataPointer<QStyleSheetPositionData>
p;
619 QSharedDataPointer<QStyleSheetImageData>
img;
620 QSharedDataPointer<QStyleSheetImageData> iconPtr;
628static constexpr std::array<const char*, 90> knownStyleHints = {
629 "activate-on-singleclick",
631 "arrow-keys-navigate-into-children",
635 "combobox-list-mousetracking",
640 "dialog-cancel-icon",
642 "dialog-discard-icon",
650 "dialogbuttonbox-buttons-have-icons",
651 "directory-closed-icon",
653 "directory-link-icon",
654 "directory-open-icon",
655 "dither-disable-text",
656 "dockwidget-close-icon",
659 "etch-disabled-text",
662 "filedialog-backward-icon",
663 "filedialog-contentsview-icon",
664 "filedialog-detailedview-icon",
665 "filedialog-end-icon",
666 "filedialog-infoview-icon",
667 "filedialog-listview-icon",
668 "filedialog-new-directory-icon",
669 "filedialog-parent-directory-icon",
670 "filedialog-start-icon",
676 "lineedit-clear-button-icon",
679 "lineedit-password-character",
680 "lineedit-password-mask-delay",
681 "mdi-fill-space-on-maximize",
683 "menubar-altkey-navigation",
685 "messagebox-critical-icon",
686 "messagebox-information-icon",
687 "messagebox-question-icon",
688 "messagebox-text-interaction-flags",
689 "messagebox-warning-icon",
693 "paint-alternating-row-colors-for-empty-area",
695 "scrollbar-contextmenu",
696 "scrollbar-leftclick-absolute-position",
697 "scrollbar-middleclick-absolute-position",
698 "scrollbar-roll-between-buttons",
699 "scrollbar-scroll-when-pointer-leaves-control",
700 "scrollview-frame-around-contents",
701 "show-decoration-selected",
702 "spinbox-click-autorepeat-rate",
703 "spincontrol-disable-on-bounds",
705 "tabbar-prefer-no-arrows",
706 "titlebar-close-icon",
707 "titlebar-contexthelp-icon",
708 "titlebar-maximize-icon",
709 "titlebar-menu-icon",
710 "titlebar-minimize-icon",
711 "titlebar-normal-icon",
712 "titlebar-shade-icon",
713 "titlebar-show-tooltips-on-buttons",
714 "titlebar-unshade-icon",
715 "toolbutton-popup-delay",
718 "widget-animation-duration"
723 QList<QVariant> buttons;
727 buttons.append(PseudoElement_MdiMinButton);
728 buttons.append(PseudoElement_TitleBarMinButton);
731 buttons.append(PseudoElement_TitleBarMaxButton);
734 buttons.append(PseudoElement_MdiCloseButton);
735 buttons.append(PseudoElement_TitleBarCloseButton);
738 buttons.append(PseudoElement_MdiNormalButton);
739 buttons.append(PseudoElement_TitleBarNormalButton);
742 buttons.append(PseudoElement_TitleBarSysMenu);
745 buttons.append(PseudoElement_TitleBar);
748 buttons.append(PseudoElement_TitleBarContextHelpButton);
751 buttons.append(PseudoElement_TitleBarShadeButton);
774 QHash<QStyle::SubControl, QRect> layoutRects;
778 QRect cr = subRule.contentsRect(tb->rect);
779 QList<QVariant>
layout = subRule.styleHint(
"button-layout"_L1).toList();
781 layout = subControlLayout(
"I(T)HSmMX"_L1);
785 QList<ButtonInfo> infos;
786 infos.reserve(
layout.size());
788 const int element =
val.toInt();
789 if (element ==
'(') {
791 }
else if (element ==
')') {
795 info.element = element;
797 case PseudoElement_TitleBar:
801 case PseudoElement_TitleBarContextHelpButton:
805 case PseudoElement_TitleBarMinButton:
809 info.element = PseudoElement_TitleBarNormalButton;
811 case PseudoElement_TitleBarMaxButton:
815 info.element = PseudoElement_TitleBarNormalButton;
817 case PseudoElement_TitleBarShadeButton:
821 info.element = PseudoElement_TitleBarUnshadeButton;
823 case PseudoElement_TitleBarCloseButton:
824 case PseudoElement_TitleBarSysMenu:
831 if (
info.element == PseudoElement_TitleBar) {
832 info.width = tb->fontMetrics.horizontalAdvance(tb->text) + 6;
833 subRule.geo =
new QStyleSheetGeometryData(
info.width, tb->fontMetrics.height(), -1, -1, -1, -1);
835 subRule = renderRule(
w, tb,
info.element);
836 info.width = subRule.size().width();
843 infos.append(std::move(
info));
847 for (
const ButtonInfo &
info :
std::as_const(infos)) {
849 switch (
info.where) {
854 r.moveCenter(lr.center());
855 r.setLeft(
r.left()+
info.offset);
856 r.setWidth(
info.width);
860 lr.translate(
info.offset, 0);
861 lr.setWidth(
info.width);
865 lr.setWidth(
info.width);
871 layoutRects[control] = positionRect(
w,
info.rule,
info.element, lr, tb->direction);
895QRenderRule::QRenderRule(
const QList<Declaration> &declarations,
const QObject *
object)
910 features =
v.extractStyleFeatures();
912 int w = -1,
h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1;
913 if (
v.extractGeometry(&
w, &
h, &minw, &minh, &maxw, &maxh))
914 geo =
new QStyleSheetGeometryData(
w,
h, minw, minh, maxw, maxh);
920 Qt::Alignment textAlignment;
924 int margins[4], paddings[4],
spacing = -1;
925 for (
int i = 0;
i < 4;
i++)
926 margins[
i] = paddings[
i] = 0;
927 if (
v.extractBox(margins, paddings, &
spacing))
928 b =
new QStyleSheetBoxData(margins, paddings,
spacing);
934 for (
int i = 0;
i < 4;
i++) {
938 if (
v.extractBorder(borders,
colors, styles, radii))
939 bd =
new QStyleSheetBorderData(borders,
colors, styles, radii);
942 for (
int i = 0;
i < 4;
i++) {
947 ou =
new QStyleSheetOutlineData(borders,
colors, styles, radii,
offsets);
964 QBrush selectedForeground;
965 QBrush selectedBackground;
966 QBrush alternateBackground;
967 QBrush placeHolderTextForeground;
969 if (
v.extractPalette(&foreground, &selectedForeground, &selectedBackground,
970 &alternateBackground, &placeHolderTextForeground, &accent)) {
971 pal =
new QStyleSheetPaletteData(foreground, selectedForeground, selectedBackground,
972 alternateBackground, placeHolderTextForeground, accent);
978 if (
v.extractImage(&imgIcon, &
alignment, &imgSize))
979 img =
new QStyleSheetImageData(imgIcon,
alignment, imgSize);
987 hasFont =
v.extractFont(&
font, &adj);
989#if QT_CONFIG(tooltip)
990 if (
object &&
qstrcmp(
object->metaObject()->className(),
"QTipLabel") == 0)
994 for (
int i = 0;
i < declarations.size();
i++) {
996 if (decl.
d->propertyId == BorderImage) {
1002 if (uri.
isEmpty() || uri ==
"none"_L1) {
1007 bd =
new QStyleSheetBorderData;
1009 bd->bi =
new QStyleSheetBorderImageData;
1011 QStyleSheetBorderImageData *bi = bd->bi;
1012 bi->pixmap = QStyleSheetStyle::loadPixmap(uri,
object);
1013 for (
int i = 0;
i < 4;
i++)
1014 bi->cuts[
i] = cuts[
i];
1015 bi->horizStretch = horizStretch;
1016 bi->vertStretch = vertStretch;
1018 }
else if (decl.
d->propertyId == QtBackgroundRole) {
1021 int role = decl.
d->values.at(0).variant.toInt();
1022 if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
1026 }
else if (decl.
d->propertyId == UnknownProperty) {
1027 bool knownStyleHint =
false;
1028 for (
const auto sh : knownStyleHints) {
1030 if (decl.
d->property.compare(styleHint) == 0) {
1033 if (hintName.endsWith(
"alignment"_L1)) {
1035 }
else if (hintName.endsWith(
"color"_L1)) {
1037 }
else if (hintName.endsWith(
"size"_L1)) {
1039 const QString valueString = decl.
d->values.at(0).variant.toString();
1053 qreal emexSize = {};
1054 if (decl.
realValue(&emexSize, isEmSize ?
"em" :
"ex") && emexSize > 0) {
1055 pixelSize *= emexSize;
1056 const QSizeF newSize(pixelSize, pixelSize);
1057 decl.
d->parsed = QVariant::fromValue<QSizeF>(newSize);
1058 hintValue = newSize;
1060 qWarning(
"Invalid '%s' size for %s. Skipping.",
1061 isEmSize ?
"em" :
"ex",
qPrintable(valueString));
1067 }
else if (hintName.endsWith(
"icon"_L1)) {
1069 }
else if (hintName ==
"button-layout"_L1 && decl.
d->values.size() != 0
1071 hintValue = subControlLayout(decl.
d->values.at(0).variant.toString().toLatin1());
1077 styleHints[decl.
d->property] = hintValue;
1078 knownStyleHint =
true;
1082 if (!knownStyleHint)
1088 if (
const QWidget *
widget = qobject_cast<const QWidget *>(
object)) {
1093 fixupBorder(style->nativeFrameWidth(
widget));
1095 if (
border()->hasBorderImage())
1096 defaultBackground =
QBrush();
1100QRect QRenderRule::borderRect(
const QRect&
r)
const
1104 const int*
m =
box()->margins;
1105 return r.
adjusted(
m[LeftEdge],
m[TopEdge], -
m[RightEdge], -
m[BottomEdge]);
1108QRect QRenderRule::outlineRect(
const QRect&
r)
const
1110 QRect br = borderRect(
r);
1113 const int *
b = outline()->borders;
1114 return r.
adjusted(
b[LeftEdge],
b[TopEdge], -
b[RightEdge], -
b[BottomEdge]);
1117QRect QRenderRule::paddingRect(
const QRect&
r)
const
1119 QRect br = borderRect(
r);
1122 const int *
b =
border()->borders;
1123 return br.
adjusted(
b[LeftEdge],
b[TopEdge], -
b[RightEdge], -
b[BottomEdge]);
1126QRect QRenderRule::contentsRect(
const QRect&
r)
const
1128 QRect pr = paddingRect(
r);
1131 const int *
p =
box()->paddings;
1132 return pr.adjusted(
p[LeftEdge],
p[TopEdge], -
p[RightEdge], -
p[BottomEdge]);
1139 if (
flags & Margin) {
1140 const int *
m =
box()->margins;
1141 r.
adjust(-
m[LeftEdge], -
m[TopEdge],
m[RightEdge],
m[BottomEdge]);
1143 if (
flags & Padding) {
1144 const int *
p =
box()->paddings;
1145 r.adjust(-
p[LeftEdge], -
p[TopEdge],
p[RightEdge],
p[BottomEdge]);
1148 if (hasBorder() && (
flags & Border)) {
1149 const int *
b =
border()->borders;
1150 r.adjust(-
b[LeftEdge], -
b[TopEdge],
b[RightEdge],
b[BottomEdge]);
1159 if (cs.
height() < 0) bs.setHeight(-1);
1163void QRenderRule::fixupBorder(
int nativeWidth)
1168 if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
1172 const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
1173 || bd->radii[2].isValid() || bd->radii[3].isValid();
1174 for (
int i = 0;
i < 4;
i++) {
1175 if ((bd->styles[
i] == BorderStyle_Native) && hasRadius)
1178 switch (bd->styles[
i]) {
1185 if (bd->borders[
i] == 0)
1186 bd->borders[
i] = nativeWidth;
1199 QStyleSheetBorderImageData *bi = bd->bi;
1200 if (bi->cuts[0] == -1) {
1201 for (
int i = 0;
i < 4;
i++)
1202 bi->cuts[
i] =
int(
border()->borders[
i]);
1212 const QStyleSheetBorderImageData *borderImageData =
border()->borderImage();
1213 const int *targetBorders =
border()->borders;
1214 const int *sourceBorders = borderImageData->cuts;
1215 QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
1216 sourceBorders[RightEdge], sourceBorders[BottomEdge]);
1217 QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
1218 targetBorders[RightEdge], targetBorders[BottomEdge]);
1223 QRect(
QPoint(), borderImageData->pixmap.size()), sourceMargins,
1224 QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
1233 return paddingRect(
rect);
1235 return borderRect(
rect);
1237 return contentsRect(
rect);
1246 if (!hasBackground())
1249 const QPixmap& bgp = background()->pixmap;
1255 if (background()->origin != background()->clip) {
1260 if (background()->
attachment == Attachment_Fixed)
1263 QSize bgpSize = bgp.size() / bgp.devicePixelRatio();
1264 int bgpHeight = bgpSize.
height();
1265 int bgpWidth = bgpSize.width();
1266 QRect r = originRect(
rect, background()->origin);
1270 switch (background()->repeat) {
1272 p->drawTiledPixmap(inter.x(),
r.y(), inter.width(),
r.height(), bgp,
1274 bgpHeight -
int(
aligned.y() -
r.y()) % bgpHeight + off.
y());
1277 p->drawTiledPixmap(
r.x(), inter.y(),
r.width(), inter.height(), bgp,
1278 bgpWidth -
int(
aligned.x() -
r.x())%bgpWidth + off.
x(),
1279 inter.y() -
aligned.y() + off.
y());
1282 p->drawTiledPixmap(
r, bgp,
1284 bgpHeight -
int(
aligned.y() -
r.y())%bgpHeight + off.
y()));
1288 p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() -
aligned.x() + off.
x(),
1289 inter.y() -
aligned.y() + off.
y(), bgp.width() , bgp.height());
1294 if (background()->origin != background()->clip)
1316 if (
border()->hasBorderImage()) {
1317 drawBorderImage(
p,
rect);
1332 QSize tlr, trr, blr, brr;
1334 if (tlr.isNull() && trr.isNull() && blr.isNull() && brr.isNull())
1338 const int *borders =
border()->borders;
1341 path.moveTo(
rect.x() + tlr.width(), curY);
1342 path.lineTo(
rect.right() - trr.width(), curY);
1344 path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
1345 trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
1347 path.lineTo(curX,
rect.bottom() - brr.height());
1349 path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
1350 brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
1352 path.lineTo(
rect.x() + blr.width(), curY);
1354 path.arcTo(curX,
rect.bottom() - 2*blr.height() + borders[BottomEdge]/2.0,
1355 blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);
1357 path.lineTo(curX,
rect.top() + tlr.height());
1358 path.arcTo(curX,
rect.top() + borders[TopEdge]/2.0,
1359 tlr.width()*2 - borders[LeftEdge], tlr.height()*2 - borders[TopEdge], 180, -90);
1361 path.closeSubpath();
1372 clipPath = borderClip(
rect);
1373 if (!clipPath.isEmpty()) {
1383 if (!clipPath.isEmpty())
1391 brush = defaultBackground;
1397 if (!borderPath.isEmpty()) {
1401 p->fillPath(borderPath,
brush);
1404 p->fillRect(originRect(
rect, origin),
brush);
1408 drawBackgroundImage(
p,
rect, off);
1415 drawBorder(
p, borderRect(
rect));
1436 p->setBrush(br, bg->brush);
1451 p->setBrush(fr, pal->foreground);
1455 if (pal->selectionBackground.style() !=
Qt::NoBrush)
1457 if (pal->selectionForeground.style() !=
Qt::NoBrush)
1459 if (pal->alternateBackground.style() !=
Qt::NoBrush)
1467 if (widgetPalette.isBrushSet(
group, role))
1478 p->setBrush(cg,
w->backgroundRole(), bg->brush);
1485 if ((hasBackground() && background()->isTransparent())
1486 || (hasBorder() &&
border()->hasBorderImage() && !
border()->borderImage()->
pixmap.isNull()))
1495 setDefault(
p, cg,
w->foregroundRole(), pal->foreground,
w);
1498 QColor phColor(pal->foreground.color());
1499 phColor.setAlpha((phColor.alpha() + 1) / 2);
1500 QBrush placeholder = pal->foreground;
1504 if (pal->selectionBackground.style() !=
Qt::NoBrush)
1506 if (pal->selectionForeground.style() !=
Qt::NoBrush)
1508 if (pal->alternateBackground.style() !=
Qt::NoBrush)
1510 if (pal->placeholderForeground.style() !=
Qt::NoBrush)
1516bool QRenderRule::hasModification()
const
1518 return hasPalette() ||
1520 hasGradientBackground() ||
1521 !hasNativeBorder() ||
1522 !hasNativeOutline() ||
1528 !styleHints.isEmpty();
1533#define OBJECT_PTR(x) (static_cast<QObject *>(x.ptr))
1537#if QT_CONFIG(tooltip)
1538 if (qobject_cast<const QLabel *>(
obj) &&
qstrcmp(
obj->metaObject()->className(),
"QTipLabel") == 0) {
1539 QObject *
p = qvariant_cast<QObject *>(
obj->property(
"_q_stylesheet_parent"));
1544 return obj->parent();
1550 QStyleSheetStyleSelector() { }
1552 QStringList nodeNames(NodePtr node)
const override
1554 if (isNullNode(node))
1557#if QT_CONFIG(tooltip)
1570 if (isNullNode(node))
1574 QHash<QString, QString> &
cache = m_attributeCache[OBJECT_PTR(node)];
1576 if (cacheIt !=
cache.constEnd())
1577 return cacheIt.value();
1582 const int propertyIndex =
obj->metaObject()->indexOfProperty(
name.toLatin1());
1583 if (propertyIndex == -1) {
1585 if (!
value.isValid()) {
1586 if (
name ==
"class"_L1) {
1591 }
else if (
name ==
"style"_L1) {
1606 value.convert(QMetaType::fromType<int>());
1609 if (
value.isValid()) {
1610 valueStr = (
value.userType() == QMetaType::QStringList
1611 ||
value.userType() == QMetaType::QVariantList)
1612 ?
value.toStringList().join(u
' ')
1618 bool nodeNameEquals(NodePtr node,
const QString& nodeName)
const override
1620 if (isNullNode(node))
1623#if QT_CONFIG(tooltip)
1625 return nodeName ==
"QToolTip"_L1;
1628 const auto *uc =
reinterpret_cast<const char16_t *
>(nodeName.
constData());
1629 const auto *e = uc + nodeName.
size();
1631 while (*
c && uc != e && (*uc == *
c || (*
c ==
':' && *uc ==
'-'))) {
1641 bool hasAttributes(NodePtr)
const override
1645 bool isNullNode(NodePtr node)
const override
1646 {
return node.ptr ==
nullptr; }
1647 NodePtr parentNode(NodePtr node)
const override
1648 { NodePtr
n;
n.ptr = isNullNode(node) ?
nullptr : parentObject(OBJECT_PTR(node));
return n; }
1649 NodePtr previousSiblingNode(NodePtr)
const override
1650 { NodePtr
n;
n.ptr =
nullptr;
return n; }
1651 NodePtr duplicateNode(NodePtr node)
const override
1653 void freeNode(NodePtr)
const override
1657 mutable QHash<const QObject *, QHash<QString, QString> > m_attributeCache;
1660QList<QCss::StyleRule> QStyleSheetStyle::styleRules(
const QObject *
obj)
const
1662 QHash<const QObject *, QList<StyleRule>>::const_iterator cacheIt =
1663 styleSheetCaches->styleRulesCache.constFind(
obj);
1664 if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
1665 return cacheIt.
value();
1667 if (!initObject(
obj)) {
1668 return QList<StyleRule>();
1671 QStyleSheetStyleSelector styleSelector;
1675 if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1676 defaultSs = getDefaultStyleSheet();
1678 styleSheetCaches->styleSheetCache.insert(bs, defaultSs);
1682 defaultSs = defaultCacheIt.value();
1684 styleSelector.styleSheets += defaultSs;
1686 if (!
qApp->styleSheet().isEmpty()) {
1689 if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1691 if (ss.startsWith(
"file:///"_L1))
1693 parser.
init(ss,
qApp->styleSheet() != ss);
1695 qWarning(
"Could not parse application stylesheet");
1698 styleSheetCaches->styleSheetCache.insert(
qApp, appSs);
1700 appSs = appCacheIt.value();
1702 styleSelector.styleSheets += appSs;
1705 QList<QCss::StyleSheet> objectSs;
1707 QString styleSheet =
o->property(
"styleSheet").toString();
1712 if (objCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
1713 parser.
init(styleSheet);
1714 if (!parser.
parse(&ss)) {
1715 parser.
init(
"* {"_L1 + styleSheet + u
'}');
1717 qWarning() <<
"Could not parse stylesheet of object" <<
o;
1720 styleSheetCaches->styleSheetCache.insert(
o, ss);
1722 ss = objCacheIt.value();
1724 objectSs.append(ss);
1727 for (
int i = 0;
i < objectSs.size();
i++)
1728 objectSs[
i].
depth = objectSs.size() -
i + 2;
1730 styleSelector.styleSheets += objectSs;
1734 QList<QCss::StyleRule> rules = styleSelector.styleRulesForNode(
n);
1735 styleSheetCaches->styleRulesCache.insert(
obj, rules);
1741static QList<Declaration> declarations(
const QList<StyleRule> &styleRules,
const QString &part,
1742 quint64 pseudoClass = PseudoClass_Unspecified)
1744 QList<Declaration> decls;
1745 for (
int i = 0;
i < styleRules.size();
i++) {
1753 if ((pseudoClass == PseudoClass_Any) || (cssClass == PseudoClass_Unspecified)
1754 || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
1755 decls += styleRules.at(
i).declarations;
1760int QStyleSheetStyle::nativeFrameWidth(
const QWidget *
w)
1764#if QT_CONFIG(spinbox)
1765 if (qobject_cast<const QAbstractSpinBox *>(
w))
1769#if QT_CONFIG(combobox)
1770 if (qobject_cast<const QComboBox *>(
w))
1775 if (qobject_cast<const QMenu *>(
w))
1779#if QT_CONFIG(menubar)
1780 if (qobject_cast<const QMenuBar *>(
w))
1784 if (
const QFrame *
frame = qobject_cast<const QFrame *>(
w)) {
1790 if (
qstrcmp(
w->metaObject()->className(),
"QTipLabel") == 0)
1827 pc |= PseudoClass_Open;
1838#ifdef QT_KEYPAD_NAVIGATION
1839 if (
state & QStyle::State_HasEditFocus)
1845static void qt_check_if_internal_object(
const QObject **
obj,
int *element)
1847#if !QT_CONFIG(dockwidget)
1851 if (*
obj &&
qstrcmp((*obj)->metaObject()->className(),
"QDockWidgetTitleButton") == 0) {
1852 if ((*obj)->objectName() ==
"qt_dockwidget_closebutton"_L1) {
1853 *element = PseudoElement_DockWidgetCloseButton;
1854 }
else if ((*obj)->objectName() ==
"qt_dockwidget_floatbutton"_L1) {
1855 *element = PseudoElement_DockWidgetFloatButton;
1857 *
obj = (*obj)->parent();
1864 qt_check_if_internal_object(&
obj, &element);
1865 QHash<quint64, QRenderRule> &
cache = styleSheetCaches->renderRulesCache[
obj][element];
1867 if (cacheIt !=
cache.constEnd())
1868 return cacheIt.value();
1870 if (!initObject(
obj))
1874 const QList<StyleRule> rules = styleRules(
obj);
1875 for (
int i = 0;
i < rules.size();
i++) {
1878 stateMask |=
selector.pseudoClass(&negated);
1879 stateMask |= negated;
1882 cacheIt =
cache.constFind(
state & stateMask);
1883 if (cacheIt !=
cache.constEnd()) {
1891 QList<Declaration> decls = declarations(rules, part,
state);
1905 if (pseudoElement != PseudoElement_None) {
1909 if (!(complex->activeSubControls & subControl))
1913 switch (pseudoElement) {
1914 case PseudoElement_ComboBoxDropDown:
1915 case PseudoElement_ComboBoxArrow:
1918 case PseudoElement_SpinBoxUpButton:
1919 case PseudoElement_SpinBoxDownButton:
1920 case PseudoElement_SpinBoxUpArrow:
1921 case PseudoElement_SpinBoxDownArrow:
1922#if QT_CONFIG(spinbox)
1923 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
1925 bool up = pseudoElement == PseudoElement_SpinBoxUpButton
1926 || pseudoElement == PseudoElement_SpinBoxUpArrow;
1935 case PseudoElement_GroupBoxTitle:
1938 case PseudoElement_ToolButtonMenu:
1939 case PseudoElement_ToolButtonMenuArrow:
1940 case PseudoElement_ToolButtonMenuIndicator:
1946 case PseudoElement_SliderGroove:
1956 if (pseudoElement == PseudoElement_None
1964 if (!combo->editable)
1968#if QT_CONFIG(spinbox)
1969 }
else if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
1976 if (gb->lineWidth == 0)
1995 extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked)
2013#if QT_CONFIG(tabwidget)
2014 }
else if (
const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
opt)) {
2015 switch (tab->shape) {
2036#if QT_CONFIG(tabbar)
2037 }
else if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
2038 if (tab->position == QStyleOptionTab::OnlyOneTab)
2040 else if (tab->position == QStyleOptionTab::Beginning)
2042 else if (tab->position == QStyleOptionTab::End)
2044 else if (tab->position == QStyleOptionTab::Middle)
2047 if (tab->selectedPosition == QStyleOptionTab::NextIsSelected)
2049 else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
2052 switch (tab->shape) {
2079 if (frm->lineWidth == 0)
2084#if QT_CONFIG(toolbar)
2085 else if (
const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(
opt)) {
2095 if (tb->positionWithinLine == QStyleOptionToolBar::Beginning)
2097 else if (tb->positionWithinLine == QStyleOptionToolBar::Middle)
2099 else if (tb->positionWithinLine == QStyleOptionToolBar::End)
2101 else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
2105#if QT_CONFIG(toolbox)
2122#if QT_CONFIG(dockwidget)
2124 if (dw->verticalTitleBar)
2136#if QT_CONFIG(itemviews)
2137 else if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
2138 if (vopt->features & QStyleOptionViewItem::Alternate)
2140 if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne)
2142 else if (vopt->viewItemPosition == QStyleOptionViewItem::Beginning)
2144 else if (vopt->viewItemPosition == QStyleOptionViewItem::End)
2146 else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
2151#if QT_CONFIG(textedit)
2159#if QT_CONFIG(lineedit)
2164 extraClass &= ~PseudoClass_Frameless;
2170 if (
const QFrame *frm = qobject_cast<const QFrame *>(
obj)) {
2171 if (frm->lineWidth() == 0)
2172 extraClass |= PseudoClass_Frameless;
2176 return renderRule(
obj, pseudoElement, pseudoClass(
state) | extraClass);
2179bool QStyleSheetStyle::hasStyleRule(
const QObject *
obj,
int part)
const
2181 QHash<int, bool> &
cache = styleSheetCaches->hasStyleRuleCache[
obj];
2183 if (cacheIt !=
cache.constEnd())
2184 return cacheIt.value();
2186 if (!initObject(
obj))
2189 const QList<StyleRule> &rules = styleRules(
obj);
2190 if (part == PseudoElement_None) {
2197 for (
int i = 0;
i < rules.size();
i++) {
2205 cache[part] =
false;
2209static Origin defaultOrigin(
int pe)
2212 case PseudoElement_ScrollBarAddPage:
2213 case PseudoElement_ScrollBarSubPage:
2214 case PseudoElement_ScrollBarAddLine:
2215 case PseudoElement_ScrollBarSubLine:
2216 case PseudoElement_ScrollBarFirst:
2217 case PseudoElement_ScrollBarLast:
2218 case PseudoElement_GroupBoxTitle:
2219 case PseudoElement_GroupBoxIndicator:
2220 case PseudoElement_ToolButtonMenu:
2221 case PseudoElement_SliderAddPage:
2222 case PseudoElement_SliderSubPage:
2225 case PseudoElement_SpinBoxUpButton:
2226 case PseudoElement_SpinBoxDownButton:
2227 case PseudoElement_PushButtonMenuIndicator:
2228 case PseudoElement_ComboBoxDropDown:
2229 case PseudoElement_ToolButtonMenuIndicator:
2230 case PseudoElement_MenuCheckMark:
2231 case PseudoElement_MenuIcon:
2232 case PseudoElement_MenuRightArrow:
2235 case PseudoElement_Indicator:
2236 case PseudoElement_ExclusiveIndicator:
2237 case PseudoElement_ComboBoxArrow:
2238 case PseudoElement_ScrollBarSlider:
2239 case PseudoElement_ScrollBarUpArrow:
2240 case PseudoElement_ScrollBarDownArrow:
2241 case PseudoElement_ScrollBarLeftArrow:
2242 case PseudoElement_ScrollBarRightArrow:
2243 case PseudoElement_SpinBoxUpArrow:
2244 case PseudoElement_SpinBoxDownArrow:
2245 case PseudoElement_ToolButtonMenuArrow:
2246 case PseudoElement_HeaderViewUpArrow:
2247 case PseudoElement_HeaderViewDownArrow:
2248 case PseudoElement_SliderGroove:
2249 case PseudoElement_SliderHandle:
2257static Qt::Alignment defaultPosition(
int pe)
2260 case PseudoElement_Indicator:
2261 case PseudoElement_ExclusiveIndicator:
2262 case PseudoElement_MenuCheckMark:
2263 case PseudoElement_MenuIcon:
2266 case PseudoElement_ScrollBarAddLine:
2267 case PseudoElement_ScrollBarLast:
2268 case PseudoElement_SpinBoxDownButton:
2269 case PseudoElement_PushButtonMenuIndicator:
2270 case PseudoElement_ToolButtonMenuIndicator:
2273 case PseudoElement_ScrollBarSubLine:
2274 case PseudoElement_ScrollBarFirst:
2275 case PseudoElement_SpinBoxUpButton:
2276 case PseudoElement_ComboBoxDropDown:
2277 case PseudoElement_ToolButtonMenu:
2278 case PseudoElement_DockWidgetCloseButton:
2279 case PseudoElement_DockWidgetFloatButton:
2282 case PseudoElement_ScrollBarUpArrow:
2283 case PseudoElement_ScrollBarDownArrow:
2284 case PseudoElement_ScrollBarLeftArrow:
2285 case PseudoElement_ScrollBarRightArrow:
2286 case PseudoElement_SpinBoxUpArrow:
2287 case PseudoElement_SpinBoxDownArrow:
2288 case PseudoElement_ComboBoxArrow:
2289 case PseudoElement_DownArrow:
2290 case PseudoElement_UpArrow:
2291 case PseudoElement_LeftArrow:
2292 case PseudoElement_RightArrow:
2293 case PseudoElement_ToolButtonMenuArrow:
2294 case PseudoElement_SliderGroove:
2297 case PseudoElement_GroupBoxTitle:
2298 case PseudoElement_GroupBoxIndicator:
2301 case PseudoElement_HeaderViewUpArrow:
2302 case PseudoElement_HeaderViewDownArrow:
2303 case PseudoElement_MenuRightArrow:
2316 case PseudoElement_Indicator:
2317 case PseudoElement_MenuCheckMark:
2318 if (sz.
width() == -1)
2324 case PseudoElement_ExclusiveIndicator:
2325 case PseudoElement_GroupBoxIndicator:
2326 if (sz.
width() == -1)
2332 case PseudoElement_PushButtonMenuIndicator: {
2334 if (sz.
width() == -1)
2341 case PseudoElement_ComboBoxDropDown:
2342 if (sz.
width() == -1)
2346 case PseudoElement_ComboBoxArrow:
2347 case PseudoElement_DownArrow:
2348 case PseudoElement_UpArrow:
2349 case PseudoElement_LeftArrow:
2350 case PseudoElement_RightArrow:
2351 case PseudoElement_ToolButtonMenuArrow:
2352 case PseudoElement_ToolButtonMenuIndicator:
2353 case PseudoElement_MenuRightArrow:
2354 if (sz.
width() == -1)
2360 case PseudoElement_SpinBoxUpButton:
2361 case PseudoElement_SpinBoxDownButton:
2362 if (sz.
width() == -1)
2368 case PseudoElement_ToolButtonMenu:
2369 if (sz.
width() == -1)
2373 case PseudoElement_HeaderViewUpArrow:
2374 case PseudoElement_HeaderViewDownArrow: {
2376 if (sz.
width() == -1)
2383 case PseudoElement_ScrollBarFirst:
2384 case PseudoElement_ScrollBarLast:
2385 case PseudoElement_ScrollBarAddLine:
2386 case PseudoElement_ScrollBarSubLine:
2387 case PseudoElement_ScrollBarSlider: {
2389 if (sz.
width() == -1)
2396 case PseudoElement_DockWidgetCloseButton:
2397 case PseudoElement_DockWidgetFloatButton: {
2409 if (sz.
width() == -1)
2418 case PseudoElement_ScrollBarFirst:
2419 case PseudoElement_ScrollBarLast:
2420 case PseudoElement_ScrollBarAddLine:
2421 case PseudoElement_ScrollBarSubLine:
2422 case PseudoElement_ScrollBarAddPage:
2423 case PseudoElement_ScrollBarSubPage:
2424 case PseudoElement_ScrollBarSlider:
2425 case PseudoElement_SliderGroove:
2426 case PseudoElement_SliderHandle:
2427 case PseudoElement_TabWidgetPane:
2434QRect QStyleSheetStyle::positionRect(
const QWidget *
w,
const QRenderRule &rule2,
int pe,
2437 const QStyleSheetPositionData *
p = rule2.position();
2439 Qt::Alignment
position = (
p &&
p->position != 0) ?
p->position : defaultPosition(pe);
2442 if (
mode != PositionMode_Absolute) {
2443 QSize sz = defaultSize(
w, rule2.size(), originRect, pe);
2444 sz = sz.
expandedTo(rule2.minimumContentsSize());
2447 int left =
p->left ?
p->left : -
p->right;
2448 int top =
p->top ?
p->top : -
p->bottom;
2455 if (rule2.hasContentsSize()) {
2465QRect QStyleSheetStyle::positionRect(
const QWidget *
w,
const QRenderRule& rule1,
const QRenderRule& rule2,
int pe,
2468 const QStyleSheetPositionData *
p = rule2.position();
2470 QRect originRect = rule1.originRect(
rect, origin);
2471 return positionRect(
w, rule2, pe, originRect,
dir);
2481#if QT_CONFIG(combobox)
2482 if (
QComboBox *cmb = qobject_cast<QComboBox *>(
w)) {
2483 if (cmb->isEditable())
2484 return cmb->lineEdit();
2490#if QT_CONFIG(spinbox)
2495#if QT_CONFIG(scrollarea)
2496 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w))
2497 return sa->viewport();
2513#if QT_CONFIG(lineedit)
2514 if (qobject_cast<const QLineEdit *>(
w)) {
2516#if QT_CONFIG(combobox)
2517 if (qobject_cast<const QComboBox *>(
w->parentWidget()))
2520#if QT_CONFIG(spinbox)
2521 if (qobject_cast<const QAbstractSpinBox *>(
w->parentWidget()))
2527#if QT_CONFIG(scrollarea)
2528 if (
const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(
w->parentWidget())) {
2529 if (sa->viewport() ==
w)
2540static bool unstylable(
const QWidget *
w)
2545 if (!
w->styleSheet().isEmpty())
2548 if (containerWidget(
w) !=
w)
2553 else if (qobject_cast<const QFrame *>(
w)) {
2556 || qobject_cast<const QComboBox *>(
w->parentWidget())
2563#if QT_CONFIG(tabbar)
2564 if (
w->metaObject() == &QWidget::staticMetaObject
2565 && qobject_cast<const QTabBar*>(
w->parentWidget()))
2575#if QT_CONFIG(abstractslider)
2576 if (
const QAbstractSlider *slider = qobject_cast<const QAbstractSlider *>(
w)) {
2580#if QT_CONFIG(combobox)
2581 if (
const QComboBox *combo = qobject_cast<const QComboBox *>(
w)) {
2582 if (combo->isEditable())
2586#if QT_CONFIG(lineedit)
2587 if (
const QLineEdit *
edit = qobject_cast<const QLineEdit *>(
w)) {
2591#if QT_CONFIG(textedit)
2592 if (
const QTextEdit *
edit = qobject_cast<const QTextEdit *>(
w)) {
2609void QStyleSheetStyle::setGeometry(
QWidget *
w)
2611 QRenderRule rule = renderRule(
w, PseudoElement_None, PseudoClass_Enabled | extendedPseudoClass(
w));
2612 const QStyleSheetGeometryData *geo =
rule.geometry();
2613 if (
w->property(
"_q_stylesheet_minw").toBool()
2614 && ((!
rule.hasGeometry() || geo->minWidth == -1))) {
2615 w->setMinimumWidth(0);
2618 if (
w->property(
"_q_stylesheet_minh").toBool()
2619 && ((!
rule.hasGeometry() || geo->minHeight == -1))) {
2620 w->setMinimumHeight(0);
2621 w->setProperty(
"_q_stylesheet_minh",
QVariant());
2623 if (
w->property(
"_q_stylesheet_maxw").toBool()
2624 && ((!
rule.hasGeometry() || geo->maxWidth == -1))) {
2626 w->setProperty(
"_q_stylesheet_maxw",
QVariant());
2628 if (
w->property(
"_q_stylesheet_maxh").toBool()
2629 && ((!
rule.hasGeometry() || geo->maxHeight == -1))) {
2631 w->setProperty(
"_q_stylesheet_maxh",
QVariant());
2635 if (
rule.hasGeometry()) {
2636 if (geo->minWidth != -1) {
2637 w->setProperty(
"_q_stylesheet_minw",
true);
2638 w->setMinimumWidth(
rule.boxSize(
QSize(
qMax(geo->width, geo->minWidth), 0)).width());
2640 if (geo->minHeight != -1) {
2641 w->setProperty(
"_q_stylesheet_minh",
true);
2642 w->setMinimumHeight(
rule.boxSize(
QSize(0,
qMax(geo->height, geo->minHeight))).height());
2644 if (geo->maxWidth != -1) {
2645 w->setProperty(
"_q_stylesheet_maxw",
true);
2649 if (geo->maxHeight != -1) {
2650 w->setProperty(
"_q_stylesheet_maxh",
true);
2657void QStyleSheetStyle::setProperties(
QWidget *
w)
2663 const QList<Declaration> decls = declarations(styleRules(
w),
QString());
2668 QDuplicateTracker<QString> propertySet(decls.size());
2669 for (
int i = decls.size() - 1;
i >= 0; --
i) {
2670 const QString property = decls.at(
i).d->property;
2673 if (!propertySet.hasSeen(
property))
2678 for (
int i = finals.size() - 1;
i >= 0; --
i) {
2681 property =
property.mid(10);
2682 const auto propertyL1 =
property.toLatin1();
2698 switch (
value.userType()) {
2699 case QMetaType::QIcon:
v = decl.
iconValue();
break;
2702 case QMetaType::QRect:
v = decl.
rectValue();
break;
2703 case QMetaType::QSize:
v = decl.
sizeValue();
break;
2704 case QMetaType::QColor:
v = decl.
colorValue();
break;
2705 case QMetaType::QBrush:
v = decl.
brushValue();
break;
2706#ifndef QT_NO_SHORTCUT
2707 case QMetaType::QKeySequence:
v =
QKeySequence(decl.
d->values.at(0).variant.toString());
break;
2709 default:
v = decl.
d->values.at(0).variant;
break;
2715 w->setProperty(propertyL1,
v);
2719void QStyleSheetStyle::setPalette(
QWidget *
w)
2721 struct RuleRoleMap {
2730 const bool useStyleSheetPropagationInWidgetStyles =
2734 if (!useStyleSheetPropagationInWidgetStyles)
2739 for (
int i = 0;
i < 3;
i++) {
2742 if (!
w->property(
"_q_styleSheetWidgetFont").isValid()) {
2753 if (!useStyleSheetPropagationInWidgetStyles ||
p.resolveMask() != 0) {
2755 styleSheetCaches->customPaletteWidgets.insert(
w, {wp,
p.
resolveMask()});
2757 if (useStyleSheetPropagationInWidgetStyles) {
2768void QStyleSheetStyle::unsetPalette(
QWidget *
w)
2770 const bool useStyleSheetPropagationInWidgetStyles =
2773 const auto it = styleSheetCaches->customPaletteWidgets.
find(
w);
2774 if (
it != styleSheetCaches->customPaletteWidgets.
end()) {
2775 auto customizedPalette = std::move(*
it);
2776 styleSheetCaches->customPaletteWidgets.erase(
it);
2779 if (useStyleSheetPropagationInWidgetStyles)
2780 original = std::move(customizedPalette).reverted(
w->palette());
2782 original = customizedPalette.oldWidgetValue;
2784 w->setPalette(original);
2787 ew->setPalette(original);
2790 if (useStyleSheetPropagationInWidgetStyles) {
2791 unsetStyleSheetFont(
w);
2794 unsetStyleSheetFont(ew);
2796 QVariant oldFont =
w->property(
"_q_styleSheetWidgetFont");
2797 if (oldFont.isValid()) {
2798 w->setFont(qvariant_cast<QFont>(oldFont));
2802 if (styleSheetCaches->autoFillDisabledWidgets.contains(
w)) {
2803 embeddedWidget(
w)->setAutoFillBackground(
true);
2804 styleSheetCaches->autoFillDisabledWidgets.remove(
w);
2808void QStyleSheetStyle::unsetStyleSheetFont(
QWidget *
w)
const
2810 const auto it = styleSheetCaches->customFontWidgets.
find(
w);
2811 if (
it != styleSheetCaches->customFontWidgets.
end()) {
2812 auto customizedFont = std::move(*
it);
2813 styleSheetCaches->customFontWidgets.erase(
it);
2814 w->setFont(std::move(customizedFont).reverted(
w->font()));
2818static void updateObjects(
const QList<const QObject *>& objects)
2820 if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
2821 for (
const QObject *
object : objects) {
2822 styleSheetCaches->styleRulesCache.remove(
object);
2823 styleSheetCaches->hasStyleRuleCache.remove(
object);
2824 styleSheetCaches->renderRulesCache.remove(
object);
2829 for (
const QObject *
object : objects) {
2830 if (
auto widget = qobject_cast<QWidget*>(
const_cast<QObject*
>(
object))) {
2833 QList<const QObject *> children;
2837 updateObjects(children);
2847 : QWindowsStyle(*new QStyleSheetStylePrivate),
base(
base), refcount(1)
2850 if (numinstances == 1) {
2859 delete styleSheetCaches;
2891bool QStyleSheetStyle::initObject(
const QObject *
obj)
const
2895 if (
const QWidget *
w = qobject_cast<const QWidget*>(
obj)) {
2912 RECURSION_GUARD(
return)
2917 if (styleSheetCaches->styleRulesCache.contains(
w)) {
2920 styleSheetCaches->styleRulesCache.remove(
w);
2921 styleSheetCaches->hasStyleRuleCache.remove(
w);
2922 styleSheetCaches->renderRulesCache.remove(
w);
2923 styleSheetCaches->styleSheetCache.remove(
w);
2931 QList<StyleRule> rules = styleRules(
w);
2932 for (
int i = 0;
i < rules.size();
i++) {
2936 if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) {
2939 embeddedWidget(
w)->setMouseTracking(
true);
2944#if QT_CONFIG(scrollarea)
2945 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w)) {
2946 QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled);
2947 if ((
rule.hasBorder() &&
rule.border()->hasBorderImage())
2948 || (
rule.hasBackground() && !
rule.background()->pixmap.isNull())) {
2961 if (
rule.hasDrawable() ||
rule.hasBox()) {
2962 if (
w->metaObject() == &QWidget::staticMetaObject
2964 || qobject_cast<QHeaderView *>(
w)
2967 || qobject_cast<QTabBar *>(
w)
2970 || qobject_cast<QFrame *>(
w)
2973 || qobject_cast<QMainWindow *>(
w)
2976 || qobject_cast<QMdiSubWindow *>(
w)
2979 || qobject_cast<QMenuBar *>(
w)
2982 || qobject_cast<QDialog *>(
w)
2988 if (ew->autoFillBackground()) {
2989 ew->setAutoFillBackground(
false);
2990 styleSheetCaches->autoFillDisabledWidgets.insert(
w);
2996 if (!
rule.hasBackground() ||
rule.background()->isTransparent() ||
rule.hasBox()
2997 || (!
rule.hasNativeBorder() && !
rule.border()->isOpaque()))
2999 if (
rule.hasBox() || !
rule.hasNativeBorder()
3001 || (qobject_cast<QPushButton *>(
w))
3020 QList<const QObject *> children;
3021 children.reserve(
w->children().size() + 1);
3022 for (
auto child:
std::as_const(
w->children()))
3025 styleSheetCaches->styleSheetCache.remove(
w);
3026 updateObjects(children);
3032 const QList<const QObject*> allObjects = styleSheetCaches->styleRulesCache.keys();
3033 styleSheetCaches->styleSheetCache.remove(
qApp);
3034 styleSheetCaches->styleRulesCache.clear();
3035 styleSheetCaches->hasStyleRuleCache.clear();
3036 styleSheetCaches->renderRulesCache.clear();
3037 updateObjects(allObjects);
3047 styleSheetCaches->styleRulesCache.remove(
w);
3048 styleSheetCaches->hasStyleRuleCache.remove(
w);
3049 styleSheetCaches->renderRulesCache.remove(
w);
3050 styleSheetCaches->styleSheetCache.remove(
w);
3055 w->disconnect(
this);
3056#if QT_CONFIG(scrollarea)
3057 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w)) {
3070 RECURSION_GUARD(
return)
3071 styleSheetCaches->styleRulesCache.clear();
3072 styleSheetCaches->hasStyleRuleCache.clear();
3073 styleSheetCaches->renderRulesCache.clear();
3074 styleSheetCaches->styleSheetCache.remove(
qApp);
3089 if (
rule.hasNativeBorder()) {
3090 rule.drawBackgroundImage(
p, cmbOpt.rect);
3093 && (hasStyleRule(
w, PseudoElement_ComboBoxDropDown) || hasStyleRule(
w, PseudoElement_ComboBoxArrow));
3095 cmbOpt.subControls &=
~QStyle::SC_ComboBoxArrow;
3096 if (
rule.baseStyleCanDraw()) {
3099 QWindowsStyle::drawComplexControl(cc, &cmbOpt,
p,
w);
3101 if (!customDropDown)
3108 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
3109 if (subRule.hasDrawable()) {
3111 subRule.drawRule(
p,
r);
3112 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_ComboBoxArrow);
3113 r = positionRect(
w, subRule, subRule2, PseudoElement_ComboBoxArrow,
r,
opt->
direction);
3114 subRule2.drawRule(
p,
r);
3118 QWindowsStyle::drawComplexControl(cc, &cmbOpt,
p,
w);
3126#if QT_CONFIG(spinbox)
3128 if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
3129 QStyleOptionSpinBox spinOpt(*spin);
3133 bool customUp =
true, customDown =
true;
3134 QRenderRule upRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
3135 QRenderRule downRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
3136 bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
3137 bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
3138 if (
rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
3139 rule.drawBackgroundImage(
p, spinOpt.rect);
3141 && (hasStyleRule(
w, PseudoElement_SpinBoxUpButton) || hasStyleRule(
w, PseudoElement_UpArrow));
3143 spinOpt.subControls &=
~QStyle::SC_SpinBoxUp;
3145 && (hasStyleRule(
w, PseudoElement_SpinBoxDownButton) || hasStyleRule(
w, PseudoElement_DownArrow));
3147 spinOpt.subControls &=
~QStyle::SC_SpinBoxDown;
3148 if (
rule.baseStyleCanDraw()) {
3151 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3153 if (!customUp && !customDown)
3160 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
3161 if (subRule.hasDrawable()) {
3163 subRule.drawRule(
p,
r);
3164 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SpinBoxUpArrow);
3165 r = positionRect(
w, subRule, subRule2, PseudoElement_SpinBoxUpArrow,
r,
opt->
direction);
3166 subRule2.drawRule(
p,
r);
3169 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3174 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
3175 if (subRule.hasDrawable()) {
3177 subRule.drawRule(
p,
r);
3178 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SpinBoxDownArrow);
3179 r = positionRect(
w, subRule, subRule2, PseudoElement_SpinBoxDownArrow,
r,
opt->
direction);
3180 subRule2.drawRule(
p,
r);
3183 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3194 QRect labelRect, checkBoxRect, titleRect, frameRect;
3197 if (!
rule.hasDrawable() && (!hasTitle || !hasStyleRule(
w, PseudoElement_GroupBoxTitle))
3198 && !hasStyleRule(
w, PseudoElement_Indicator) && !
rule.hasBox() && !
rule.hasFont && !
rule.hasPalette()) {
3204 QRenderRule titleRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
3205 bool clipSet =
false;
3210 labelRect.setSize(labelRect.size().expandedTo(ParentStyle::subControlRect(CC_GroupBox,
opt, SC_GroupBoxLabel,
w).size()));
3213 titleRect = titleRule.boxRect(checkBoxRect.united(labelRect));
3215 titleRect = titleRule.boxRect(labelRect);
3217 if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) {
3226 frame.QStyleOption::operator=(*gb);
3227 frame.features = gb->features;
3238 titleRule.drawRule(
p, titleRect);
3243 box.QStyleOption::operator=(*gb);
3249 if (!gb->text.isEmpty()) {
3256 if (gb->textColor.isValid())
3262 if (gb->state & State_HasFocus) {
3264 fropt.QStyleOption::operator=(*gb);
3265 fropt.
rect = labelRect;
3278 toolOpt.font =
rule.font.resolve(toolOpt.font);
3280 const auto customArrowElement = [tool]{
3281 switch (tool->arrowType) {
3288 return PseudoElement_None;
3293 bool customArrow = drawArrow && hasStyleRule(
w, customArrowElement());
3299 bool customDropDown = drawDropDown && hasStyleRule(
w, PseudoElement_ToolButtonMenu);
3300 bool customDropDownArrow =
false;
3302 if (customDropDown) {
3303 toolOpt.subControls &=
~QStyle::SC_ToolButtonMenu;
3304 customDropDownArrow = hasStyleRule(
w, PseudoElement_ToolButtonMenuArrow);
3305 if (customDropDownArrow)
3308 const bool customMenuIndicator = (!drawDropDown && drawMenuIndicator)
3309 && hasStyleRule(
w, PseudoElement_ToolButtonMenuIndicator);
3310 if (customMenuIndicator)
3313 if (
rule.hasNativeBorder()) {
3314 if (tool->subControls & SC_ToolButton) {
3318 State bflags = tool->state & ~State_Sunken;
3319 if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled)))
3320 bflags &= ~State_Raised;
3321 if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton)
3322 bflags |= State_Sunken;
3323 if (!(bflags & (State_Sunken | State_On | State_Raised)))
3324 rule.drawBackground(
p, toolOpt.rect);
3329 if (customMenuIndicator)
3331 if (customDropDown || customDropDownArrow)
3337 QWindowsStyle::drawComplexControl(cc, &nativeToolOpt,
p,
w);
3340 drawMenuIndicator =
false;
3342 drawDropDown =
false;
3347 toolOpt.font =
rule.font.resolve(toolOpt.font);
3351 const QRect cr = toolOpt.rect;
3355 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
3357 if (subRule.hasDrawable()) {
3358 subRule.drawRule(
p, menuButtonRect);
3360 toolOpt.rect = menuButtonRect;
3364 if (customDropDownArrow || drawMenuIndicator) {
3365 QRenderRule arrowRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuArrow);
3366 QRect arrowRect = arrowRule.hasGeometry()
3367 ? positionRect(
w, arrowRule, PseudoElement_ToolButtonMenuArrow, menuButtonRect, toolOpt.direction)
3368 : arrowRule.contentsRect(menuButtonRect);
3369 if (arrowRule.hasDrawable()) {
3370 arrowRule.drawRule(
p, arrowRect);
3372 toolOpt.rect = arrowRect;
3377 }
else if (drawMenuIndicator) {
3378 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuIndicator);
3382 QRect r = positionRect(
w,
rule, subRule, PseudoElement_ToolButtonMenuIndicator,
opt->
rect, toolOpt.direction);
3383 if (subRule.hasDrawable()) {
3384 subRule.drawRule(
p,
r);
3395 const auto arrowElement = customArrowElement();
3397 QRect arrowRect = subRule.hasGeometry() ? positionRect(
w, subRule, arrowElement, toolOpt.rect, toolOpt.direction)
3398 : subRule.contentsRect(toolOpt.
rect);
3400 switch (toolOpt.toolButtonStyle) {
3408 toolOpt.text = tool->text;
3409 if (!subRule.hasGeometry())
3412 if (!subRule.hasGeometry())
3421 subRule.drawRule(
p, arrowRect);
3427#if QT_CONFIG(scrollbar)
3429 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
3430 if (!
rule.hasDrawable()) {
3431 QStyleOptionSlider sbOpt(*sb);
3437 QWindowsStyle::drawComplexControl(cc,
opt,
p,
w);
3444#if QT_CONFIG(slider)
3446 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
3449 QRenderRule grooveSubRule = renderRule(
w,
opt, PseudoElement_SliderGroove);
3450 QRenderRule handleSubRule = renderRule(
w,
opt, PseudoElement_SliderHandle);
3451 if (!grooveSubRule.hasDrawable()) {
3452 QStyleOptionSlider slOpt(*slider);
3453 bool handleHasRule = handleSubRule.hasDrawable();
3456 slOpt.subControls &= ~SC_SliderHandle;
3463 if (slider->subControls & SC_SliderGroove) {
3464 grooveSubRule.drawRule(
p, gr);
3467 if (slider->subControls & SC_SliderHandle) {
3470 QRenderRule subRule1 = renderRule(
w,
opt, PseudoElement_SliderSubPage);
3471 if (subRule1.hasDrawable()) {
3474 ?
QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1)
3476 subRule1.drawRule(
p,
r);
3479 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SliderAddPage);
3480 if (subRule2.hasDrawable()) {
3482 ?
QPoint(hr.x()+hr.width()/2+1, gr.y())
3485 subRule2.drawRule(
p,
r);
3488 handleSubRule.drawRule(
p, handleSubRule.boxRect(hr, Margin));
3491 if (slider->subControls & SC_SliderTickmarks) {
3500 case CC_MdiControls:
3501 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
3502 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
3503 || hasStyleRule(
w, PseudoElement_MdiMinButton)) {
3504 QList<QVariant>
layout =
rule.styleHint(
"button-layout"_L1).toList();
3506 layout = subControlLayout(
"mNX");
3509 optCopy.subControls = { };
3511 int layoutButton =
val.toInt();
3512 if (layoutButton < PseudoElement_MdiCloseButton
3513 || layoutButton > PseudoElement_MdiNormalButton)
3516 if (!(
opt->subControls & control))
3519 if (subRule.hasDrawable()) {
3521 subRule.drawRule(
p,
rect);
3525 optCopy.subControls |= control;
3529 if (optCopy.subControls)
3538 if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
3541 QHash<QStyle::SubControl, QRect>
layout = titleBarLayout(
w, tb);
3542 const auto paintDeviceDpr =
p->device()->devicePixelRatio();
3545 ir =
layout[SC_TitleBarLabel];
3547 if (subRule.hasPalette())
3548 p->setPen(subRule.palette()->foreground.color());
3553 ir =
layout[SC_TitleBarSysMenu];
3555 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_TitleBarSysMenu);
3556 subSubRule.drawRule(
p, ir);
3557 ir = subSubRule.contentsRect(ir);
3558 if (!tb->icon.isNull()) {
3559 tb->icon.paint(
p, ir);
3563 const auto pm =
standardIcon(SP_TitleBarMenuButton,
nullptr,
w)
3564 .
pixmap(sz, paintDeviceDpr);
3569 ir =
layout[SC_TitleBarCloseButton];
3571 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_TitleBarCloseButton);
3572 subSubRule.drawRule(
p, ir);
3574 const QSize sz = subSubRule.contentsRect(ir).size();
3576 ? SP_DockWidgetCloseButton : SP_TitleBarCloseButton;
3581 constexpr std::array<int, 6> pes = {
3582 PseudoElement_TitleBarMaxButton,
3583 PseudoElement_TitleBarMinButton,
3584 PseudoElement_TitleBarNormalButton,
3585 PseudoElement_TitleBarShadeButton,
3586 PseudoElement_TitleBarUnshadeButton,
3587 PseudoElement_TitleBarContextHelpButton
3590 for (
int pe : pes) {
3596 subSubRule.drawRule(
p, ir);
3597 const QSize sz = subSubRule.contentsRect(ir).size();
3615 const QRect &
rect, QRenderRule &subRule)
const
3626 const int pixh =
pixmap.height() /
pixmap.devicePixelRatio();
3627 QRenderRule iconRule = renderRule(
w, mi, PseudoElement_MenuIcon);
3628 if (!iconRule.hasGeometry()) {
3629 iconRule.geo =
new QStyleSheetGeometryData(pixw, pixh, pixw, pixh, -1, -1);
3631 iconRule.geo->width = pixw;
3632 iconRule.geo->height = pixh;
3634 QRect iconRect = positionRect(
w, subRule, iconRule, PseudoElement_MenuIcon,
rect, mi->direction);
3636 iconRect.moveLeft(iconRect.left());
3638 iconRect.moveRight(iconRect.right());
3639 iconRule.drawRule(
p, iconRect);
3640 QRect pmr(0, 0, pixw, pixh);
3641 pmr.moveCenter(iconRect.center());
3642 p->drawPixmap(pmr.topLeft(),
pixmap);
3651 int pe1 = PseudoElement_None, pe2 = PseudoElement_None;
3652 bool fallback =
false;
3655 case CE_ToolButtonLabel:
3658 QWindowsStyle::drawControl(ce,
opt,
p,
w);
3669 if (!
rule.hasNativeBorder()) {
3677 if (
rule.hasDrawable() ||
rule.hasBox() ||
rule.hasPosition() ||
rule.hasPalette() ||
3679 ParentStyle::drawControl(ce,
opt,
p,
w);
3684 case CE_PushButtonBevel:
3688 if (
rule.hasNativeBorder()) {
3689 rule.drawBackgroundImage(
p, btnOpt.rect);
3692 && hasStyleRule(
w, PseudoElement_PushButtonMenuIndicator));
3695 if (
rule.baseStyleCanDraw()) {
3698 QWindowsStyle::drawControl(ce, &btnOpt,
p,
w);
3708 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_PushButtonMenuIndicator);
3709 QRect ir = positionRect(
w,
rule, subRule, PseudoElement_PushButtonMenuIndicator,
3711 if (subRule.hasDrawable()) {
3712 subRule.drawRule(
p, ir);
3721 case CE_PushButtonLabel:
3726 const QFont oldFont =
p->font();
3728 p->setFont(
rule.font.resolve(
p->font()));
3730 if (
rule.hasPosition() ||
rule.hasIcon()) {
3737 if (
rule.hasPosition() &&
rule.position()->textAlignment != 0) {
3738 Qt::Alignment textAlignment =
rule.position()->textAlignment;
3739 tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) :
Qt::AlignVCenter;
3740 tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) :
Qt::AlignHCenter;
3755 if (
button->state & State_On)
3761 int pixmapHeight =
pixmap.height() /
pixmap.devicePixelRatio();
3762 int labelWidth = pixmapWidth;
3763 int labelHeight = pixmapHeight;
3764 int iconSpacing = 4;
3767 labelWidth += (textWidth + iconSpacing);
3772 pixmapWidth, pixmapHeight);
3776 pixmapWidth, pixmapHeight);
3780 pixmapWidth, pixmapHeight);
3786 tf &= ~horizontalAlignMask;
3794 if (
button->state & (State_On | State_Sunken))
3797 p->drawPixmap(iconRect,
pixmap);
3800 if (
button->state & (State_On | State_Sunken))
3814 ParentStyle::drawControl(ce, &butOpt,
p,
w);
3818 p->setFont(oldFont);
3822 case CE_RadioButton:
3824 if (
rule.hasBox() || !
rule.hasNativeBorder() ||
rule.hasDrawable() || hasStyleRule(
w, PseudoElement_Indicator)) {
3826 ParentStyle::drawControl(ce,
opt,
p,
w);
3835 case CE_RadioButtonLabel:
3836 case CE_CheckBoxLabel:
3840 ParentStyle::drawControl(ce, &butOpt,
p,
w);
3845 pe1 = PseudoElement_SplitterHandle;
3849 if (
rule.hasBackground()) {
3852 if (
rule.hasBorder()) {
3855#if QT_CONFIG(toolbar)
3856 if (
const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(
opt)) {
3857 QStyleOptionToolBar newTb(*tb);
3865 case CE_MenuEmptyArea:
3866 case CE_MenuBarEmptyArea:
3867 if (
rule.hasDrawable()) {
3873 case CE_MenuTearoff:
3874 case CE_MenuScroller:
3877 int pe = ce == CE_MenuTearoff ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
3879 mi.rect = subRule.contentsRect(
opt->
rect);
3883 if (subRule.hasDrawable()) {
3897 mi.rect = subRule.contentsRect(
opt->
rect);
3902 QFont oldFont =
p->font();
3903 if (subRule.hasFont)
3904 p->setFont(subRule.font.resolve(mi.font));
3906 p->setFont(mi.font);
3910 QRenderRule allRules = renderRule(
w, PseudoElement_Item, PseudoClass_Any);
3912 if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
3914 }
else if ((pseudo == PseudoElement_Item)
3915 && (allRules.hasBox() || allRules.hasBorder() || subRule.hasFont
3916 || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
3918 if (subRule.hasBackground()) {
3926 int textRectOffset =
m->maxIconWidth;
3927 if (!mi.icon.isNull()) {
3928 renderMenuItemIcon(&mi,
p,
w,
opt->
rect, subRule);
3929 }
else if (mi.menuHasCheckableItems) {
3931 const bool checked = checkable ? mi.checked :
false;
3933 const QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
3935 if (checkable && (subSubRule.hasDrawable() || checked)) {
3938 newMi.
state |= State_Enabled;
3940 newMi.state |= State_On;
3941 newMi.rect = cmRect;
3944 textRectOffset = std::max(textRectOffset, cmRect.width());
3953 p->setPen(mi.palette.buttonText().color());
3956 if (!
styleHint(SH_UnderlineShortcut, &mi,
w))
3962 p->drawText(vShortcutRect, text_flags,
s.mid(
t + 1).toString());
3965 p->drawText(vTextRect, text_flags,
s.left(
t).toString());
3970 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_MenuRightArrow);
3971 mi.rect = positionRect(
w, subRule, subRule2, PseudoElement_MenuRightArrow,
opt->
rect, mi.direction);
3974 }
else if (!mi.icon.isNull() && hasStyleRule(
w, PseudoElement_MenuIcon)) {
3980 if (
rule.baseStyleCanDraw() && subRule.baseStyleCanDraw())
3983 ParentStyle::drawControl(ce, &newMi,
p,
w);
3984 renderMenuItemIcon(&mi,
p,
w,
opt->
rect, subRule);
3985 }
else if (hasStyleRule(
w, PseudoElement_MenuCheckMark) || hasStyleRule(
w, PseudoElement_MenuRightArrow)) {
3986 QWindowsStyle::drawControl(ce, &mi,
p,
w);
3990 int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
3992 if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
3998 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
3999 if (subSubRule.hasDrawable()) {
4002 mi.rect.y() + QWindowsStylePrivate::windowsItemFrame,
4003 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
4004 mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
4013 if (
rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
4016 ParentStyle::drawControl(ce, &mi,
p,
w);
4020 p->setFont(oldFont);
4026 case CE_MenuBarItem:
4030 mi.rect = subRule.contentsRect(
opt->
rect);
4034 if (subRule.hasDrawable()) {
4048#if QT_CONFIG(combobox)
4049 case CE_ComboBoxLabel:
4055 p->setClipRect(editRect);
4056 if (!
cb->currentIcon.isNull()) {
4061 const auto paintDeviceDpr =
p->device()->devicePixelRatio();
4063 QRect iconRect(editRect);
4064 iconRect.setWidth(
cb->iconSize.width());
4067 iconRect.size(), editRect);
4071 editRect.translate(-
spacing -
cb->iconSize.width(), 0);
4073 editRect.translate(
cb->iconSize.width() +
spacing, 0);
4075 if (!
cb->currentText.isEmpty() && !
cb->editable) {
4078 drawItemText(
p, editRect.adjusted(0, 0, 0, 0),
cb->textAlignment, styledPalette,
4088 if (hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)
4089 || hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)) {
4090 ParentStyle::drawControl(ce,
opt,
p,
w);
4093 if (hasStyleRule(
w, PseudoElement_HeaderViewSection)) {
4094 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4095 if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
4096 || subRule.hasBackground() || subRule.hasPalette() || subRule.hasFont || subRule.hasBorder()) {
4097 ParentStyle::drawControl(ce,
opt,
p,
w);
4102 case CE_HeaderSection:
4104 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4105 if (subRule.hasNativeBorder()) {
4109 if (subRule.baseStyleCanDraw()) {
4112 QWindowsStyle::drawControl(CE_HeaderSection, &hdr,
p,
w);
4121 case CE_HeaderLabel:
4125 if (
auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(
opt))
4129 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4130 if (hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)
4131 || hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)) {
4141 if (subRule.hasFont) {
4142 QFont oldFont =
p->font();
4143 p->setFont(subRule.font.resolve(
p->font()));
4144 ParentStyle::drawControl(ce, &hdr,
p,
w);
4145 p->setFont(oldFont);
4153 case CE_HeaderEmptyArea:
4154 if (
rule.hasDrawable()) {
4159 case CE_ProgressBar:
4160 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4163 case CE_ProgressBarGroove:
4164 if (!
rule.hasNativeBorder()) {
4170 case CE_ProgressBarContents: {
4171 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ProgressBarChunk);
4172 if (subRule.hasDrawable()) {
4175 p->setClipRect(pb->rect);
4181 bool inverted = pb->invertedAppearance;
4188 m.translate(0, -(
rect.height() +
rect.y()*2));
4191 bool reverse = ((!vertical && (pb->direction ==
Qt::RightToLeft)) || vertical);
4194 const bool indeterminate = pb->minimum == pb->maximum;
4195 const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (
maximum -
minimum);
4196 const auto fillWidth =
static_cast<int>(
rect.width() * fillRatio);
4197 int chunkWidth = fillWidth;
4198 if (subRule.hasContentsSize()) {
4199 QSize sz = subRule.size();
4204#if QT_CONFIG(animation)
4205 Q_D(
const QWindowsStyle);
4207 if (pb->minimum == 0 && pb->maximum == 0) {
4208 int chunkCount = fillWidth/chunkWidth;
4210#if QT_CONFIG(animation)
4216 int x = reverse ?
r.left() +
r.width() -
offset - chunkWidth :
r.x() +
offset;
4217 while (chunkCount > 0) {
4218 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4220 subRule.drawRule(
p,
r);
4221 x += reverse ? -chunkWidth : chunkWidth;
4228 x = reverse ?
r.right() - (
r.left() -
x - chunkWidth)
4230 while (chunkCount > 0) {
4231 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4233 subRule.drawRule(
p,
r);
4234 x += reverse ? -chunkWidth : chunkWidth;
4237 }
else if (chunkWidth > 0) {
4238 const auto ceil = [](
qreal x) {
return int(
x) + (
x > 0 &&
x != int(
x)); };
4239 const int chunkCount = ceil(
qreal(fillWidth)/chunkWidth);
4240 int x = reverse ?
r.left() +
r.width() - chunkWidth :
r.x();
4242 for (
int i = 0;
i < chunkCount; ++
i) {
4243 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4245 subRule.drawRule(
p,
r);
4246 x += reverse ? -chunkWidth : chunkWidth;
4248#if QT_CONFIG(animation)
4260 case CE_ProgressBarLabel:
4262 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_ProgressBarChunk)) {
4276 if (
rule.hasDrawable()) {
4279 static constexpr int rotation[] = { 180, 270, 90, 0 };
4280 if (rotation[sgOpt->corner]) {
4282 p->rotate(rotation[sgOpt->corner]);
4297 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4300 case CE_ToolBoxTabShape: {
4302 if (subRule.hasDrawable()) {
4309 case CE_ToolBoxTabLabel:
4314 QFont oldFont =
p->font();
4315 if (subRule.hasFont)
4316 p->setFont(subRule.font.resolve(
p->font()));
4317 boxCopy.rect = subRule.contentsRect(
opt->
rect);
4318 if (subRule.hasImage()) {
4321 boxCopy.rect.setLeft(boxCopy.rect.left() + iconExtent);
4323 QWindowsStyle::drawControl(ce, &boxCopy,
p ,
w);
4324 if (subRule.hasFont)
4325 p->setFont(oldFont);
4330 case CE_ScrollBarAddPage:
4331 pe1 = PseudoElement_ScrollBarAddPage;
4334 case CE_ScrollBarSubPage:
4335 pe1 = PseudoElement_ScrollBarSubPage;
4338 case CE_ScrollBarAddLine:
4339 pe1 = PseudoElement_ScrollBarAddLine;
4344 case CE_ScrollBarSubLine:
4345 pe1 = PseudoElement_ScrollBarSubLine;
4350 case CE_ScrollBarFirst:
4351 pe1 = PseudoElement_ScrollBarFirst;
4354 case CE_ScrollBarLast:
4355 pe1 = PseudoElement_ScrollBarLast;
4358 case CE_ScrollBarSlider:
4359 pe1 = PseudoElement_ScrollBarSlider;
4363#if QT_CONFIG(itemviews)
4364 case CE_ItemViewItem:
4365 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4367 QStyleOptionViewItem optCopy(*vopt);
4368 if (subRule.hasDrawable()) {
4371 QWindowsStyle::drawControl(ce, &optCopy,
p,
w);
4374 if (hasStyleRule(
w, PseudoElement_Indicator)) {
4378 QStyleOptionViewItem optIndicator(*vopt);
4379 subRule.configurePalette(&optIndicator.palette,
4388 optIndicator.text.clear();
4389 optIndicator.icon =
QIcon();
4390 QWindowsStyle::drawControl(ce, &optIndicator,
p,
w);
4402 - crStyle.united(crBase);
4403 p->setClipRegion(clipRegion);
4414#if QT_CONFIG(tabbar)
4416 if (hasStyleRule(
w, PseudoElement_TabBarTab)) {
4417 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4422 case CE_TabBarTabLabel:
4423 case CE_TabBarTabShape:
4424 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
4429 subRule.drawRule(
p,
r);
4432 QStyleOptionTab tabCopy(*tab);
4433 subRule.configurePalette(&tabCopy.palette, foregroundRole,
QPalette::Base);
4434 QFont oldFont =
p->font();
4435 if (subRule.hasFont)
4436 p->setFont(subRule.font.resolve(
p->font()));
4437 if (subRule.hasBox() || !subRule.hasNativeBorder()) {
4438 tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(
r)
4439 : subRule.contentsRect(
r);
4440 QWindowsStyle::drawControl(ce, &tabCopy,
p,
w);
4444 if (subRule.hasFont)
4445 p->setFont(oldFont);
4452 case CE_ColumnViewGrip:
4453 if (
rule.hasDrawable()) {
4459 case CE_DockWidgetTitle:
4461 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
4462 if (!subRule.hasDrawable() && !subRule.hasPosition())
4464 if (subRule.hasDrawable()) {
4472 if (!dwOpt->title.isEmpty()) {
4474 if (dwOpt->verticalTitleBar) {
4477 p->translate(
r.left(),
r.top() +
r.width());
4479 p->translate(-
r.left(), -
r.top());
4481 r = subRule.contentsRect(
r);
4484 if (subRule.hasPosition())
4485 alignment = subRule.position()->textAlignment;
4492 dwOpt->state & State_Enabled, titleText,
4495 if (dwOpt->verticalTitleBar)
4502 case CE_ShapedFrame:
4504 if (
rule.hasNativeBorder()) {
4507 frmOpt.rect =
rule.borderRect(frmOpt.rect);
4519 if (pe1 != PseudoElement_None) {
4521 if (subRule.bg !=
nullptr || subRule.hasDrawable()) {
4525 }
else if (fallback) {
4526 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4527 pe2 = PseudoElement_None;
4531 if (pe2 != PseudoElement_None) {
4534 subSubRule.drawRule(
p,
r);
4559 int pseudoElement = PseudoElement_None;
4565 case PE_FrameStatusBarItem: {
4567 if (subRule.hasDrawable()) {
4574 case PE_IndicatorArrowDown:
4575 pseudoElement = PseudoElement_DownArrow;
4578 case PE_IndicatorArrowUp:
4579 pseudoElement = PseudoElement_UpArrow;
4582 case PE_IndicatorRadioButton:
4583 pseudoElement = PseudoElement_ExclusiveIndicator;
4586 case PE_IndicatorItemViewItemCheck:
4587 pseudoElement = PseudoElement_ViewItemIndicator;
4590 case PE_IndicatorCheckBox:
4591 pseudoElement = PseudoElement_Indicator;
4594 case PE_IndicatorHeaderArrow:
4597 ? PseudoElement_HeaderViewUpArrow
4598 : PseudoElement_HeaderViewDownArrow;
4602 case PE_PanelButtonTool:
4603 case PE_PanelButtonCommand:
4604#if QT_CONFIG(abstractbutton)
4605 if (qobject_cast<const QAbstractButton *>(
w) &&
rule.hasBackground() &&
rule.hasNativeBorder()) {
4607 ParentStyle::drawPrimitive(pe,
opt,
p,
w);
4608 if (!
rule.background()->pixmap.isNull() ||
rule.hasImage()) {
4609 rule.drawRule(
p,
rule.boxRect(
opt->
rect, QRenderRule::Margin).adjusted(1,1,-1,-1));
4614 if (!
rule.hasNativeBorder()) {
4620 case PE_IndicatorButtonDropDown: {
4621 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
4622 if (!subRule.hasNativeBorder()) {
4629 case PE_FrameDefaultButton:
4630 if (
rule.hasNativeBorder()) {
4631 if (
rule.baseStyleCanDraw())
4633 QWindowsStyle::drawPrimitive(pe,
opt,
p,
w);
4637 case PE_FrameWindow:
4638 case PE_FrameDockWidget:
4641 if (
rule.hasNativeBorder()) {
4651 case PE_PanelLineEdit:
4655 if (
QWidget *container = containerWidget(
w); container !=
w) {
4657 if (!containerRule.hasNativeBorder() || !containerRule.baseStyleCanDraw())
4659 rule = containerRule;
4663 if (
rule.hasNativeBorder()) {
4666 frmOpt.rect =
rule.borderRect(frmOpt.rect);
4667 if (
rule.baseStyleCanDraw()) {
4672 if (frmOpt.lineWidth > 0)
4682 if (
w && !
rule.hasDrawable()) {
4683 QWidget *container = containerWidget(
w);
4684 if (styleSheetCaches->autoFillDisabledWidgets.contains(container)
4685 && (container ==
w || !renderRule(container,
opt).hasBackground())) {
4692#if QT_CONFIG(scrollarea)
4693 if (
const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(
w)) {
4694 const QAbstractScrollAreaPrivate *sap = sa->d_func();
4695 rule.drawBackground(
p,
opt->
rect, sap->contentsOffset());
4696 if (
rule.hasBorder()) {
4699 QRect r = brect.
adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
4700 sa->horizontalScrollBar()->
isVisible() ? -sa->horizontalScrollBar()->
height() : 0);
4703 rule.drawBorder(
p, brect);
4710 case PE_PanelStatusBar:
4711 if (
rule.hasDrawable()) {
4718 if (
rule.hasDrawable()) {
4724 case PE_PanelMenuBar:
4725 if (
rule.hasDrawable()) {
4731 case PE_IndicatorToolBarSeparator:
4732 case PE_IndicatorToolBarHandle: {
4733 PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator;
4735 if (subRule.hasDrawable()) {
4742 case PE_IndicatorMenuCheckMark:
4743 pseudoElement = PseudoElement_MenuCheckMark;
4746 case PE_IndicatorArrowLeft:
4747 pseudoElement = PseudoElement_LeftArrow;
4750 case PE_IndicatorArrowRight:
4751 pseudoElement = PseudoElement_RightArrow;
4754 case PE_IndicatorColumnViewArrow:
4755#if QT_CONFIG(itemviews)
4756 if (
const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4758 pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow;
4762 pseudoElement = PseudoElement_RightArrow;
4766#if QT_CONFIG(itemviews)
4767 case PE_IndicatorBranch:
4768 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4769 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_TreeViewBranch);
4770 if (subRule.hasDrawable()) {
4771 proxy()->drawPrimitive(PE_PanelItemViewRow, vopt,
p,
w);
4780 case PE_PanelTipLabel:
4781 if (!
rule.hasDrawable())
4785 if (
rule.hasNativeBorder()) {
4797 case PE_FrameGroupBox:
4798 if (
rule.hasNativeBorder())
4803#if QT_CONFIG(tabwidget)
4804 case PE_FrameTabWidget:
4805 if (
const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
opt)) {
4806 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_TabWidgetPane);
4807 if (subRule.hasNativeBorder()) {
4808 subRule.drawBackground(
p,
opt->
rect);
4809 QStyleOptionTabWidgetFrame frmCopy(*frm);
4820 case PE_IndicatorProgressChunk:
4821 pseudoElement = PseudoElement_ProgressBarChunk;
4824 case PE_IndicatorTabTear:
4825 pseudoElement = PseudoElement_TabBarTear;
4828 case PE_FrameFocusRect:
4829 if (!
rule.hasNativeOutline()) {
4835 case PE_IndicatorDockWidgetResizeHandle:
4836 pseudoElement = PseudoElement_DockWidgetSeparator;
4839 case PE_PanelItemViewRow:
4847 if (renderRule(
w,
opt, PseudoElement_ViewItem).hasBackground())
4848 pseudoElement = PseudoElement_ViewItem;
4850 case PE_PanelItemViewItem:
4851 pseudoElement = PseudoElement_ViewItem;
4854 case PE_PanelScrollAreaCorner:
4855 pseudoElement = PseudoElement_ScrollAreaCorner;
4858 case PE_IndicatorSpinDown:
4859 case PE_IndicatorSpinMinus:
4860 pseudoElement = PseudoElement_SpinBoxDownArrow;
4863 case PE_IndicatorSpinUp:
4864 case PE_IndicatorSpinPlus:
4865 pseudoElement = PseudoElement_SpinBoxUpArrow;
4867#if QT_CONFIG(tabbar)
4868 case PE_IndicatorTabClose:
4873 w =
w->parentWidget();
4875 pseudoElement = PseudoElement_TabBarTabCloseButton;
4883 if (pseudoElement != PseudoElement_None) {
4885 if (subRule.hasDrawable()) {
4886 subRule.drawRule(
p,
rect);
4912 if (
rule.hasDrawable() ||
rule.hasBox() ||
rule.hasBorder()) {
4913 QHash<QStyle::SubControl, QRect>
layout = titleBarLayout(
w, tb);
4916 uint ctrl = SC_TitleBarSysMenu;
4917 while (ctrl <= SC_TitleBarLabel) {
4919 if (
r.isValid() &&
r.contains(pt)) {
4930 case CC_MdiControls:
4931 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
4932 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
4933 || hasStyleRule(
w, PseudoElement_MdiMinButton))
4934 return QWindowsStyle::hitTestComplexControl(cc,
opt, pt,
w);
4937 case CC_ScrollBar: {
4939 if (!
rule.hasDrawable() && !
rule.hasBox())
4948 return QWindowsStyle::hitTestComplexControl(cc,
opt, pt,
w);
4975 case PM_MenuButtonIndicator:
4976#if QT_CONFIG(toolbutton)
4978 if (qobject_cast<const QToolButton *>(
w)) {
4979 if (
rule.hasBox() || !
rule.hasNativeBorder())
4981 if (
const auto *tbOpt = qstyleoption_cast<const QStyleOptionToolButton*>(
opt)) {
4983 subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
4985 subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuIndicator);
4986 if (subRule.hasContentsSize())
4987 return subRule.size().width();
4992 subRule = renderRule(
w,
opt, PseudoElement_PushButtonMenuIndicator);
4993 if (subRule.hasContentsSize())
4994 return subRule.size().width();
4997 case PM_ButtonShiftHorizontal:
4998 case PM_ButtonShiftVertical:
4999 case PM_ButtonMargin:
5000 case PM_ButtonDefaultIndicator:
5005 case PM_DefaultFrameWidth:
5006 if (!
rule.hasNativeBorder())
5010 case PM_ExclusiveIndicatorWidth:
5011 case PM_IndicatorWidth:
5012 case PM_ExclusiveIndicatorHeight:
5013 case PM_IndicatorHeight:
5014 subRule = renderRule(
w,
opt, PseudoElement_Indicator);
5015 if (subRule.hasContentsSize()) {
5016 return (
m == PM_ExclusiveIndicatorWidth) || (
m == PM_IndicatorWidth)
5017 ? subRule.size().width() : subRule.size().height();
5021 case PM_DockWidgetFrameWidth:
5022 case PM_ToolTipLabelFrameWidth:
5023 if (!
rule.hasDrawable())
5029 case PM_ToolBarFrameWidth:
5030 if (
rule.hasBorder() ||
rule.hasBox())
5035 case PM_MenuPanelWidth:
5036 case PM_MenuBarPanelWidth:
5037 if (
rule.hasBorder() ||
rule.hasBox())
5043 case PM_MenuHMargin:
5044 case PM_MenuBarHMargin:
5049 case PM_MenuVMargin:
5050 case PM_MenuBarVMargin:
5055 case PM_DockWidgetTitleBarButtonMargin:
5056 case PM_ToolBarItemMargin:
5061 case PM_ToolBarItemSpacing:
5062 case PM_MenuBarItemSpacing:
5063 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5064 return rule.box()->spacing;
5067 case PM_MenuTearoffHeight:
5068 case PM_MenuScrollerHeight: {
5069 PseudoElement ps =
m == PM_MenuTearoffHeight ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
5070 subRule = renderRule(
w,
opt, ps);
5071 if (subRule.hasContentsSize())
5072 return subRule.size().height();
5076 case PM_ToolBarExtensionExtent:
5079 case PM_SplitterWidth:
5080 case PM_ToolBarSeparatorExtent:
5081 case PM_ToolBarHandleExtent: {
5083 if (
m == PM_ToolBarHandleExtent) ps = PseudoElement_ToolBarHandle;
5084 else if (
m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle;
5085 else ps = PseudoElement_ToolBarSeparator;
5086 subRule = renderRule(
w,
opt, ps);
5087 if (subRule.hasContentsSize()) {
5088 QSize sz = subRule.size();
5094 case PM_RadioButtonLabelSpacing:
5095 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5096 return rule.box()->spacing;
5098 case PM_CheckBoxLabelSpacing:
5099#if QT_CONFIG(checkbox)
5100 if (qobject_cast<const QCheckBox *>(
w)) {
5101 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5102 return rule.box()->spacing;
5106 subRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
5107 if (subRule.hasBox() && subRule.box()->spacing != -1)
5108 return subRule.box()->spacing;
5111#if QT_CONFIG(scrollbar)
5112 case PM_ScrollBarExtent:
5113 if (
rule.hasContentsSize()) {
5115 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt))
5121 case PM_ScrollBarSliderMin:
5122 if (hasStyleRule(
w, PseudoElement_ScrollBarSlider)) {
5123 subRule = renderRule(
w,
opt, PseudoElement_ScrollBarSlider);
5124 QSize msz = subRule.minimumSize();
5125 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt))
5127 return msz.width() == -1 ? msz.height() : msz.width();
5131 case PM_ScrollView_ScrollBarSpacing:
5132 if (!
rule.hasNativeBorder() ||
rule.hasBox())
5136 case PM_ScrollView_ScrollBarOverlap:
5143 case PM_ProgressBarChunkWidth:
5144 subRule = renderRule(
w,
opt, PseudoElement_ProgressBarChunk);
5145 if (subRule.hasContentsSize()) {
5146 QSize sz = subRule.size();
5152#if QT_CONFIG(tabwidget)
5153 case PM_TabBarTabHSpace:
5154 case PM_TabBarTabVSpace:
5155 subRule = renderRule(
w,
opt, PseudoElement_TabBarTab);
5156 if (subRule.hasBox() || subRule.hasBorder())
5160 case PM_TabBarScrollButtonWidth:
5161 subRule = renderRule(
w,
opt, PseudoElement_TabBarScroller);
5162 if (subRule.hasContentsSize()) {
5163 QSize sz = subRule.size();
5168 case PM_TabBarTabShiftHorizontal:
5169 case PM_TabBarTabShiftVertical:
5170 subRule = renderRule(
w,
opt, PseudoElement_TabBarTab);
5171 if (subRule.hasBox())
5175 case PM_TabBarBaseOverlap: {
5176 const QWidget *tabWidget = qobject_cast<const QTabWidget *>(
w);
5177 if (!tabWidget &&
w)
5178 tabWidget =
w->parentWidget();
5179 if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) {
5186 case PM_SliderThickness:
5187 case PM_SliderLength:
5188 if (
rule.hasContentsSize()) {
5190 if (
m == PM_SliderThickness) {
5195 return horizontal ? msz.width() : msz.height();
5200 case PM_SliderControlThickness: {
5202 if (!subRule.hasContentsSize())
5208 case PM_ToolBarIconSize:
5209 case PM_ListViewIconSize:
5210 case PM_IconViewIconSize:
5211 case PM_TabBarIconSize:
5212 case PM_MessageBoxIconSize:
5213 case PM_ButtonIconSize:
5214 case PM_SmallIconSize:
5215 if (
rule.hasStyleHint(
"icon-size"_L1))
5216 return rule.styleHint(
"icon-size"_L1).toSize().width();
5219 case PM_DockWidgetTitleMargin: {
5220 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
5221 if (!subRule.hasBox())
5223 return (subRule.border() ? subRule.border()->borders[TopEdge] : 0)
5227 case PM_DockWidgetSeparatorExtent: {
5228 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetSeparator);
5229 if (!subRule.hasContentsSize())
5231 QSize sz = subRule.size();
5235 case PM_TitleBarHeight: {
5237 if (subRule.hasContentsSize())
5238 return subRule.size().height();
5239 else if (subRule.hasBox() || subRule.hasBorder()) {
5246 case PM_MdiSubWindowFrameWidth:
5247 if (
rule.hasBox() ||
rule.hasBorder()) {
5248 return (
rule.border() ?
rule.border()->borders[LeftEdge] : 0)
5253 case PM_MdiSubWindowMinimizedWidth: {
5254 QRenderRule subRule = renderRule(
w, PseudoElement_None, PseudoClass_Minimized);
5255 int width = subRule.size().width();
5276#if QT_CONFIG(spinbox)
5278 if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
5281 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
5282 if (subRule.hasDrawable()) {
5283 QRect r = positionRect(
w,
rule, subRule, PseudoElement_SpinBoxUpButton,
5287 QSize defaultUpSize = defaultSize(
w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton);
5288 sz.
rwidth() += defaultUpSize.width();
5291 if (
rule.hasBox() ||
rule.hasBorder() || !
rule.hasNativeBorder())
5292 sz =
rule.boxSize(sz);
5298 if (
rule.hasBox() || !
rule.hasNativeBorder() || !
rule.baseStyleCanDraw())
5303 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5304 if (ct == CT_ComboBox) {
5306 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5309 sz +=
QSize(comboRect.width() + 2, 0);
5311 return rule.boxSize(sz);
5314 : QWindowsStyle::sizeFromContents(ct,
opt, sz,
w);
5315 return rule.boxSize(sz, Margin);
5317 case CT_HeaderSection: {
5319 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
5320 if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
5321 sz = subRule.adjustSize(csz);
5330 if (!subRule.hasGeometry()) {
5331 QSize nativeContentsSize;
5336 if (subRule.hasFont) {
5337 QFont styleFont =
w ? subRule.font.
resolve(
w->font()) : subRule.font;
5342 nativeContentsSize.setWidth((nullIcon ? 0 : margin) +
iconSize
5346 return subRule.size(sz);
5349 : QWindowsStyle::sizeFromContents(ct,
opt, sz,
w);
5350 if (hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)
5351 || hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)) {
5354 sz.
rwidth() += arrowRect.width();
5356 sz.
rheight() += arrowRect.height();
5364#if QT_CONFIG(spinbox)
5365 if (qobject_cast<QAbstractSpinBox *>(
w ?
w->parentWidget() :
nullptr))
5368 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5369 return rule.boxSize(sz);
5374 case CT_RadioButton:
5376 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
5377 bool isRadio = (ct == CT_RadioButton);
5378 int iw =
pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
5379 : PM_IndicatorWidth,
btn,
w);
5380 int ih =
pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
5381 : PM_IndicatorHeight,
btn,
w);
5384 : PM_CheckBoxLabelSpacing,
btn,
w);
5387 return rule.boxSize(sz);
5395 if (
rule.hasBox() ||
rule.hasBorder())
5402 ? PseudoElement_MenuSeparator : PseudoElement_Item;
5404 if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
5405 return QSize(sz.
width(), subRule.size().height());
5407 if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder() || subRule.hasFont)) {
5409 if (mi->text.contains(u
'\t'))
5411 if (!mi->icon.isNull()) {
5412 const int pmSmall =
pixelMetric(PM_SmallIconSize);
5413 const QSize pmSize = mi->icon.actualSize(
QSize(pmSmall, pmSmall));
5414 sz.
rwidth() += std::max(mi->maxIconWidth, pmSize.width()) + 4;
5415 }
else if (mi->menuHasCheckableItems) {
5416 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
5418 sz.
rwidth() += std::max(mi->maxIconWidth, checkmarkRect.width()) + 4;
5420 sz.
rwidth() += mi->maxIconWidth;
5422 if (subRule.hasFont) {
5427 return subRule.boxSize(subRule.adjustSize(sz));
5433 case CT_MenuBarItem: {
5434 PseudoElement pe = (ct == CT_Splitter) ? PseudoElement_SplitterHandle : PseudoElement_Item;
5436 if (subRule.hasBox() || subRule.hasBorder())
5437 return subRule.boxSize(sz);
5441 case CT_ProgressBar:
5443 return (
rule.hasContentsSize())
5449 if (
rule.hasBorder() ||
rule.hasBox() ||
rule.hasGeometry())
5450 return rule.boxSize(sz);
5453#if QT_CONFIG(tabbar)
5454 case CT_TabBarTab: {
5456 if (subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
5457 int spaceForIcon = 0;
5458 bool vertical =
false;
5460 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
5461 if (!tab->icon.isNull())
5462 spaceForIcon = 6 + 4 + 2 ;
5466 if (subRule.hasBox() || !subRule.hasNativeBorder())
5467 sz = csz +
QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0);
5468 if (subRule.hasFont) {
5480 sz.
rheight() += textSize.width();
5483 sz.
rwidth() += textSize.width();
5488 return subRule.boxSize(subRule.adjustSize(sz));
5490 sz = subRule.adjustSize(csz);
5495 case CT_MdiControls:
5497 if (!hasStyleRule(
w, PseudoElement_MdiCloseButton)
5498 && !hasStyleRule(
w, PseudoElement_MdiNormalButton)
5499 && !hasStyleRule(
w, PseudoElement_MdiMinButton))
5502 QList<QVariant>
layout =
rule.styleHint(
"button-layout"_L1).toList();
5504 layout = subControlLayout(
"mNX");
5508 int layoutButton =
val.toInt();
5509 if (layoutButton < PseudoElement_MdiCloseButton
5510 || layoutButton > PseudoElement_MdiNormalButton)
5513 if (!(ccOpt->subControls & sc))
5516 QSize sz = subRule.size();
5525#if QT_CONFIG(itemviews)
5526 case CT_ItemViewItem: {
5529 sz = subRule.adjustSize(sz);
5530 if (subRule.hasBox() || subRule.hasBorder())
5531 sz = subRule.boxSize(sz);
5604 default:
return ""_L1;
5615 if (
rule.hasStyleHint(
s))
5616 return qvariant_cast<QIcon>(
rule.styleHint(
s));
5633 if (
rule.hasStyleHint(
s)) {
5635 const auto dpr =
w ?
w->devicePixelRatio() :
qApp->devicePixelRatio();
5655 if (sh == SH_Widget_ShareActivation)
5661 case SH_LineEdit_PasswordCharacter:
s =
"lineedit-password-character"_L1;
break;
5662 case SH_LineEdit_PasswordMaskDelay:
s =
"lineedit-password-mask-delay"_L1;
break;
5663 case SH_DitherDisabledText:
s =
"dither-disabled-text"_L1;
break;
5664 case SH_EtchDisabledText:
s =
"etch-disabled-text"_L1;
break;
5665 case SH_ItemView_ActivateItemOnSingleClick:
s =
"activate-on-singleclick"_L1;
break;
5666 case SH_ItemView_ShowDecorationSelected:
s =
"show-decoration-selected"_L1;
break;
5667 case SH_Table_GridLineColor:
s =
"gridline-color"_L1;
break;
5668 case SH_DialogButtonLayout:
s =
"button-layout"_L1;
break;
5669 case SH_ToolTipLabel_Opacity:
s =
"opacity"_L1;
break;
5670 case SH_ComboBox_Popup:
s =
"combobox-popup"_L1;
break;
5671 case SH_ComboBox_ListMouseTracking:
s =
"combobox-list-mousetracking"_L1;
break;
5672 case SH_MenuBar_AltKeyNavigation:
s =
"menubar-altkey-navigation"_L1;
break;
5673 case SH_Menu_Scrollable:
s =
"menu-scrollable"_L1;
break;
5674 case SH_DrawMenuBarSeparator:
s =
"menubar-separator"_L1;
break;
5675 case SH_MenuBar_MouseTracking:
s =
"mouse-tracking"_L1;
break;
5676 case SH_SpinBox_ClickAutoRepeatRate:
s =
"spinbox-click-autorepeat-rate"_L1;
break;
5677 case SH_SpinControls_DisableOnBounds:
s =
"spincontrol-disable-on-bounds"_L1;
break;
5678 case SH_MessageBox_TextInteractionFlags:
s =
"messagebox-text-interaction-flags"_L1;
break;
5679 case SH_ToolButton_PopupDelay:
s =
"toolbutton-popup-delay"_L1;
break;
5680 case SH_ToolBox_SelectedPageTitleBold:
5681 if (renderRule(
w,
opt, PseudoElement_ToolBoxTab).hasFont)
5684 case SH_GroupBox_TextLabelColor:
5686 return rule.palette()->foreground.color().rgba();
5688 case SH_ScrollView_FrameOnlyAroundContents:
s =
"scrollview-frame-around-contents"_L1;
break;
5689 case SH_ScrollBar_ContextMenu:
s =
"scrollbar-contextmenu"_L1;
break;
5690 case SH_ScrollBar_LeftClickAbsolutePosition:
s =
"scrollbar-leftclick-absolute-position"_L1;
break;
5691 case SH_ScrollBar_MiddleClickAbsolutePosition:
s =
"scrollbar-middleclick-absolute-position"_L1;
break;
5692 case SH_ScrollBar_RollBetweenButtons:
s =
"scrollbar-roll-between-buttons"_L1;
break;
5693 case SH_ScrollBar_ScrollWhenPointerLeavesControl:
s =
"scrollbar-scroll-when-pointer-leaves-control"_L1;
break;
5694 case SH_TabBar_Alignment:
5695#if QT_CONFIG(tabwidget)
5696 if (qobject_cast<const QTabWidget *>(
w)) {
5697 rule = renderRule(
w,
opt, PseudoElement_TabWidgetTabBar);
5698 if (
rule.hasPosition())
5699 return rule.position()->position;
5704#if QT_CONFIG(tabbar)
5705 case SH_TabBar_CloseButtonPosition:
5706 rule = renderRule(
w,
opt, PseudoElement_TabBarTabCloseButton);
5707 if (
rule.hasPosition()) {
5708 Qt::Alignment align =
rule.position()->position;
5716 case SH_TabBar_ElideMode:
s =
"tabbar-elide-mode"_L1;
break;
5717 case SH_TabBar_PreferNoArrows:
s =
"tabbar-prefer-no-arrows"_L1;
break;
5718 case SH_ComboBox_PopupFrameStyle:
5719#if QT_CONFIG(combobox)
5720 if (qobject_cast<const QComboBox *>(
w)) {
5723 view->ensurePolished();
5725 if (subRule.hasBox() || !subRule.hasNativeBorder())
5731 case SH_DialogButtonBox_ButtonsHaveIcons:
s =
"dialogbuttonbox-buttons-have-icons"_L1;
break;
5732 case SH_Workspace_FillSpaceOnMaximize:
s =
"mdi-fill-space-on-maximize"_L1;
break;
5733 case SH_TitleBar_NoBorder:
5734 if (
rule.hasBorder())
5737 case SH_TitleBar_AutoRaise: {
5739 if (subRule.hasDrawable())
5743 case SH_ItemView_ArrowKeysNavigateIntoChildren:
s =
"arrow-keys-navigate-into-children"_L1;
break;
5744 case SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
s =
"paint-alternating-row-colors-for-empty-area"_L1;
break;
5745 case SH_TitleBar_ShowToolTipsOnButtons:
s =
"titlebar-show-tooltips-on-buttons"_L1;
break;
5746 case SH_Widget_Animation_Duration:
s =
"widget-animation-duration"_L1;
break;
5747 case SH_ScrollBar_Transient:
5748 if (!
rule.hasNativeBorder() ||
rule.hasBox() ||
rule.hasDrawable())
5753 if (!
s.isEmpty() &&
rule.hasStyleHint(
s)) {
5754 return rule.styleHint(
s).toInt();
5769 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5771 case SC_ComboBoxFrame:
return rule.borderRect(
opt->
rect);
5772 case SC_ComboBoxEditField:
5774 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5776 QRect r2 = positionRect(
w,
rule, subRule, PseudoElement_ComboBoxDropDown,
5778 if (subRule.hasPosition() && subRule.position()->position &
Qt::AlignLeft) {
5784 case SC_ComboBoxArrow: {
5785 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5788 case SC_ComboBoxListBoxPopup:
5797 : QWindowsStyle::subControlRect(cc, &comboBox, sc,
w);
5801#if QT_CONFIG(spinbox)
5803 if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
5804 QRenderRule upRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
5805 QRenderRule downRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
5806 bool ruleMatch =
rule.hasBox() || !
rule.hasNativeBorder();
5807 bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
5808 bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
5809 if (ruleMatch || upRuleMatch || downRuleMatch) {
5811 case SC_SpinBoxFrame:
5813 case SC_SpinBoxEditField:
5817 Qt::Alignment upAlign, downAlign;
5819 upAlign = upRule.hasPosition() ? upRule.position()->position
5823 downAlign = downRule.hasPosition() ? downRule.position()->position
5825 downAlign = resolveAlignment(
opt->
direction, downAlign);
5828 const int upSize = hasButtons
5830 const int downSize = hasButtons
5837 r.setRight(
r.right() - widestR);
5838 r.setLeft(
r.left() + widestL);
5841 case SC_SpinBoxDown:
5843 return positionRect(
w,
rule, downRule, PseudoElement_SpinBoxDownButton,
5848 return positionRect(
w,
rule, upRule, PseudoElement_SpinBoxUpButton,
5858 QStyleOptionSpinBox
spinBox(*spin);
5861 : QWindowsStyle::subControlRect(cc, &
spinBox, sc,
w);
5869 case SC_GroupBoxFrame:
5870 case SC_GroupBoxContents: {
5871 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5872 return sc == SC_GroupBoxFrame ?
rule.borderRect(
opt->
rect)
5880 case SC_GroupBoxLabel:
5881 case SC_GroupBoxCheckBox: {
5882 QRenderRule indRule = renderRule(
w,
opt, PseudoElement_GroupBoxIndicator);
5883 QRenderRule labelRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
5884 if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
5885 && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
5900 if (!labelRule.hasGeometry()) {
5901 labelRule.geo =
new QStyleSheetGeometryData(tw, th, tw, th, -1, -1);
5903 labelRule.geo->width = tw;
5904 labelRule.geo->height = th;
5906 if (!labelRule.hasPosition()) {
5907 labelRule.p =
new QStyleSheetPositionData(0, 0, 0, 0, defaultOrigin(PseudoElement_GroupBoxTitle),
5908 gb->textAlignment, PositionMode_Static);
5910 QRect r = positionRect(
w,
rule, labelRule, PseudoElement_GroupBoxTitle,
5912 if (gb->subControls & SC_GroupBoxCheckBox) {
5913 r = labelRule.contentsRect(
r);
5914 if (sc == SC_GroupBoxLabel) {
5916 r.setTop(
r.center().y() - th/2);
5918 r =
QRect(
r.left(),
r.center().y() - ih/2, iw, ih);
5922 return labelRule.contentsRect(
r);
5931 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5933 case SC_ToolButton:
return rule.borderRect(
opt->
rect);
5934 case SC_ToolButtonMenu: {
5935 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
5946 : QWindowsStyle::subControlRect(cc, &tool, sc,
w);
5950#if QT_CONFIG(scrollbar)
5952 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
5953 QStyleOptionSlider styleOptionSlider(*sb);
5954 styleOptionSlider.rect =
rule.borderRect(
opt->
rect);
5955 if (
rule.hasDrawable() ||
rule.hasBox()) {
5957 if (!
rule.hasBox()) {
5959 : QWindowsStyle::subControlRect(cc, sb, SC_ScrollBarGroove,
w);
5964 PseudoElement pe = PseudoElement_None;
5967 case SC_ScrollBarGroove:
5969 case SC_ScrollBarAddPage:
5970 case SC_ScrollBarSubPage:
5971 case SC_ScrollBarSlider: {
5972 QRect contentRect = grooveRect;
5973 if (hasStyleRule(
w, PseudoElement_ScrollBarSlider)) {
5974 QRenderRule sliderRule = renderRule(
w,
opt, PseudoElement_ScrollBarSlider);
5975 Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
5980 if (sb->maximum != sb->minimum) {
5982 sliderlen = (
qint64(sb->pageStep) * maxlen) / (
range + sb->pageStep);
5984 int slidermin =
pixelMetric(PM_ScrollBarSliderMin, sb,
w);
5985 if (sliderlen < slidermin || range > INT_MAX / 2)
5986 sliderlen = slidermin;
5987 if (sliderlen > maxlen)
5992 int sliderstart = (styleOptionSlider.orientation ==
Qt::Horizontal ? contentRect.
left() : contentRect.
top())
5993 + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition,
5994 maxlen - sliderlen, sb->upsideDown);
5997 ?
QRect(sliderstart, contentRect.
top(), sliderlen, contentRect.
height())
5998 :
QRect(contentRect.
left(), sliderstart, contentRect.
width(), sliderlen);
5999 if (sc == SC_ScrollBarSubPage)
6001 else if (sc == SC_ScrollBarAddPage)
6002 sr =
QRect(sb->orientation ==
Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight());
6003 return visualRect(styleOptionSlider.direction, grooveRect, sr);
6005 case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine;
break;
6006 case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine;
break;
6007 case SC_ScrollBarFirst: pe = PseudoElement_ScrollBarFirst;
break;
6008 case SC_ScrollBarLast: pe = PseudoElement_ScrollBarLast;
break;
6011 if (hasStyleRule(
w,pe)) {
6013 if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
6014 const QStyleSheetPositionData *
pos = subRule.position();
6015 QRect originRect = grooveRect;
6016 if (
rule.hasBox()) {
6020 return positionRect(
w, subRule, pe, originRect, styleOptionSlider.direction);
6025 : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc,
w);
6030#if QT_CONFIG(slider)
6032 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
6034 if (!subRule.hasDrawable())
6036 subRule.img =
nullptr;
6039 case SC_SliderGroove:
6041 case SC_SliderHandle: {
6043 QRect cr = subRule.contentsRect(gr);
6044 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SliderHandle);
6045 int len = horizontal ? subRule2.size().width() : subRule2.size().height();
6046 subRule2.img =
nullptr;
6047 subRule2.geo =
nullptr;
6048 cr = positionRect(
w, subRule2, PseudoElement_SliderHandle, cr,
opt->
direction);
6049 int thickness = horizontal ? cr.
height() : cr.
width();
6050 int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
6051 (horizontal ? cr.
width() : cr.
height()) -
len, slider->upsideDown);
6052 cr = horizontal ?
QRect(cr.
x() + sliderPos, cr.
y(),
len, thickness)
6053 :
QRect(cr.
x(), cr.
y() + sliderPos, thickness,
len);
6054 return subRule2.borderRect(cr);
6056 case SC_SliderTickmarks:
6065 case CC_MdiControls:
6066 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
6067 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
6068 || hasStyleRule(
w, PseudoElement_MdiMinButton)) {
6069 QList<QVariant>
layout =
rule.styleHint(
"button-layout"_L1).toList();
6071 layout = subControlLayout(
"mNX");
6076 int layoutButton =
val.toInt();
6077 if (layoutButton < PseudoElement_MdiCloseButton
6078 || layoutButton > PseudoElement_MdiNormalButton)
6081 if (!(
opt->subControls & control))
6083 subRule = renderRule(
w,
opt, layoutButton);
6084 width = subRule.size().width();
6097 if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
6099 QHash<QStyle::SubControl, QRect> layoutRects = titleBarLayout(
w, tb);
6100 return layoutRects.value(sc);
6116#if QT_CONFIG(tabbar)
6117 int pe = PseudoElement_None;
6121 case SE_PushButtonContents:
6122 case SE_PushButtonBevel:
6123 case SE_PushButtonFocusRect:
6126 && hasStyleRule(
w, PseudoElement_PushButtonMenuIndicator)) {
6130 : QWindowsStyle::subElementRect(se, &btnOpt,
w);
6132 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
6138 : QWindowsStyle::subElementRect(se,
btn,
w);
6142 case SE_LineEditContents:
6143 case SE_FrameContents:
6144 case SE_ShapedFrameContents:
6145 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
6150 case SE_CheckBoxIndicator:
6151 case SE_RadioButtonIndicator:
6152 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6153 PseudoElement pe = se == SE_CheckBoxIndicator ? PseudoElement_Indicator : PseudoElement_ExclusiveIndicator;
6159 case SE_CheckBoxContents:
6160 case SE_RadioButtonContents:
6161 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6162 bool isRadio = se == SE_RadioButtonContents;
6168 ir.setRect(ir.left() + ir.width() +
spacing, cr.
y(),
6174 case SE_ToolBoxTabContents:
6175 if (
w && hasStyleRule(
w->parentWidget(), PseudoElement_ToolBoxTab)) {
6176 QRenderRule subRule = renderRule(
w->parentWidget(),
opt, PseudoElement_ToolBoxTab);
6181 case SE_RadioButtonFocusRect:
6182 case SE_RadioButtonClickRect:
6183 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6188 case SE_CheckBoxFocusRect:
6189 case SE_CheckBoxClickRect:
6190 return ParentStyle::subElementRect(se,
opt,
w);
6192#if QT_CONFIG(itemviews)
6193 case SE_ItemViewItemCheckIndicator:
6194 if (!qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
6198 case SE_ItemViewItemText:
6199 case SE_ItemViewItemDecoration:
6200 case SE_ItemViewItemFocusRect:
6201 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
6203 PseudoElement pe = PseudoElement_None;
6204 if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
6205 pe = PseudoElement_ViewItemText;
6206 else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItem::HasDecoration)
6207 pe = PseudoElement_ViewItemIcon;
6208 else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItem::HasCheckIndicator)
6209 pe = PseudoElement_ViewItemIndicator;
6212 if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(
w, pe)) {
6214 QStyleOptionViewItem optCopy(*vopt);
6215 optCopy.rect = subRule.contentsRect(vopt->rect);
6216 QRect rect = ParentStyle::subElementRect(se, &optCopy,
w);
6223 case SE_HeaderArrow: {
6224 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewUpArrow);
6225 if (subRule.hasPosition() || subRule.hasGeometry())
6230 case SE_HeaderLabel: {
6231 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
6232 if (subRule.hasBox() || !subRule.hasNativeBorder()) {
6233 auto r = subRule.contentsRect(
opt->
rect);
6238 if (arrowRect.isValid()) {
6240 r.setWidth(
r.width() - arrowRect.width());
6242 r.setHeight(
r.height() - arrowRect.height());
6251 case SE_ProgressBarGroove:
6252 case SE_ProgressBarContents:
6253 case SE_ProgressBarLabel:
6255 if (
rule.hasBox() || !
rule.hasNativeBorder() ||
rule.hasPosition() || hasStyleRule(
w, PseudoElement_ProgressBarChunk)) {
6256 if (se == SE_ProgressBarGroove)
6257 return rule.borderRect(pb->rect);
6258 else if (se == SE_ProgressBarContents)
6259 return rule.contentsRect(pb->rect);
6261 QSize sz = pb->fontMetrics.size(0, pb->text);
6268#if QT_CONFIG(tabbar)
6269 case SE_TabWidgetLeftCorner:
6270 pe = PseudoElement_TabWidgetLeftCorner;
6272 case SE_TabWidgetRightCorner:
6273 if (pe == PseudoElement_None)
6274 pe = PseudoElement_TabWidgetRightCorner;
6276 case SE_TabWidgetTabBar:
6277 if (pe == PseudoElement_None)
6278 pe = PseudoElement_TabWidgetTabBar;
6280 case SE_TabWidgetTabPane:
6281 case SE_TabWidgetTabContents:
6282 if (pe == PseudoElement_None)
6283 pe = PseudoElement_TabWidgetPane;
6285 if (hasStyleRule(
w, pe)) {
6286 QRect r = QWindowsStyle::subElementRect(pe == PseudoElement_TabWidgetPane ? SE_TabWidgetTabPane : se,
opt,
w);
6289 if (pe == PseudoElement_TabWidgetTabBar) {
6293 if (se == SE_TabWidgetTabContents)
6294 r = subRule.contentsRect(
r);
6299 case SE_TabBarScrollLeftButton:
6300 case SE_TabBarScrollRightButton:
6301 if (hasStyleRule(
w, PseudoElement_TabBarScroller))
6302 return ParentStyle::subElementRect(se,
opt,
w);
6305 case SE_TabBarTearIndicator: {
6307 if (subRule.hasContentsSize()) {
6309 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
6310 switch (tab->shape) {
6321 r.setRect(tab->rect.left(), tab->rect.top(),
opt->
rect.
width(), subRule.size().height());
6332 case SE_TabBarTabText:
6333 case SE_TabBarTabLeftButton:
6334 case SE_TabBarTabRightButton: {
6336 if (subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
6337 if (se == SE_TabBarTabText) {
6338 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
6339 const QTabBar *bar = qobject_cast<const QTabBar *>(
w);
6340 const QRect optRect = bar && tab->tabIndex != -1 ? bar->
tabRect(tab->tabIndex) :
opt->
rect;
6341 const QRect r = positionRect(
w, subRule, PseudoElement_TabBarTab, optRect,
opt->
direction);
6342 QStyleOptionTab tabCopy(*tab);
6343 if (subRule.hasFont) {
6344 const QFont ruleFont =
w ? subRule.font.
resolve(
w->font()) : subRule.font;
6347 tabCopy.rect = subRule.contentsRect(
r);
6348 return ParentStyle::subElementRect(se, &tabCopy,
w);
6351 return ParentStyle::subElementRect(se,
opt,
w);
6357 case SE_DockWidgetCloseButton:
6358 case SE_DockWidgetFloatButton: {
6359 PseudoElement pe = (se == SE_DockWidgetCloseButton) ? PseudoElement_DockWidgetCloseButton : PseudoElement_DockWidgetFloatButton;
6361 if (!subRule2.hasPosition())
6363 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
6367#if QT_CONFIG(toolbar)
6368 case SE_ToolBarHandle:
6369 if (hasStyleRule(
w, PseudoElement_ToolBarHandle))
6370 return ParentStyle::subElementRect(se,
opt,
w);
6376 case SE_CheckBoxLayoutItem:
6377 case SE_ComboBoxLayoutItem:
6378 case SE_DateTimeEditLayoutItem:
6379 case SE_LabelLayoutItem:
6380 case SE_ProgressBarLayoutItem:
6381 case SE_PushButtonLayoutItem:
6382 case SE_RadioButtonLayoutItem:
6383 case SE_SliderLayoutItem:
6384 case SE_SpinBoxLayoutItem:
6385 case SE_ToolButtonLayoutItem:
6386 case SE_FrameLayoutItem:
6387 case SE_GroupBoxLayoutItem:
6388 case SE_TabWidgetLayoutItem:
6389 if (!
rule.hasNativeBorder())
6409 if (
w->objectName() ==
"qt_fontDialog_sampleEdit"_L1)
6412 QWidget *container = containerWidget(
w);
6414 PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
6416 const bool useStyleSheetPropagationInWidgetStyles =
6419 if (useStyleSheetPropagationInWidgetStyles) {
6420 unsetStyleSheetFont(
w);
6422 if (
rule.font.resolveMask()) {
6423 QFont wf =
w->d_func()->localFont();
6424 styleSheetCaches->customFontWidgets.insert(
w, {wf,
rule.font.resolveMask()});
6431 QFont wf =
w->d_func()->localFont();
6436 && isNaturalChild(
w) && qobject_cast<QWidget *>(
w->parent())) {
6444 w->data->fnt =
font;
6454 w->setProperty(
"_q_styleSheetWidgetFont",
font);
6459 w->setProperty(
"_q_styleSheetWidgetFont",
QVariant());
6468 if (!
w || !
opt || !pal)
6471 RECURSION_GUARD(
return false)
6473 w = containerWidget(
w);
6476 if (!
rule.hasPalette())
6505bool QStyleSheetStyle::isNaturalChild(
const QObject *
obj)
6507 if (
obj->objectName().startsWith(
"qt_"_L1))
6531 qreal sourceDevicePixelRatio = 1.0;
6534 pixmap.setDevicePixelRatio(sourceDevicePixelRatio);
6540#include "moc_qstylesheetstyle_p.cpp"
The QAbstractItemView class provides the basic functionality for item view classes.
The QAbstractSlider class provides an integer value within a range.
void valueChanged(int value)
This signal is emitted when the slider value has changed, with the new slider value as argument.
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
The QApplication class manages the GUI application's control flow and main settings.
static QStyle * style()
Returns the application's style object.
void setColor(const QColor &color)
Sets the brush color to the given color.
The QColor class provides colors based on RGB, HSV or CMYK values.
QRgb rgba() const noexcept
Returns the RGB value of the color, including its alpha.
The QComboBox widget combines a button with a dropdown list.
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
void init(const QString &css, bool file=false)
bool parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity=Qt::CaseSensitive)
static QString toNativeSeparators(const QString &pathName)
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=nullptr) const
Returns the size in pixels of text.
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
void setResolveMask(uint mask)
The QFrame class is the base class of widgets that can have a frame.
int midLineWidth
the width of the mid-line
int lineWidth
the line width
Shape frameShape
the frame shape value from the frame style
static QPalette palette()
Returns the current application palette.
qreal devicePixelRatio() const
Returns the highest screen device pixel ratio found on the system.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
bool remove(const Key &key)
Removes the item that has the key from the hash.
The QIcon class provides scalable icons in different modes and states.
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
State
This enum describes the state for which a pixmap is intended to be used.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
bool isEmpty() const override
\reimp
The QLineEdit widget is a one-line text editor.
qsizetype size() const noexcept
T value(qsizetype i) const
T findChild(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
const QObjectList & children() const
Returns a list of child objects.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
qreal devicePixelRatio() const
The QPainter class performs low-level painting on widgets and other paint devices.
The QPalette class contains color groups for each widget state.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
void setResolveMask(ResolveMask mask)
ResolveMask resolveMask() const
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int width() const
Returns the width of the pixmap.
The QPlainTextEdit class provides a widget that is used to edit and display plain text.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr int height() const noexcept
Returns the height of the rectangle.
QRect intersected(const QRect &other) const noexcept
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint topRight() const noexcept
Returns the position of the rectangle's top-right corner.
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setRect(int x, int y, int w, int h) noexcept
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void setWidth(int w) noexcept
Sets the width of the rectangle to the given width.
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setHeight(int h) noexcept
Sets the height of the rectangle to the given height.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QRegion class specifies a clip region for a painter.
The QScreen class is used to query screen properties. \inmodule QtGui.
qreal devicePixelRatio
the screen's ratio between physical pixels and device-independent pixels
bool remove(const T &value)
iterator find(const T &value)
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr int & rwidth() noexcept
Returns a reference to the width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
qsizetype size() const noexcept
Returns the number of characters in this string.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
\variable QStyleOption::palette
\variable QStyleOptionFocusRect::backgroundColor
\variable QStyleOptionFrame::features
\variable QStyleOptionButton::features
\variable QStyleOptionToolBox::selectedPosition
The QStyleOption class stores the parameters used by QStyle functions.
Qt::LayoutDirection direction
QHash< const QObject *, QList< QCss::StyleRule > > styleRulesCache
QHash< const QWidget *, Tampered< QFont > > customFontWidgets
QHash< const QWidget *, Tampered< QPalette > > customPaletteWidgets
QHash< const void *, QCss::StyleSheet > styleSheetCache
void styleDestroyed(QObject *)
QHash< const QObject *, QRenderRules > renderRulesCache
QHash< const QObject *, QHash< int, bool > > hasStyleRuleCache
QSet< const QWidget * > autoFillDisabledWidgets
void objectDestroyed(QObject *)
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
bool styleSheetPalette(const QWidget *w, const QStyleOption *opt, QPalette *pal)
void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override
void updateStyleSheetFont(QWidget *w) const
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
QStyleSheetStyle(QStyle *baseStyle)
QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const override
void unpolish(QWidget *widget) override
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option=nullptr, const QWidget *w=nullptr) const override
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=nullptr) const override
void polish(QWidget *widget) override
void repolish(QWidget *widget)
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=nullptr) const override
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=nullptr) const override
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
void saveWidgetFont(QWidget *w, const QFont &font) const
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
bool event(QEvent *e) override
void clearWidgetFont(QWidget *w) const
QPalette standardPalette() const override
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=nullptr) const override
QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const override
QStyle * baseStyle() const
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual void polish(QWidget *widget)
Initializes the appearance of the given widget.
virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
Returns the area within the given rectangle in which to draw the specified pixmap according to the de...
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=nullptr) const =0
Draws the given control using the provided painter with the style options specified by option.
virtual QPalette standardPalette() const
Returns the style's standard palette.
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget=nullptr) const =0
Returns the rectangle containing the specified subControl of the given complex control (with the styl...
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_ScrollView_FrameOnlyAroundContents
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment,...
virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
Returns the area within the given rectangle in which to draw the provided text according to the speci...
virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
StandardPixmap
This enum describes the available standard pixmaps.
@ SP_DockWidgetCloseButton
@ SP_TitleBarContextHelpButton
@ SP_TitleBarNormalButton
@ SP_FileDialogDetailedView
@ SP_MessageBoxInformation
@ SP_FileDialogContentsView
@ SP_TitleBarUnshadeButton
static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
Returns a new rectangle of the specified size that is aligned to the given rectangle according to the...
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const =0
Returns the sub-area for the given element as described in the provided style option.
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget=nullptr) const =0
Returns the sub control at the given position in the given complex control (with the style options sp...
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
@ PM_CheckBoxLabelSpacing
@ PM_ToolTipLabelFrameWidth
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const =0
Returns a copy of the given pixmap, styled to conform to the specified iconMode and taking into accou...
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const =0
virtual void unpolish(QWidget *widget)
Uninitialize the given {widget}'s appearance.
@ SE_ItemViewItemCheckIndicator
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
SubControl
This enum describes the available sub controls.
@ SC_TitleBarUnshadeButton
@ SC_TitleBarNormalButton
@ SC_TitleBarContextHelpButton
The QTabBar class provides a tab bar, e.g.
QRect tabRect(int index) const
Returns the visual rectangle of the tab at position index, or a null rectangle if index is hidden,...
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
QMap< QString, QString > map
[6]
list append(new Employee("Blackpool", "Stephen"))
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
const QStyleOptionButton * btn
[3]
const quint64 PseudoClass_Floatable
const quint64 PseudoClass_Movable
const quint64 PseudoClass_Children
const quint64 PseudoClass_Disabled
const quint64 PseudoClass_Sibling
const quint64 PseudoClass_ReadOnly
const quint64 PseudoClass_Closed
const quint64 PseudoClass_Maximized
const quint64 PseudoClass_Default
const quint64 PseudoClass_Bottom
const quint64 PseudoClass_EditFocus
const quint64 PseudoClass_Focus
const quint64 PseudoClass_Enabled
const quint64 PseudoClass_Editable
const quint64 PseudoClass_Vertical
const quint64 PseudoClass_Flat
const quint64 PseudoClass_NonExclusive
const quint64 PseudoClass_Pressed
const quint64 PseudoClass_Item
const quint64 PseudoClass_Alternate
const quint64 PseudoClass_PreviousSelected
const quint64 PseudoClass_Closable
const quint64 PseudoClass_Horizontal
const quint64 PseudoClass_Off
const quint64 PseudoClass_Active
const quint64 PseudoClass_NextSelected
@ StyleFeature_BackgroundGradient
@ StyleFeature_BackgroundColor
const quint64 PseudoClass_Frameless
const quint64 PseudoClass_Checked
const quint64 PseudoClass_Selected
const quint64 PseudoClass_Right
const quint64 PseudoClass_Window
const quint64 PseudoClass_Minimized
@ StyleSheetOrigin_Inline
const quint64 PseudoClass_On
const quint64 PseudoClass_Unchecked
const quint64 PseudoClass_First
const quint64 PseudoClass_Indeterminate
const quint64 PseudoClass_Middle
const quint64 PseudoClass_Top
const quint64 PseudoClass_Hover
const quint64 PseudoClass_Left
const quint64 PseudoClass_Last
const quint64 PseudoClass_OnlyOne
const quint64 PseudoClass_Exclusive
QVector3D minimum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
QVector3D maximum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
Combined button and popup list for selecting options.
QSize adjustSize(const QSize &size, PixelFormat srcFmt, PixelFormat dstFmt)
@ AA_UseStyleSheetPropagationInWidgetStyles
@ WindowContextHelpButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
@ ToolButtonTextUnderIcon
@ ToolButtonTextBesideIcon
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
void qNormalizeRadii(const QRect &br, const QSize *radii, QSize *tlr, QSize *trr, QSize *blr, QSize *brr)
void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles, const int *borders, const QBrush *colors, const QSize *radii)
DBusConnection const char * rule
static QString header(const QString &name)
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h, const QPalette &pal, bool sunken, int lineWidth, const QBrush *fill)
Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMargins, const QTileRules &rules=QTileRules(), QDrawBorderPixmap::DrawingHints hints=QDrawBorderPixmap::DrawingHints())
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static void setClip(QPainter *painter, QGraphicsItem *item)
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, qreal *sourceDevicePixelRatio)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
static bool isNumber(char s)
GLint GLfloat GLfloat GLfloat v2
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLenum GLuint GLintptr offset
GLsizei const GLint * box
GLfloat GLfloat GLfloat GLfloat h
GLuint GLsizei const GLuint const GLintptr * offsets
GLsizei const GLchar *const * path
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
static QRectF alignedRect(bool mirrored, Qt::Alignment alignment, const QSizeF &size, const QRectF &rectangle)
static QT_BEGIN_NAMESPACE const QRgb colors[][14]
Int aligned(Int v, Int byteAlign)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define qPrintable(string)
QStyleSheetStyle * qt_styleSheet(QStyle *style)
constexpr bool verticalTabs(QTabBar::Shape shape) noexcept
#define QT_CONFIG(feature)
static void drawBackground(QPainter *p, const QTextCharFormat &chf, const QRectF &r)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
const char className[16]
[1]
p drawImage(offset, thumbnail)
QFileSelector selector
[1]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
obj metaObject() -> className()
myObject disconnect()
[26]
QFileDialog dialog(this)
[1]
app setAttribute(Qt::AA_DontShowIconsInMenus)
QApplication app(argc, argv)
[0]
Qt::Alignment alignmentValue() const
bool realValue(qreal *r, const char *unit=nullptr) const
QExplicitlySharedDataPointer< DeclarationData > d
QColor colorValue(const QPalette &=QPalette()) const
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const
bool intValue(int *i, const char *unit=nullptr) const
QBrush brushValue(const QPalette &=QPalette()) const
The QTileRules class provides the rules used to draw a pixmap or image split into nine segments.
QT_BEGIN_NAMESPACE bool toBool(const QString &str)