From d08deb0b4a64e24884eedaf5d8e20f967c38e82a Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 8 Mar 2017 20:11:43 +0100 Subject: Add feature.abstractbutton Change-Id: Ie93c6d0a8256bc466d3419408b753d5f3738aa6b Reviewed-by: Lars Knoll --- src/widgets/accessible/complexwidgets.cpp | 1 - src/widgets/accessible/qaccessiblewidgetfactory.cpp | 2 ++ src/widgets/accessible/qaccessiblewidgets.cpp | 1 - src/widgets/accessible/simplewidgets.cpp | 5 ++++- src/widgets/accessible/simplewidgets_p.h | 2 ++ src/widgets/configure.json | 14 +++++++++++--- src/widgets/itemviews/qtableview.cpp | 10 ++++++++++ src/widgets/itemviews/qtableview.h | 4 ++++ src/widgets/itemviews/qtableview_p.h | 2 ++ src/widgets/styles/qfusionstyle.cpp | 13 ++++++++++--- src/widgets/styles/qstylesheetstyle.cpp | 2 ++ src/widgets/styles/qwindowsxpstyle.cpp | 10 ++++++++-- src/widgets/widgets/qabstractbutton.h | 2 ++ src/widgets/widgets/qlabel.cpp | 6 +++++- src/widgets/widgets/qtoolbutton.h | 9 +++++---- src/widgets/widgets/widgets.pri | 12 +++++++++--- 16 files changed, 76 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index ea3b88468b..397a58a5d4 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -41,7 +41,6 @@ #include #include -#include #include #include #include diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index c95b5b1097..e7db53c251 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -103,11 +103,13 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QToolButton")) { iface = new QAccessibleToolButton(widget); #endif // QT_NO_TOOLBUTTON +#if QT_CONFIG(abstractbutton) } else if (classname == QLatin1String("QCheckBox") || classname == QLatin1String("QRadioButton") || classname == QLatin1String("QPushButton") || classname == QLatin1String("QAbstractButton")) { iface = new QAccessibleButton(widget); +#endif } else if (classname == QLatin1String("QDialog")) { iface = new QAccessibleWidget(widget, QAccessible::Dialog); } else if (classname == QLatin1String("QMessageBox")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 40aca37f11..7f77f7c524 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -64,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 600754f90c..a53e5eaf30 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -39,7 +39,9 @@ #include "simplewidgets_p.h" +#if QT_CONFIG(abstractbutton) #include +#endif #if QT_CONFIG(checkbox) #include #endif @@ -80,6 +82,7 @@ extern QList childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); +#if QT_CONFIG(abstractbutton) /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -267,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c } return QStringList(); } - +#endif // QT_CONFIG(abstractbutton) #ifndef QT_NO_TOOLBUTTON /*! diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index 8bd0af8261..1e4ae5ab67 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -65,6 +65,7 @@ class QToolButton; class QGroupBox; class QProgressBar; +#if QT_CONFIG(abstractbutton) class QAccessibleButton : public QAccessibleWidget { Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) @@ -83,6 +84,7 @@ public: protected: QAbstractButton *button() const; }; +#endif #ifndef QT_NO_TOOLBUTTON class QAccessibleToolButton : public QAccessibleButton diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 99e1bd6940..14e4d10d38 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -117,6 +117,12 @@ "condition": "features.tableview", "output": [ "publicFeature", "feature" ] }, + "abstractbutton": { + "label": "QAbstractButton", + "purpose": "Abstract base class of button widgets, providing functionality common to buttons.", + "section": "Widgets", + "output": [ "publicFeature" ] + }, "commandlinkbutton": { "label": "QCommandLinkButton", "purpose": "Provides a Vista style command link button.", @@ -193,6 +199,7 @@ "label": "QRadioButton", "purpose": "Provides a radio button with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "spinbox": { @@ -234,20 +241,21 @@ "label": "QCheckBox(", "purpose": "Provides a checkbox with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "pushbutton": { "label": "QPushButton", "purpose": "Provides a command button.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature" ] }, "toolbutton": { "label": "QToolButton", "purpose": "Provides quick-access buttons to commands and options.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature", "feature" ] }, "toolbar": { @@ -274,7 +282,7 @@ "label": "QButtonGroup", "purpose": "Supports organizing groups of button widgets.", "section": "Widgets", - "condition": "features.groupbox", + "condition": "features.abstractbutton && features.groupbox", "output": [ "publicFeature", "feature" ] }, "mainwindow": { diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index c7cc1d155e..ed6482a8bc 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(abstractbutton) #include +#endif #include #include #include @@ -578,6 +580,7 @@ bool QSpanCollection::checkConsistency() const } #endif +#if QT_CONFIG(abstractbutton) class QTableCornerButton : public QAbstractButton { Q_OBJECT @@ -600,6 +603,7 @@ public: style()->drawControl(QStyle::CE_Header, &opt, &painter, this); } }; +#endif void QTableViewPrivate::init() { @@ -619,9 +623,11 @@ void QTableViewPrivate::init() tabKeyNavigation = true; +#if QT_CONFIG(abstractbutton) cornerWidget = new QTableCornerButton(q); cornerWidget->setFocusPolicy(Qt::NoFocus); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); +#endif } /*! @@ -2121,6 +2127,7 @@ void QTableView::updateGeometries() if (d->horizontalHeader->isHidden()) QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); +#if QT_CONFIG(abstractbutton) // update cornerWidget if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) { d->cornerWidget->setHidden(true); @@ -2128,6 +2135,7 @@ void QTableView::updateGeometries() d->cornerWidget->setHidden(false); d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); } +#endif // update scroll bars @@ -2642,6 +2650,7 @@ bool QTableView::wordWrap() const return d->wrapItemText; } +#if QT_CONFIG(abstractbutton) /*! \property QTableView::cornerButtonEnabled \brief whether the button in the top-left corner is enabled @@ -2664,6 +2673,7 @@ bool QTableView::isCornerButtonEnabled() const Q_D(const QTableView); return d->cornerWidget->isEnabled(); } +#endif /*! \internal diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index 8c9ac379bc..b1c38d521f 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -58,7 +58,9 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) +#if QT_CONFIG(abstractbutton) Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) +#endif public: explicit QTableView(QWidget *parent = Q_NULLPTR); @@ -103,8 +105,10 @@ public: void setWordWrap(bool on); bool wordWrap() const; +#if QT_CONFIG(abstractbutton) void setCornerButtonEnabled(bool enable); bool isCornerButtonEnabled() const; +#endif QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE; void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 2ca158d657..d2f45d557d 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -192,7 +192,9 @@ public: QVector rowsToUpdate; QHeaderView *horizontalHeader; QHeaderView *verticalHeader; +#if QT_CONFIG(abstractbutton) QWidget *cornerWidget; +#endif bool sortingEnabled; bool geometryRecursionBlock; QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 1267907303..02e0ad2a9b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -45,7 +45,8 @@ #include #if QT_CONFIG(pushbutton) #include -#else +#endif +#if QT_CONFIG(abstractbutton) #include #endif #include @@ -3284,7 +3285,10 @@ void QFusionStyle::polish(QApplication *app) void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast(widget) #endif @@ -3325,7 +3329,10 @@ void QFusionStyle::polish(QPalette &pal) void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast(widget) #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 275a0550d2..2886093732 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4268,6 +4268,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelButtonTool: case PE_PanelButtonCommand: +#if QT_CONFIG(abstractbutton) if (qobject_cast(w) && rule.hasBackground() && rule.hasNativeBorder()) { //the window style will draw the borders ParentStyle::drawPrimitive(pe, opt, p, w); @@ -4276,6 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } return; } +#endif if (!rule.hasNativeBorder()) { rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); return; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f3c6069f8a..b50c4b6be4 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1139,7 +1139,10 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!QWindowsXPStylePrivate::useXP()) return; - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) #ifndef QT_NO_COMBOBOX @@ -1211,7 +1214,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget) // already in the map might be old (other style). d->cleanupHandleMap(); } - if (qobject_cast(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast(widget) +#endif || qobject_cast(widget) || qobject_cast(widget) #ifndef QT_NO_COMBOBOX diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7bf0e0b9d6..4e438bd851 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -45,6 +45,8 @@ #include #include +QT_REQUIRE_CONFIG(abstractbutton); + QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index fa0cff45c9..39e072234e 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -41,7 +41,9 @@ #include "qevent.h" #include "qdrawutil.h" #include "qapplication.h" +#if QT_CONFIG(abstractbutton) #include "qabstractbutton.h" +#endif #include "qstyle.h" #include "qstyleoption.h" #include @@ -972,12 +974,14 @@ bool QLabel::event(QEvent *e) QShortcutEvent *se = static_cast(e); if (se->shortcutId() == d->shortcutId) { QWidget * w = d->buddy; - QAbstractButton *button = qobject_cast(w); if (w->focusPolicy() != Qt::NoFocus) w->setFocus(Qt::ShortcutFocusReason); +#if QT_CONFIG(abstractbutton) + QAbstractButton *button = qobject_cast(w); if (button && !se->isAmbiguous()) button->animateClick(); else +#endif window()->setAttribute(Qt::WA_KeyboardFocusChange); return true; } diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 95d159f12d..e2470524da 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -41,13 +41,14 @@ #define QTOOLBUTTON_H #include + +#if QT_CONFIG(toolbutton) + #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_TOOLBUTTON - class QToolButtonPrivate; class QMenu; class QStyleOptionToolButton; @@ -134,8 +135,8 @@ private: }; -#endif // QT_NO_TOOLBUTTON - QT_END_NAMESPACE +#endif // QT_CONFIG(toolbutton) + #endif // QTOOLBUTTON_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index f67640e40f..22e083a3d4 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qbuttongroup.h \ widgets/qbuttongroup_p.h \ - widgets/qabstractbutton.h \ - widgets/qabstractbutton_p.h \ widgets/qabstractspinbox.h \ widgets/qabstractspinbox_p.h \ widgets/qcalendarwidget.h \ @@ -76,7 +74,6 @@ HEADERS += \ SOURCES += \ widgets/qbuttongroup.cpp \ - widgets/qabstractbutton.cpp \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ widgets/qcombobox.cpp \ @@ -128,6 +125,15 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp +qtConfig(abstractbutton) { + HEADERS += \ + widgets/qabstractbutton.h \ + widgets/qabstractbutton_p.h + + SOURCES += \ + widgets/qabstractbutton.cpp +} + qtConfig(abstractslider) { HEADERS += \ widgets/qabstractslider.h \ -- cgit v1.2.3