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; }
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,
442 const QBrush &accentColor)
443 : foreground(foreground)
444 , selectionForeground(selectedForeground)
445 , selectionBackground(selectedBackground)
446 , alternateBackground(alternateBackground)
447 , placeholderForeground(placeHolderTextForeground)
448 , accentColor(accentColor)
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) { }
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();
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();
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);
595 bool hasStyleHint(
const QString &sh)
const {
return styleHints.contains(sh); }
598 void fixupBorder(
int);
628static const char knownStyleHints[][45] = {
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"
721static const int numKnownStyleHints =
sizeof(knownStyleHints)/
sizeof(knownStyleHints[0]);
726 for (
int i = 0;
i <
layout.size();
i++) {
730 buttons.
append(PseudoElement_MdiMinButton);
731 buttons.
append(PseudoElement_TitleBarMinButton);
734 buttons.
append(PseudoElement_TitleBarMaxButton);
737 buttons.
append(PseudoElement_MdiCloseButton);
738 buttons.
append(PseudoElement_TitleBarCloseButton);
741 buttons.
append(PseudoElement_MdiNormalButton);
742 buttons.
append(PseudoElement_TitleBarNormalButton);
745 buttons.
append(PseudoElement_TitleBarSysMenu);
748 buttons.
append(PseudoElement_TitleBar);
751 buttons.
append(PseudoElement_TitleBarContextHelpButton);
754 buttons.
append(PseudoElement_TitleBarShadeButton);
781 QRect cr = subRule.contentsRect(tb->
rect);
784 layout = subControlLayout(
"I(T)HSmMX"_L1);
789 const int numLayouts =
layout.size();
791 for (
int i = 0;
i < numLayouts;
i++) {
792 const int element =
layout[
i].toInt();
793 if (element ==
'(') {
795 }
else if (element ==
')') {
799 info.element = element;
801 case PseudoElement_TitleBar:
805 case PseudoElement_TitleBarContextHelpButton:
809 case PseudoElement_TitleBarMinButton:
813 info.element = PseudoElement_TitleBarNormalButton;
815 case PseudoElement_TitleBarMaxButton:
819 info.element = PseudoElement_TitleBarNormalButton;
821 case PseudoElement_TitleBarShadeButton:
825 info.element = PseudoElement_TitleBarUnshadeButton;
827 case PseudoElement_TitleBarCloseButton:
828 case PseudoElement_TitleBarSysMenu:
835 if (
info.element == PseudoElement_TitleBar) {
839 subRule = renderRule(
w, tb,
info.element);
840 info.width = subRule.size().width();
851 for (
int i = 0;
i < infos.
size();
i++) {
852 const ButtonInfo &
info = infos[
i];
854 switch (
info.where) {
860 r.setLeft(
r.left()+
info.offset);
861 r.setWidth(
info.width);
915 features =
v.extractStyleFeatures();
917 int w = -1,
h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1;
918 if (
v.extractGeometry(&
w, &
h, &minw, &minh, &maxw, &maxh))
919 geo =
new QStyleSheetGeometryData(
w,
h, minw, minh, maxw, maxh);
925 Qt::Alignment textAlignment;
929 int margins[4], paddings[4],
spacing = -1;
930 for (
int i = 0;
i < 4;
i++)
931 margins[
i] = paddings[
i] = 0;
932 if (
v.extractBox(margins, paddings, &
spacing))
933 b =
new QStyleSheetBoxData(margins, paddings,
spacing);
939 for (
int i = 0;
i < 4;
i++) {
943 if (
v.extractBorder(borders,
colors, styles, radii))
944 bd =
new QStyleSheetBorderData(borders,
colors, styles, radii);
947 for (
int i = 0;
i < 4;
i++) {
952 ou =
new QStyleSheetOutlineData(borders,
colors, styles, radii,
offsets);
969 QBrush selectedForeground;
970 QBrush selectedBackground;
971 QBrush alternateBackground;
972 QBrush placeHolderTextForeground;
974 if (
v.extractPalette(&foreground, &selectedForeground, &selectedBackground,
975 &alternateBackground, &placeHolderTextForeground, &accentColor)) {
976 pal =
new QStyleSheetPaletteData(foreground, selectedForeground, selectedBackground,
977 alternateBackground, placeHolderTextForeground, accentColor);
983 if (
v.extractImage(&imgIcon, &
alignment, &imgSize))
984 img =
new QStyleSheetImageData(imgIcon,
alignment, imgSize);
992 hasFont =
v.extractFont(&
font, &adj);
994#if QT_CONFIG(tooltip)
995 if (
object &&
qstrcmp(
object->metaObject()->className(),
"QTipLabel") == 0)
999 for (
int i = 0;
i < declarations.
size();
i++) {
1001 if (decl.
d->propertyId == BorderImage) {
1007 if (uri.
isEmpty() || uri ==
"none"_L1) {
1012 bd =
new QStyleSheetBorderData;
1014 bd->bi =
new QStyleSheetBorderImageData;
1016 QStyleSheetBorderImageData *bi = bd->bi;
1017 bi->pixmap = QStyleSheetStyle::loadPixmap(uri,
object);
1018 for (
int i = 0;
i < 4;
i++)
1019 bi->cuts[
i] = cuts[
i];
1020 bi->horizStretch = horizStretch;
1021 bi->vertStretch = vertStretch;
1023 }
else if (decl.
d->propertyId == QtBackgroundRole) {
1026 int role = decl.
d->values.at(0).variant.toInt();
1027 if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
1031 }
else if (decl.
d->propertyId == UnknownProperty) {
1032 bool knownStyleHint =
false;
1033 for (
int i = 0;
i < numKnownStyleHints;
i++) {
1035 if (decl.
d->property.compare(styleHint) == 0) {
1038 if (hintName.
endsWith(
"alignment"_L1)) {
1040 }
else if (hintName.
endsWith(
"color"_L1)) {
1042 }
else if (hintName.
endsWith(
"size"_L1)) {
1044 const QString valueString = decl.
d->values.at(0).variant.toString();
1058 qreal emexSize = {};
1059 if (decl.
realValue(&emexSize, isEmSize ?
"em" :
"ex") && emexSize > 0) {
1060 pixelSize *= emexSize;
1061 const QSizeF newSize(pixelSize, pixelSize);
1062 decl.
d->parsed = QVariant::fromValue<QSizeF>(newSize);
1063 hintValue = newSize;
1065 qWarning(
"Invalid '%s' size for %s. Skipping.",
1066 isEmSize ?
"em" :
"ex",
qPrintable(valueString));
1072 }
else if (hintName.
endsWith(
"icon"_L1)) {
1074 }
else if (hintName ==
"button-layout"_L1 && decl.
d->values.size() != 0
1076 hintValue = subControlLayout(decl.
d->values.at(0).variant.toString());
1082 styleHints[decl.
d->property] = hintValue;
1083 knownStyleHint =
true;
1087 if (!knownStyleHint)
1098 fixupBorder(style->nativeFrameWidth(
widget));
1100 if (
border()->hasBorderImage())
1101 defaultBackground =
QBrush();
1105QRect QRenderRule::borderRect(
const QRect&
r)
const
1109 const int*
m =
box()->margins;
1110 return r.adjusted(
m[LeftEdge],
m[TopEdge], -
m[RightEdge], -
m[BottomEdge]);
1113QRect QRenderRule::outlineRect(
const QRect&
r)
const
1115 QRect br = borderRect(
r);
1118 const int *
b = outline()->borders;
1119 return r.
adjusted(
b[LeftEdge],
b[TopEdge], -
b[RightEdge], -
b[BottomEdge]);
1122QRect QRenderRule::paddingRect(
const QRect&
r)
const
1124 QRect br = borderRect(
r);
1127 const int *
b =
border()->borders;
1128 return br.
adjusted(
b[LeftEdge],
b[TopEdge], -
b[RightEdge], -
b[BottomEdge]);
1131QRect QRenderRule::contentsRect(
const QRect&
r)
const
1133 QRect pr = paddingRect(
r);
1136 const int *
p =
box()->paddings;
1137 return pr.
adjusted(
p[LeftEdge],
p[TopEdge], -
p[RightEdge], -
p[BottomEdge]);
1144 if (
flags & Margin) {
1145 const int *
m =
box()->margins;
1146 r.adjust(-
m[LeftEdge], -
m[TopEdge],
m[RightEdge],
m[BottomEdge]);
1148 if (
flags & Padding) {
1149 const int *
p =
box()->paddings;
1150 r.adjust(-
p[LeftEdge], -
p[TopEdge],
p[RightEdge],
p[BottomEdge]);
1153 if (hasBorder() && (
flags & Border)) {
1154 const int *
b =
border()->borders;
1155 r.adjust(-
b[LeftEdge], -
b[TopEdge],
b[RightEdge],
b[BottomEdge]);
1168void QRenderRule::fixupBorder(
int nativeWidth)
1173 if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
1177 const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
1178 || bd->radii[2].isValid() || bd->radii[3].isValid();
1179 for (
int i = 0;
i < 4;
i++) {
1180 if ((bd->styles[
i] == BorderStyle_Native) && hasRadius)
1183 switch (bd->styles[
i]) {
1190 if (bd->borders[
i] == 0)
1191 bd->borders[
i] = nativeWidth;
1204 QStyleSheetBorderImageData *bi = bd->bi;
1205 if (bi->cuts[0] == -1) {
1206 for (
int i = 0;
i < 4;
i++)
1207 bi->cuts[
i] =
int(
border()->borders[
i]);
1217 const QStyleSheetBorderImageData *borderImageData =
border()->borderImage();
1218 const int *targetBorders =
border()->borders;
1219 const int *sourceBorders = borderImageData->cuts;
1220 QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
1221 sourceBorders[RightEdge], sourceBorders[BottomEdge]);
1222 QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
1223 targetBorders[RightEdge], targetBorders[BottomEdge]);
1228 QRect(
QPoint(), borderImageData->pixmap.size()), sourceMargins,
1229 QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
1238 return paddingRect(
rect);
1240 return borderRect(
rect);
1242 return contentsRect(
rect);
1251 if (!hasBackground())
1254 const QPixmap& bgp = background()->pixmap;
1260 if (background()->origin != background()->clip) {
1265 if (background()->
attachment == Attachment_Fixed)
1269 int bgpHeight = bgpSize.
height();
1270 int bgpWidth = bgpSize.
width();
1271 QRect r = originRect(
rect, background()->origin);
1275 switch (background()->repeat) {
1277 p->drawTiledPixmap(inter.
x(),
r.y(), inter.
width(),
r.height(), bgp,
1279 bgpHeight -
int(
aligned.y() -
r.y()) % bgpHeight + off.
y());
1282 p->drawTiledPixmap(
r.x(), inter.
y(),
r.width(), inter.
height(), bgp,
1283 bgpWidth -
int(
aligned.x() -
r.x())%bgpWidth + off.
x(),
1287 p->drawTiledPixmap(
r, bgp,
1289 bgpHeight -
int(
aligned.y() -
r.y())%bgpHeight + off.
y()));
1293 p->drawPixmap(inter.
x(), inter.
y(), bgp, inter.
x() -
aligned.x() + off.
x(),
1299 if (background()->origin != background()->clip)
1321 if (
border()->hasBorderImage()) {
1322 drawBorderImage(
p,
rect);
1337 QSize tlr, trr, blr, brr;
1343 const int *borders =
border()->borders;
1349 path.arcTo(curX - 2*trr.
width() + borders[RightEdge], curY,
1350 trr.
width()*2 - borders[RightEdge], trr.
height()*2 - borders[TopEdge], 90, -90);
1354 path.arcTo(curX - 2*brr.
width() + borders[RightEdge], curY - 2*brr.
height() + borders[BottomEdge],
1355 brr.
width()*2 - borders[RightEdge], brr.
height()*2 - borders[BottomEdge], 0, -90);
1359 path.arcTo(curX,
rect.bottom() - 2*blr.
height() + borders[BottomEdge]/2.0,
1360 blr.
width()*2 - borders[LeftEdge], blr.
height()*2 - borders[BottomEdge], 270, -90);
1363 path.arcTo(curX,
rect.top() + borders[TopEdge]/2.0,
1364 tlr.
width()*2 - borders[LeftEdge], tlr.
height()*2 - borders[TopEdge], 180, -90);
1366 path.closeSubpath();
1377 clipPath = borderClip(
rect);
1378 if (!clipPath.isEmpty()) {
1388 if (!clipPath.isEmpty())
1396 brush = defaultBackground;
1406 p->fillPath(borderPath,
brush);
1409 p->fillRect(originRect(
rect, origin),
brush);
1413 drawBackgroundImage(
p,
rect, off);
1418 drawBackground(
p,
rect);
1420 drawBorder(
p, borderRect(
rect));
1441 p->setBrush(br, bg->brush);
1456 p->setBrush(fr, pal->foreground);
1460 if (pal->selectionBackground.style() !=
Qt::NoBrush)
1462 if (pal->selectionForeground.style() !=
Qt::NoBrush)
1464 if (pal->alternateBackground.style() !=
Qt::NoBrush)
1483 p->setBrush(cg,
w->backgroundRole(), bg->brush);
1490 if ((hasBackground() && background()->isTransparent())
1491 || (hasBorder() &&
border()->hasBorderImage() && !
border()->borderImage()->
pixmap.isNull()))
1500 setDefault(
p, cg,
w->foregroundRole(), pal->foreground,
w);
1503 QColor phColor(pal->foreground.color());
1504 phColor.setAlpha((phColor.alpha() + 1) / 2);
1505 QBrush placeholder = pal->foreground;
1509 if (pal->selectionBackground.style() !=
Qt::NoBrush)
1511 if (pal->selectionForeground.style() !=
Qt::NoBrush)
1513 if (pal->alternateBackground.style() !=
Qt::NoBrush)
1515 if (pal->placeholderForeground.style() !=
Qt::NoBrush)
1521bool QRenderRule::hasModification()
const
1523 return hasPalette() ||
1525 hasGradientBackground() ||
1526 !hasNativeBorder() ||
1527 !hasNativeOutline() ||
1533 !styleHints.isEmpty();
1538#define OBJECT_PTR(x) (static_cast<QObject *>(x.ptr))
1542#if QT_CONFIG(tooltip)
1543 if (qobject_cast<const QLabel *>(
obj) &&
qstrcmp(
obj->metaObject()->className(),
"QTipLabel") == 0) {
1544 QObject *
p = qvariant_cast<QObject *>(
obj->property(
"_q_stylesheet_parent"));
1549 return obj->parent();
1555 QStyleSheetStyleSelector() { }
1557 QStringList nodeNames(NodePtr node)
const override
1559 if (isNullNode(node))
1562#if QT_CONFIG(tooltip)
1575 if (isNullNode(node))
1581 if (cacheIt !=
cache.constEnd())
1582 return cacheIt.
value();
1587 const int propertyIndex =
obj->metaObject()->indexOfProperty(
name.toLatin1());
1588 if (propertyIndex == -1) {
1590 if (!
value.isValid()) {
1591 if (
name ==
"class"_L1) {
1596 }
else if (
name ==
"style"_L1) {
1611 value.convert(QMetaType::fromType<int>());
1614 if (
value.isValid()) {
1615 valueStr = (
value.userType() == QMetaType::QStringList
1616 ||
value.userType() == QMetaType::QVariantList)
1617 ?
value.toStringList().join(u
' ')
1623 bool nodeNameEquals(NodePtr node,
const QString& nodeName)
const override
1625 if (isNullNode(node))
1628#if QT_CONFIG(tooltip)
1630 return nodeName ==
"QToolTip"_L1;
1633 const auto *uc =
reinterpret_cast<const char16_t *
>(nodeName.
constData());
1634 const auto *
e = uc + nodeName.
size();
1636 while (*
c && uc !=
e && (*uc == *
c || (*
c ==
':' && *uc ==
'-'))) {
1646 bool hasAttributes(NodePtr)
const override
1650 bool isNullNode(NodePtr node)
const override
1651 {
return node.ptr ==
nullptr; }
1652 NodePtr parentNode(NodePtr node)
const override
1653 { NodePtr
n;
n.ptr = isNullNode(node) ?
nullptr : parentObject(OBJECT_PTR(node));
return n; }
1654 NodePtr previousSiblingNode(NodePtr)
const override
1655 { NodePtr
n;
n.ptr =
nullptr;
return n; }
1656 NodePtr duplicateNode(NodePtr node)
const override
1658 void freeNode(NodePtr)
const override
1670 return cacheIt.
value();
1672 if (!initObject(
obj)) {
1676 QStyleSheetStyleSelector styleSelector;
1681 defaultSs = getDefaultStyleSheet();
1686 defaultSs = defaultCacheIt.
value();
1688 styleSelector.styleSheets += defaultSs;
1690 if (!
qApp->styleSheet().isEmpty()) {
1697 parser.
init(ss,
qApp->styleSheet() != ss);
1699 qWarning(
"Could not parse application stylesheet");
1704 appSs = appCacheIt.
value();
1706 styleSelector.styleSheets += appSs;
1711 QString styleSheet =
o->property(
"styleSheet").toString();
1717 parser.
init(styleSheet);
1718 if (!parser.
parse(&ss)) {
1719 parser.
init(
"* {"_L1 + styleSheet + u
'}');
1721 qWarning() <<
"Could not parse stylesheet of object" <<
o;
1726 ss = objCacheIt.
value();
1731 for (
int i = 0;
i < objectSs.
size();
i++)
1734 styleSelector.styleSheets += objectSs;
1746 quint64 pseudoClass = PseudoClass_Unspecified)
1749 for (
int i = 0;
i < styleRules.
size();
i++) {
1757 if ((pseudoClass == PseudoClass_Any) || (cssClass == PseudoClass_Unspecified)
1758 || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
1759 decls += styleRules.
at(
i).declarations;
1764int QStyleSheetStyle::nativeFrameWidth(
const QWidget *
w)
1768#if QT_CONFIG(spinbox)
1769 if (qobject_cast<const QAbstractSpinBox *>(
w))
1773#if QT_CONFIG(combobox)
1774 if (qobject_cast<const QComboBox *>(
w))
1779 if (qobject_cast<const QMenu *>(
w))
1783#if QT_CONFIG(menubar)
1784 if (qobject_cast<const QMenuBar *>(
w))
1788 if (
const QFrame *
frame = qobject_cast<const QFrame *>(
w)) {
1794 if (
qstrcmp(
w->metaObject()->className(),
"QTipLabel") == 0)
1831 pc |= PseudoClass_Open;
1842#ifdef QT_KEYPAD_NAVIGATION
1843 if (
state & QStyle::State_HasEditFocus)
1849static void qt_check_if_internal_object(
const QObject **
obj,
int *element)
1851#if !QT_CONFIG(dockwidget)
1855 if (*
obj &&
qstrcmp((*obj)->metaObject()->className(),
"QDockWidgetTitleButton") == 0) {
1856 if ((*obj)->objectName() ==
"qt_dockwidget_closebutton"_L1) {
1857 *element = PseudoElement_DockWidgetCloseButton;
1858 }
else if ((*obj)->objectName() ==
"qt_dockwidget_floatbutton"_L1) {
1859 *element = PseudoElement_DockWidgetFloatButton;
1861 *
obj = (*obj)->parent();
1868 qt_check_if_internal_object(&
obj, &element);
1871 if (cacheIt !=
cache.constEnd())
1872 return cacheIt.
value();
1874 if (!initObject(
obj))
1879 for (
int i = 0;
i < rules.
size();
i++) {
1882 stateMask |=
selector.pseudoClass(&negated);
1883 stateMask |= negated;
1886 cacheIt =
cache.constFind(
state & stateMask);
1887 if (cacheIt !=
cache.constEnd()) {
1909 if (pseudoElement != PseudoElement_None) {
1913 if (!(complex->activeSubControls & subControl))
1917 switch (pseudoElement) {
1918 case PseudoElement_ComboBoxDropDown:
1919 case PseudoElement_ComboBoxArrow:
1922 case PseudoElement_SpinBoxUpButton:
1923 case PseudoElement_SpinBoxDownButton:
1924 case PseudoElement_SpinBoxUpArrow:
1925 case PseudoElement_SpinBoxDownArrow:
1926#if QT_CONFIG(spinbox)
1927 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
1929 bool up = pseudoElement == PseudoElement_SpinBoxUpButton
1930 || pseudoElement == PseudoElement_SpinBoxUpArrow;
1939 case PseudoElement_GroupBoxTitle:
1942 case PseudoElement_ToolButtonMenu:
1943 case PseudoElement_ToolButtonMenuArrow:
1944 case PseudoElement_ToolButtonMenuIndicator:
1950 case PseudoElement_SliderGroove:
1960 if (pseudoElement == PseudoElement_None
1968 if (!combo->editable)
1972#if QT_CONFIG(spinbox)
1973 }
else if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
1980 if (gb->lineWidth == 0)
1999 extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked)
2017#if QT_CONFIG(tabwidget)
2018 }
else if (
const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
opt)) {
2019 switch (tab->shape) {
2040#if QT_CONFIG(tabbar)
2041 }
else if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
2042 if (tab->position == QStyleOptionTab::OnlyOneTab)
2044 else if (tab->position == QStyleOptionTab::Beginning)
2046 else if (tab->position == QStyleOptionTab::End)
2048 else if (tab->position == QStyleOptionTab::Middle)
2051 if (tab->selectedPosition == QStyleOptionTab::NextIsSelected)
2053 else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
2056 switch (tab->shape) {
2083 if (frm->lineWidth == 0)
2088#if QT_CONFIG(toolbar)
2089 else if (
const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(
opt)) {
2099 if (tb->positionWithinLine == QStyleOptionToolBar::Beginning)
2101 else if (tb->positionWithinLine == QStyleOptionToolBar::Middle)
2103 else if (tb->positionWithinLine == QStyleOptionToolBar::End)
2105 else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
2109#if QT_CONFIG(toolbox)
2126#if QT_CONFIG(dockwidget)
2128 if (dw->verticalTitleBar)
2140#if QT_CONFIG(itemviews)
2141 else if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
2142 if (vopt->features & QStyleOptionViewItem::Alternate)
2144 if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne)
2146 else if (vopt->viewItemPosition == QStyleOptionViewItem::Beginning)
2148 else if (vopt->viewItemPosition == QStyleOptionViewItem::End)
2150 else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
2155#if QT_CONFIG(textedit)
2163#if QT_CONFIG(lineedit)
2168 extraClass &= ~PseudoClass_Frameless;
2174 if (
const QFrame *frm = qobject_cast<const QFrame *>(
obj)) {
2175 if (frm->lineWidth() == 0)
2176 extraClass |= PseudoClass_Frameless;
2180 return renderRule(
obj, pseudoElement, pseudoClass(
state) | extraClass);
2183bool QStyleSheetStyle::hasStyleRule(
const QObject *
obj,
int part)
const
2187 if (cacheIt !=
cache.constEnd())
2188 return cacheIt.
value();
2190 if (!initObject(
obj))
2194 if (part == PseudoElement_None) {
2201 for (
int i = 0;
i < rules.
size();
i++) {
2209 cache[part] =
false;
2213static Origin defaultOrigin(
int pe)
2216 case PseudoElement_ScrollBarAddPage:
2217 case PseudoElement_ScrollBarSubPage:
2218 case PseudoElement_ScrollBarAddLine:
2219 case PseudoElement_ScrollBarSubLine:
2220 case PseudoElement_ScrollBarFirst:
2221 case PseudoElement_ScrollBarLast:
2222 case PseudoElement_GroupBoxTitle:
2223 case PseudoElement_GroupBoxIndicator:
2224 case PseudoElement_ToolButtonMenu:
2225 case PseudoElement_SliderAddPage:
2226 case PseudoElement_SliderSubPage:
2229 case PseudoElement_SpinBoxUpButton:
2230 case PseudoElement_SpinBoxDownButton:
2231 case PseudoElement_PushButtonMenuIndicator:
2232 case PseudoElement_ComboBoxDropDown:
2233 case PseudoElement_ToolButtonMenuIndicator:
2234 case PseudoElement_MenuCheckMark:
2235 case PseudoElement_MenuIcon:
2236 case PseudoElement_MenuRightArrow:
2239 case PseudoElement_Indicator:
2240 case PseudoElement_ExclusiveIndicator:
2241 case PseudoElement_ComboBoxArrow:
2242 case PseudoElement_ScrollBarSlider:
2243 case PseudoElement_ScrollBarUpArrow:
2244 case PseudoElement_ScrollBarDownArrow:
2245 case PseudoElement_ScrollBarLeftArrow:
2246 case PseudoElement_ScrollBarRightArrow:
2247 case PseudoElement_SpinBoxUpArrow:
2248 case PseudoElement_SpinBoxDownArrow:
2249 case PseudoElement_ToolButtonMenuArrow:
2250 case PseudoElement_HeaderViewUpArrow:
2251 case PseudoElement_HeaderViewDownArrow:
2252 case PseudoElement_SliderGroove:
2253 case PseudoElement_SliderHandle:
2261static Qt::Alignment defaultPosition(
int pe)
2264 case PseudoElement_Indicator:
2265 case PseudoElement_ExclusiveIndicator:
2266 case PseudoElement_MenuCheckMark:
2267 case PseudoElement_MenuIcon:
2270 case PseudoElement_ScrollBarAddLine:
2271 case PseudoElement_ScrollBarLast:
2272 case PseudoElement_SpinBoxDownButton:
2273 case PseudoElement_PushButtonMenuIndicator:
2274 case PseudoElement_ToolButtonMenuIndicator:
2277 case PseudoElement_ScrollBarSubLine:
2278 case PseudoElement_ScrollBarFirst:
2279 case PseudoElement_SpinBoxUpButton:
2280 case PseudoElement_ComboBoxDropDown:
2281 case PseudoElement_ToolButtonMenu:
2282 case PseudoElement_DockWidgetCloseButton:
2283 case PseudoElement_DockWidgetFloatButton:
2286 case PseudoElement_ScrollBarUpArrow:
2287 case PseudoElement_ScrollBarDownArrow:
2288 case PseudoElement_ScrollBarLeftArrow:
2289 case PseudoElement_ScrollBarRightArrow:
2290 case PseudoElement_SpinBoxUpArrow:
2291 case PseudoElement_SpinBoxDownArrow:
2292 case PseudoElement_ComboBoxArrow:
2293 case PseudoElement_DownArrow:
2294 case PseudoElement_UpArrow:
2295 case PseudoElement_LeftArrow:
2296 case PseudoElement_RightArrow:
2297 case PseudoElement_ToolButtonMenuArrow:
2298 case PseudoElement_SliderGroove:
2301 case PseudoElement_GroupBoxTitle:
2302 case PseudoElement_GroupBoxIndicator:
2305 case PseudoElement_HeaderViewUpArrow:
2306 case PseudoElement_HeaderViewDownArrow:
2307 case PseudoElement_MenuRightArrow:
2320 case PseudoElement_Indicator:
2321 case PseudoElement_MenuCheckMark:
2322 if (sz.
width() == -1)
2328 case PseudoElement_ExclusiveIndicator:
2329 case PseudoElement_GroupBoxIndicator:
2330 if (sz.
width() == -1)
2336 case PseudoElement_PushButtonMenuIndicator: {
2338 if (sz.
width() == -1)
2345 case PseudoElement_ComboBoxDropDown:
2346 if (sz.
width() == -1)
2350 case PseudoElement_ComboBoxArrow:
2351 case PseudoElement_DownArrow:
2352 case PseudoElement_UpArrow:
2353 case PseudoElement_LeftArrow:
2354 case PseudoElement_RightArrow:
2355 case PseudoElement_ToolButtonMenuArrow:
2356 case PseudoElement_ToolButtonMenuIndicator:
2357 case PseudoElement_MenuRightArrow:
2358 if (sz.
width() == -1)
2364 case PseudoElement_SpinBoxUpButton:
2365 case PseudoElement_SpinBoxDownButton:
2366 if (sz.
width() == -1)
2372 case PseudoElement_ToolButtonMenu:
2373 if (sz.
width() == -1)
2377 case PseudoElement_HeaderViewUpArrow:
2378 case PseudoElement_HeaderViewDownArrow: {
2380 if (sz.
width() == -1)
2387 case PseudoElement_ScrollBarFirst:
2388 case PseudoElement_ScrollBarLast:
2389 case PseudoElement_ScrollBarAddLine:
2390 case PseudoElement_ScrollBarSubLine:
2391 case PseudoElement_ScrollBarSlider: {
2393 if (sz.
width() == -1)
2400 case PseudoElement_DockWidgetCloseButton:
2401 case PseudoElement_DockWidgetFloatButton: {
2413 if (sz.
width() == -1)
2422 case PseudoElement_ScrollBarFirst:
2423 case PseudoElement_ScrollBarLast:
2424 case PseudoElement_ScrollBarAddLine:
2425 case PseudoElement_ScrollBarSubLine:
2426 case PseudoElement_ScrollBarAddPage:
2427 case PseudoElement_ScrollBarSubPage:
2428 case PseudoElement_ScrollBarSlider:
2429 case PseudoElement_SliderGroove:
2430 case PseudoElement_SliderHandle:
2431 case PseudoElement_TabWidgetPane:
2438QRect QStyleSheetStyle::positionRect(
const QWidget *
w,
const QRenderRule &rule2,
int pe,
2441 const QStyleSheetPositionData *
p = rule2.position();
2443 Qt::Alignment
position = (
p &&
p->position != 0) ?
p->position : defaultPosition(pe);
2446 if (
mode != PositionMode_Absolute) {
2447 QSize sz = defaultSize(
w, rule2.size(), originRect, pe);
2448 sz = sz.
expandedTo(rule2.minimumContentsSize());
2451 int left =
p->left ?
p->left : -
p->right;
2452 int top =
p->top ?
p->top : -
p->bottom;
2459 if (rule2.hasContentsSize()) {
2460 QSize sz = rule2.size().expandedTo(rule2.minimumContentsSize());
2469QRect QStyleSheetStyle::positionRect(
const QWidget *
w,
const QRenderRule& rule1,
const QRenderRule& rule2,
int pe,
2472 const QStyleSheetPositionData *
p = rule2.position();
2474 QRect originRect = rule1.originRect(
rect, origin);
2475 return positionRect(
w, rule2, pe, originRect,
dir);
2485#if QT_CONFIG(combobox)
2486 if (
QComboBox *cmb = qobject_cast<QComboBox *>(
w)) {
2487 if (cmb->isEditable())
2488 return cmb->lineEdit();
2494#if QT_CONFIG(spinbox)
2499#if QT_CONFIG(scrollarea)
2500 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w))
2501 return sa->viewport();
2517#if QT_CONFIG(lineedit)
2518 if (qobject_cast<const QLineEdit *>(
w)) {
2520#if QT_CONFIG(combobox)
2521 if (qobject_cast<const QComboBox *>(
w->parentWidget()))
2524#if QT_CONFIG(spinbox)
2525 if (qobject_cast<const QAbstractSpinBox *>(
w->parentWidget()))
2531#if QT_CONFIG(scrollarea)
2532 if (
const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(
w->parentWidget())) {
2533 if (sa->viewport() ==
w)
2544static bool unstylable(
const QWidget *
w)
2549 if (!
w->styleSheet().isEmpty())
2552 if (containerWidget(
w) !=
w)
2557 else if (qobject_cast<const QFrame *>(
w)) {
2560 || qobject_cast<const QComboBox *>(
w->parentWidget())
2567#if QT_CONFIG(tabbar)
2568 if (
w->metaObject() == &QWidget::staticMetaObject
2569 && qobject_cast<const QTabBar*>(
w->parentWidget()))
2579#if QT_CONFIG(abstractslider)
2580 if (
const QAbstractSlider *slider = qobject_cast<const QAbstractSlider *>(
w)) {
2584#if QT_CONFIG(combobox)
2585 if (
const QComboBox *combo = qobject_cast<const QComboBox *>(
w)) {
2586 if (combo->isEditable())
2590#if QT_CONFIG(lineedit)
2591 if (
const QLineEdit *
edit = qobject_cast<const QLineEdit *>(
w)) {
2595#if QT_CONFIG(textedit)
2596 if (
const QTextEdit *
edit = qobject_cast<const QTextEdit *>(
w)) {
2613void QStyleSheetStyle::setGeometry(
QWidget *
w)
2615 QRenderRule rule = renderRule(
w, PseudoElement_None, PseudoClass_Enabled | extendedPseudoClass(
w));
2616 const QStyleSheetGeometryData *geo =
rule.geometry();
2617 if (
w->property(
"_q_stylesheet_minw").toBool()
2618 && ((!
rule.hasGeometry() || geo->minWidth == -1))) {
2619 w->setMinimumWidth(0);
2622 if (
w->property(
"_q_stylesheet_minh").toBool()
2623 && ((!
rule.hasGeometry() || geo->minHeight == -1))) {
2624 w->setMinimumHeight(0);
2625 w->setProperty(
"_q_stylesheet_minh",
QVariant());
2627 if (
w->property(
"_q_stylesheet_maxw").toBool()
2628 && ((!
rule.hasGeometry() || geo->maxWidth == -1))) {
2630 w->setProperty(
"_q_stylesheet_maxw",
QVariant());
2632 if (
w->property(
"_q_stylesheet_maxh").toBool()
2633 && ((!
rule.hasGeometry() || geo->maxHeight == -1))) {
2635 w->setProperty(
"_q_stylesheet_maxh",
QVariant());
2639 if (
rule.hasGeometry()) {
2640 if (geo->minWidth != -1) {
2641 w->setProperty(
"_q_stylesheet_minw",
true);
2642 w->setMinimumWidth(
rule.boxSize(
QSize(
qMax(geo->width, geo->minWidth), 0)).width());
2644 if (geo->minHeight != -1) {
2645 w->setProperty(
"_q_stylesheet_minh",
true);
2646 w->setMinimumHeight(
rule.boxSize(
QSize(0,
qMax(geo->height, geo->minHeight))).height());
2648 if (geo->maxWidth != -1) {
2649 w->setProperty(
"_q_stylesheet_maxw",
true);
2653 if (geo->maxHeight != -1) {
2654 w->setProperty(
"_q_stylesheet_maxh",
true);
2661void QStyleSheetStyle::setProperties(
QWidget *
w)
2673 for (
int i = decls.
size() - 1;
i >= 0; --
i) {
2674 const QString property = decls.
at(
i).d->property;
2677 if (!propertySet.hasSeen(
property))
2682 for (
int i = finals.
size() - 1;
i >= 0; --
i) {
2685 property =
property.mid(10);
2686 const auto propertyL1 =
property.toLatin1();
2702 switch (
value.userType()) {
2703 case QMetaType::QIcon:
v = decl.
iconValue();
break;
2706 case QMetaType::QRect:
v = decl.
rectValue();
break;
2707 case QMetaType::QSize:
v = decl.
sizeValue();
break;
2708 case QMetaType::QColor:
v = decl.
colorValue();
break;
2709 case QMetaType::QBrush:
v = decl.
brushValue();
break;
2710#ifndef QT_NO_SHORTCUT
2711 case QMetaType::QKeySequence:
v =
QKeySequence(decl.
d->values.at(0).variant.toString());
break;
2713 default:
v = decl.
d->values.at(0).variant;
break;
2719 w->setProperty(propertyL1,
v);
2723void QStyleSheetStyle::setPalette(
QWidget *
w)
2725 struct RuleRoleMap {
2734 const bool useStyleSheetPropagationInWidgetStyles =
2738 if (!useStyleSheetPropagationInWidgetStyles)
2743 for (
int i = 0;
i < 3;
i++) {
2746 if (!
w->property(
"_q_styleSheetWidgetFont").isValid()) {
2757 if (!useStyleSheetPropagationInWidgetStyles ||
p.resolveMask() != 0) {
2761 if (useStyleSheetPropagationInWidgetStyles) {
2772void QStyleSheetStyle::unsetPalette(
QWidget *
w)
2774 const bool useStyleSheetPropagationInWidgetStyles =
2779 auto customizedPalette = std::move(*
it);
2783 if (useStyleSheetPropagationInWidgetStyles)
2784 original = std::move(customizedPalette).reverted(
w->palette());
2786 original = customizedPalette.oldWidgetValue;
2788 w->setPalette(original);
2794 if (useStyleSheetPropagationInWidgetStyles) {
2795 unsetStyleSheetFont(
w);
2798 unsetStyleSheetFont(ew);
2800 QVariant oldFont =
w->property(
"_q_styleSheetWidgetFont");
2802 w->setFont(qvariant_cast<QFont>(oldFont));
2807 embeddedWidget(
w)->setAutoFillBackground(
true);
2812void QStyleSheetStyle::unsetStyleSheetFont(
QWidget *
w)
const
2816 auto customizedFont = std::move(*
it);
2818 w->setFont(std::move(customizedFont).reverted(
w->font()));
2825 for (
const QObject *
object : objects) {
2833 for (
const QObject *
object : objects) {
2841 updateObjects(children);
2851 : QWindowsStyle(*new QStyleSheetStylePrivate),
base(
base), refcount(1)
2854 if (numinstances == 1) {
2863 delete styleSheetCaches;
2895bool QStyleSheetStyle::initObject(
const QObject *
obj)
const
2914 RECURSION_GUARD(
return)
2934 for (
int i = 0;
i < rules.
size();
i++) {
2938 if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) {
2941 embeddedWidget(
w)->setMouseTracking(
true);
2946#if QT_CONFIG(scrollarea)
2947 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w)) {
2948 QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled);
2949 if ((
rule.hasBorder() &&
rule.border()->hasBorderImage())
2950 || (
rule.hasBackground() && !
rule.background()->pixmap.isNull())) {
2963 if (
rule.hasDrawable() ||
rule.hasBox()) {
2964 if (
w->metaObject() == &QWidget::staticMetaObject
2966 || qobject_cast<QHeaderView *>(
w)
2969 || qobject_cast<QTabBar *>(
w)
2972 || qobject_cast<QFrame *>(
w)
2975 || qobject_cast<QMainWindow *>(
w)
2978 || qobject_cast<QMdiSubWindow *>(
w)
2981 || qobject_cast<QMenuBar *>(
w)
2984 || qobject_cast<QDialog *>(
w)
2998 if (!
rule.hasBackground() ||
rule.background()->isTransparent() ||
rule.hasBox()
2999 || (!
rule.hasNativeBorder() && !
rule.border()->isOpaque()))
3001 if (
rule.hasBox() || !
rule.hasNativeBorder()
3003 || (qobject_cast<QPushButton *>(
w))
3023 children.
reserve(
w->children().size() + 1);
3024 for (
auto child:
std::as_const(
w->children()))
3028 updateObjects(children);
3039 updateObjects(allObjects);
3058#if QT_CONFIG(scrollarea)
3059 if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(
w)) {
3061 sa,
SLOT(update()));
3063 sa,
SLOT(update()));
3072 RECURSION_GUARD(
return)
3091 if (
rule.hasNativeBorder()) {
3092 rule.drawBackgroundImage(
p, cmbOpt.rect);
3095 && (hasStyleRule(
w, PseudoElement_ComboBoxDropDown) || hasStyleRule(
w, PseudoElement_ComboBoxArrow));
3097 cmbOpt.subControls &=
~QStyle::SC_ComboBoxArrow;
3098 if (
rule.baseStyleCanDraw()) {
3101 QWindowsStyle::drawComplexControl(cc, &cmbOpt,
p,
w);
3103 if (!customDropDown)
3110 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
3111 if (subRule.hasDrawable()) {
3113 subRule.drawRule(
p,
r);
3114 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_ComboBoxArrow);
3115 r = positionRect(
w, subRule, subRule2, PseudoElement_ComboBoxArrow,
r,
opt->
direction);
3116 subRule2.drawRule(
p,
r);
3120 QWindowsStyle::drawComplexControl(cc, &cmbOpt,
p,
w);
3128#if QT_CONFIG(spinbox)
3130 if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
3131 QStyleOptionSpinBox spinOpt(*spin);
3135 bool customUp =
true, customDown =
true;
3136 QRenderRule upRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
3137 QRenderRule downRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
3138 bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
3139 bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
3140 if (
rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
3141 rule.drawBackgroundImage(
p, spinOpt.rect);
3143 && (hasStyleRule(
w, PseudoElement_SpinBoxUpButton) || hasStyleRule(
w, PseudoElement_UpArrow));
3145 spinOpt.subControls &=
~QStyle::SC_SpinBoxUp;
3147 && (hasStyleRule(
w, PseudoElement_SpinBoxDownButton) || hasStyleRule(
w, PseudoElement_DownArrow));
3149 spinOpt.subControls &=
~QStyle::SC_SpinBoxDown;
3150 if (
rule.baseStyleCanDraw()) {
3153 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3155 if (!customUp && !customDown)
3162 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
3163 if (subRule.hasDrawable()) {
3165 subRule.drawRule(
p,
r);
3166 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SpinBoxUpArrow);
3167 r = positionRect(
w, subRule, subRule2, PseudoElement_SpinBoxUpArrow,
r,
opt->
direction);
3168 subRule2.drawRule(
p,
r);
3171 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3176 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
3177 if (subRule.hasDrawable()) {
3179 subRule.drawRule(
p,
r);
3180 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SpinBoxDownArrow);
3181 r = positionRect(
w, subRule, subRule2, PseudoElement_SpinBoxDownArrow,
r,
opt->
direction);
3182 subRule2.drawRule(
p,
r);
3185 QWindowsStyle::drawComplexControl(cc, &spinOpt,
p,
w);
3196 QRect labelRect, checkBoxRect, titleRect, frameRect;
3199 if (!
rule.hasDrawable() && (!hasTitle || !hasStyleRule(
w, PseudoElement_GroupBoxTitle))
3200 && !hasStyleRule(
w, PseudoElement_Indicator) && !
rule.hasBox() && !
rule.hasFont && !
rule.hasPalette()) {
3206 QRenderRule titleRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
3207 bool clipSet =
false;
3212 labelRect.
setSize(labelRect.
size().
expandedTo(ParentStyle::subControlRect(CC_GroupBox,
opt, SC_GroupBoxLabel,
w).size()));
3215 titleRect = titleRule.boxRect(checkBoxRect.
united(labelRect));
3217 titleRect = titleRule.boxRect(labelRect);
3219 if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) {
3228 frame.QStyleOption::operator=(*gb);
3229 frame.features = gb->features;
3240 titleRule.drawRule(
p, titleRect);
3245 box.QStyleOption::operator=(*gb);
3246 box.rect = checkBoxRect;
3251 if (!gb->text.isEmpty()) {
3258 if (gb->textColor.isValid())
3264 if (gb->state & State_HasFocus) {
3266 fropt.QStyleOption::operator=(*gb);
3267 fropt.
rect = labelRect;
3280 toolOpt.font =
rule.font.resolve(toolOpt.font);
3282 const auto customArrowElement = [tool]{
3283 switch (tool->arrowType) {
3290 return PseudoElement_None;
3295 bool customArrow = drawArrow && hasStyleRule(
w, customArrowElement());
3301 bool customDropDown = drawDropDown && hasStyleRule(
w, PseudoElement_ToolButtonMenu);
3302 bool customDropDownArrow =
false;
3304 if (customDropDown) {
3305 toolOpt.subControls &=
~QStyle::SC_ToolButtonMenu;
3306 customDropDownArrow = hasStyleRule(
w, PseudoElement_ToolButtonMenuArrow);
3307 if (customDropDownArrow)
3310 const bool customMenuIndicator = (!drawDropDown && drawMenuIndicator)
3311 && hasStyleRule(
w, PseudoElement_ToolButtonMenuIndicator);
3312 if (customMenuIndicator)
3315 if (
rule.hasNativeBorder()) {
3316 if (tool->subControls & SC_ToolButton) {
3320 State bflags = tool->state & ~State_Sunken;
3321 if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled)))
3322 bflags &= ~State_Raised;
3323 if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton)
3324 bflags |= State_Sunken;
3325 if (!(bflags & (State_Sunken | State_On | State_Raised)))
3326 rule.drawBackground(
p, toolOpt.rect);
3331 if (customMenuIndicator)
3333 if (customDropDown || customDropDownArrow)
3339 QWindowsStyle::drawComplexControl(cc, &nativeToolOpt,
p,
w);
3342 drawMenuIndicator =
false;
3344 drawDropDown =
false;
3349 toolOpt.font =
rule.font.resolve(toolOpt.font);
3353 const QRect cr = toolOpt.rect;
3357 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
3359 if (subRule.hasDrawable()) {
3360 subRule.drawRule(
p, menuButtonRect);
3362 toolOpt.rect = menuButtonRect;
3366 if (customDropDownArrow || drawMenuIndicator) {
3367 QRenderRule arrowRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuArrow);
3368 QRect arrowRect = arrowRule.hasGeometry()
3369 ? positionRect(
w, arrowRule, PseudoElement_ToolButtonMenuArrow, menuButtonRect, toolOpt.direction)
3370 : arrowRule.contentsRect(menuButtonRect);
3371 if (arrowRule.hasDrawable()) {
3372 arrowRule.drawRule(
p, arrowRect);
3374 toolOpt.rect = arrowRect;
3379 }
else if (drawMenuIndicator) {
3380 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuIndicator);
3384 QRect r = positionRect(
w,
rule, subRule, PseudoElement_ToolButtonMenuIndicator,
opt->
rect, toolOpt.direction);
3385 if (subRule.hasDrawable()) {
3386 subRule.drawRule(
p,
r);
3397 const auto arrowElement = customArrowElement();
3399 QRect arrowRect = subRule.hasGeometry() ? positionRect(
w, subRule, arrowElement, toolOpt.rect, toolOpt.direction)
3400 : subRule.contentsRect(toolOpt.
rect);
3402 switch (toolOpt.toolButtonStyle) {
3410 toolOpt.text = tool->text;
3411 if (!subRule.hasGeometry())
3414 if (!subRule.hasGeometry())
3423 subRule.drawRule(
p, arrowRect);
3429#if QT_CONFIG(scrollbar)
3431 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
3432 if (!
rule.hasDrawable()) {
3433 QStyleOptionSlider sbOpt(*sb);
3439 QWindowsStyle::drawComplexControl(cc,
opt,
p,
w);
3446#if QT_CONFIG(slider)
3448 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
3451 QRenderRule grooveSubRule = renderRule(
w,
opt, PseudoElement_SliderGroove);
3452 QRenderRule handleSubRule = renderRule(
w,
opt, PseudoElement_SliderHandle);
3453 if (!grooveSubRule.hasDrawable()) {
3454 QStyleOptionSlider slOpt(*slider);
3455 bool handleHasRule = handleSubRule.hasDrawable();
3458 slOpt.subControls &= ~SC_SliderHandle;
3465 if (slider->subControls & SC_SliderGroove) {
3466 grooveSubRule.drawRule(
p, gr);
3469 if (slider->subControls & SC_SliderHandle) {
3472 QRenderRule subRule1 = renderRule(
w,
opt, PseudoElement_SliderSubPage);
3473 if (subRule1.hasDrawable()) {
3478 subRule1.drawRule(
p,
r);
3481 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SliderAddPage);
3482 if (subRule2.hasDrawable()) {
3487 subRule2.drawRule(
p,
r);
3490 handleSubRule.drawRule(
p, handleSubRule.boxRect(hr, Margin));
3493 if (slider->subControls & SC_SliderTickmarks) {
3502 case CC_MdiControls:
3503 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
3504 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
3505 || hasStyleRule(
w, PseudoElement_MdiMinButton)) {
3508 layout = subControlLayout(
"mNX"_L1);
3511 optCopy.subControls = { };
3512 for (
int i = 0;
i <
layout.size();
i++) {
3513 int layoutButton =
layout[
i].toInt();
3514 if (layoutButton < PseudoElement_MdiCloseButton
3515 || layoutButton > PseudoElement_MdiNormalButton)
3518 if (!(
opt->subControls & control))
3521 if (subRule.hasDrawable()) {
3523 subRule.drawRule(
p,
rect);
3527 optCopy.subControls |= control;
3531 if (optCopy.subControls)
3540 if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
3546 ir =
layout[SC_TitleBarLabel];
3548 if (subRule.hasPalette())
3549 p->setPen(subRule.palette()->foreground.color());
3556 ir =
layout[SC_TitleBarSysMenu];
3558 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_TitleBarSysMenu);
3559 subSubRule.drawRule(
p, ir);
3560 ir = subSubRule.contentsRect(ir);
3570 ir =
layout[SC_TitleBarCloseButton];
3572 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_TitleBarCloseButton);
3573 subSubRule.drawRule(
p, ir);
3575 QSize sz = subSubRule.contentsRect(ir).size();
3584 PseudoElement_TitleBarMaxButton,
3585 PseudoElement_TitleBarMinButton,
3586 PseudoElement_TitleBarNormalButton,
3587 PseudoElement_TitleBarShadeButton,
3588 PseudoElement_TitleBarUnshadeButton,
3589 PseudoElement_TitleBarContextHelpButton
3592 for (
unsigned int i = 0;
i <
sizeof(pes)/
sizeof(
int);
i++) {
3599 subSubRule.drawRule(
p, ir);
3600 pm =
standardIcon(subControlIcon(pe),
nullptr,
w).
pixmap(subSubRule.contentsRect(ir).size());
3617 const QRect &
rect, QRenderRule &subRule)
const
3625 const int pixw =
pixmap.width() /
pixmap.devicePixelRatio();
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);
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)
3759 int pixmapWidth =
pixmap.width() /
pixmap.devicePixelRatio();
3760 int pixmapHeight =
pixmap.height() /
pixmap.devicePixelRatio();
3761 int labelWidth = pixmapWidth;
3762 int labelHeight = pixmapHeight;
3763 int iconSpacing = 4;
3766 labelWidth += (textWidth + iconSpacing);
3771 pixmapWidth, pixmapHeight);
3775 pixmapWidth, pixmapHeight);
3779 pixmapWidth, pixmapHeight);
3785 tf &= ~horizontalAlignMask;
3793 if (
button->state & (State_On | State_Sunken))
3796 p->drawPixmap(iconRect,
pixmap);
3799 if (
button->state & (State_On | State_Sunken))
3813 ParentStyle::drawControl(ce, &butOpt,
p,
w);
3817 p->setFont(oldFont);
3821 case CE_RadioButton:
3823 if (
rule.hasBox() || !
rule.hasNativeBorder() ||
rule.hasDrawable() || hasStyleRule(
w, PseudoElement_Indicator)) {
3825 ParentStyle::drawControl(ce,
opt,
p,
w);
3834 case CE_RadioButtonLabel:
3835 case CE_CheckBoxLabel:
3839 ParentStyle::drawControl(ce, &butOpt,
p,
w);
3844 pe1 = PseudoElement_SplitterHandle;
3848 if (
rule.hasBackground()) {
3851 if (
rule.hasBorder()) {
3854#if QT_CONFIG(toolbar)
3855 if (
const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(
opt)) {
3856 QStyleOptionToolBar newTb(*tb);
3864 case CE_MenuEmptyArea:
3865 case CE_MenuBarEmptyArea:
3866 if (
rule.hasDrawable()) {
3872 case CE_MenuTearoff:
3873 case CE_MenuScroller:
3876 int pe = ce == CE_MenuTearoff ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
3882 if (subRule.hasDrawable()) {
3901 QFont oldFont =
p->font();
3902 if (subRule.hasFont)
3903 p->setFont(subRule.font.resolve(mi.
font));
3905 p->setFont(mi.
font);
3909 QRenderRule allRules = renderRule(
w, PseudoElement_Item, PseudoClass_Any);
3911 if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
3913 }
else if ((pseudo == PseudoElement_Item)
3914 && (allRules.hasBox() || allRules.hasBorder() || subRule.hasFont
3915 || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
3917 if (subRule.hasBackground()) {
3925 int textRectOffset =
m->maxIconWidth;
3927 renderMenuItemIcon(&mi,
p,
w,
opt->
rect, subRule);
3930 const bool checked = checkable ? mi.
checked :
false;
3932 const QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
3934 if (checkable && (subSubRule.hasDrawable() || checked)) {
3937 newMi.
state |= State_Enabled;
3939 newMi.
state |= State_On;
3940 newMi.
rect = cmRect;
3943 textRectOffset = std::max(textRectOffset, cmRect.
width());
3955 if (!
styleHint(SH_UnderlineShortcut, &mi,
w))
3961 p->drawText(vShortcutRect, text_flags,
s.mid(
t + 1).toString());
3964 p->drawText(vTextRect, text_flags,
s.left(
t).toString());
3969 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_MenuRightArrow);
3970 mi.
rect = positionRect(
w, subRule, subRule2, PseudoElement_MenuRightArrow,
opt->
rect, mi.
direction);
3973 }
else if (!mi.
icon.
isNull() && hasStyleRule(
w, PseudoElement_MenuIcon)) {
3979 if (
rule.baseStyleCanDraw() && subRule.baseStyleCanDraw())
3982 ParentStyle::drawControl(ce, &newMi,
p,
w);
3983 renderMenuItemIcon(&mi,
p,
w,
opt->
rect, subRule);
3984 }
else if (hasStyleRule(
w, PseudoElement_MenuCheckMark) || hasStyleRule(
w, PseudoElement_MenuRightArrow)) {
3985 QWindowsStyle::drawControl(ce, &mi,
p,
w);
3989 int checkcol = qMax<int>(mi.
maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
3991 if (mi.
state.testFlag(State_Enabled) && mi.
state.testFlag(State_Selected)) {
3997 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
3998 if (subSubRule.hasDrawable()) {
4001 mi.
rect.
y() + QWindowsStylePrivate::windowsItemFrame,
4002 checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
4003 mi.
rect.
height() - 2 * QWindowsStylePrivate::windowsItemFrame));
4012 if (
rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
4015 ParentStyle::drawControl(ce, &mi,
p,
w);
4019 p->setFont(oldFont);
4025 case CE_MenuBarItem:
4033 if (subRule.hasDrawable()) {
4047#if QT_CONFIG(combobox)
4048 case CE_ComboBoxLabel:
4054 p->setClipRect(editRect);
4055 if (!
cb->currentIcon.isNull()) {
4061 QRect iconRect(editRect);
4065 iconRect.
size(), editRect);
4073 if (!
cb->currentText.isEmpty() && !
cb->editable) {
4086 if (hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)
4087 || hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)) {
4088 ParentStyle::drawControl(ce,
opt,
p,
w);
4091 if (hasStyleRule(
w, PseudoElement_HeaderViewSection)) {
4092 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4093 if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
4094 || subRule.hasBackground() || subRule.hasPalette() || subRule.hasFont || subRule.hasBorder()) {
4095 ParentStyle::drawControl(ce,
opt,
p,
w);
4100 case CE_HeaderSection:
4102 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4103 if (subRule.hasNativeBorder()) {
4107 if (subRule.baseStyleCanDraw()) {
4110 QWindowsStyle::drawControl(CE_HeaderSection, &hdr,
p,
w);
4119 case CE_HeaderLabel:
4123 if (
auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(
opt))
4127 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
4128 if (hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)
4129 || hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)) {
4137 if (subRule.hasFont) {
4138 QFont oldFont =
p->font();
4139 p->setFont(subRule.font.resolve(
p->font()));
4140 ParentStyle::drawControl(ce, &hdr,
p,
w);
4141 p->setFont(oldFont);
4149 case CE_HeaderEmptyArea:
4150 if (
rule.hasDrawable()) {
4155 case CE_ProgressBar:
4156 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4159 case CE_ProgressBarGroove:
4160 if (!
rule.hasNativeBorder()) {
4166 case CE_ProgressBarContents: {
4167 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ProgressBarChunk);
4168 if (subRule.hasDrawable()) {
4171 p->setClipRect(pb->rect);
4177 bool inverted = pb->invertedAppearance;
4184 m.translate(0, -(
rect.height() +
rect.y()*2));
4187 bool reverse = ((!vertical && (pb->direction ==
Qt::RightToLeft)) || vertical);
4190 const bool indeterminate = pb->minimum == pb->maximum;
4191 const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (
maximum -
minimum);
4192 const auto fillWidth =
static_cast<int>(
rect.width() * fillRatio);
4193 int chunkWidth = fillWidth;
4194 if (subRule.hasContentsSize()) {
4195 QSize sz = subRule.size();
4200#if QT_CONFIG(animation)
4201 Q_D(
const QWindowsStyle);
4203 if (pb->minimum == 0 && pb->maximum == 0) {
4204 int chunkCount = fillWidth/chunkWidth;
4206#if QT_CONFIG(animation)
4212 int x = reverse ?
r.left() +
r.width() -
offset - chunkWidth :
r.x() +
offset;
4213 while (chunkCount > 0) {
4214 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4216 subRule.drawRule(
p,
r);
4217 x += reverse ? -chunkWidth : chunkWidth;
4224 x = reverse ?
r.right() - (
r.left() -
x - chunkWidth)
4226 while (chunkCount > 0) {
4227 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4229 subRule.drawRule(
p,
r);
4230 x += reverse ? -chunkWidth : chunkWidth;
4233 }
else if (chunkWidth > 0) {
4234 const auto ceil = [](
qreal x) {
return int(
x) + (
x > 0 &&
x != int(
x)); };
4235 const int chunkCount = ceil(
qreal(fillWidth)/chunkWidth);
4236 int x = reverse ?
r.left() +
r.width() - chunkWidth :
r.x();
4238 for (
int i = 0;
i < chunkCount; ++
i) {
4239 r.setRect(
x,
rect.y(), chunkWidth,
rect.height());
4241 subRule.drawRule(
p,
r);
4242 x += reverse ? -chunkWidth : chunkWidth;
4244#if QT_CONFIG(animation)
4256 case CE_ProgressBarLabel:
4258 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_ProgressBarChunk)) {
4272 if (
rule.hasDrawable()) {
4275 static constexpr int rotation[] = { 180, 270, 90, 0 };
4276 if (rotation[sgOpt->corner]) {
4278 p->rotate(rotation[sgOpt->corner]);
4293 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4296 case CE_ToolBoxTabShape: {
4298 if (subRule.hasDrawable()) {
4305 case CE_ToolBoxTabLabel:
4310 QFont oldFont =
p->font();
4311 if (subRule.hasFont)
4312 p->setFont(subRule.font.resolve(
p->font()));
4313 boxCopy.rect = subRule.contentsRect(
opt->
rect);
4314 if (subRule.hasImage()) {
4317 boxCopy.rect.setLeft(boxCopy.rect.left() + iconExtent);
4319 QWindowsStyle::drawControl(ce, &boxCopy,
p ,
w);
4320 if (subRule.hasFont)
4321 p->setFont(oldFont);
4326 case CE_ScrollBarAddPage:
4327 pe1 = PseudoElement_ScrollBarAddPage;
4330 case CE_ScrollBarSubPage:
4331 pe1 = PseudoElement_ScrollBarSubPage;
4334 case CE_ScrollBarAddLine:
4335 pe1 = PseudoElement_ScrollBarAddLine;
4340 case CE_ScrollBarSubLine:
4341 pe1 = PseudoElement_ScrollBarSubLine;
4346 case CE_ScrollBarFirst:
4347 pe1 = PseudoElement_ScrollBarFirst;
4350 case CE_ScrollBarLast:
4351 pe1 = PseudoElement_ScrollBarLast;
4354 case CE_ScrollBarSlider:
4355 pe1 = PseudoElement_ScrollBarSlider;
4359#if QT_CONFIG(itemviews)
4360 case CE_ItemViewItem:
4361 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4363 QStyleOptionViewItem optCopy(*vopt);
4364 if (subRule.hasDrawable()) {
4367 QWindowsStyle::drawControl(ce, &optCopy,
p,
w);
4370 if (hasStyleRule(
w, PseudoElement_Indicator)) {
4374 QStyleOptionViewItem optIndicator(*vopt);
4375 subRule.configurePalette(&optIndicator.palette,
4384 optIndicator.text.clear();
4385 QWindowsStyle::drawControl(ce, &optIndicator,
p,
w);
4389 optCopy.icon =
QIcon();
4400 p->setClipRegion(clipRegion);
4411#if QT_CONFIG(tabbar)
4413 if (hasStyleRule(
w, PseudoElement_TabBarTab)) {
4414 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4419 case CE_TabBarTabLabel:
4420 case CE_TabBarTabShape:
4421 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
4426 subRule.drawRule(
p,
r);
4429 QStyleOptionTab tabCopy(*tab);
4430 subRule.configurePalette(&tabCopy.palette, foregroundRole,
QPalette::Base);
4431 QFont oldFont =
p->font();
4432 if (subRule.hasFont)
4433 p->setFont(subRule.font.resolve(
p->font()));
4434 if (subRule.hasBox() || !subRule.hasNativeBorder()) {
4435 tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(
r)
4436 : subRule.contentsRect(
r);
4437 QWindowsStyle::drawControl(ce, &tabCopy,
p,
w);
4441 if (subRule.hasFont)
4442 p->setFont(oldFont);
4449 case CE_ColumnViewGrip:
4450 if (
rule.hasDrawable()) {
4456 case CE_DockWidgetTitle:
4458 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
4459 if (!subRule.hasDrawable() && !subRule.hasPosition())
4461 if (subRule.hasDrawable()) {
4469 if (!dwOpt->title.isEmpty()) {
4471 if (dwOpt->verticalTitleBar) {
4474 p->translate(
r.left(),
r.top() +
r.width());
4476 p->translate(-
r.left(), -
r.top());
4478 r = subRule.contentsRect(
r);
4481 if (subRule.hasPosition())
4482 alignment = subRule.position()->textAlignment;
4489 dwOpt->state & State_Enabled, titleText,
4492 if (dwOpt->verticalTitleBar)
4499 case CE_ShapedFrame:
4501 if (
rule.hasNativeBorder()) {
4504 frmOpt.rect =
rule.borderRect(frmOpt.rect);
4516 if (pe1 != PseudoElement_None) {
4518 if (subRule.bg !=
nullptr || subRule.hasDrawable()) {
4522 }
else if (fallback) {
4523 QWindowsStyle::drawControl(ce,
opt,
p,
w);
4524 pe2 = PseudoElement_None;
4528 if (pe2 != PseudoElement_None) {
4531 subSubRule.drawRule(
p,
r);
4556 int pseudoElement = PseudoElement_None;
4562 case PE_FrameStatusBarItem: {
4564 if (subRule.hasDrawable()) {
4571 case PE_IndicatorArrowDown:
4572 pseudoElement = PseudoElement_DownArrow;
4575 case PE_IndicatorArrowUp:
4576 pseudoElement = PseudoElement_UpArrow;
4579 case PE_IndicatorRadioButton:
4580 pseudoElement = PseudoElement_ExclusiveIndicator;
4583 case PE_IndicatorItemViewItemCheck:
4584 pseudoElement = PseudoElement_ViewItemIndicator;
4587 case PE_IndicatorCheckBox:
4588 pseudoElement = PseudoElement_Indicator;
4591 case PE_IndicatorHeaderArrow:
4594 ? PseudoElement_HeaderViewUpArrow
4595 : PseudoElement_HeaderViewDownArrow;
4599 case PE_PanelButtonTool:
4600 case PE_PanelButtonCommand:
4601#if QT_CONFIG(abstractbutton)
4602 if (qobject_cast<const QAbstractButton *>(
w) &&
rule.hasBackground() &&
rule.hasNativeBorder()) {
4604 ParentStyle::drawPrimitive(pe,
opt,
p,
w);
4605 if (!
rule.background()->pixmap.isNull() ||
rule.hasImage()) {
4606 rule.drawRule(
p,
rule.boxRect(
opt->
rect, QRenderRule::Margin).adjusted(1,1,-1,-1));
4611 if (!
rule.hasNativeBorder()) {
4617 case PE_IndicatorButtonDropDown: {
4618 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
4619 if (!subRule.hasNativeBorder()) {
4626 case PE_FrameDefaultButton:
4627 if (
rule.hasNativeBorder()) {
4628 if (
rule.baseStyleCanDraw())
4630 QWindowsStyle::drawPrimitive(pe,
opt,
p,
w);
4634 case PE_FrameWindow:
4635 case PE_FrameDockWidget:
4638 if (
rule.hasNativeBorder()) {
4648 case PE_PanelLineEdit:
4652 if (
QWidget *container = containerWidget(
w); container !=
w) {
4654 if (!containerRule.hasNativeBorder() || !containerRule.baseStyleCanDraw())
4656 rule = containerRule;
4660 if (
rule.hasNativeBorder()) {
4663 frmOpt.rect =
rule.borderRect(frmOpt.rect);
4664 if (
rule.baseStyleCanDraw()) {
4669 if (frmOpt.lineWidth > 0)
4679 if (
w && !
rule.hasDrawable()) {
4680 QWidget *container = containerWidget(
w);
4682 && (container ==
w || !renderRule(container,
opt).hasBackground())) {
4689#if QT_CONFIG(scrollarea)
4690 if (
const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(
w)) {
4691 const QAbstractScrollAreaPrivate *sap = sa->d_func();
4692 rule.drawBackground(
p,
opt->
rect, sap->contentsOffset());
4693 if (
rule.hasBorder()) {
4696 QRect r = brect.
adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
4697 sa->horizontalScrollBar()->
isVisible() ? -sa->horizontalScrollBar()->
height() : 0);
4700 rule.drawBorder(
p, brect);
4707 case PE_PanelStatusBar:
4708 if (
rule.hasDrawable()) {
4715 if (
rule.hasDrawable()) {
4721 case PE_PanelMenuBar:
4722 if (
rule.hasDrawable()) {
4728 case PE_IndicatorToolBarSeparator:
4729 case PE_IndicatorToolBarHandle: {
4730 PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator;
4732 if (subRule.hasDrawable()) {
4739 case PE_IndicatorMenuCheckMark:
4740 pseudoElement = PseudoElement_MenuCheckMark;
4743 case PE_IndicatorArrowLeft:
4744 pseudoElement = PseudoElement_LeftArrow;
4747 case PE_IndicatorArrowRight:
4748 pseudoElement = PseudoElement_RightArrow;
4751 case PE_IndicatorColumnViewArrow:
4752#if QT_CONFIG(itemviews)
4753 if (
const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4755 pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow;
4759 pseudoElement = PseudoElement_RightArrow;
4763#if QT_CONFIG(itemviews)
4764 case PE_IndicatorBranch:
4765 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
4766 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_TreeViewBranch);
4767 if (subRule.hasDrawable()) {
4768 proxy()->drawPrimitive(PE_PanelItemViewRow, vopt,
p,
w);
4777 case PE_PanelTipLabel:
4778 if (!
rule.hasDrawable())
4782 if (
rule.hasNativeBorder()) {
4794 case PE_FrameGroupBox:
4795 if (
rule.hasNativeBorder())
4800#if QT_CONFIG(tabwidget)
4801 case PE_FrameTabWidget:
4802 if (
const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(
opt)) {
4803 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_TabWidgetPane);
4804 if (subRule.hasNativeBorder()) {
4805 subRule.drawBackground(
p,
opt->
rect);
4806 QStyleOptionTabWidgetFrame frmCopy(*frm);
4817 case PE_IndicatorProgressChunk:
4818 pseudoElement = PseudoElement_ProgressBarChunk;
4821 case PE_IndicatorTabTear:
4822 pseudoElement = PseudoElement_TabBarTear;
4825 case PE_FrameFocusRect:
4826 if (!
rule.hasNativeOutline()) {
4832 case PE_IndicatorDockWidgetResizeHandle:
4833 pseudoElement = PseudoElement_DockWidgetSeparator;
4836 case PE_PanelItemViewRow:
4844 if (renderRule(
w,
opt, PseudoElement_ViewItem).hasBackground())
4845 pseudoElement = PseudoElement_ViewItem;
4847 case PE_PanelItemViewItem:
4848 pseudoElement = PseudoElement_ViewItem;
4851 case PE_PanelScrollAreaCorner:
4852 pseudoElement = PseudoElement_ScrollAreaCorner;
4855 case PE_IndicatorSpinDown:
4856 case PE_IndicatorSpinMinus:
4857 pseudoElement = PseudoElement_SpinBoxDownArrow;
4860 case PE_IndicatorSpinUp:
4861 case PE_IndicatorSpinPlus:
4862 pseudoElement = PseudoElement_SpinBoxUpArrow;
4864#if QT_CONFIG(tabbar)
4865 case PE_IndicatorTabClose:
4870 w =
w->parentWidget();
4872 pseudoElement = PseudoElement_TabBarTabCloseButton;
4879 if (pseudoElement != PseudoElement_None) {
4881 if (subRule.hasDrawable()) {
4882 subRule.drawRule(
p,
rect);
4908 if (
rule.hasDrawable() ||
rule.hasBox() ||
rule.hasBorder()) {
4912 uint ctrl = SC_TitleBarSysMenu;
4913 while (ctrl <= SC_TitleBarLabel) {
4915 if (
r.isValid() &&
r.contains(pt)) {
4926 case CC_MdiControls:
4927 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
4928 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
4929 || hasStyleRule(
w, PseudoElement_MdiMinButton))
4930 return QWindowsStyle::hitTestComplexControl(cc,
opt, pt,
w);
4933 case CC_ScrollBar: {
4935 if (!
rule.hasDrawable() && !
rule.hasBox())
4944 return QWindowsStyle::hitTestComplexControl(cc,
opt, pt,
w);
4971 case PM_MenuButtonIndicator:
4972#if QT_CONFIG(toolbutton)
4974 if (qobject_cast<const QToolButton *>(
w)) {
4975 if (
rule.hasBox() || !
rule.hasNativeBorder())
4977 if (
const auto *tbOpt = qstyleoption_cast<const QStyleOptionToolButton*>(
opt)) {
4979 subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
4981 subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenuIndicator);
4982 if (subRule.hasContentsSize())
4983 return subRule.size().width();
4988 subRule = renderRule(
w,
opt, PseudoElement_PushButtonMenuIndicator);
4989 if (subRule.hasContentsSize())
4990 return subRule.size().width();
4993 case PM_ButtonShiftHorizontal:
4994 case PM_ButtonShiftVertical:
4995 case PM_ButtonMargin:
4996 case PM_ButtonDefaultIndicator:
5001 case PM_DefaultFrameWidth:
5002 if (!
rule.hasNativeBorder())
5006 case PM_ExclusiveIndicatorWidth:
5007 case PM_IndicatorWidth:
5008 case PM_ExclusiveIndicatorHeight:
5009 case PM_IndicatorHeight:
5010 subRule = renderRule(
w,
opt, PseudoElement_Indicator);
5011 if (subRule.hasContentsSize()) {
5012 return (
m == PM_ExclusiveIndicatorWidth) || (
m == PM_IndicatorWidth)
5013 ? subRule.size().width() : subRule.size().height();
5017 case PM_DockWidgetFrameWidth:
5018 case PM_ToolTipLabelFrameWidth:
5019 if (!
rule.hasDrawable())
5025 case PM_ToolBarFrameWidth:
5026 if (
rule.hasBorder() ||
rule.hasBox())
5031 case PM_MenuPanelWidth:
5032 case PM_MenuBarPanelWidth:
5033 if (
rule.hasBorder() ||
rule.hasBox())
5039 case PM_MenuHMargin:
5040 case PM_MenuBarHMargin:
5045 case PM_MenuVMargin:
5046 case PM_MenuBarVMargin:
5051 case PM_DockWidgetTitleBarButtonMargin:
5052 case PM_ToolBarItemMargin:
5057 case PM_ToolBarItemSpacing:
5058 case PM_MenuBarItemSpacing:
5059 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5060 return rule.box()->spacing;
5063 case PM_MenuTearoffHeight:
5064 case PM_MenuScrollerHeight: {
5065 PseudoElement ps =
m == PM_MenuTearoffHeight ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
5066 subRule = renderRule(
w,
opt, ps);
5067 if (subRule.hasContentsSize())
5068 return subRule.size().height();
5072 case PM_ToolBarExtensionExtent:
5075 case PM_SplitterWidth:
5076 case PM_ToolBarSeparatorExtent:
5077 case PM_ToolBarHandleExtent: {
5079 if (
m == PM_ToolBarHandleExtent) ps = PseudoElement_ToolBarHandle;
5080 else if (
m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle;
5081 else ps = PseudoElement_ToolBarSeparator;
5082 subRule = renderRule(
w,
opt, ps);
5083 if (subRule.hasContentsSize()) {
5084 QSize sz = subRule.size();
5090 case PM_RadioButtonLabelSpacing:
5091 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5092 return rule.box()->spacing;
5094 case PM_CheckBoxLabelSpacing:
5095#if QT_CONFIG(checkbox)
5096 if (qobject_cast<const QCheckBox *>(
w)) {
5097 if (
rule.hasBox() &&
rule.box()->spacing != -1)
5098 return rule.box()->spacing;
5102 subRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
5103 if (subRule.hasBox() && subRule.box()->spacing != -1)
5104 return subRule.box()->spacing;
5107#if QT_CONFIG(scrollbar)
5108 case PM_ScrollBarExtent:
5109 if (
rule.hasContentsSize()) {
5111 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt))
5117 case PM_ScrollBarSliderMin:
5118 if (hasStyleRule(
w, PseudoElement_ScrollBarSlider)) {
5119 subRule = renderRule(
w,
opt, PseudoElement_ScrollBarSlider);
5120 QSize msz = subRule.minimumSize();
5121 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt))
5127 case PM_ScrollView_ScrollBarSpacing:
5128 if (!
rule.hasNativeBorder() ||
rule.hasBox())
5132 case PM_ScrollView_ScrollBarOverlap:
5139 case PM_ProgressBarChunkWidth:
5140 subRule = renderRule(
w,
opt, PseudoElement_ProgressBarChunk);
5141 if (subRule.hasContentsSize()) {
5142 QSize sz = subRule.size();
5148#if QT_CONFIG(tabwidget)
5149 case PM_TabBarTabHSpace:
5150 case PM_TabBarTabVSpace:
5151 subRule = renderRule(
w,
opt, PseudoElement_TabBarTab);
5152 if (subRule.hasBox() || subRule.hasBorder())
5156 case PM_TabBarScrollButtonWidth:
5157 subRule = renderRule(
w,
opt, PseudoElement_TabBarScroller);
5158 if (subRule.hasContentsSize()) {
5159 QSize sz = subRule.size();
5164 case PM_TabBarTabShiftHorizontal:
5165 case PM_TabBarTabShiftVertical:
5166 subRule = renderRule(
w,
opt, PseudoElement_TabBarTab);
5167 if (subRule.hasBox())
5171 case PM_TabBarBaseOverlap: {
5172 const QWidget *tabWidget = qobject_cast<const QTabWidget *>(
w);
5173 if (!tabWidget &&
w)
5175 if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) {
5182 case PM_SliderThickness:
5183 case PM_SliderLength:
5184 if (
rule.hasContentsSize()) {
5186 if (
m == PM_SliderThickness) {
5196 case PM_SliderControlThickness: {
5198 if (!subRule.hasContentsSize())
5204 case PM_ToolBarIconSize:
5205 case PM_ListViewIconSize:
5206 case PM_IconViewIconSize:
5207 case PM_TabBarIconSize:
5208 case PM_MessageBoxIconSize:
5209 case PM_ButtonIconSize:
5210 case PM_SmallIconSize:
5211 if (
rule.hasStyleHint(
"icon-size"_L1))
5212 return rule.styleHint(
"icon-size"_L1).toSize().width();
5215 case PM_DockWidgetTitleMargin: {
5216 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
5217 if (!subRule.hasBox())
5219 return (subRule.border() ? subRule.border()->borders[TopEdge] : 0)
5223 case PM_DockWidgetSeparatorExtent: {
5224 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetSeparator);
5225 if (!subRule.hasContentsSize())
5227 QSize sz = subRule.size();
5231 case PM_TitleBarHeight: {
5233 if (subRule.hasContentsSize())
5234 return subRule.size().height();
5235 else if (subRule.hasBox() || subRule.hasBorder()) {
5237 return subRule.size(
QSize(0, fm.
height())).height();
5242 case PM_MdiSubWindowFrameWidth:
5243 if (
rule.hasBox() ||
rule.hasBorder()) {
5244 return (
rule.border() ?
rule.border()->borders[LeftEdge] : 0)
5249 case PM_MdiSubWindowMinimizedWidth: {
5250 QRenderRule subRule = renderRule(
w, PseudoElement_None, PseudoClass_Minimized);
5251 int width = subRule.size().width();
5272#if QT_CONFIG(spinbox)
5274 if (
const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
5277 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
5278 if (subRule.hasDrawable()) {
5279 QRect r = positionRect(
w,
rule, subRule, PseudoElement_SpinBoxUpButton,
5283 QSize defaultUpSize = defaultSize(
w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton);
5287 if (
rule.hasBox() ||
rule.hasBorder() || !
rule.hasNativeBorder())
5288 sz =
rule.boxSize(sz);
5294 if (
rule.hasBox() || !
rule.hasNativeBorder() || !
rule.baseStyleCanDraw())
5299 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5300 if (ct == CT_ComboBox) {
5302 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5307 return rule.boxSize(sz);
5310 : QWindowsStyle::sizeFromContents(ct,
opt, sz,
w);
5311 return rule.boxSize(sz, Margin);
5313 case CT_HeaderSection: {
5315 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
5316 if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
5317 sz = subRule.adjustSize(csz);
5326 if (!subRule.hasGeometry()) {
5327 QSize nativeContentsSize;
5332 if (subRule.hasFont) {
5333 QFont styleFont =
w ? subRule.font.resolve(
w->font()) : subRule.font;
5342 return subRule.size(sz);
5345 : QWindowsStyle::sizeFromContents(ct,
opt, sz,
w);
5346 if (hasStyleRule(
w, PseudoElement_HeaderViewDownArrow)
5347 || hasStyleRule(
w, PseudoElement_HeaderViewUpArrow)) {
5360#if QT_CONFIG(spinbox)
5361 if (qobject_cast<QAbstractSpinBox *>(
w ?
w->parentWidget() :
nullptr))
5364 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5365 return rule.boxSize(sz);
5370 case CT_RadioButton:
5372 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
5373 bool isRadio = (ct == CT_RadioButton);
5374 int iw =
pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
5375 : PM_IndicatorWidth,
btn,
w);
5376 int ih =
pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
5377 : PM_IndicatorHeight,
btn,
w);
5380 : PM_CheckBoxLabelSpacing,
btn,
w);
5383 return rule.boxSize(sz);
5391 if (
rule.hasBox() ||
rule.hasBorder())
5398 ? PseudoElement_MenuSeparator : PseudoElement_Item;
5400 if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
5401 return QSize(sz.
width(), subRule.size().height());
5403 if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder() || subRule.hasFont)) {
5408 const int pmSmall =
pixelMetric(PM_SmallIconSize);
5412 QRenderRule subSubRule = renderRule(
w,
opt, PseudoElement_MenuCheckMark);
5418 if (subRule.hasFont) {
5423 return subRule.boxSize(subRule.adjustSize(sz));
5429 case CT_MenuBarItem: {
5430 PseudoElement pe = (ct == CT_Splitter) ? PseudoElement_SplitterHandle : PseudoElement_Item;
5432 if (subRule.hasBox() || subRule.hasBorder())
5433 return subRule.boxSize(sz);
5437 case CT_ProgressBar:
5439 return (
rule.hasContentsSize())
5445 if (
rule.hasBorder() ||
rule.hasBox() ||
rule.hasGeometry())
5446 return rule.boxSize(sz);
5449#if QT_CONFIG(tabbar)
5450 case CT_TabBarTab: {
5452 if (subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
5453 int spaceForIcon = 0;
5454 bool vertical =
false;
5456 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
5457 if (!tab->icon.isNull())
5458 spaceForIcon = 6 + 4 + 2 ;
5462 if (subRule.hasBox() || !subRule.hasNativeBorder())
5463 sz = csz +
QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0);
5464 if (subRule.hasFont) {
5472 const QFont ruleFont = subRule.font.resolve(
w->font());
5484 return subRule.boxSize(subRule.adjustSize(sz));
5486 sz = subRule.adjustSize(csz);
5491 case CT_MdiControls:
5493 if (!hasStyleRule(
w, PseudoElement_MdiCloseButton)
5494 && !hasStyleRule(
w, PseudoElement_MdiNormalButton)
5495 && !hasStyleRule(
w, PseudoElement_MdiMinButton))
5500 layout = subControlLayout(
"mNX"_L1);
5503 for (
int i = 0;
i <
layout.size();
i++) {
5504 int layoutButton =
layout[
i].toInt();
5505 if (layoutButton < PseudoElement_MdiCloseButton
5506 || layoutButton > PseudoElement_MdiNormalButton)
5509 if (!(ccOpt->subControls & sc))
5512 QSize sz = subRule.size();
5521#if QT_CONFIG(itemviews)
5522 case CT_ItemViewItem: {
5525 sz = subRule.adjustSize(sz);
5526 if (subRule.hasBox() || subRule.hasBorder())
5527 sz = subRule.boxSize(sz);
5600 default:
return ""_L1;
5611 if (
rule.hasStyleHint(
s))
5612 return qvariant_cast<QIcon>(
rule.styleHint(
s));
5629 if (
rule.hasStyleHint(
s)) {
5650 if (sh == SH_Widget_ShareActivation)
5656 case SH_LineEdit_PasswordCharacter:
s =
"lineedit-password-character"_L1;
break;
5657 case SH_LineEdit_PasswordMaskDelay:
s =
"lineedit-password-mask-delay"_L1;
break;
5658 case SH_DitherDisabledText:
s =
"dither-disabled-text"_L1;
break;
5659 case SH_EtchDisabledText:
s =
"etch-disabled-text"_L1;
break;
5660 case SH_ItemView_ActivateItemOnSingleClick:
s =
"activate-on-singleclick"_L1;
break;
5661 case SH_ItemView_ShowDecorationSelected:
s =
"show-decoration-selected"_L1;
break;
5662 case SH_Table_GridLineColor:
s =
"gridline-color"_L1;
break;
5663 case SH_DialogButtonLayout:
s =
"button-layout"_L1;
break;
5664 case SH_ToolTipLabel_Opacity:
s =
"opacity"_L1;
break;
5665 case SH_ComboBox_Popup:
s =
"combobox-popup"_L1;
break;
5666 case SH_ComboBox_ListMouseTracking:
s =
"combobox-list-mousetracking"_L1;
break;
5667 case SH_MenuBar_AltKeyNavigation:
s =
"menubar-altkey-navigation"_L1;
break;
5668 case SH_Menu_Scrollable:
s =
"menu-scrollable"_L1;
break;
5669 case SH_DrawMenuBarSeparator:
s =
"menubar-separator"_L1;
break;
5670 case SH_MenuBar_MouseTracking:
s =
"mouse-tracking"_L1;
break;
5671 case SH_SpinBox_ClickAutoRepeatRate:
s =
"spinbox-click-autorepeat-rate"_L1;
break;
5672 case SH_SpinControls_DisableOnBounds:
s =
"spincontrol-disable-on-bounds"_L1;
break;
5673 case SH_MessageBox_TextInteractionFlags:
s =
"messagebox-text-interaction-flags"_L1;
break;
5674 case SH_ToolButton_PopupDelay:
s =
"toolbutton-popup-delay"_L1;
break;
5675 case SH_ToolBox_SelectedPageTitleBold:
5676 if (renderRule(
w,
opt, PseudoElement_ToolBoxTab).hasFont)
5679 case SH_GroupBox_TextLabelColor:
5681 return rule.palette()->foreground.color().rgba();
5683 case SH_ScrollView_FrameOnlyAroundContents:
s =
"scrollview-frame-around-contents"_L1;
break;
5684 case SH_ScrollBar_ContextMenu:
s =
"scrollbar-contextmenu"_L1;
break;
5685 case SH_ScrollBar_LeftClickAbsolutePosition:
s =
"scrollbar-leftclick-absolute-position"_L1;
break;
5686 case SH_ScrollBar_MiddleClickAbsolutePosition:
s =
"scrollbar-middleclick-absolute-position"_L1;
break;
5687 case SH_ScrollBar_RollBetweenButtons:
s =
"scrollbar-roll-between-buttons"_L1;
break;
5688 case SH_ScrollBar_ScrollWhenPointerLeavesControl:
s =
"scrollbar-scroll-when-pointer-leaves-control"_L1;
break;
5689 case SH_TabBar_Alignment:
5690#if QT_CONFIG(tabwidget)
5691 if (qobject_cast<const QTabWidget *>(
w)) {
5692 rule = renderRule(
w,
opt, PseudoElement_TabWidgetTabBar);
5693 if (
rule.hasPosition())
5694 return rule.position()->position;
5699#if QT_CONFIG(tabbar)
5700 case SH_TabBar_CloseButtonPosition:
5701 rule = renderRule(
w,
opt, PseudoElement_TabBarTabCloseButton);
5702 if (
rule.hasPosition()) {
5703 Qt::Alignment align =
rule.position()->position;
5711 case SH_TabBar_ElideMode:
s =
"tabbar-elide-mode"_L1;
break;
5712 case SH_TabBar_PreferNoArrows:
s =
"tabbar-prefer-no-arrows"_L1;
break;
5713 case SH_ComboBox_PopupFrameStyle:
5714#if QT_CONFIG(combobox)
5715 if (qobject_cast<const QComboBox *>(
w)) {
5718 view->ensurePolished();
5720 if (subRule.hasBox() || !subRule.hasNativeBorder())
5726 case SH_DialogButtonBox_ButtonsHaveIcons:
s =
"dialogbuttonbox-buttons-have-icons"_L1;
break;
5727 case SH_Workspace_FillSpaceOnMaximize:
s =
"mdi-fill-space-on-maximize"_L1;
break;
5728 case SH_TitleBar_NoBorder:
5729 if (
rule.hasBorder())
5732 case SH_TitleBar_AutoRaise: {
5734 if (subRule.hasDrawable())
5738 case SH_ItemView_ArrowKeysNavigateIntoChildren:
s =
"arrow-keys-navigate-into-children"_L1;
break;
5739 case SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
s =
"paint-alternating-row-colors-for-empty-area"_L1;
break;
5740 case SH_TitleBar_ShowToolTipsOnButtons:
s =
"titlebar-show-tooltips-on-buttons"_L1;
break;
5741 case SH_Widget_Animation_Duration:
s =
"widget-animation-duration"_L1;
break;
5742 case SH_ScrollBar_Transient:
5743 if (!
rule.hasNativeBorder() ||
rule.hasBox() ||
rule.hasDrawable())
5748 if (!
s.isEmpty() &&
rule.hasStyleHint(
s)) {
5749 return rule.styleHint(
s).toInt();
5764 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5766 case SC_ComboBoxFrame:
return rule.borderRect(
opt->
rect);
5767 case SC_ComboBoxEditField:
5769 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5771 QRect r2 = positionRect(
w,
rule, subRule, PseudoElement_ComboBoxDropDown,
5773 if (subRule.hasPosition() && subRule.position()->position &
Qt::AlignLeft) {
5779 case SC_ComboBoxArrow: {
5780 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ComboBoxDropDown);
5783 case SC_ComboBoxListBoxPopup:
5792 : QWindowsStyle::subControlRect(cc, &comboBox, sc,
w);
5796#if QT_CONFIG(spinbox)
5798 if (
const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(
opt)) {
5799 QRenderRule upRule = renderRule(
w,
opt, PseudoElement_SpinBoxUpButton);
5800 QRenderRule downRule = renderRule(
w,
opt, PseudoElement_SpinBoxDownButton);
5801 bool ruleMatch =
rule.hasBox() || !
rule.hasNativeBorder();
5802 bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
5803 bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
5804 if (ruleMatch || upRuleMatch || downRuleMatch) {
5806 case SC_SpinBoxFrame:
5808 case SC_SpinBoxEditField:
5812 Qt::Alignment upAlign, downAlign;
5814 upAlign = upRule.hasPosition() ? upRule.position()->position
5818 downAlign = downRule.hasPosition() ? downRule.position()->position
5820 downAlign = resolveAlignment(
opt->
direction, downAlign);
5823 const int upSize = hasButtons
5825 const int downSize = hasButtons
5832 r.setRight(
r.right() - widestR);
5833 r.setLeft(
r.left() + widestL);
5836 case SC_SpinBoxDown:
5838 return positionRect(
w,
rule, downRule, PseudoElement_SpinBoxDownButton,
5843 return positionRect(
w,
rule, upRule, PseudoElement_SpinBoxUpButton,
5853 QStyleOptionSpinBox
spinBox(*spin);
5856 : QWindowsStyle::subControlRect(cc, &
spinBox, sc,
w);
5864 case SC_GroupBoxFrame:
5865 case SC_GroupBoxContents: {
5866 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5867 return sc == SC_GroupBoxFrame ?
rule.borderRect(
opt->
rect)
5875 case SC_GroupBoxLabel:
5876 case SC_GroupBoxCheckBox: {
5877 QRenderRule indRule = renderRule(
w,
opt, PseudoElement_GroupBoxIndicator);
5878 QRenderRule labelRule = renderRule(
w,
opt, PseudoElement_GroupBoxTitle);
5879 if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
5880 && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
5895 if (!labelRule.hasGeometry()) {
5896 labelRule.geo =
new QStyleSheetGeometryData(tw, th, tw, th, -1, -1);
5898 labelRule.geo->width = tw;
5899 labelRule.geo->height = th;
5901 if (!labelRule.hasPosition()) {
5902 labelRule.p =
new QStyleSheetPositionData(0, 0, 0, 0, defaultOrigin(PseudoElement_GroupBoxTitle),
5903 gb->textAlignment, PositionMode_Static);
5905 QRect r = positionRect(
w,
rule, labelRule, PseudoElement_GroupBoxTitle,
5907 if (gb->subControls & SC_GroupBoxCheckBox) {
5908 r = labelRule.contentsRect(
r);
5909 if (sc == SC_GroupBoxLabel) {
5911 r.setTop(
r.center().y() - th/2);
5913 r =
QRect(
r.left(),
r.center().y() - ih/2, iw, ih);
5917 return labelRule.contentsRect(
r);
5926 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
5928 case SC_ToolButton:
return rule.borderRect(
opt->
rect);
5929 case SC_ToolButtonMenu: {
5930 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_ToolButtonMenu);
5941 : QWindowsStyle::subControlRect(cc, &tool, sc,
w);
5945#if QT_CONFIG(scrollbar)
5947 if (
const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
5948 QStyleOptionSlider styleOptionSlider(*sb);
5949 styleOptionSlider.rect =
rule.borderRect(
opt->
rect);
5950 if (
rule.hasDrawable() ||
rule.hasBox()) {
5952 if (!
rule.hasBox()) {
5954 : QWindowsStyle::subControlRect(cc, sb, SC_ScrollBarGroove,
w);
5959 PseudoElement pe = PseudoElement_None;
5962 case SC_ScrollBarGroove:
5964 case SC_ScrollBarAddPage:
5965 case SC_ScrollBarSubPage:
5966 case SC_ScrollBarSlider: {
5967 QRect contentRect = grooveRect;
5968 if (hasStyleRule(
w, PseudoElement_ScrollBarSlider)) {
5969 QRenderRule sliderRule = renderRule(
w,
opt, PseudoElement_ScrollBarSlider);
5970 Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
5975 if (sb->maximum != sb->minimum) {
5977 sliderlen = (
qint64(sb->pageStep) * maxlen) / (
range + sb->pageStep);
5979 int slidermin =
pixelMetric(PM_ScrollBarSliderMin, sb,
w);
5980 if (sliderlen < slidermin || range > INT_MAX / 2)
5981 sliderlen = slidermin;
5982 if (sliderlen > maxlen)
5987 int sliderstart = (styleOptionSlider.orientation ==
Qt::Horizontal ? contentRect.
left() : contentRect.
top())
5988 + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition,
5989 maxlen - sliderlen, sb->upsideDown);
5992 ?
QRect(sliderstart, contentRect.
top(), sliderlen, contentRect.
height())
5993 :
QRect(contentRect.
left(), sliderstart, contentRect.
width(), sliderlen);
5994 if (sc == SC_ScrollBarSubPage)
5996 else if (sc == SC_ScrollBarAddPage)
5998 return visualRect(styleOptionSlider.direction, grooveRect, sr);
6000 case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine;
break;
6001 case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine;
break;
6002 case SC_ScrollBarFirst: pe = PseudoElement_ScrollBarFirst;
break;
6003 case SC_ScrollBarLast: pe = PseudoElement_ScrollBarLast;
break;
6006 if (hasStyleRule(
w,pe)) {
6008 if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
6009 const QStyleSheetPositionData *
pos = subRule.position();
6010 QRect originRect = grooveRect;
6011 if (
rule.hasBox()) {
6015 return positionRect(
w, subRule, pe, originRect, styleOptionSlider.direction);
6020 : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc,
w);
6025#if QT_CONFIG(slider)
6027 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(
opt)) {
6029 if (!subRule.hasDrawable())
6031 subRule.img =
nullptr;
6034 case SC_SliderGroove:
6036 case SC_SliderHandle: {
6038 QRect cr = subRule.contentsRect(gr);
6039 QRenderRule subRule2 = renderRule(
w,
opt, PseudoElement_SliderHandle);
6040 int len = horizontal ? subRule2.size().width() : subRule2.size().height();
6041 subRule2.img =
nullptr;
6042 subRule2.geo =
nullptr;
6043 cr = positionRect(
w, subRule2, PseudoElement_SliderHandle, cr,
opt->
direction);
6044 int thickness = horizontal ? cr.
height() : cr.
width();
6045 int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
6046 (horizontal ? cr.
width() : cr.
height()) -
len, slider->upsideDown);
6047 cr = horizontal ?
QRect(cr.
x() + sliderPos, cr.
y(),
len, thickness)
6048 :
QRect(cr.
x(), cr.
y() + sliderPos, thickness,
len);
6049 return subRule2.borderRect(cr);
6051 case SC_SliderTickmarks:
6060 case CC_MdiControls:
6061 if (hasStyleRule(
w, PseudoElement_MdiCloseButton)
6062 || hasStyleRule(
w, PseudoElement_MdiNormalButton)
6063 || hasStyleRule(
w, PseudoElement_MdiMinButton)) {
6066 layout = subControlLayout(
"mNX"_L1);
6070 for (
int i = 0;
i <
layout.size();
i++) {
6071 int layoutButton =
layout[
i].toInt();
6072 if (layoutButton < PseudoElement_MdiCloseButton
6073 || layoutButton > PseudoElement_MdiNormalButton)
6076 if (!(
opt->subControls & control))
6078 subRule = renderRule(
w,
opt, layoutButton);
6079 width = subRule.size().width();
6092 if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
6095 return layoutRects.
value(sc);
6111#if QT_CONFIG(tabbar)
6112 int pe = PseudoElement_None;
6116 case SE_PushButtonContents:
6117 case SE_PushButtonBevel:
6118 case SE_PushButtonFocusRect:
6121 && hasStyleRule(
w, PseudoElement_PushButtonMenuIndicator)) {
6125 : QWindowsStyle::subElementRect(se, &btnOpt,
w);
6127 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
6133 : QWindowsStyle::subElementRect(se,
btn,
w);
6137 case SE_LineEditContents:
6138 case SE_FrameContents:
6139 case SE_ShapedFrameContents:
6140 if (
rule.hasBox() || !
rule.hasNativeBorder()) {
6145 case SE_CheckBoxIndicator:
6146 case SE_RadioButtonIndicator:
6147 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6148 PseudoElement pe = se == SE_CheckBoxIndicator ? PseudoElement_Indicator : PseudoElement_ExclusiveIndicator;
6154 case SE_CheckBoxContents:
6155 case SE_RadioButtonContents:
6156 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6157 bool isRadio = se == SE_RadioButtonContents;
6169 case SE_ToolBoxTabContents:
6170 if (
w && hasStyleRule(
w->parentWidget(), PseudoElement_ToolBoxTab)) {
6171 QRenderRule subRule = renderRule(
w->parentWidget(),
opt, PseudoElement_ToolBoxTab);
6176 case SE_RadioButtonFocusRect:
6177 case SE_RadioButtonClickRect:
6178 if (
rule.hasBox() ||
rule.hasBorder() || hasStyleRule(
w, PseudoElement_Indicator)) {
6183 case SE_CheckBoxFocusRect:
6184 case SE_CheckBoxClickRect:
6185 return ParentStyle::subElementRect(se,
opt,
w);
6187#if QT_CONFIG(itemviews)
6188 case SE_ItemViewItemCheckIndicator:
6189 if (!qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
6193 case SE_ItemViewItemText:
6194 case SE_ItemViewItemDecoration:
6195 case SE_ItemViewItemFocusRect:
6196 if (
const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(
opt)) {
6198 PseudoElement pe = PseudoElement_None;
6199 if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
6200 pe = PseudoElement_ViewItemText;
6201 else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItem::HasDecoration)
6202 pe = PseudoElement_ViewItemIcon;
6203 else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItem::HasCheckIndicator)
6204 pe = PseudoElement_ViewItemIndicator;
6207 if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(
w, pe)) {
6209 QStyleOptionViewItem optCopy(*vopt);
6210 optCopy.rect = subRule.contentsRect(vopt->rect);
6211 QRect rect = ParentStyle::subElementRect(se, &optCopy,
w);
6218 case SE_HeaderArrow: {
6219 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewUpArrow);
6220 if (subRule.hasPosition() || subRule.hasGeometry())
6225 case SE_HeaderLabel: {
6226 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_HeaderViewSection);
6227 if (subRule.hasBox() || !subRule.hasNativeBorder())
6228 return subRule.contentsRect(
opt->
rect);
6232 case SE_ProgressBarGroove:
6233 case SE_ProgressBarContents:
6234 case SE_ProgressBarLabel:
6236 if (
rule.hasBox() || !
rule.hasNativeBorder() ||
rule.hasPosition() || hasStyleRule(
w, PseudoElement_ProgressBarChunk)) {
6237 if (se == SE_ProgressBarGroove)
6238 return rule.borderRect(pb->rect);
6239 else if (se == SE_ProgressBarContents)
6240 return rule.contentsRect(pb->rect);
6242 QSize sz = pb->fontMetrics.size(0, pb->text);
6249#if QT_CONFIG(tabbar)
6250 case SE_TabWidgetLeftCorner:
6251 pe = PseudoElement_TabWidgetLeftCorner;
6253 case SE_TabWidgetRightCorner:
6254 if (pe == PseudoElement_None)
6255 pe = PseudoElement_TabWidgetRightCorner;
6257 case SE_TabWidgetTabBar:
6258 if (pe == PseudoElement_None)
6259 pe = PseudoElement_TabWidgetTabBar;
6261 case SE_TabWidgetTabPane:
6262 case SE_TabWidgetTabContents:
6263 if (pe == PseudoElement_None)
6264 pe = PseudoElement_TabWidgetPane;
6266 if (hasStyleRule(
w, pe)) {
6267 QRect r = QWindowsStyle::subElementRect(pe == PseudoElement_TabWidgetPane ? SE_TabWidgetTabPane : se,
opt,
w);
6270 if (pe == PseudoElement_TabWidgetTabBar) {
6274 if (se == SE_TabWidgetTabContents)
6275 r = subRule.contentsRect(
r);
6280 case SE_TabBarScrollLeftButton:
6281 case SE_TabBarScrollRightButton:
6282 if (hasStyleRule(
w, PseudoElement_TabBarScroller))
6283 return ParentStyle::subElementRect(se,
opt,
w);
6286 case SE_TabBarTearIndicator: {
6288 if (subRule.hasContentsSize()) {
6290 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
6291 switch (tab->shape) {
6296 r.setRect(tab->rect.left(), tab->rect.top(), subRule.size().width(),
opt->
rect.
height());
6302 r.setRect(tab->rect.left(), tab->rect.top(),
opt->
rect.
width(), subRule.size().height());
6313 case SE_TabBarTabText:
6314 case SE_TabBarTabLeftButton:
6315 case SE_TabBarTabRightButton: {
6317 if (subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) {
6318 if (se == SE_TabBarTabText) {
6319 if (
const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(
opt)) {
6320 const QTabBar *bar = qobject_cast<const QTabBar *>(
w);
6321 const QRect optRect = bar && tab->tabIndex != -1 ? bar->
tabRect(tab->tabIndex) :
opt->
rect;
6322 const QRect r = positionRect(
w, subRule, PseudoElement_TabBarTab, optRect,
opt->
direction);
6323 QStyleOptionTab tabCopy(*tab);
6324 if (subRule.hasFont) {
6325 const QFont ruleFont =
w ? subRule.font.resolve(
w->font()) : subRule.font;
6328 tabCopy.rect = subRule.contentsRect(
r);
6329 return ParentStyle::subElementRect(se, &tabCopy,
w);
6332 return ParentStyle::subElementRect(se,
opt,
w);
6338 case SE_DockWidgetCloseButton:
6339 case SE_DockWidgetFloatButton: {
6340 PseudoElement pe = (se == SE_DockWidgetCloseButton) ? PseudoElement_DockWidgetCloseButton : PseudoElement_DockWidgetFloatButton;
6342 if (!subRule2.hasPosition())
6344 QRenderRule subRule = renderRule(
w,
opt, PseudoElement_DockWidgetTitle);
6348#if QT_CONFIG(toolbar)
6349 case SE_ToolBarHandle:
6350 if (hasStyleRule(
w, PseudoElement_ToolBarHandle))
6351 return ParentStyle::subElementRect(se,
opt,
w);
6357 case SE_CheckBoxLayoutItem:
6358 case SE_ComboBoxLayoutItem:
6359 case SE_DateTimeEditLayoutItem:
6360 case SE_LabelLayoutItem:
6361 case SE_ProgressBarLayoutItem:
6362 case SE_PushButtonLayoutItem:
6363 case SE_RadioButtonLayoutItem:
6364 case SE_SliderLayoutItem:
6365 case SE_SpinBoxLayoutItem:
6366 case SE_ToolButtonLayoutItem:
6367 case SE_FrameLayoutItem:
6368 case SE_GroupBoxLayoutItem:
6369 case SE_TabWidgetLayoutItem:
6370 if (!
rule.hasNativeBorder())
6390 if (
w->objectName() ==
"qt_fontDialog_sampleEdit"_L1)
6393 QWidget *container = containerWidget(
w);
6395 PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
6397 const bool useStyleSheetPropagationInWidgetStyles =
6400 if (useStyleSheetPropagationInWidgetStyles) {
6401 unsetStyleSheetFont(
w);
6403 if (
rule.font.resolveMask()) {
6404 QFont wf =
w->d_func()->localFont();
6412 QFont wf =
w->d_func()->localFont();
6425 w->data->fnt =
font;
6435 w->setProperty(
"_q_styleSheetWidgetFont",
font);
6440 w->setProperty(
"_q_styleSheetWidgetFont",
QVariant());
6449 if (!
w || !
opt || !pal)
6452 RECURSION_GUARD(
return false)
6454 w = containerWidget(
w);
6457 if (!
rule.hasPalette())
6486bool QStyleSheetStyle::isNaturalChild(
const QObject *
obj)
6488 if (
obj->objectName().startsWith(
"qt_"_L1))
6509 qreal sourceDevicePixelRatio = 1.0;
6512 pixmap.setDevicePixelRatio(sourceDevicePixelRatio);
6518#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.
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.
const QColor & color() const
Returns the brush 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 is a combined button and popup 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.
const T & value() const noexcept
Returns the current item's value.
bool remove(const Key &key)
Removes the item that has the key from the hash.
const_iterator constFind(const Key &key) const noexcept
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
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.
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
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
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
T findChild(const QString &aName=QString(), 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
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
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.
const QBrush & light() const
Returns the light brush of the current color group.
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.
bool isBrushSet(ColorGroup cg, ColorRole cr) const
ResolveMask resolveMask() const
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
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...
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int height() const
Returns the height of the pixmap.
QSize size() const
Returns the size of the pixmap.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
int width() const
Returns the width of the pixmap.
qreal devicePixelRatio() const
Returns the device pixel ratio for 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 QPoint bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr void moveRight(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
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 void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
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 moveLeft(int pos) noexcept
Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.
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 QSize size() const noexcept
Returns the size of the rectangle.
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.
QRect united(const QRect &other) const noexcept
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)
bool contains(const T &value) const
iterator insert(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 bool isNull() const noexcept
Returns true if both the width and height is 0; otherwise returns false.
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
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QChar * constData() const
Returns a pointer to the data stored in the QString.
qsizetype size() const
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.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
\variable QStyleOption::palette
\variable QStyleOptionFocusRect::backgroundColor
\variable QStyleOptionFrame::features
\variable QStyleOptionButton::features
\variable QStyleOptionToolBox::selectedPosition
Qt::WindowFlags titleBarFlags
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.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
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
Combined button and popup list for selecting options.
@ AA_UseStyleSheetPropagationInWidgetStyles
@ WindowContextHelpButtonHint
@ WindowMaximizeButtonHint
@ WindowMinimizeButtonHint
@ ToolButtonTextUnderIcon
@ ToolButtonTextBesideIcon
QVector3D minimum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
QVector3D maximum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
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 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)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
const char className[16]
[1]
p drawImage(offset, thumbnail)
QFileInfo info(fileName)
[8]
QFileSelector selector
[1]
obj metaObject() -> className()
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)