From 5367f76e1755aecf9527660d1c00e4e6d29d7c78 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Oct 2019 15:03:08 +0200 Subject: [PATCH] QAction: Properly port to the new configure system Use QT_REQUIRE_CONFIG in the headers of classes to be disabled. Add headers/source files in the .pro file depending on the configure feature in libraries and tests. Add the necessary exclusions and use QT_CONFIG. Only the widgets/kernel tests were made to compile since also the buttons depend on the action feature and it would become too involved. Task-number: QTBUG-69478 Change-Id: Id5bf88bc108f2bbb14dce8625bfdcb7eb0deb8e3 Reviewed-by: Oliver Wolff Reviewed-by: Volker Hilsheimer --- src/gui/configure.json | 4 ++-- src/gui/kernel/qevent.h | 4 ++-- src/widgets/accessible/qaccessiblewidget.cpp | 1 - src/widgets/graphicsview/qgraphicswidget.h | 4 +++- src/widgets/kernel/kernel.pri | 19 +++++++++++-------- src/widgets/kernel/qaction.cpp | 3 --- src/widgets/kernel/qaction.h | 7 ++----- src/widgets/kernel/qactiongroup.cpp | 4 ---- src/widgets/kernel/qactiongroup.h | 7 ++----- src/widgets/kernel/qshortcut.cpp | 12 +++++++----- src/widgets/kernel/qt_widgets_pch.h | 4 +++- src/widgets/kernel/qwidget.cpp | 4 +++- src/widgets/kernel/qwidgetaction.cpp | 3 --- src/widgets/kernel/qwidgetaction.h | 7 ++----- src/widgets/kernel/qwidgetaction_p.h | 2 ++ src/widgets/util/qundostack.cpp | 4 ++-- src/widgets/util/qundostack_p.h | 4 +++- src/widgets/widgets/qabstractbutton.cpp | 1 - src/widgets/widgets/qlabel.cpp | 1 - src/widgets/widgets/qlineedit.cpp | 4 +++- src/widgets/widgets/qlineedit_p.cpp | 12 +++++------- src/widgets/widgets/qlineedit_p.h | 4 ++++ src/widgets/widgets/qmdisubwindow.cpp | 8 +++++--- tests/auto/widgets/kernel/kernel.pro | 8 +++++--- 24 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index 90d0c8c134..5b8063d720 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1638,8 +1638,8 @@ "output": [ "publicFeature", "feature" ] }, "action": { - "label": "QAction", - "purpose": "Provides widget actions.", + "label": "Q(Gui)Action(Group)", + "purpose": "Provides abstract user interface actions.", "section": "Kernel", "output": [ "publicFeature", "feature" ] }, diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 85d22319ae..6f3215652b 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -753,7 +753,7 @@ private: }; #endif -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) class Q_GUI_EXPORT QActionEvent : public QEvent { QGuiAction *act, *bef; @@ -764,7 +764,7 @@ public: inline QGuiAction *action() const { return act; } inline QGuiAction *before() const { return bef; } }; -#endif +#endif // QT_CONFIG(action) class Q_GUI_EXPORT QFileOpenEvent : public QEvent { diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 27e6b09dc7..a55bf1106a 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -41,7 +41,6 @@ #ifndef QT_NO_ACCESSIBILITY -#include "qaction.h" #include "qapplication.h" #if QT_CONFIG(groupbox) #include "qgroupbox.h" diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index b757af5c0e..6c5171cc02 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -42,7 +42,9 @@ #include #include -#include +#if QT_CONFIG(action) +# include +#endif #include #include #include diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index 8115741b6e..58107973d8 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -7,9 +7,6 @@ KERNEL_P= kernel HEADERS += \ kernel/qtwidgetsglobal.h \ kernel/qtwidgetsglobal_p.h \ - kernel/qaction.h \ - kernel/qaction_p.h \ - kernel/qactiongroup.h \ kernel/qapplication.h \ kernel/qapplication_p.h \ kernel/qwidgetrepaintmanager_p.h \ @@ -24,8 +21,6 @@ HEADERS += \ kernel/qstackedlayout.h \ kernel/qwidget.h \ kernel/qwidget_p.h \ - kernel/qwidgetaction.h \ - kernel/qwidgetaction_p.h \ kernel/qgesture.h \ kernel/qgesture_p.h \ kernel/qstandardgestures_p.h \ @@ -37,8 +32,6 @@ HEADERS += \ kernel/qtestsupport_widgets.h SOURCES += \ - kernel/qaction.cpp \ - kernel/qactiongroup.cpp \ kernel/qapplication.cpp \ kernel/qwidgetrepaintmanager.cpp \ kernel/qboxlayout.cpp \ @@ -49,7 +42,6 @@ SOURCES += \ kernel/qsizepolicy.cpp \ kernel/qstackedlayout.cpp \ kernel/qwidget.cpp \ - kernel/qwidgetaction.cpp \ kernel/qgesture.cpp \ kernel/qstandardgestures.cpp \ kernel/qgesturerecognizer.cpp \ @@ -65,6 +57,17 @@ macx: { SOURCES += kernel/qmacgesturerecognizer.cpp } +qtConfig(action) { + HEADERS += kernel/qaction.h \ + kernel/qaction_p.h \ + kernel/qactiongroup.h \ + kernel/qwidgetaction.h \ + kernel/qwidgetaction_p.h + SOURCES += kernel/qaction.cpp \ + kernel/qactiongroup.cpp \ + kernel/qwidgetaction.cpp +} + qtConfig(opengl) { HEADERS += kernel/qopenglwidget.h SOURCES += kernel/qopenglwidget.cpp diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 77b33a89aa..fdf262c947 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -40,7 +40,6 @@ #include "qaction.h" #include "qactiongroup.h" -#ifndef QT_NO_ACTION #include "qaction_p.h" #include "qapplication.h" #include "qevent.h" @@ -353,5 +352,3 @@ QAction::showStatusText(QWidget *widget) } QT_END_NAMESPACE - -#endif // QT_NO_ACTION diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index f835c50265..808ee9065d 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -46,11 +46,10 @@ #include #include +QT_REQUIRE_CONFIG(action); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACTION - class QMenu; class QActionGroup; class QActionPrivate; @@ -108,8 +107,6 @@ QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE -#endif // QT_NO_ACTION - QT_END_NAMESPACE #endif // QACTION_H diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index 56e1df6b23..cc900cbb0f 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -40,8 +40,6 @@ #include "qactiongroup.h" #include -#ifndef QT_NO_ACTION - #include "qaction.h" QT_BEGIN_NAMESPACE @@ -188,5 +186,3 @@ QList QActionGroup::actions() const } QT_END_NAMESPACE - -#endif // QT_NO_ACTION diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h index 6ec2fc09ef..0a6a85f093 100644 --- a/src/widgets/kernel/qactiongroup.h +++ b/src/widgets/kernel/qactiongroup.h @@ -44,11 +44,10 @@ #include #include +QT_REQUIRE_CONFIG(action); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACTION - class QActionGroupPrivate; class Q_WIDGETS_EXPORT QActionGroup : public QGuiActionGroup @@ -76,8 +75,6 @@ private: Q_DISABLE_COPY(QActionGroup) }; -#endif // QT_NO_ACTION - QT_END_NAMESPACE #endif // QACTIONGROUP_H diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 49440ad383..be5708aea7 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -53,7 +53,9 @@ #include #include #include -#include +#if QT_CONFIG(action) +# include +#endif #include #include @@ -70,7 +72,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge #if QT_CONFIG(graphicsview) static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window); #endif -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window); #endif @@ -107,7 +109,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) if (!active_window) return false; -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) if (auto a = qobject_cast(object)) return correctActionContext(context, a, active_window); #endif @@ -283,7 +285,7 @@ static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsW } #endif -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) { const QWidgetList &widgets = static_cast(QObjectPrivate::get(a))->widgets; @@ -331,7 +333,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge #endif return false; } -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) /*! diff --git a/src/widgets/kernel/qt_widgets_pch.h b/src/widgets/kernel/qt_widgets_pch.h index b70941950b..3551f19e80 100644 --- a/src/widgets/kernel/qt_widgets_pch.h +++ b/src/widgets/kernel/qt_widgets_pch.h @@ -53,7 +53,9 @@ #include #include #include -#include +#if QT_CONFIG(action) +# include +#endif #include #include #include diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 0f2e2545cd..efe225a5f5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -88,7 +88,9 @@ #include "qwidget_p.h" #include -#include "qaction_p.h" +#if QT_CONFIG(action) +# include "qaction_p.h" +#endif #include "qlayout_p.h" #if QT_CONFIG(graphicsview) #include "QtWidgets/qgraphicsproxywidget.h" diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index 6eebaca42c..14b7bc74c9 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -40,7 +40,6 @@ #include "qwidgetaction.h" #include "qdebug.h" -#ifndef QT_NO_ACTION #include "qwidgetaction_p.h" QT_BEGIN_NAMESPACE @@ -282,5 +281,3 @@ QList QWidgetAction::createdWidgets() const QT_END_NAMESPACE #include "moc_qwidgetaction.cpp" - -#endif // QT_NO_ACTION diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h index 4769332a23..4d302e8c61 100644 --- a/src/widgets/kernel/qwidgetaction.h +++ b/src/widgets/kernel/qwidgetaction.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(action); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACTION - class QWidgetActionPrivate; class Q_WIDGETS_EXPORT QWidgetAction : public QAction @@ -78,8 +77,6 @@ private: friend class QToolBar; }; -#endif // QT_NO_ACTION - QT_END_NAMESPACE #endif // QWIDGETACTION_H diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h index 1fbcf236a1..0e633a65e4 100644 --- a/src/widgets/kernel/qwidgetaction_p.h +++ b/src/widgets/kernel/qwidgetaction_p.h @@ -54,6 +54,8 @@ #include #include "private/qaction_p.h" +QT_REQUIRE_CONFIG(action); + QT_BEGIN_NAMESPACE class QWidgetActionPrivate : public QActionPrivate diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 8788c42252..dbe01e4ad8 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -443,7 +443,7 @@ const QUndoCommand *QUndoCommand::child(int index) const \sa QUndoCommand, QUndoView */ -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) QUndoAction::QUndoAction(const QString &prefix, QObject *parent) : QAction(parent) @@ -473,7 +473,7 @@ void QUndoAction::setTextFormat(const QString &textFormat, const QString &defaul m_defaultText = defaultText; } -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) /*! \internal Sets the current index to \a idx, emitting appropriate signals. If \a clean is true, diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h index 05c9e0d27e..c44cdd6603 100644 --- a/src/widgets/util/qundostack_p.h +++ b/src/widgets/util/qundostack_p.h @@ -44,7 +44,9 @@ #include #include #include -#include +#if QT_CONFIG(action) +# include +#endif #include "qundostack.h" diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index d956d2ba23..c2f8538ab7 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -52,7 +52,6 @@ #include "qpainter.h" #include "qapplication.h" #include "qstyle.h" -#include "qaction.h" #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index a840bf4ee6..943b30bacc 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -47,7 +47,6 @@ #include "qstyle.h" #include "qstyleoption.h" #include -#include "qaction.h" #include "qclipboard.h" #include #include diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index a5499c8ce8..fe0d87d8c1 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -40,7 +40,9 @@ #include "qlineedit.h" #include "qlineedit_p.h" -#include "qaction.h" +#if QT_CONFIG(action) +# include "qaction.h" +#endif #include "qapplication.h" #include "qclipboard.h" #if QT_CONFIG(draganddrop) diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index f6e7337878..462691ffb3 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -47,7 +47,9 @@ #if QT_CONFIG(draganddrop) #include "qdrag.h" #endif -#include "qwidgetaction.h" +#if QT_CONFIG(action) +# include "qwidgetaction.h" +#endif #include "qclipboard.h" #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" @@ -545,6 +547,7 @@ void QLineEditPrivate::positionSideWidgets() } } +#if QT_CONFIG(action) QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(const QGuiAction *a) const { int i = 0; @@ -574,12 +577,10 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QWidget *w = 0; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. -#if QT_CONFIG(action) if (QWidgetAction *widgetAction = qobject_cast(newAction)) { if ((w = widgetAction->requestWidget(q))) flags |= SideWidgetCreatedByWidgetAction; } -#endif if (!w) { #if QT_CONFIG(toolbutton) QLineEditIconButton *toolButton = new QLineEditIconButton(q); @@ -636,7 +637,6 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE void QLineEditPrivate::removeAction(QGuiAction *action) { -#if QT_CONFIG(action) Q_Q(QLineEdit); const auto location = findSideWidget(action); if (!location.isValid()) @@ -652,10 +652,8 @@ void QLineEditPrivate::removeAction(QGuiAction *action) if (!hasSideWidgets()) // Last widget, remove connection QObject::disconnect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); q->update(); -#else - Q_UNUSED(action); -#endif // QT_CONFIG(action) } +#endif // QT_CONFIG(action) static int effectiveTextMargin(int defaultMargin, const QLineEditPrivate::SideWidgetEntryList &widgets, const QLineEditPrivate::SideWidgetParameters ¶meters) diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 5b4936667e..bb2a0530f1 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -238,8 +238,10 @@ public: QString placeholderText; +#if QT_CONFIG(action) QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0); void removeAction(QGuiAction *action); +#endif SideWidgetParameters sideWidgetParameters() const; QIcon clearButtonIcon() const; void setClearButtonEnabled(bool enabled); @@ -261,7 +263,9 @@ private: }; friend class QTypeInfo; +#if QT_CONFIG(action) SideWidgetLocation findSideWidget(const QGuiAction *a) const; +#endif SideWidgetEntryList leadingSideWidgets; SideWidgetEntryList trailingSideWidgets; diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index d58a1d06db..f4d3367a95 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -162,7 +162,9 @@ #include #include #include -#include +#if QT_CONFIG(action) +# include +#endif #if QT_CONFIG(menu) #include #endif @@ -895,7 +897,7 @@ QMdiSubWindowPrivate::QMdiSubWindowPrivate() */ void QMdiSubWindowPrivate::_q_updateStaysOnTopHint() { -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) Q_Q(QMdiSubWindow); if (QAction *senderAction = qobject_cast(q->sender())) { if (senderAction->isChecked()) { @@ -906,7 +908,7 @@ void QMdiSubWindowPrivate::_q_updateStaysOnTopHint() q->lower(); } } -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) } /*! diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 5c5868e607..9d0bf58b03 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -1,7 +1,5 @@ TEMPLATE=subdirs SUBDIRS=\ - qaction \ - qactiongroup \ qapplication \ qboxlayout \ qdesktopwidget \ @@ -13,7 +11,6 @@ SUBDIRS=\ qtooltip \ qwidget \ qwidget_window \ - qwidgetaction \ qwidgetmetatype \ qwidgetsvariant \ qwindowcontainer \ @@ -23,5 +20,10 @@ SUBDIRS=\ darwin:SUBDIRS -= \ # Uses native recognizers qgesturerecognizer \ +!qtConfig(action):SUBDIRS -= \ + qaction \ + qactiongroup \ + qwidgetaction + !qtConfig(shortcut): SUBDIRS -= \ qshortcut