summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstylesheetstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qstylesheetstyle.cpp')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp92
1 files changed, 50 insertions, 42 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 4fe697a32f..b42876d72e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -51,7 +51,9 @@
#include <qstyleoption.h>
#include <qlineedit.h>
#include <private/qwindowsstyle_p.h>
+#if QT_CONFIG(combobox)
#include <qcombobox.h>
+#endif
#include "private/qcssparser_p.h"
#include "private/qmath_p.h"
#include <qabstractscrollarea.h>
@@ -69,13 +71,19 @@
#include <qcheckbox.h>
#endif
#include <qstatusbar.h>
+#if QT_CONFIG(itemviews)
#include <qheaderview.h>
+#endif
#include <private/qwindowsstyle_p_p.h>
#include <private/qstyleanimation_p.h>
+#if QT_CONFIG(tabbar)
#include <qtabbar.h>
+#endif
#include <QMetaProperty>
#include <qmainwindow.h>
+#if QT_CONFIG(dockwidget)
#include <qdockwidget.h>
+#endif
#include <qmdisubwindow.h>
#if QT_CONFIG(dialog)
#include <qdialog.h>
@@ -1641,7 +1649,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
#endif
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
if (qobject_cast<const QComboBox *>(w))
return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
#endif
@@ -1719,7 +1727,7 @@ static quint64 pseudoClass(QStyle::State state)
static void qt_check_if_internal_object(const QObject **obj, int *element)
{
-#ifdef QT_NO_DOCKWIDGET
+#if !QT_CONFIG(dockwidget)
Q_UNUSED(obj);
Q_UNUSED(element);
#else
@@ -1885,7 +1893,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
extraClass |= PseudoClass_NextSelected;
else if (hdr->selectedPosition == QStyleOptionHeader::PreviousIsSelected)
extraClass |= PseudoClass_PreviousSelected;
-#ifndef QT_NO_TABWIDGET
+#if QT_CONFIG(tabwidget)
} else if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
switch (tab->shape) {
case QTabBar::RoundedNorth:
@@ -1908,7 +1916,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
break;
}
#endif
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
} else if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
if (tab->position == QStyleOptionTab::OnlyOneTab)
extraClass |= PseudoClass_OnlyOne;
@@ -1944,7 +1952,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
default:
break;
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
} else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
if (btn->features & QStyleOptionButton::Flat)
extraClass |= PseudoClass_Flat;
@@ -1994,7 +2002,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
extraClass |= PseudoClass_PreviousSelected;
}
#endif // QT_NO_TOOLBOX
-#ifndef QT_NO_DOCKWIDGET
+#if QT_CONFIG(dockwidget)
else if (const QStyleOptionDockWidget *dw = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
if (dw->verticalTitleBar)
extraClass |= PseudoClass_Vertical;
@@ -2007,8 +2015,8 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
if (dw->movable)
extraClass |= PseudoClass_Movable;
}
-#endif // QT_NO_DOCKWIDGET
-#ifndef QT_NO_ITEMVIEWS
+#endif // QT_CONFIG(dockwidget)
+#if QT_CONFIG(itemviews)
else if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
if (vopt->features & QStyleOptionViewItem::Alternate)
extraClass |= PseudoClass_Alternate;
@@ -2340,7 +2348,7 @@ QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule& rule1,
*/
static QWidget *embeddedWidget(QWidget *w)
{
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
if (QComboBox *cmb = qobject_cast<QComboBox *>(w)) {
if (cmb->isEditable())
return cmb->lineEdit();
@@ -2374,7 +2382,7 @@ static QWidget *containerWidget(const QWidget *w)
#ifndef QT_NO_LINEEDIT
if (qobject_cast<const QLineEdit *>(w)) {
//if the QLineEdit is an embeddedWidget, we need the rule of the real widget
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
if (qobject_cast<const QComboBox *>(w->parentWidget()))
return w->parentWidget();
#endif
@@ -2413,7 +2421,7 @@ static bool unstylable(const QWidget *w)
// detect QComboBoxPrivateContainer
else if (qobject_cast<const QFrame *>(w)) {
if (0
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
|| qobject_cast<const QComboBox *>(w->parentWidget())
#endif
)
@@ -2421,7 +2429,7 @@ static bool unstylable(const QWidget *w)
}
#endif
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
if (w->metaObject() == &QWidget::staticMetaObject
&& qobject_cast<const QTabBar*>(w->parentWidget()))
return true; // The moving tab of a QTabBar
@@ -2438,7 +2446,7 @@ static quint64 extendedPseudoClass(const QWidget *w)
pc |= ((slider->orientation() == Qt::Vertical) ? PseudoClass_Vertical : PseudoClass_Horizontal);
} else
#endif
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
if (const QComboBox *combo = qobject_cast<const QComboBox *>(w)) {
if (combo->isEditable())
pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly);
@@ -2805,10 +2813,10 @@ void QStyleSheetStyle::polish(QWidget *w)
QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any);
if (rule.hasDrawable() || rule.hasBox()) {
if (w->metaObject() == &QWidget::staticMetaObject
-#ifndef QT_NO_ITEMVIEWS
+#if QT_CONFIG(itemviews)
|| qobject_cast<QHeaderView *>(w)
#endif
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
|| qobject_cast<QTabBar *>(w)
#endif
#ifndef QT_NO_FRAME
@@ -2912,7 +2920,7 @@ void QStyleSheetStyle::unpolish(QApplication *app)
styleSheetCaches->styleSheetCache.remove(qApp);
}
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
inline static bool verticalTabs(QTabBar::Shape shape)
{
return shape == QTabBar::RoundedWest
@@ -2920,7 +2928,7 @@ inline static bool verticalTabs(QTabBar::Shape shape)
|| shape == QTabBar::TriangularWest
|| shape == QTabBar::TriangularEast;
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
const QWidget *w) const
@@ -3771,7 +3779,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
return;
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
case CE_ComboBoxLabel:
if (!rule.hasBox())
break;
@@ -3807,7 +3815,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
return;
}
break;
-#endif // QT_NO_COMBOBOX
+#endif // QT_CONFIG(combobox)
case CE_Header:
if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
@@ -4069,7 +4077,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
fallback = true;
break;
-#ifndef QT_NO_ITEMVIEWS
+#if QT_CONFIG(itemviews)
case CE_ItemViewItem:
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
@@ -4086,9 +4094,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
return;
}
break;
-#endif // QT_NO_ITEMVIEWS
+#endif // QT_CONFIG(itemviews)
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
case CE_TabBarTab:
if (hasStyleRule(w, PseudoElement_TabBarTab)) {
QWindowsStyle::drawControl(ce, opt, p, w);
@@ -4123,7 +4131,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
return;
}
break;
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
case CE_ColumnViewGrip:
if (rule.hasDrawable()) {
@@ -4477,7 +4485,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
rule.drawBorder(p, opt->rect);
return;
-#ifndef QT_NO_TABWIDGET
+#if QT_CONFIG(tabwidget)
case PE_FrameTabWidget:
if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane);
@@ -4492,7 +4500,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
return;
}
break;
-#endif // QT_NO_TABWIDGET
+#endif // QT_CONFIG(tabwidget)
case PE_IndicatorProgressChunk:
pseudoElement = PseudoElement_ProgressBarChunk;
@@ -4530,7 +4538,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_IndicatorSpinPlus:
pseudoElement = PseudoElement_SpinBoxUpArrow;
break;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
case PE_IndicatorTabClose:
if (w)
w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
@@ -4790,7 +4798,7 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
}
break;
-#ifndef QT_NO_TABWIDGET
+#if QT_CONFIG(tabwidget)
case PM_TabBarTabHSpace:
case PM_TabBarTabVSpace:
subRule = renderRule(w, opt, PseudoElement_TabBarTab);
@@ -4823,7 +4831,7 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
}
break;
}
-#endif // QT_NO_TABWIDGET
+#endif // QT_CONFIG(tabwidget)
case PM_SliderThickness: // horizontal slider's height (sizeHint)
case PM_SliderLength: // minimum length of slider
@@ -5051,7 +5059,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
return rule.boxSize(sz);
break;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
case CT_TabBarTab: {
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
if (subRule.hasBox() || !subRule.hasNativeBorder()) {
@@ -5075,7 +5083,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
sz = subRule.adjustSize(csz);
break;
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
case CT_MdiControls:
if (const QStyleOptionComplex *ccOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
@@ -5107,7 +5115,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
}
break;
-#ifndef QT_NO_ITEMVIEWS
+#if QT_CONFIG(itemviews)
case CT_ItemViewItem: {
QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
sz = baseStyle()->sizeFromContents(ct, opt, csz, w);
@@ -5116,7 +5124,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
sz = subRule.boxSize(sz);
return sz;
}
-#endif // QT_NO_ITEMVIEWS
+#endif // QT_CONFIG(itemviews)
default:
break;
@@ -5275,16 +5283,16 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
case SH_ScrollBar_RollBetweenButtons: s = QLatin1String("scrollbar-roll-between-buttons"); break;
case SH_ScrollBar_ScrollWhenPointerLeavesControl: s = QLatin1String("scrollbar-scroll-when-pointer-leaves-control"); break;
case SH_TabBar_Alignment:
-#ifndef QT_NO_TABWIDGET
+#if QT_CONFIG(tabwidget)
if (qobject_cast<const QTabWidget *>(w)) {
rule = renderRule(w, opt, PseudoElement_TabWidgetTabBar);
if (rule.hasPosition())
return rule.position()->position;
}
-#endif // QT_NO_TABWIDGET
+#endif // QT_CONFIG(tabwidget)
s = QLatin1String("alignment");
break;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
case SH_TabBar_CloseButtonPosition:
rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton);
if (rule.hasPosition()) {
@@ -5299,7 +5307,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break;
case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break;
case SH_ComboBox_PopupFrameStyle:
-#ifndef QT_NO_COMBOBOX
+#if QT_CONFIG(combobox)
if (qobject_cast<const QComboBox *>(w)) {
QAbstractItemView *view = w->findChild<QAbstractItemView *>();
if (view) {
@@ -5309,7 +5317,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
return QFrame::NoFrame;
}
}
-#endif // QT_NO_COMBOBOX
+#endif // QT_CONFIG(combobox)
break;
case SH_DialogButtonBox_ButtonsHaveIcons: s = QLatin1String("dialogbuttonbox-buttons-have-icons"); break;
case SH_Workspace_FillSpaceOnMaximize: s = QLatin1String("mdi-fill-space-on-maximize"); break;
@@ -5692,7 +5700,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
RECURSION_GUARD(return baseStyle()->subElementRect(se, opt, w))
QRenderRule rule = renderRule(w, opt);
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
int pe = PseudoElement_None;
#endif
@@ -5758,7 +5766,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_CheckBoxClickRect: // relies on indicator and contents
return ParentStyle::subElementRect(se, opt, w);
-#ifndef QT_NO_ITEMVIEWS
+#if QT_CONFIG(itemviews)
case SE_ViewItemCheckIndicator:
if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
return subElementRect(SE_CheckBoxIndicator, opt, w);
@@ -5787,7 +5795,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
}
}
break;
-#endif // QT_NO_ITEMVIEWS
+#endif // QT_CONFIG(itemviews)
case SE_HeaderArrow: {
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewUpArrow);
@@ -5820,7 +5828,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
}
break;
-#ifndef QT_NO_TABBAR
+#if QT_CONFIG(tabbar)
case SE_TabWidgetLeftCorner:
pe = PseudoElement_TabWidgetLeftCorner;
// intentionally falls through
@@ -5887,7 +5895,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
}
break;
}
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabbar)
case SE_DockWidgetCloseButton:
case SE_DockWidgetFloatButton: {