diff options
Diffstat (limited to 'src/widgets/styles/qpixmapstyle.cpp')
-rw-r--r-- | src/widgets/styles/qpixmapstyle.cpp | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index ce37065fb6..a947f5d079 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -129,12 +129,14 @@ void QPixmapStyle::polish(QWidget *widget) Q_D(QPixmapStyle); // Don't fill the interior of the QTextEdit +#if QT_CONFIG(textedit) if (qobject_cast<QTextEdit*>(widget)) { QPalette p = widget->palette(); p.setBrush(QPalette::Base, Qt::NoBrush); widget->setPalette(p); } - +#endif +#if QT_CONFIG(progressbar) if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget)) { // Center the text in the progress bar pb->setAlignment(Qt::AlignCenter); @@ -143,10 +145,12 @@ void QPixmapStyle::polish(QWidget *widget) font.setPixelSize(d->descriptors.value(PB_HBackground).size.height()/2); pb->setFont(font); } - +#endif +#if QT_CONFIG(slider) if (qobject_cast<QSlider*>(widget)) widget->installEventFilter(this); - +#endif +#if QT_CONFIG(combobox) if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) { widget->installEventFilter(this); // NOTE: This will break if the private API of QComboBox changes drastically @@ -177,24 +181,28 @@ void QPixmapStyle::polish(QWidget *widget) #endif } } - +#endif // QT_CONFIG(combobox) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->installEventFilter(this); +#if QT_CONFIG(scrollarea) if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) { scrollArea->viewport()->setAutoFillBackground(false); +#if QT_CONFIG(itemviews) if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(scrollArea)) { view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); } +#endif #if QT_CONFIG(gestures) QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); #endif } - +#endif // QT_CONFIG(scrollarea) +#if QT_CONFIG(scrollbar) if (qobject_cast<QScrollBar*>(widget)) widget->setAttribute(Qt::WA_OpaquePaintEvent, false); - +#endif QCommonStyle::polish(widget); } @@ -211,15 +219,23 @@ void QPixmapStyle::unpolish(QApplication *application) */ void QPixmapStyle::unpolish(QWidget *widget) { - if (qobject_cast<QSlider*>(widget) || - qobject_cast<QComboBox*>(widget)) { + if ( +#if QT_CONFIG(slider) + qobject_cast<QSlider*>(widget) +#else + false +#endif +#if QT_CONFIG(combobox) + || qobject_cast<QComboBox*>(widget) +#endif + ) { widget->removeEventFilter(this); } if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->removeEventFilter(this); -#if QT_CONFIG(gestures) +#if QT_CONFIG(gestures) && QT_CONFIG(scrollarea) if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) QScroller::ungrabGesture(scrollArea->viewport()); #endif @@ -245,10 +261,12 @@ void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *o drawLineEdit(option, painter, widget); break; case PE_Frame: +#if QT_CONFIG(textedit) case PE_FrameDefaultButton: if (qobject_cast<const QTextEdit*>(widget)) drawTextEdit(option, painter, widget); break; +#endif case PE_IndicatorCheckBox: drawCheckBox(option, painter, widget); break; @@ -256,9 +274,11 @@ void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *o drawRadioButton(option, painter, widget); break; case PE_PanelItemViewItem: +#if QT_CONFIG(listview) if (qobject_cast<const QListView*>(widget)) drawPanelItemViewItem(option, painter, widget); else +#endif QCommonStyle::drawPrimitive(element, option, painter, widget); break; default: @@ -404,11 +424,13 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, case PM_ButtonShiftVertical: return 0; case PM_DefaultFrameWidth: +#if QT_CONFIG(textedit) if (qobject_cast<const QTextEdit*>(widget)) { const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled); return qMax(qMax(desc.margins.left(), desc.margins.right()), qMax(desc.margins.top(), desc.margins.bottom())); } +#endif return 0; case PM_IndicatorWidth: return d->pixmaps.value(CB_Enabled).pixmap.width(); @@ -430,6 +452,7 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); } +#if QT_CONFIG(slider) case PM_SliderThickness: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) { @@ -470,6 +493,7 @@ int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, ? desc.size.height() : desc.size.width(); } break; +#endif // QT_CONFIG(slider) case PM_ScrollBarSliderMin: return 0; default: ; @@ -520,7 +544,7 @@ QStyle::SubControl QPixmapStyle::hitTestComplexControl(QStyle::ComplexControl co bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) { Q_D(QPixmapStyle); - +#if QT_CONFIG(slider) if (QSlider *slider = qobject_cast<QSlider*>(watched)) { switch (event->type()) { case QEvent::MouseButtonPress: @@ -531,7 +555,8 @@ bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) default: ; } } - +#endif // QT_CONFIG(slider) +#if QT_CONFIG(combobox) if (QComboBox *comboBox = qobject_cast<QComboBox*>(watched)) { switch (event->type()) { case QEvent::MouseButtonPress: @@ -552,6 +577,7 @@ bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) default: ; } } +#endif // QT_CONFIG(combobox) if (qstrcmp(watched->metaObject()->className(),"QComboBoxPrivateContainer") == 0) { if (event->type() == QEvent::Show) { @@ -701,9 +727,10 @@ void QPixmapStyle::drawLineEdit(const QStyleOption *option, QPainter *painter, const QWidget *widget) const { // Don't draw for the line edit inside a combobox +#if QT_CONFIG(combobox) if (widget && qobject_cast<const QComboBox*>(widget->parentWidget())) return; - +#endif const bool enabled = option->state & State_Enabled; const bool focused = option->state & State_HasFocus; ControlDescriptor control = enabled ? (focused ? LE_Focused : LE_Enabled) : LE_Disabled; @@ -848,6 +875,7 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { +#if QT_CONFIG(slider) Q_D(const QPixmapStyle); const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); @@ -897,6 +925,7 @@ void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, painter->drawPixmap(handle, d->pixmaps.value(pix).pixmap); } } +#endif // QT_CONFIG(slider) } void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, @@ -923,6 +952,7 @@ void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const { +#if QT_CONFIG(slider) if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) { // Do not draw the scrollbar @@ -934,6 +964,7 @@ void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, ? SB_Horizontal : SB_Vertical; drawCachedPixmap(control, rect, painter); } +#endif // QT_CONFIG(slider) } QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option, @@ -992,6 +1023,7 @@ QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const { +#if QT_CONFIG(slider) Q_D(const QPixmapStyle); const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); @@ -1007,6 +1039,9 @@ QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, return QSize(result.width(), desc.size.height()); else return QSize(desc.size.width(), result.height()); +#else // QT_CONFIG(slider) + return QSize(); +#endif // QT_CONFIG(slider) } QSize QPixmapStyle::comboBoxSizeFromContents(const QStyleOption *option, @@ -1074,6 +1109,7 @@ QRect QPixmapStyle::comboBoxSubControlRect(const QStyleOptionComplex *option, QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, QStyle::SubControl sc, const QWidget *) const { +#if QT_CONFIG(slider) if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) { int length = (slider->orientation == Qt::Horizontal) @@ -1120,6 +1156,7 @@ QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, } } } +#endif // QT_CONFIG(slider) return QRect(); } |