diff options
Diffstat (limited to 'src/widgets/styles/qstylesheetstyle.cpp')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 6abef62835..51426f1609 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -714,7 +714,7 @@ static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleH static QList<QVariant> subControlLayout(const QString& layout) { QList<QVariant> buttons; - for (int i = 0; i < layout.length(); i++) { + for (int i = 0; i < layout.size(); i++) { int button = layout[i].toLatin1(); switch (button) { case 'm': @@ -980,7 +980,7 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject * palette = QToolTip::palette(); #endif - for (int i = 0; i < declarations.count(); i++) { + for (int i = 0; i < declarations.size(); i++) { const Declaration& decl = declarations.at(i); if (decl.d->propertyId == BorderImage) { QString uri; @@ -1056,7 +1056,7 @@ QRenderRule::QRenderRule(const QList<Declaration> &declarations, const QObject * } else if (hintName.endsWith("icon"_L1)) { hintValue = decl.iconValue(); } else if (hintName == "button-layout"_L1 - && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) { + && decl.d->values.size() != 0 && decl.d->values.at(0).type == Value::String) { hintValue = subControlLayout(decl.d->values.at(0).variant.toString()); } else { int integer; @@ -1474,7 +1474,11 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q p->setBrush(cg, w->foregroundRole(), pal->foreground); p->setBrush(cg, QPalette::WindowText, pal->foreground); p->setBrush(cg, QPalette::Text, pal->foreground); - p->setBrush(cg, QPalette::PlaceholderText, pal->foreground); + QColor phColor(pal->foreground.color()); + phColor.setAlpha((phColor.alpha() + 1) / 2); + QBrush placeholder = pal->foreground; + placeholder.setColor(phColor); + p->setBrush(cg, QPalette::PlaceholderText, placeholder); } if (pal->selectionBackground.style() != Qt::NoBrush) p->setBrush(cg, QPalette::Highlight, pal->selectionBackground); @@ -1597,7 +1601,7 @@ public: #endif do { const ushort *uc = (const ushort *)nodeName.constData(); - const ushort *e = uc + nodeName.length(); + const ushort *e = uc + nodeName.size(); const uchar *c = (const uchar *)metaObject->className(); while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) { ++uc; @@ -1694,8 +1698,8 @@ QList<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const objectSs.append(ss); } - for (int i = 0; i < objectSs.count(); i++) - objectSs[i].depth = objectSs.count() - i + 2; + for (int i = 0; i < objectSs.size(); i++) + objectSs[i].depth = objectSs.size() - i + 2; styleSelector.styleSheets += objectSs; @@ -1712,7 +1716,7 @@ static QList<Declaration> declarations(const QList<StyleRule> &styleRules, const quint64 pseudoClass = PseudoClass_Unspecified) { QList<Declaration> decls; - for (int i = 0; i < styleRules.count(); i++) { + for (int i = 0; i < styleRules.size(); i++) { const Selector& selector = styleRules.at(i).selectors.at(0); // Rules with pseudo elements don't cascade. This is an intentional // diversion for CSS @@ -1842,7 +1846,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint6 quint64 stateMask = 0; const QList<StyleRule> rules = styleRules(obj); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); quint64 negated = 0; stateMask |= selector.pseudoClass(&negated); @@ -2164,7 +2168,7 @@ bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const } QString pseudoElement = QLatin1StringView(knownPseudoElements[part].name); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) { cache[part] = true; @@ -2635,7 +2639,7 @@ void QStyleSheetStyle::setProperties(QWidget *w) { // scan decls for final occurrence of each "qproperty" QDuplicateTracker<QString> propertySet(decls.size()); - for (int i = decls.count() - 1; i >= 0; --i) { + for (int i = decls.size() - 1; i >= 0; --i) { const QString property = decls.at(i).d->property; if (!property.startsWith("qproperty-"_L1, Qt::CaseInsensitive)) continue; @@ -2644,7 +2648,7 @@ void QStyleSheetStyle::setProperties(QWidget *w) } } - for (int i = finals.count() - 1; i >= 0; --i) { + for (int i = finals.size() - 1; i >= 0; --i) { const Declaration &decl = decls.at(finals[i]); QStringView property = decl.d->property; property = property.mid(10); // strip "qproperty-" @@ -2801,7 +2805,7 @@ static void updateObjects(const QList<const QObject *>& objects) QCoreApplication::sendEvent(widget, &event); QList<const QObject *> children; children.reserve(widget->children().size() + 1); - for (auto child: qAsConst(widget->children())) + for (auto child: std::as_const(widget->children())) children.append(child); updateObjects(children); } @@ -2896,7 +2900,7 @@ void QStyleSheetStyle::polish(QWidget *w) //set the WA_Hover attribute if one of the selector depends of the hover state QList<StyleRule> rules = styleRules(w); - for (int i = 0; i < rules.count(); i++) { + for (int i = 0; i < rules.size(); i++) { const Selector& selector = rules.at(i).selectors.at(0); quint64 negated = 0; quint64 cssClass = selector.pseudoClass(&negated); @@ -2986,7 +2990,7 @@ void QStyleSheetStyle::repolish(QWidget *w) { QList<const QObject *> children; children.reserve(w->children().size() + 1); - for (auto child: qAsConst(w->children())) + for (auto child: std::as_const(w->children())) children.append(child); children.append(w); styleSheetCaches->styleSheetCache.remove(w); @@ -3484,7 +3488,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC QStyleOptionComplex optCopy(*opt); optCopy.subControls = { }; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) @@ -4730,10 +4734,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch); if (subRule.hasDrawable()) { - if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected) - p->fillRect(vopt->rect, vopt->palette.highlight()); - else if (vopt->features & QStyleOptionViewItem::Alternate) - p->fillRect(vopt->rect, vopt->palette.alternateBase()); + proxy()->drawPrimitive(PE_PanelItemViewRow, vopt, p, w); subRule.drawRule(p, opt->rect); } else { baseStyle()->drawPrimitive(pe, vopt, p, w); @@ -4801,6 +4802,17 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op pseudoElement = PseudoElement_DockWidgetSeparator; break; + case PE_PanelItemViewRow: + // For compatibility reasons, QTreeView draws different parts of + // the background of an item row separately, before calling the + // delegate to draw the item. The row background of an item is + // however not separately styleable through a style sheet, but + // only indirectly through the background of the item. To get the + // same background for all parts drawn by QTreeView, we have to + // use the background rule for the item here. + if (renderRule(w, opt, PseudoElement_ViewItem).hasBackground()) + pseudoElement = PseudoElement_ViewItem; + break; case PE_PanelItemViewItem: pseudoElement = PseudoElement_ViewItem; break; @@ -5087,7 +5099,7 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const break; case PM_ScrollView_ScrollBarOverlap: - if (!rule.hasNativeBorder() || rule.hasBox()) + if (!proxy()->styleHint(SH_ScrollBar_Transient, opt, w)) return 0; break; #endif // QT_CONFIG(scrollbar) @@ -5457,7 +5469,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op layout = subControlLayout("mNX"_L1); int width = 0, height = 0; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) @@ -5697,7 +5709,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi case SH_TitleBar_ShowToolTipsOnButtons: s = "titlebar-show-tooltips-on-buttons"_L1; break; case SH_Widget_Animation_Duration: s = "widget-animation-duration"_L1; break; case SH_ScrollBar_Transient: - if (!rule.hasNativeBorder() || rule.hasBox()) + if (!rule.hasNativeBorder() || rule.hasBox() || rule.hasDrawable()) return 0; break; default: break; @@ -6024,7 +6036,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp int x = 0, width = 0; QRenderRule subRule; - for (int i = 0; i < layout.count(); i++) { + for (int i = 0; i < layout.size(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton || layoutButton > PseudoElement_MdiNormalButton) |