diff options
Diffstat (limited to 'src/widgets')
38 files changed, 301 insertions, 111 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 463019dbd0..ea3b88468b 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -130,12 +130,16 @@ public: case QAccessible::Accelerator: str = qt_accHotKey(m_parent->tabText(m_index)); break; +#if QT_CONFIG(tooltip) case QAccessible::Description: str = m_parent->tabToolTip(m_index); break; +#endif +#if QT_CONFIG(whatsthis) case QAccessible::Help: str = m_parent->tabWhatsThis(m_index); break; +#endif default: break; } diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 4a684e01f9..ae50bbaef0 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -117,7 +117,11 @@ QAccessibleInterface *QAccessibleMenu::parent() const parentCandidates << menu()->parentWidget(); parentCandidates << menuAction->associatedWidgets(); foreach (QWidget *w, parentCandidates) { - if (qobject_cast<QMenu*>(w) || qobject_cast<QMenuBar*>(w)) { + if (qobject_cast<QMenu*>(w) +#if QT_CONFIG(menubar) + || qobject_cast<QMenuBar*>(w) +#endif + ) { if (w->actions().indexOf(menuAction) != -1) return getOrCreateMenu(w, menuAction); } @@ -348,13 +352,16 @@ void QAccessibleMenuItem::doAction(const QString &actionName) if (actionName == pressAction()) { m_action->trigger(); } else if (actionName == showMenuAction()) { +#if QT_CONFIG(menubar) if (QMenuBar *bar = qobject_cast<QMenuBar*>(owner())) { if (m_action->menu() && m_action->menu()->isVisible()) { m_action->menu()->hide(); } else { bar->setActiveAction(m_action); } - } else if (QMenu *menu = qobject_cast<QMenu*>(owner())){ + } else +#endif + if (QMenu *menu = qobject_cast<QMenu*>(owner())){ if (m_action->menu() && m_action->menu()->isVisible()) { m_action->menu()->hide(); } else { diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index dfc8c84836..da184fd90d 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -94,9 +94,9 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QScrollBar")) { iface = new QAccessibleScrollBar(widget); #endif +#ifndef QT_NO_SLIDER } else if (classname == QLatin1String("QAbstractSlider")) { iface = new QAccessibleAbstractSlider(widget); -#ifndef QT_NO_SLIDER } else if (classname == QLatin1String("QSlider")) { iface = new QAccessibleSlider(widget); #endif diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index b814762168..4c48ecb465 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -85,7 +85,9 @@ QList<QWidget*> childWidgets(const QWidget *widget) QString objectName = w->objectName(); if (!w->isWindow() && !qobject_cast<QFocusFrame*>(w) +#if QT_CONFIG(menu) && !qobject_cast<QMenu*>(w) +#endif && objectName != QLatin1String("qt_rubberband") && objectName != QLatin1String("qt_qmainwindow_extended_splitter")) { widgets.append(w); diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 2f781fe619..602d0c7e11 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -81,10 +81,14 @@ QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const QAccessibleInterface *QAccessibleAbstractSpinBox::lineEditIface() const { +#if QT_CONFIG(lineedit) // QAccessibleLineEdit is only used to forward the text functions if (!lineEdit) lineEdit = new QAccessibleLineEdit(abstractSpinBox()->lineEdit()); return lineEdit; +#else + return nullptr; +#endif } QString QAccessibleAbstractSpinBox::text(QAccessible::Text t) const diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 28f613462d..c0b010c292 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -143,6 +143,7 @@ protected: }; #endif // QT_NO_SPINBOX +#if QT_CONFIG(slider) class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleValueInterface { public: @@ -159,6 +160,7 @@ public: protected: QAbstractSlider *abstractSlider() const; }; +#endif // QT_CONFIG(slider) #ifndef QT_NO_SCROLLBAR class QAccessibleScrollBar : public QAccessibleAbstractSlider diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index bd9f0c6e01..a2805a2458 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -339,10 +339,12 @@ QStringList QAccessibleToolButton::actionNames() const { QStringList names; if (widget()->isEnabled()) { +#if QT_CONFIG(menu) if (toolButton()->menu()) names << showMenuAction(); if (toolButton()->popupMode() != QToolButton::InstantPopup) names << QAccessibleButton::actionNames(); +#endif } return names; } @@ -355,12 +357,12 @@ void QAccessibleToolButton::doAction(const QString &actionName) if (actionName == pressAction()) { button()->click(); } else if (actionName == showMenuAction()) { +#if QT_CONFIG(menu) if (toolButton()->popupMode() != QToolButton::InstantPopup) { toolButton()->setDown(true); -#ifndef QT_NO_MENU toolButton()->showMenu(); -#endif } +#endif } else { QAccessibleButton::doAction(actionName); } @@ -542,9 +544,11 @@ QString QAccessibleGroupBox::text(QAccessible::Text t) const case QAccessible::Name: txt = qt_accStripAmp(groupBox()->title()); break; +#if QT_CONFIG(tooltip) case QAccessible::Description: txt = groupBox()->toolTip(); break; +#endif case QAccessible::Accelerator: txt = qt_accHotKey(groupBox()->title()); break; diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 8acbffef6a..e7007f71b7 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -173,7 +173,7 @@ "label": "QSpinBox", "purpose": "Provides spin boxes handling integers and discrete sets of values.", "section": "Widgets", - "condition": "features.spinwidget && features.lineedit && features.validator", + "condition": "features.lineedit && features.validator", "output": [ "publicFeature", "feature" ] }, "tabbar": { @@ -332,12 +332,6 @@ "condition": "features.graphicsview", "output": [ "publicFeature", "feature" ] }, - "spinbox": { - "label": "QSpinBox", - "purpose": "Provides spinbox control widgets.", - "section": "Widgets", - "output": [ "publicFeature", "feature" ] - }, "textedit": { "label": "QTextEdit", "purpose": "Supports rich text editing.", @@ -435,7 +429,7 @@ "label": "QInputDialog", "purpose": "Provides a simple convenience dialog to get a single value from the user.", "section": "Dialogs", - "condition": "features.combobox && features.spinbox && features.stackedwidget", + "condition": "features.combobox && features.spinbox && features.stackedwidget && features.textedit", "output": [ "publicFeature", "feature" ] }, "errormessage": { @@ -504,7 +498,7 @@ "label": "QCompleter", "purpose": "Provides completions based on an item model.", "section": "Utilities", - "condition": "features.proxymodel", + "condition": "features.proxymodel && features.itemviews", "output": [ "publicFeature", "feature" ] }, "fscompleter": { diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index deb8a02961..b20a1449eb 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include "qwindowdefs.h" +#include "qfontdialog.h" -#ifndef QT_NO_FONTDIALOG +#if QT_CONFIG(fontdialog) -#include "qfontdialog.h" #include "qfontdialog_p.h" #include <qapplication.h> @@ -1050,4 +1050,4 @@ QT_END_NAMESPACE #include "qfontdialog.moc" #include "moc_qfontdialog.cpp" -#endif // QT_NO_FONTDIALOG +#endif // QT_CONFIG(fontdialog) diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 57b3f47863..98d070e493 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -336,8 +336,10 @@ void QMessageBoxPrivate::setupLayout() #else grid->addWidget(buttonBox, grid->rowCount(), 0, 1, grid->columnCount()); #endif +#if QT_CONFIG(textedit) if (detailsText) grid->addWidget(detailsText, grid->rowCount(), 0, 1, grid->columnCount()); +#endif grid->setSizeConstraint(QLayout::SetNoConstraint); q->setLayout(grid); @@ -2654,7 +2656,9 @@ void QMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *) options->setWindowTitle(q->windowTitle()); options->setText(q->text()); options->setInformativeText(q->informativeText()); +#if QT_CONFIG(textedit) options->setDetailedText(q->detailedText()); +#endif options->setIcon(helperIcon(q->icon())); options->setStandardButtons(helperStandardButtons(q)); } diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 84819e8c1a..f6b7c80656 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -2073,10 +2073,12 @@ model's structure, perhaps involving internal reorganization, sorting of data or any other structural change, it is necessary to perform the following sequence: + \list \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal \li Update internal data which represents the structure of the model. \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()} \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal. + \endlist This sequence can be used for any structural update in lieu of the more high-level and convenient protected methods. For example, if a model of diff --git a/src/widgets/graphicsview/graphicsview.pri b/src/widgets/graphicsview/graphicsview.pri index b81f736ef4..7d10244634 100644 --- a/src/widgets/graphicsview/graphicsview.pri +++ b/src/widgets/graphicsview/graphicsview.pri @@ -1,4 +1,6 @@ # Qt graphicsview module + +qtConfig(graphicsview) { HEADERS += graphicsview/qgraphicsgridlayout.h \ graphicsview/qgraphicsitem.h \ graphicsview/qgraphicsitem_p.h \ @@ -53,3 +55,4 @@ SOURCES += graphicsview/qgraphicsgridlayout.cpp \ graphicsview/qsimplex_p.cpp \ graphicsview/qgraphicsanchorlayout_p.cpp \ graphicsview/qgraphicsanchorlayout.cpp +} diff --git a/src/widgets/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri index 245962d35f..d78bc4b40e 100644 --- a/src/widgets/itemviews/itemviews.pri +++ b/src/widgets/itemviews/itemviews.pri @@ -1,5 +1,6 @@ # Qt gui library, itemviews +qtConfig(itemviews) { HEADERS += \ itemviews/qabstractitemview.h \ itemviews/qabstractitemview_p.h \ @@ -27,8 +28,6 @@ HEADERS += \ itemviews/qitemeditorfactory_p.h \ itemviews/qtreewidgetitemiterator.h \ itemviews/qdatawidgetmapper.h \ - itemviews/qfileiconprovider.h \ - itemviews/qfileiconprovider_p.h \ itemviews/qcolumnviewgrip_p.h \ itemviews/qcolumnview.h \ itemviews/qcolumnview_p.h \ @@ -50,8 +49,14 @@ SOURCES += \ itemviews/qitemeditorfactory.cpp \ itemviews/qtreewidgetitemiterator.cpp \ itemviews/qdatawidgetmapper.cpp \ - itemviews/qfileiconprovider.cpp \ itemviews/qcolumnview.cpp \ itemviews/qcolumnviewgrip.cpp \ itemviews/qstyleditemdelegate.cpp +} + +HEADERS += \ + itemviews/qfileiconprovider.h \ + itemviews/qfileiconprovider_p.h \ +SOURCES += \ + itemviews/qfileiconprovider.cpp diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 6c7c914bc0..ea9bbb0fb9 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include <qglobal.h> +#include "qcolumnview.h" -#ifndef QT_NO_COLUMNVIEW +#if QT_CONFIG(columnview) -#include "qcolumnview.h" #include "qcolumnview_p.h" #include "qcolumnviewgrip_p.h" @@ -1170,4 +1170,4 @@ QT_END_NAMESPACE #include "moc_qcolumnview.cpp" -#endif // QT_NO_COLUMNVIEW +#endif // QT_CONFIG(columnview) diff --git a/src/widgets/itemviews/qtreewidgetitemiterator_p.h b/src/widgets/itemviews/qtreewidgetitemiterator_p.h index 4b6c7b0a57..e68f6103d3 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator_p.h +++ b/src/widgets/itemviews/qtreewidgetitemiterator_p.h @@ -53,8 +53,8 @@ #include <QtCore/qstack.h> -#ifndef QT_NO_TREEWIDGET #include "qtreewidgetitemiterator.h" +#if QT_CONFIG(treewidget) QT_BEGIN_NAMESPACE @@ -103,6 +103,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_TREEWIDGET +#endif // QT_CONFIG(treewidget) #endif //QTREEWIDGETITEMITERATOR_P_H diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index b75088ae50..c174a7af26 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5226,9 +5226,11 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_Splitter_OpaqueResize: ret = true; break; +#if QT_CONFIG(itemviews) case SH_ItemView_ScrollMode: ret = QAbstractItemView::ScrollPerItem; break; +#endif default: ret = 0; break; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 54cc82bea9..75c50bb146 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -453,6 +453,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, drawPrimitive(PE_IndicatorArrowRight, option, painter, widget); break; } +#if QT_CONFIG(tabbar) case PE_FrameTabBarBase: if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) { @@ -489,6 +490,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, painter->restore(); } return; +#endif // QT_CONFIG(tabbar) case PE_PanelScrollAreaCorner: { painter->save(); QColor alphaOutline = outline; @@ -938,6 +940,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, case PE_FrameTabWidget: painter->save(); painter->fillRect(option->rect.adjusted(0, 0, -1, -1), tabFrameColor); +#if QT_CONFIG(tabwidget) if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) { QColor borderColor = outline.lighter(110); QRect rect = option->rect.adjusted(0, 0, -1, -1); @@ -960,6 +963,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, painter->drawRect(rect.adjusted(1, 1, -1, -1)); } +#endif // QT_CONFIG(tabwidget) painter->restore(); break ; @@ -1057,6 +1061,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } break; } +#if QT_CONFIG(rubberband) case CE_RubberBand: if (qstyleoption_cast<const QStyleOptionRubberBand *>(option)) { QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight); @@ -1082,6 +1087,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->restore(); } break; +#endif //QT_CONFIG(rubberband) case CE_SizeGrip: painter->save(); { @@ -1097,6 +1103,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#if QT_CONFIG(toolbar) case CE_ToolBar: if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { // Reserve the beveled appearance only for mainwindow toolbars @@ -1217,6 +1224,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio painter->setPen(oldPen); } break; +#endif // QT_CONFIG(toolbar) case CE_DockWidgetTitle: painter->save(); if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { @@ -1550,7 +1558,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio bool ignoreCheckMark = false; int checkcol = qMax(menuItem->maxIconWidth, 20); - if (qobject_cast<const QComboBox*>(widget) || + if ( +#if QT_CONFIG(combobox) + qobject_cast<const QComboBox*>(widget) || +#endif (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool())) ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate @@ -1607,8 +1618,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); +#if QT_CONFIG(combobox) if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) iconSize = combo->iconSize(); +#endif if (checked) pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); else @@ -1793,6 +1806,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#if QT_CONFIG(tabbar) case CE_TabBarTabShape: painter->save(); if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { @@ -1908,6 +1922,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio } painter->restore(); break; +#endif //QT_CONFIG(tabbar) default: QCommonStyle::drawControl(element,option,painter,widget); break; @@ -1993,6 +2008,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { QPixmap cache; @@ -2143,6 +2159,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->drawPixmap(spinBox->rect.topLeft(), cache); } break; +#endif // QT_CONFIG(spinbox) case CC_TitleBar: painter->save(); if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) { @@ -2403,6 +2420,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(slider) case CC_ScrollBar: painter->save(); if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { @@ -2711,6 +2729,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break;; +#endif // QT_CONFIG(slider) case CC_ComboBox: painter->save(); if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { @@ -2808,6 +2827,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } painter->restore(); break; +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); @@ -3018,10 +3038,13 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->setPen(oldPen); } break; +#endif // QT_CONFIG(slider) +#if QT_CONFIG(dial) case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) QStyleHelper::drawDial(dial, painter); break; +#endif default: QCommonStyle::drawComplexControl(control, option, painter, widget); break; @@ -3217,9 +3240,11 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti } } else if (!menuItem->icon.isNull()) { +#if QT_CONFIG(combobox) if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) { newSize.setHeight(qMax(combo->iconSize().height() + 2, newSize.height())); } +#endif } newSize.setWidth(newSize.width() + 12); newSize.setWidth(qMax(newSize.width(), 120)); @@ -3252,12 +3277,22 @@ void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); if (qobject_cast<QAbstractButton*>(widget) +#if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) +#endif +#if QT_CONFIG(progressbar) || qobject_cast<QProgressBar *>(widget) +#endif +#if QT_CONFIG(scrollbar) || qobject_cast<QScrollBar *>(widget) +#endif +#if QT_CONFIG(splitter) || qobject_cast<QSplitterHandle *>(widget) +#endif || qobject_cast<QAbstractSlider *>(widget) +#if QT_CONFIG(spinbox) || qobject_cast<QAbstractSpinBox *>(widget) +#endif || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { @@ -3281,12 +3316,22 @@ void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); if (qobject_cast<QAbstractButton*>(widget) +#if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) +#endif +#if QT_CONFIG(progressbar) || qobject_cast<QProgressBar *>(widget) +#endif +#if QT_CONFIG(scrollbar) || qobject_cast<QScrollBar *>(widget) +#endif +#if QT_CONFIG(splitter) || qobject_cast<QSplitterHandle *>(widget) +#endif || qobject_cast<QAbstractSlider *>(widget) +#if QT_CONFIG(spinbox) || qobject_cast<QAbstractSpinBox *>(widget) +#endif || (widget->inherits("QDockSeparator")) || (widget->inherits("QDockWidgetSeparator")) ) { @@ -3311,6 +3356,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget); switch (control) { +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); @@ -3361,6 +3407,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom } } break; +#endif // QT_CONFIG(slider) +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { int center = spinbox->rect.height() / 2; @@ -3398,7 +3446,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom rect = visualRect(spinbox->direction, spinbox->rect, rect); } break; - +#endif // QT_CONFIG(spinbox) case CC_GroupBox: if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { rect = option->rect; 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(); } diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 602421725f..9b381c383b 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -411,7 +411,7 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec QColor backgroundColor(const QPalette &pal, const QWidget* widget) { -#ifndef QT_NO_SCROLLBAR +#if QT_CONFIG(scrollarea) if (qobject_cast<const QScrollBar *>(widget) && widget->parent() && qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent())) return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 68ee8c22d3..d9d270643c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -38,10 +38,10 @@ ****************************************************************************/ #include <qglobal.h> +#include "qstylesheetstyle_p.h" -#ifndef QT_NO_STYLE_STYLESHEET +#if QT_CONFIG(style_stylesheet) -#include "qstylesheetstyle_p.h" #include "private/qcssutil_p.h" #include <qdebug.h> #include <qapplication.h> @@ -4415,14 +4415,18 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; case PE_IndicatorColumnViewArrow: +#if QT_CONFIG(itemviews) if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { bool reverse = (viewOpt->direction == Qt::RightToLeft); pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow; - } else { + } else +#endif + { pseudoElement = PseudoElement_RightArrow; } break; +#if QT_CONFIG(itemviews) case PE_IndicatorBranch: if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch); @@ -4437,6 +4441,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } } return; +#endif // QT_CONFIG(itemviews) case PE_PanelTipLabel: if (!rule.hasDrawable()) @@ -4898,6 +4903,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op QSize sz = rule.adjustSize(csz); switch (ct) { +#if QT_CONFIG(spinbox) case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1) if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { // Add some space for the up/down buttons @@ -4915,6 +4921,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op return sz; } break; +#endif // QT_CONFIG(spinbox) case CT_ToolButton: if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw()) sz += QSize(3, 3); // ### broken QToolButton @@ -6024,4 +6031,4 @@ QT_END_NAMESPACE #include "moc_qstylesheetstyle_p.cpp" -#endif // QT_NO_STYLE_STYLESHEET +#endif // QT_CONFIG(style_stylesheet) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index a8ee881a30..f9370a2cc7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -815,6 +815,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->save(); doRestore = true; } +#if QT_CONFIG(itemviews) if (pe == PE_IndicatorViewItemCheck) { const QStyleOptionViewItem *itemViewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt); p->setPen(itemViewOpt @@ -826,6 +827,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->setBrush(opt->palette.brush(QPalette::Button)); p->drawRect(opt->rect.x() + 1, opt->rect.y() + 1, 11, 11); } +#endif // QT_CONFIG(itemviews) if (!(opt->state & State_Off)) { QLineF lines[7]; int i, xx, yy; diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 225c47052b..83c1764f38 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -704,6 +704,7 @@ void QSystemTrayIconPrivate::remove_sys_qpa() void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const { +#if QT_CONFIG(menu) if (menu->platformMenu()) return; // The platform menu already exists. @@ -720,6 +721,7 @@ void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const QPlatformMenu *platformMenu = qpa_sys->createMenu(); if (platformMenu) menu->setPlatformMenu(platformMenu); +#endif // QT_CONFIG(menu) } QT_END_NAMESPACE diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp index 8399732a4a..c0bf058681 100644 --- a/src/widgets/util/qsystemtrayicon_qpa.cpp +++ b/src/widgets/util/qsystemtrayicon_qpa.cpp @@ -89,10 +89,12 @@ void QSystemTrayIconPrivate::updateIcon_sys() void QSystemTrayIconPrivate::updateMenu_sys() { +#if QT_CONFIG(menu) if (qpa_sys && menu) { addPlatformMenu(menu); qpa_sys->updateMenu(menu->platformMenu()); } +#endif } void QSystemTrayIconPrivate::updateToolTip_sys() diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp index 638d2050fb..d110cb8be4 100644 --- a/src/widgets/util/qsystemtrayicon_win.cpp +++ b/src/widgets/util/qsystemtrayicon_win.cpp @@ -564,7 +564,8 @@ void QSystemTrayIconPrivate::updateIcon_sys() void QSystemTrayIconPrivate::updateMenu_sys() { - +#if QT_CONFIG(menu) +#endif } void QSystemTrayIconPrivate::updateToolTip_sys() diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 20ab0f6377..ac6c14dc63 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -104,7 +104,9 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) , q(qIn) { setObjectName(QStringLiteral("QSystemTrayIconSys")); +#if QT_CONFIG(tooltip) setToolTip(q->toolTip()); +#endif setAttribute(Qt::WA_AlwaysShowToolTips, true); setAttribute(Qt::WA_QuitOnClose, false); const QSize size(22, 22); // Gnome, standard size @@ -316,10 +318,12 @@ void QSystemTrayIconPrivate::updateIcon_sys() void QSystemTrayIconPrivate::updateMenu_sys() { +#if QT_CONFIG(menu) if (qpa_sys && menu) { addPlatformMenu(menu); qpa_sys->updateMenu(menu->platformMenu()); } +#endif } void QSystemTrayIconPrivate::updateToolTip_sys() diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index aaf7e165cd..d091d1e970 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -473,6 +473,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // move the scrollbars away from top/left headers int vHeaderRight = 0; int hHeaderBottom = 0; +#if QT_CONFIG(itemviews) if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) { const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>(); if (headers.count() <= 2) { @@ -485,7 +486,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() } } } - +#endif // QT_CONFIG(itemviews) if (needh) { QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); #if 0 // Used to be included in Qt4 for Q_WS_MAC diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index c61bf4729a..6bcdc372ef 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1246,11 +1246,9 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) \reimp */ +#if QT_CONFIG(contextmenu) void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) { -#ifdef QT_NO_CONTEXTMENU - Q_UNUSED(event); -#else Q_D(QAbstractSpinBox); QPointer<QMenu> menu = d->edit->createStandardContextMenu(); @@ -1286,8 +1284,8 @@ void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) } } event->accept(); -#endif // QT_NO_CONTEXTMENU } +#endif // QT_CONFIG(contextmenu) /*! \reimp diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index ac46894a27..b60178b94c 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -142,7 +142,9 @@ protected: #endif void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; +#if QT_CONFIG(contextmenu) void contextMenuEvent(QContextMenuEvent *event) override; +#endif void changeEvent(QEvent *event) override; void closeEvent(QCloseEvent *event) override; void hideEvent(QHideEvent *event) override; diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index ad19e5d5f9..b33f2dc798 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2092,7 +2092,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) const QDockAreaLayoutItem &item = item_list.at(i); if (item.flags & QDockAreaLayoutItem::GapItem) continue; - if (item.skip()) + if (!item.widgetItem && item.skip()) continue; if (item.subinfo) item.subinfo->reparentWidgets(parent); @@ -2608,7 +2608,9 @@ QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) Q_ASSERT(!path.isEmpty()); const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].plug(path.mid(1)); + QLayoutItem *item = docks[index].plug(path.mid(1)); + docks[index].reparentWidgets(mainWindow); + return item; } QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) @@ -3175,6 +3177,7 @@ void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, while (path.size() > 1) { QDockAreaLayoutInfo *info = this->info(path); +#if QT_CONFIG(tabbar) if (!info->tabbed && info->o == o) { info->item_list[path.constLast()].size = size; int totalSize = 0; @@ -3187,6 +3190,7 @@ void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, } size = totalSize; } +#endif // QT_CONFIG(tabbar) path.removeLast(); } diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 3252ce5941..4d86c7cfc7 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -43,6 +43,7 @@ #include "qboxlayout.h" #include "qlineedit.h" +#include <private/qkeymapper_p.h> QT_BEGIN_NAMESPACE @@ -80,15 +81,8 @@ void QKeySequenceEditPrivate::init() int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) { + Q_UNUSED(text); int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.isEmpty() || - !text.at(0).isPrint() || - text.at(0).isLetterOrNumber() || - text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) result |= Qt::CTRL; if (state & Qt::MetaModifier) @@ -272,7 +266,27 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (d->keyNum >= QKeySequencePrivate::MaxKeyCount) return; - nextKey |= d->translateModifiers(e->modifiers(), e->text()); + if (e->modifiers() & Qt::ShiftModifier) { + QList<int> possibleKeys = QKeyMapper::possibleKeys(e); + int pkTotal = possibleKeys.count(); + if (!pkTotal) + return; + bool found = false; + for (int i = 0; i < possibleKeys.size(); ++i) { + if (possibleKeys.at(i) - nextKey == int(e->modifiers()) + || (possibleKeys.at(i) == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = possibleKeys.at(i); + found = true; + break; + } + } + // Use as fallback + if (!found) + nextKey = possibleKeys.first(); + } else { + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + } + d->key[d->keyNum] = nextKey; d->keyNum++; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 6d49b29fb9..fb0ffd6083 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2195,10 +2195,12 @@ void QLineEdit::changeEvent(QEvent *ev) update(); break; case QEvent::LayoutDirectionChange: +#if QT_CONFIG(toolbutton) for (const auto &e : d->trailingSideWidgets) { // Refresh icon to show arrow in right direction. if (e.flags & QLineEditPrivate::SideWidgetClearButton) static_cast<QLineEditIconButton *>(e.widget)->setIcon(d->clearButtonIcon()); } +#endif d->positionSideWidgets(); break; default: diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 7da1d911ee..9947d63279 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -313,6 +313,8 @@ void QLineEditPrivate::drag() #endif // QT_NO_DRAGANDDROP + +#if QT_CONFIG(toolbutton) QLineEditIconButton::QLineEditIconButton(QWidget *parent) : QToolButton(parent) , m_opacity(0) @@ -390,6 +392,7 @@ void QLineEditIconButton::updateCursor() setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor()); #endif } +#endif // QT_CONFIG(toolbutton) void QLineEditPrivate::_q_textChanged(const QString &text) { @@ -397,7 +400,7 @@ void QLineEditPrivate::_q_textChanged(const QString &text) const int newTextSize = text.size(); if (!newTextSize || !lastTextSize) { lastTextSize = newTextSize; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) && QT_CONFIG(toolbutton) const bool fadeIn = newTextSize > 0; for (const SideWidgetEntry &e : leadingSideWidgets) { if (e.flags & SideWidgetFadeInWithText) @@ -507,6 +510,7 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE flags |= SideWidgetCreatedByWidgetAction; } if (!w) { +#if QT_CONFIG(toolbutton) QLineEditIconButton *toolButton = new QLineEditIconButton(q); toolButton->setIcon(newAction->icon()); toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0); @@ -514,6 +518,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked())); toolButton->setDefaultAction(newAction); w = toolButton; +#else + return nullptr; +#endif } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 0a08aefab3..a903c003e6 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QLineEditPrivate; // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text - +#if QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton { Q_OBJECT @@ -103,6 +103,7 @@ private: qreal m_opacity; }; +#endif // QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditPrivate : public QWidgetPrivate { diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index b4f2b8959e..8e565ecfe0 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -56,27 +56,21 @@ \inmodule QtWidgets While Qt offers a lot of classes for writing your application, Apple's - Cocoa framework offers lots of functionality that is not currently in Qt or - may never end up in Qt. Using QMacCocoaViewContainer, it is possible to put an - arbitrary NSView-derived class from Cocoa and put it in a Qt hierarchy. - Depending on how comfortable you are with using objective-C, you can use - QMacCocoaViewContainer directly, or subclass it to wrap further functionality - of the underlying NSView. - - QMacCocoaViewContainer works regardless if Qt is built against Carbon or - Cocoa. However, QCocoaContainerView requires \macos 10.5 or better to be - used with Carbon. - - It should be also noted that at the low level on \macos, there is a - difference between windows (top-levels) and view (widgets that are inside a - window). For this reason, make sure that the NSView that you are wrapping - doesn't end up as a top-level. The best way to ensure this is to make sure - you always have a parent and not set the parent to 0. - - If you are using QMacCocoaViewContainer as a sub-class and are mixing and - matching objective-C with C++ (a.k.a. objective-C++). It is probably - simpler to have your file end with \tt{.mm} than \tt{.cpp}. Most Apple tools will - correctly identify the source as objective-C++. + Cocoa frameworks offer functionality that is not currently available (or + may never end up) in Qt. Using QMacCocoaViewContainer, it is possible to take an + arbitrary NSView-derived class from Cocoa and put it in a Qt widgets hierarchy. + Depending on the level of integration you need, you can use QMacCocoaViewContainer + directly or subclass it to wrap more functionality of the underlying NSView. + + It should be also noted that, at the Cocoa level, there is a difference + between top-level windows and views (widgets that are inside a window). + For this reason, make sure that the NSView that you are wrapping doesn't + end up as a top-level window. The best way to ensure this is to make sure + QMacCocoaViewContainer's parent widget is not null. + + If you are using QMacCocoaViewContainer as a subclass and are accessing Cocoa API, + it is probably simpler to have your file end with \tt{.mm} instead of \tt{.cpp}. + Most Apple tools will correctly identify the source as Objective-C++. QMacCocoaViewContainer requires knowledge of how Cocoa works, especially in regard to its reference counting (retain/release) nature. It is noted in @@ -85,7 +79,8 @@ pool. If this is done outside of a running event loop, it is up to the developer to provide the autorelease pool. - The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField. + The following is a snippet showing how to subclass QMacCocoaViewContainer + to wrap an NSSearchField. \snippet macmainwindow.mm 0 */ diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index 936bd35187..9ad8aa1305 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -65,15 +65,11 @@ but it cannot be shown on its own. It needs to be put into a window when it is created or later through a native call. - QMacNativeWidget works for either Carbon or Cocoa depending on how Qt was configured. If Qt is - using Carbon, QMacNativeWidget will embed into Carbon hierarchies. If Qt is - using Cocoa, QMacNativeWidget embeds into Cocoa hierarchies. - - Here is an example of putting a QPushButton into a NSWindow: + Here is an example showing how to put a QPushButton into a NSWindow: \snippet qmacnativewidget/main.mm 0 - Note that QMacNativeWidget requires knowledge of Carbon or Cocoa. All it + Note that QMacNativeWidget requires knowledge of Cocoa. All it does is get the Qt hierarchy into a window not owned by Qt. It is then up to the programmer to ensure it is placed correctly in the window and responds correctly to events. diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 14d7f3d835..72e06e4efa 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -125,8 +125,11 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QSt << layout.rect.height() << " min size: " << minSize.width() << ',' << minSize.height() << " orient:" << layout.o +#if QT_CONFIG(tabbar) << " tabbed:" << layout.tabbed - << " tbshape:" << layout.tabBarShape << '\n'; + << " tbshape:" << layout.tabBarShape +#endif + << '\n'; indent += QLatin1String(" "); @@ -226,7 +229,9 @@ public: if (li->isEmpty()) return; int fw = frameWidth(); +#if QT_CONFIG(tabbar) li->reparentWidgets(parentWidget()); +#endif li->rect = r.adjusted(fw, fw, -fw, -fw); li->fitItems(); li->apply(false); @@ -317,6 +322,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const { QDockAreaLayoutInfo *info = layoutInfo(); QDockWidget *dw = 0; +#if QT_CONFIG(tabbar) if (info->tabBar && info->tabBar->currentIndex() >= 0) { int i = info->tabIndexToListIndex(info->tabBar->currentIndex()); if (i >= 0) { @@ -325,6 +331,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const dw = qobject_cast<QDockWidget *>(item.widgetItem->widget()); } } +#endif if (!dw) { for (int i = 0; !dw && i < info->item_list.count(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); @@ -373,8 +380,10 @@ void QDockWidgetGroupWindow::destroyOrHideIfEmpty() if (!wasHidden) dw->show(); } +#if QT_CONFIG(tabbar) foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly)) tb->setParent(parentWidget()); +#endif deleteLater(); } @@ -1021,7 +1030,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, } } break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) case QDockAreaLayout::FloatingDockWidgetTabMarker: { auto dockWidgets = allMyDockWidgets(mainWindow); @@ -1045,7 +1054,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, floatingTab->show(); } break; -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) #endif // QT_NO_DOCKWIDGET #ifndef QT_NO_TOOLBAR @@ -1802,10 +1811,10 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&) void QMainWindowLayout::raise(QDockWidget *widget) { +#ifndef QT_NO_TABBAR QDockAreaLayoutInfo *info = dockInfo(widget); if (info == 0) return; -#ifndef QT_NO_TABBAR if (!info->tabbed) return; info->setCurrentTab(widget); @@ -2012,7 +2021,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dwgw->layoutInfo()->remove(path); } currentGapRect = QRect(); - +#if QT_CONFIG(tabwidget) if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) { //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); @@ -2030,7 +2039,8 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dropTo->d_func()->plug(QRect()); currentHoveredFloat = floatingTabs; } - +#endif // QT_CONFIG(tabwidget) +#if QT_CONFIG(tabbar) QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat); Q_ASSERT(dwgw); Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed @@ -2042,6 +2052,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft())); pluggingWidget = widget; widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks); +#endif // QT_CONFIG(tabbar) return true; } #endif @@ -2120,7 +2131,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) if (QDockWidgetGroupWindow *dropTo = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat)) { parentInfo = dropTo->layoutInfo(); +#if QT_CONFIG(tabbar) Q_ASSERT(parentInfo->tabbed); +#endif path = parentInfo->indexOf(widget); Q_ASSERT(path.size() == 1); } else { @@ -2129,7 +2142,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo = layoutState.dockAreaLayout.info(path); Q_ASSERT(parentInfo); } - +#if QT_CONFIG(tabbar) if (parentInfo->tabbed) { // merge the two tab widgets int idx = path.constLast(); @@ -2143,15 +2156,19 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget()); parentInfo->updateTabBar(); parentInfo->setCurrentTabId(currentId); - } else { + } else +#endif // QT_CONFIG(tabbar) + { QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path); Q_ASSERT(item.widgetItem->widget() == dwgw); delete item.widgetItem; item.widgetItem = 0; item.subinfo = new QDockAreaLayoutInfo(qMove(*info)); *info = QDockAreaLayoutInfo(); +#if QT_CONFIG(tabbar) item.subinfo->reparentWidgets(parentWidget()); item.subinfo->setTabBarShape(parentInfo->tabBarShape); +#endif } dwgw->destroyOrHideIfEmpty(); } @@ -2172,7 +2189,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) savedState.clear(); currentGapPos.clear(); pluggingWidget = 0; - currentHoveredFloat = Q_NULLPTR; +#if QT_CONFIG(dockwidget) + currentHoveredFloat = nullptr; +#endif //applying the state will make sure that the currentGap is updated correctly //and all the geometries (especially the one from the central widget) is correct layoutState.apply(false); @@ -2360,7 +2379,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) { Q_ASSERT(path.constFirst() == 1); bool actualGroup = false; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) { QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2)); if (parentItem.subinfo && parentItem.subinfo->tabbed) { @@ -2381,7 +2400,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) savedState = layoutState; } } -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) if (!actualGroup) { dw->d_func()->unplug(r); } @@ -2408,8 +2427,16 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) void QMainWindowLayout::updateGapIndicator() { #ifndef QT_NO_RUBBERBAND - if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) || currentHoveredFloat) { - QWidget *expectedParent = currentHoveredFloat ? currentHoveredFloat.data() : parentWidget(); + if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) +#if QT_CONFIG(dockwidget) + || currentHoveredFloat +#endif + ) { + QWidget *expectedParent = +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat.data() : +#endif + parentWidget(); if (!gapIndicator) { gapIndicator = new QRubberBand(QRubberBand::Rectangle, expectedParent); // For accessibility to identify this special widget. @@ -2417,7 +2444,11 @@ void QMainWindowLayout::updateGapIndicator() } else if (gapIndicator->parent() != expectedParent) { gapIndicator->setParent(expectedParent); } - gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect); + gapIndicator->setGeometry( +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat->rect() : +#endif + currentGapRect); gapIndicator->show(); gapIndicator->raise(); } else if (gapIndicator) { @@ -2540,17 +2571,18 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) updateGapIndicator(); } +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow() { QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool); new QDockWidgetGroupLayout(f); return f; } +#endif void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate) { -#ifndef QT_NO_DOCKWIDGET -#ifndef QT_NO_TABBAR +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars(); foreach (QDockWidgetGroupWindow *dwgw, parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) { @@ -2578,8 +2610,7 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat for (int i = 0; i < QInternal::DockCount; ++i) newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget()); -#endif // QT_NO_TABBAR -#endif // QT_NO_DOCKWIDGET +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) newState.apply(dockOptions & QMainWindow::AnimatedDocks && animate); } diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 40336caeba..857a05eb8e 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -231,9 +231,9 @@ public: void raise(QDockWidget *widget); void setVerticalTabsEnabled(bool enabled); bool restoreDockWidget(QDockWidget *dockwidget); - QDockAreaLayoutInfo *dockInfo(QWidget *w); #ifndef QT_NO_TABBAR + QDockAreaLayoutInfo *dockInfo(QWidget *w); bool _documentMode; bool documentMode() const; void setDocumentMode(bool enabled); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 9b39743281..18cb823702 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1533,20 +1533,23 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) Q_ASSERT(indexToHighlighted >= 0); } +#if QT_CONFIG(rubberband) void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) { if (!subWindow || !rubberBand) return; +#if QT_CONFIG(tabbar) if (viewMode == QMdiArea::TabbedView) rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); else +#endif rubberBand->setGeometry(subWindow->geometry()); rubberBand->raise(); rubberBand->show(); } - +#endif // QT_CONFIG(rubberBand) /*! \internal \since 4.4 |