summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp1
-rw-r--r--src/widgets/configure.json10
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp8
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp4
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/styles.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp9
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h1
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.h3
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp4
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp2
-rw-r--r--src/widgets/kernel/kernel.pri28
-rw-r--r--src/widgets/kernel/qaction.cpp1071
-rw-r--r--src/widgets/kernel/qaction.h132
-rw-r--r--src/widgets/kernel/qaction_p.h49
-rw-r--r--src/widgets/kernel/qactiongroup.cpp308
-rw-r--r--src/widgets/kernel/qactiongroup.h44
-rw-r--r--src/widgets/kernel/qapplication.cpp4
-rw-r--r--src/widgets/kernel/qapplication.h1
-rw-r--r--src/widgets/kernel/qshortcut.cpp320
-rw-r--r--src/widgets/kernel/qshortcut.h46
-rw-r--r--src/widgets/kernel/qt_widgets_pch.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp13
-rw-r--r--src/widgets/kernel/qwidget.h4
-rw-r--r--src/widgets/kernel/qwidgetaction.cpp3
-rw-r--r--src/widgets/kernel/qwidgetaction.h7
-rw-r--r--src/widgets/kernel/qwidgetaction_p.h2
-rw-r--r--src/widgets/styles/qfusionstyle.cpp2
-rw-r--r--src/widgets/styles/qstyle.cpp1
-rw-r--r--src/widgets/styles/qstyle.h6
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/util/qundostack.cpp4
-rw-r--r--src/widgets/util/qundostack_p.h4
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp1
-rw-r--r--src/widgets/widgets/qabstractbutton.h4
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp27
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h1
-rw-r--r--src/widgets/widgets/qlabel.cpp1
-rw-r--r--src/widgets/widgets/qlineedit.cpp6
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp18
-rw-r--r--src/widgets/widgets/qlineedit_p.h8
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp8
-rw-r--r--src/widgets/widgets/qmenu.cpp38
-rw-r--r--src/widgets/widgets/qmenu.h54
-rw-r--r--src/widgets/widgets/qmenubar.cpp17
-rw-r--r--src/widgets/widgets/qsplitter.h1
-rw-r--r--src/widgets/widgets/qtoolbar.cpp2
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp2
-rw-r--r--src/widgets/widgets/qtoolbarlayout_p.h2
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp2
52 files changed, 307 insertions, 1989 deletions
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/configure.json b/src/widgets/configure.json
index 0a68f082a2..cab120098a 100644
--- a/src/widgets/configure.json
+++ b/src/widgets/configure.json
@@ -26,14 +26,6 @@
}
},
- "tests": {
- "uxtheme": {
- "label": "uxtheme.h",
- "type": "files",
- "files": [ "uxtheme.h" ]
- }
- },
-
"features": {
"gtk3": {
"label": "GTK+",
@@ -56,7 +48,7 @@
},
"style-windowsvista": {
"label": "WindowsVista",
- "condition": "features.style-windows && features.animation && config.win32 && !config.winrt && tests.uxtheme",
+ "condition": "features.style-windows && features.animation && config.win32 && !config.winrt",
"output": [ "privateFeature", "styles" ]
},
"style-android": {
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index fbcc02accd..f72bc8df99 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -49,7 +49,9 @@
#include <qfontmetrics.h>
#include <qaction.h>
#include <qheaderview.h>
-#include <qshortcut.h>
+#if QT_CONFIG(shortcut)
+# include <qshortcut.h>
+#endif
#include <qgridlayout.h>
#if QT_CONFIG(menu)
#include <qmenu.h>
@@ -344,7 +346,9 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
QT_BEGIN_INCLUDE_NAMESPACE
#include <QMetaEnum>
-#include <qshortcut.h>
+#if QT_CONFIG(shortcut)
+# include <qshortcut.h>
+#endif
QT_END_INCLUDE_NAMESPACE
/*!
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 189dcd2989..5ff8cefec4 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -39,7 +39,9 @@
#include "qprogressdialog.h"
-#include "qshortcut.h"
+#if QT_CONFIG(shortcut)
+# include "qshortcut.h"
+#endif
#include "qpainter.h"
#include "qdrawutil.h"
#include "qlabel.h"
diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
index 3d1b1e0030..54a4ade921 100644
--- a/src/widgets/doc/snippets/javastyle.cpp
+++ b/src/widgets/doc/snippets/javastyle.cpp
@@ -2130,7 +2130,7 @@ void JavaStyle::drawPrimitive(PrimitiveElement element,
painter->restore();
break;
}
- case PE_IndicatorViewItemCheck: {
+ case PE_IndicatorItemViewItemCheck: {
break;
}
case PE_FrameWindow: {
diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
index 645da5bca2..faaf4e5479 100644
--- a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
@@ -1837,7 +1837,7 @@
item views keep the dimensions on individual sections. Also
note that the delegates may use the style to paint decorations
and frames around items. QItemDelegate, for instance, draws
- \c PE_FrameFocusRect and \c PE_IndicatorViewItemCheck.
+ \c PE_FrameFocusRect and \c PE_IndicatorItemViewItemCheck.
\image javastyle/header.png
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 7c0f836156..b58a8c0b3c 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1580,13 +1580,8 @@ QGraphicsItem::~QGraphicsItem()
p->wasDeleted = true;
if (p->declarativeData) {
p->wasDeleted = true; // needed, so that destroying the declarative data does the right thing
- if (static_cast<QAbstractDeclarativeDataImpl*>(p->declarativeData)->ownedByQml1) {
- if (QAbstractDeclarativeData::destroyed_qml1)
- QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o);
- } else {
- if (QAbstractDeclarativeData::destroyed)
- QAbstractDeclarativeData::destroyed(p->declarativeData, o);
- }
+ if (QAbstractDeclarativeData::destroyed)
+ QAbstractDeclarativeData::destroyed(p->declarativeData, o);
p->declarativeData = 0;
p->wasDeleted = false;
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index d36a871533..e72ed99a7b 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -54,7 +54,6 @@ QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE
-template<typename T> class QList;
class QFocusEvent;
class QFont;
class QFontMetrics;
diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h
index b494c52671..e13c2a3cd3 100644
--- a/src/widgets/graphicsview/qgraphicssceneindex_p.h
+++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h
@@ -67,7 +67,6 @@ QT_BEGIN_NAMESPACE
class QGraphicsSceneIndexPrivate;
class QPointF;
class QRectF;
-template<typename T> class QList;
typedef bool (*QGraphicsSceneIndexIntersector)(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
const QTransform &deviceTransform, const void *data);
diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h
index 8223b921c9..6c5171cc02 100644
--- a/src/widgets/graphicsview/qgraphicswidget.h
+++ b/src/widgets/graphicsview/qgraphicswidget.h
@@ -42,6 +42,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qfont.h>
+#if QT_CONFIG(action)
+# include <QtWidgets/qaction.h>
+#endif
#include <QtWidgets/qgraphicslayoutitem.h>
#include <QtWidgets/qgraphicsitem.h>
#include <QtGui/qpalette.h>
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 1931360dbc..fefadef1a2 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -112,7 +112,7 @@ void QListModel::insert(int row, QListWidgetItem *item)
QList<QListWidgetItem*>::iterator it;
it = sortedInsertionIterator(items.begin(), items.end(),
item->view->sortOrder(), item);
- row = qMax(it - items.begin(), 0);
+ row = qMax<qsizetype>(it - items.begin(), 0);
} else {
if (row < 0)
row = 0;
@@ -391,7 +391,7 @@ void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int en
--tmpitepos;
lit = tmp.begin() + tmpitepos;
lit = sortedInsertionIterator(lit, tmp.end(), order, item);
- int newRow = qMax(lit - tmp.begin(), 0);
+ int newRow = qMax<qsizetype>(lit - tmp.begin(), 0);
lit = tmp.insert(lit, item);
if (newRow != oldRow) {
changed = true;
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index cce0773fec..8575512078 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -646,7 +646,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
lit = lst.begin() + tmpitepos;
lit = sortedInsertionIterator(lit, lst.end(), order, item);
- int newRow = qMax(lit - lst.begin(), 0);
+ int newRow = qMax<qsizetype>(lit - lst.begin(), 0);
if ((newRow < oldRow) && !(*item < *lst.at(oldRow - 1)) && !(*lst.at(oldRow - 1) < *item ))
newRow = oldRow;
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri
index 693af7eb80..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 \
@@ -20,13 +17,10 @@ HEADERS += \
kernel/qlayout_p.h \
kernel/qlayoutengine_p.h \
kernel/qlayoutitem.h \
- kernel/qshortcut.h \
- kernel/qsizepolicy.h \
+ kernel/qsizepolicy.h \
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 \
@@ -38,8 +32,6 @@ HEADERS += \
kernel/qtestsupport_widgets.h
SOURCES += \
- kernel/qaction.cpp \
- kernel/qactiongroup.cpp \
kernel/qapplication.cpp \
kernel/qwidgetrepaintmanager.cpp \
kernel/qboxlayout.cpp \
@@ -47,11 +39,9 @@ SOURCES += \
kernel/qlayout.cpp \
kernel/qlayoutengine.cpp \
kernel/qlayoutitem.cpp \
- kernel/qshortcut.cpp \
kernel/qsizepolicy.cpp \
kernel/qstackedlayout.cpp \
kernel/qwidget.cpp \
- kernel/qwidgetaction.cpp \
kernel/qgesture.cpp \
kernel/qstandardgestures.cpp \
kernel/qgesturerecognizer.cpp \
@@ -67,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
@@ -77,6 +78,11 @@ qtConfig(formlayout) {
SOURCES += kernel/qformlayout.cpp
}
+qtConfig(shortcut) {
+ HEADERS += kernel/qshortcut.h
+ SOURCES += kernel/qshortcut.cpp
+}
+
qtConfig(tooltip) {
HEADERS += kernel/qtooltip.h
SOURCES += kernel/qtooltip.cpp
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 19ad65692b..fdf262c947 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -40,52 +40,29 @@
#include "qaction.h"
#include "qactiongroup.h"
-#ifndef QT_NO_ACTION
#include "qaction_p.h"
#include "qapplication.h"
#include "qevent.h"
#include "qlist.h"
#include "qstylehints.h"
-#include <private/qshortcutmap_p.h>
+#if QT_CONFIG(shortcut)
+# include <private/qshortcutmap_p.h>
+#endif
#include <private/qguiapplication_p.h>
#if QT_CONFIG(menu)
#include <private/qmenu_p.h>
#endif
#include <private/qdebug_p.h>
-#define QAPP_CHECK(functionName) \
- if (Q_UNLIKELY(!QCoreApplication::instance())) { \
- qWarning("QAction: Initialize Q(Gui)Application before calling '" functionName "'."); \
- return; \
- }
QT_BEGIN_NAMESPACE
-/*
- internal: guesses a descriptive text from a text suited for a menu entry
- */
-static QString qt_strippedText(QString s)
-{
- s.remove(QLatin1String("..."));
- for (int i = 0; i < s.size(); ++i) {
- if (s.at(i) == QLatin1Char('&'))
- s.remove(i, 1);
- }
- return s.trimmed();
-}
-
-
-QActionPrivate::QActionPrivate() :
#if QT_CONFIG(shortcut)
- autorepeat(1),
-#endif
- enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0),
- checked(0), separator(0), fontSet(false),
- iconVisibleInMenu(-1), shortcutVisibleInContextMenu(-1)
+QShortcutMap::ContextMatcher QActionPrivate::contextMatcher() const
{
+ return qWidgetShortcutContextMatcher;
}
-
-QActionPrivate::~QActionPrivate() = default;
+#endif // QT_CONFIG(shortcut)
bool QActionPrivate::showStatusText(QWidget *widget, const QString &str)
{
@@ -102,84 +79,6 @@ bool QActionPrivate::showStatusText(QWidget *widget, const QString &str)
return false;
}
-void QActionPrivate::sendDataChanged()
-{
- Q_Q(QAction);
- QActionEvent e(QEvent::ActionChanged, q);
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *w = widgets.at(i);
- QCoreApplication::sendEvent(w, &e);
- }
-#if QT_CONFIG(graphicsview)
- for (int i = 0; i < graphicsWidgets.size(); ++i) {
- QGraphicsWidget *w = graphicsWidgets.at(i);
- QCoreApplication::sendEvent(w, &e);
- }
-#endif
- QCoreApplication::sendEvent(q, &e);
-
- emit q->changed();
-}
-
-#if QT_CONFIG(shortcut)
-void QActionPrivate::redoGrab(QShortcutMap &map)
-{
- Q_Q(QAction);
- if (shortcutId)
- map.removeShortcut(shortcutId, q);
- if (shortcut.isEmpty())
- return;
- shortcutId = map.addShortcut(q, shortcut, shortcutContext, qWidgetShortcutContextMatcher);
- if (!enabled)
- map.setShortcutEnabled(false, shortcutId, q);
- if (!autorepeat)
- map.setShortcutAutoRepeat(false, shortcutId, q);
-}
-
-void QActionPrivate::redoGrabAlternate(QShortcutMap &map)
-{
- Q_Q(QAction);
- for(int i = 0; i < alternateShortcutIds.count(); ++i) {
- if (const int id = alternateShortcutIds.at(i))
- map.removeShortcut(id, q);
- }
- alternateShortcutIds.clear();
- if (alternateShortcuts.isEmpty())
- return;
- for(int i = 0; i < alternateShortcuts.count(); ++i) {
- const QKeySequence& alternate = alternateShortcuts.at(i);
- if (!alternate.isEmpty())
- alternateShortcutIds.append(map.addShortcut(q, alternate, shortcutContext, qWidgetShortcutContextMatcher));
- else
- alternateShortcutIds.append(0);
- }
- if (!enabled) {
- for(int i = 0; i < alternateShortcutIds.count(); ++i) {
- const int id = alternateShortcutIds.at(i);
- map.setShortcutEnabled(false, id, q);
- }
- }
- if (!autorepeat) {
- for(int i = 0; i < alternateShortcutIds.count(); ++i) {
- const int id = alternateShortcutIds.at(i);
- map.setShortcutAutoRepeat(false, id, q);
- }
- }
-}
-
-void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
-{
- Q_Q(QAction);
- if (shortcutId)
- map.setShortcutEnabled(enable, shortcutId, q);
- for(int i = 0; i < alternateShortcutIds.count(); ++i) {
- if (const int id = alternateShortcutIds.at(i))
- map.setShortcutEnabled(enable, id, q);
- }
-}
-#endif // QT_NO_SHORTCUT
-
-
/*!
\class QAction
\brief The QAction class provides an abstract user interface
@@ -323,12 +222,26 @@ QAction::QAction(const QIcon &icon, const QString &text, QObject* parent)
\internal
*/
QAction::QAction(QActionPrivate &dd, QObject *parent)
- : QObject(dd, parent)
+ : QGuiAction(dd, parent)
+{
+}
+
+/*!
+ \reimp
+*/
+
+bool QAction::event(QEvent *e)
{
Q_D(QAction);
- d->group = qobject_cast<QActionGroup *>(parent);
- if (d->group)
- d->group->addAction(this);
+ if (e->type() == QEvent::ActionChanged) {
+ for (auto w : qAsConst(d->widgets))
+ QCoreApplication::sendEvent(w, e);
+#if QT_CONFIG(graphicsview)
+ for (auto gw : qAsConst(d->graphicsWidgets))
+ QCoreApplication::sendEvent(gw, e);
+#endif
+ }
+ return QGuiAction::event(e);
}
/*!
@@ -368,190 +281,6 @@ QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const
}
#endif
-#if QT_CONFIG(shortcut)
-/*!
- \property QAction::shortcut
- \brief the action's primary shortcut key
-
- Valid keycodes for this property can be found in \l Qt::Key and
- \l Qt::Modifier. There is no default shortcut key.
-*/
-void QAction::setShortcut(const QKeySequence &shortcut)
-{
- QAPP_CHECK("setShortcut");
-
- Q_D(QAction);
- if (d->shortcut == shortcut)
- return;
-
- d->shortcut = shortcut;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
- d->sendDataChanged();
-}
-
-/*!
- \since 4.2
-
- Sets \a shortcuts as the list of shortcuts that trigger the
- action. The first element of the list is the primary shortcut.
-
- \sa shortcut
-*/
-void QAction::setShortcuts(const QList<QKeySequence> &shortcuts)
-{
- Q_D(QAction);
-
- QList <QKeySequence> listCopy = shortcuts;
-
- QKeySequence primary;
- if (!listCopy.isEmpty())
- primary = listCopy.takeFirst();
-
- if (d->shortcut == primary && d->alternateShortcuts == listCopy)
- return;
-
- QAPP_CHECK("setShortcuts");
-
- d->shortcut = primary;
- d->alternateShortcuts = listCopy;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
- d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap);
- d->sendDataChanged();
-}
-
-/*!
- \since 4.2
-
- Sets a platform dependent list of shortcuts based on the \a key.
- The result of calling this function will depend on the currently running platform.
- Note that more than one shortcut can assigned by this action.
- If only the primary shortcut is required, use setShortcut instead.
-
- \sa QKeySequence::keyBindings()
-*/
-void QAction::setShortcuts(QKeySequence::StandardKey key)
-{
- QList <QKeySequence> list = QKeySequence::keyBindings(key);
- setShortcuts(list);
-}
-
-/*!
- Returns the primary shortcut.
-
- \sa setShortcuts()
-*/
-QKeySequence QAction::shortcut() const
-{
- Q_D(const QAction);
- return d->shortcut;
-}
-
-/*!
- \since 4.2
-
- Returns the list of shortcuts, with the primary shortcut as
- the first element of the list.
-
- \sa setShortcuts()
-*/
-QList<QKeySequence> QAction::shortcuts() const
-{
- Q_D(const QAction);
- QList <QKeySequence> shortcuts;
- if (!d->shortcut.isEmpty())
- shortcuts << d->shortcut;
- if (!d->alternateShortcuts.isEmpty())
- shortcuts << d->alternateShortcuts;
- return shortcuts;
-}
-
-/*!
- \property QAction::shortcutContext
- \brief the context for the action's shortcut
-
- Valid values for this property can be found in \l Qt::ShortcutContext.
- The default value is Qt::WindowShortcut.
-*/
-void QAction::setShortcutContext(Qt::ShortcutContext context)
-{
- Q_D(QAction);
- if (d->shortcutContext == context)
- return;
- QAPP_CHECK("setShortcutContext");
- d->shortcutContext = context;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
- d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap);
- d->sendDataChanged();
-}
-
-Qt::ShortcutContext QAction::shortcutContext() const
-{
- Q_D(const QAction);
- return d->shortcutContext;
-}
-
-/*!
- \property QAction::autoRepeat
- \brief whether the action can auto repeat
- \since 4.2
-
- If true, the action will auto repeat when the keyboard shortcut
- combination is held down, provided that keyboard auto repeat is
- enabled on the system.
- The default value is true.
-*/
-void QAction::setAutoRepeat(bool on)
-{
- Q_D(QAction);
- if (d->autorepeat == on)
- return;
- QAPP_CHECK("setAutoRepeat");
- d->autorepeat = on;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
- d->redoGrabAlternate(QGuiApplicationPrivate::instance()->shortcutMap);
- d->sendDataChanged();
-}
-
-bool QAction::autoRepeat() const
-{
- Q_D(const QAction);
- return d->autorepeat;
-}
-#endif // QT_NO_SHORTCUT
-
-/*!
- \property QAction::font
- \brief the action's font
-
- The font property is used to render the text set on the
- QAction. The font will can be considered a hint as it will not be
- consulted in all cases based upon application and style.
-
- By default, this property contains the application's default font.
-
- \sa QAction::setText(), QStyle
-*/
-void QAction::setFont(const QFont &font)
-{
- Q_D(QAction);
- if (d->font == font)
- return;
-
- d->fontSet = true;
- d->font = font;
- d->sendDataChanged();
-}
-
-QFont QAction::font() const
-{
- Q_D(const QAction);
- return d->font;
-}
-
-
-/*!
- Destroys the object and frees allocated resources.
-*/
QAction::~QAction()
{
Q_D(QAction);
@@ -565,76 +294,17 @@ QAction::~QAction()
w->removeAction(this);
}
#endif
- if (d->group)
- d->group->removeAction(this);
-#if QT_CONFIG(shortcut)
- if (d->shortcutId && qApp) {
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->shortcutId, this);
- for(int i = 0; i < d->alternateShortcutIds.count(); ++i) {
- const int id = d->alternateShortcutIds.at(i);
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this);
- }
- }
-#endif
}
/*!
- Sets this action group to \a group. The action will be automatically
- added to the group's list of actions.
-
- Actions within the group will be mutually exclusive.
-
- \sa QActionGroup, QAction::actionGroup()
-*/
-void QAction::setActionGroup(QActionGroup *group)
-{
- Q_D(QAction);
- if(group == d->group)
- return;
+ Returns the action group for this action. If no action group manages
+ this action then \nullptr will be returned.
- if(d->group)
- d->group->removeAction(this);
- d->group = group;
- if(group)
- group->addAction(this);
- d->sendDataChanged();
-}
-
-/*!
- Returns the action group for this action. If no action group manages
- this action then 0 will be returned.
-
- \sa QActionGroup, QAction::setActionGroup()
-*/
+ \sa QActionGroup, QAction::setActionGroup()
+ */
QActionGroup *QAction::actionGroup() const
{
- Q_D(const QAction);
- return d->group;
-}
-
-
-/*!
- \property QAction::icon
- \brief the action's icon
-
- In toolbars, the icon is used as the tool button icon; in menus,
- it is displayed to the left of the menu text. There is no default
- icon.
-
- If a null icon (QIcon::isNull()) is passed into this function,
- the icon of the action is cleared.
-*/
-void QAction::setIcon(const QIcon &icon)
-{
- Q_D(QAction);
- d->icon = icon;
- d->sendDataChanged();
-}
-
-QIcon QAction::icon() const
-{
- Q_D(const QAction);
- return d->icon;
+ return static_cast<QActionGroup *>(guiActionGroup());
}
#if QT_CONFIG(menu)
@@ -667,460 +337,6 @@ void QAction::setMenu(QMenu *menu)
#endif // QT_CONFIG(menu)
/*!
- If \a b is true then this action will be considered a separator.
-
- How a separator is represented depends on the widget it is inserted
- into. Under most circumstances the text, submenu, and icon will be
- ignored for separator actions.
-
- \sa QAction::isSeparator()
-*/
-void QAction::setSeparator(bool b)
-{
- Q_D(QAction);
- if (d->separator == b)
- return;
-
- d->separator = b;
- d->sendDataChanged();
-}
-
-/*!
- Returns \c true if this action is a separator action; otherwise it
- returns \c false.
-
- \sa QAction::setSeparator()
-*/
-bool QAction::isSeparator() const
-{
- Q_D(const QAction);
- return d->separator;
-}
-
-/*!
- \property QAction::text
- \brief the action's descriptive text
-
- If the action is added to a menu, the menu option will consist of
- the icon (if there is one), the text, and the shortcut (if there
- is one). If the text is not explicitly set in the constructor, or
- by using setText(), the action's description icon text will be
- used as text. There is no default text.
-
- \sa iconText
-*/
-void QAction::setText(const QString &text)
-{
- Q_D(QAction);
- if (d->text == text)
- return;
-
- d->text = text;
- d->sendDataChanged();
-}
-
-QString QAction::text() const
-{
- Q_D(const QAction);
- QString s = d->text;
- if(s.isEmpty()) {
- s = d->iconText;
- s.replace(QLatin1Char('&'), QLatin1String("&&"));
- }
- return s;
-}
-
-
-
-
-
-/*!
- \property QAction::iconText
- \brief the action's descriptive icon text
-
- If QToolBar::toolButtonStyle is set to a value that permits text to
- be displayed, the text defined held in this property appears as a
- label in the relevant tool button.
-
- It also serves as the default text in menus and tooltips if the action
- has not been defined with setText() or setToolTip(), and will
- also be used in toolbar buttons if no icon has been defined using setIcon().
-
- If the icon text is not explicitly set, the action's normal text will be
- used for the icon text.
-
- By default, this property contains an empty string.
-
- \sa setToolTip(), setStatusTip()
-*/
-void QAction::setIconText(const QString &text)
-{
- Q_D(QAction);
- if (d->iconText == text)
- return;
-
- d->iconText = text;
- d->sendDataChanged();
-}
-
-QString QAction::iconText() const
-{
- Q_D(const QAction);
- if (d->iconText.isEmpty())
- return qt_strippedText(d->text);
- return d->iconText;
-}
-
-/*!
- \property QAction::toolTip
- \brief the action's tooltip
-
- This text is used for the tooltip. If no tooltip is specified,
- the action's text is used.
-
- By default, this property contains the action's text.
-
- \sa setStatusTip(), setShortcut()
-*/
-void QAction::setToolTip(const QString &tooltip)
-{
- Q_D(QAction);
- if (d->tooltip == tooltip)
- return;
-
- d->tooltip = tooltip;
- d->sendDataChanged();
-}
-
-QString QAction::toolTip() const
-{
- Q_D(const QAction);
- if (d->tooltip.isEmpty()) {
- if (!d->text.isEmpty())
- return qt_strippedText(d->text);
- return qt_strippedText(d->iconText);
- }
- return d->tooltip;
-}
-
-/*!
- \property QAction::statusTip
- \brief the action's status tip
-
- The status tip is displayed on all status bars provided by the
- action's top-level parent widget.
-
- By default, this property contains an empty string.
-
- \sa setToolTip(), showStatusText()
-*/
-void QAction::setStatusTip(const QString &statustip)
-{
- Q_D(QAction);
- if (d->statustip == statustip)
- return;
-
- d->statustip = statustip;
- d->sendDataChanged();
-}
-
-QString QAction::statusTip() const
-{
- Q_D(const QAction);
- return d->statustip;
-}
-
-/*!
- \property QAction::whatsThis
- \brief the action's "What's This?" help text
-
- The "What's This?" text is used to provide a brief description of
- the action. The text may contain rich text. There is no default
- "What's This?" text.
-
- \sa QWhatsThis
-*/
-void QAction::setWhatsThis(const QString &whatsthis)
-{
- Q_D(QAction);
- if (d->whatsthis == whatsthis)
- return;
-
- d->whatsthis = whatsthis;
- d->sendDataChanged();
-}
-
-QString QAction::whatsThis() const
-{
- Q_D(const QAction);
- return d->whatsthis;
-}
-
-/*!
- \enum QAction::Priority
- \since 4.6
-
- This enum defines priorities for actions in user interface.
-
- \value LowPriority The action should not be prioritized in
- the user interface.
-
- \value NormalPriority
-
- \value HighPriority The action should be prioritized in
- the user interface.
-
- \sa priority
-*/
-
-
-/*!
- \property QAction::priority
- \since 4.6
-
- \brief the actions's priority in the user interface.
-
- This property can be set to indicate how the action should be prioritized
- in the user interface.
-
- For instance, when toolbars have the Qt::ToolButtonTextBesideIcon
- mode set, then actions with LowPriority will not show the text
- labels.
-*/
-void QAction::setPriority(Priority priority)
-{
- Q_D(QAction);
- if (d->priority == priority)
- return;
-
- d->priority = priority;
- d->sendDataChanged();
-}
-
-QAction::Priority QAction::priority() const
-{
- Q_D(const QAction);
- return d->priority;
-}
-
-/*!
- \property QAction::checkable
- \brief whether the action is a checkable action
-
- A checkable action is one which has an on/off state. For example,
- in a word processor, a Bold toolbar button may be either on or
- off. An action which is not a toggle action is a command action;
- a command action is simply executed, e.g. file save.
- By default, this property is \c false.
-
- In some situations, the state of one toggle action should depend
- on the state of others. For example, "Left Align", "Center" and
- "Right Align" toggle actions are mutually exclusive. To achieve
- exclusive toggling, add the relevant toggle actions to a
- QActionGroup with the QActionGroup::exclusive property set to
- true.
-
- \sa QAction::setChecked()
-*/
-void QAction::setCheckable(bool b)
-{
- Q_D(QAction);
- if (d->checkable == b)
- return;
-
- d->checkable = b;
- d->checked = false;
- d->sendDataChanged();
-}
-
-bool QAction::isCheckable() const
-{
- Q_D(const QAction);
- return d->checkable;
-}
-
-/*!
- \fn void QAction::toggle()
-
- This is a convenience function for the \l checked property.
- Connect to it to change the checked state to its opposite state.
-*/
-void QAction::toggle()
-{
- Q_D(QAction);
- setChecked(!d->checked);
-}
-
-/*!
- \property QAction::checked
- \brief whether the action is checked.
-
- Only checkable actions can be checked. By default, this is false
- (the action is unchecked).
-
- \note The notifier signal for this property is toggled(). As toggling
- a QAction changes its state, it will also emit a changed() signal.
-
- \sa checkable, toggled()
-*/
-void QAction::setChecked(bool b)
-{
- Q_D(QAction);
- if (!d->checkable || d->checked == b)
- return;
-
- QPointer<QAction> guard(this);
- d->checked = b;
- d->sendDataChanged();
- if (guard)
- emit toggled(b);
-}
-
-bool QAction::isChecked() const
-{
- Q_D(const QAction);
- return d->checked;
-}
-
-/*!
- \fn void QAction::setDisabled(bool b)
-
- This is a convenience function for the \l enabled property, that
- is useful for signals--slots connections. If \a b is true the
- action is disabled; otherwise it is enabled.
-*/
-
-/*!
- \property QAction::enabled
- \brief whether the action is enabled
-
- Disabled actions cannot be chosen by the user. They do not
- disappear from menus or toolbars, but they are displayed in a way
- which indicates that they are unavailable. For example, they might
- be displayed using only shades of gray.
-
- \uicontrol{What's This?} help on disabled actions is still available, provided
- that the QAction::whatsThis property is set.
-
- An action will be disabled when all widgets to which it is added
- (with QWidget::addAction()) are disabled or not visible. When an
- action is disabled, it is not possible to trigger it through its
- shortcut.
-
- By default, this property is \c true (actions are enabled).
-
- \sa text
-*/
-void QAction::setEnabled(bool b)
-{
- Q_D(QAction);
- if (b == d->enabled && b != d->forceDisabled)
- return;
- d->forceDisabled = !b;
- if (b && (!d->visible || (d->group && !d->group->isEnabled())))
- return;
- QAPP_CHECK("setEnabled");
- d->enabled = b;
-#if QT_CONFIG(shortcut)
- d->setShortcutEnabled(b, QGuiApplicationPrivate::instance()->shortcutMap);
-#endif
- d->sendDataChanged();
-}
-
-bool QAction::isEnabled() const
-{
- Q_D(const QAction);
- return d->enabled;
-}
-
-/*!
- \property QAction::visible
- \brief whether the action can be seen (e.g. in menus and toolbars)
-
- If \e visible is true the action can be seen (e.g. in menus and
- toolbars) and chosen by the user; if \e visible is false the
- action cannot be seen or chosen by the user.
-
- Actions which are not visible are \e not grayed out; they do not
- appear at all.
-
- By default, this property is \c true (actions are visible).
-*/
-void QAction::setVisible(bool b)
-{
- Q_D(QAction);
- if (b == d->visible && b != d->forceInvisible)
- return;
- QAPP_CHECK("setVisible");
- d->forceInvisible = !b;
- d->visible = b;
- d->enabled = b && !d->forceDisabled && (!d->group || d->group->isEnabled()) ;
-#if QT_CONFIG(shortcut)
- d->setShortcutEnabled(d->enabled, QGuiApplicationPrivate::instance()->shortcutMap);
-#endif
- d->sendDataChanged();
-}
-
-
-bool QAction::isVisible() const
-{
- Q_D(const QAction);
- return d->visible;
-}
-
-/*!
- \reimp
-*/
-bool
-QAction::event(QEvent *e)
-{
-#if QT_CONFIG(shortcut)
- if (e->type() == QEvent::Shortcut) {
- QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
- Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()),
- "QAction::event",
- "Received shortcut event from incorrect shortcut");
- if (se->isAmbiguous())
- qWarning("QAction::event: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData());
- else
- activate(Trigger);
- return true;
- }
-#endif
- return QObject::event(e);
-}
-
-/*!
- Returns the user data as set in QAction::setData.
-
- \sa setData()
-*/
-QVariant
-QAction::data() const
-{
- Q_D(const QAction);
- return d->userData;
-}
-
-/*!
- \fn void QAction::setData(const QVariant &userData)
-
- Sets the action's internal data to the given \a userData.
-
- \sa data()
-*/
-void
-QAction::setData(const QVariant &data)
-{
- Q_D(QAction);
- if (d->userData == data)
- return;
- d->userData = data;
- d->sendDataChanged();
-}
-
-
-/*!
Updates the relevant status bar for the \a widget specified by sending a
QStatusTipEvent to its parent widget. Returns \c true if an event was sent;
otherwise returns \c false.
@@ -1135,233 +351,4 @@ QAction::showStatusText(QWidget *widget)
return d_func()->showStatusText(widget, statusTip());
}
-/*!
- Sends the relevant signals for ActionEvent \a event.
-
- Action based widgets use this API to cause the QAction
- to emit signals as well as emitting their own.
-*/
-void QAction::activate(ActionEvent event)
-{
- Q_D(QAction);
- if(event == Trigger) {
- QPointer<QObject> guard = this;
- if(d->checkable) {
- // the checked action of an exclusive group may not be unchecked
- if (d->checked && (d->group
- && d->group->exclusionPolicy() == QActionGroup::ExclusionPolicy::Exclusive
- && d->group->checkedAction() == this)) {
- if (!guard.isNull())
- emit triggered(true);
- return;
- }
- setChecked(!d->checked);
- }
- if (!guard.isNull())
- emit triggered(d->checked);
- } else if(event == Hover) {
- emit hovered();
- }
-}
-
-/*!
- \fn void QAction::triggered(bool checked)
-
- This signal is emitted when an action is activated by the user;
- for example, when the user clicks a menu option, toolbar button,
- or presses an action's shortcut key combination, or when trigger()
- was called. Notably, it is \e not emitted when setChecked() or
- toggle() is called.
-
- If the action is checkable, \a checked is true if the action is
- checked, or false if the action is unchecked.
-
- \sa QAction::activate(), QAction::toggled(), checked
-*/
-
-/*!
- \fn void QAction::toggled(bool checked)
-
- This signal is emitted whenever a checkable action changes its
- isChecked() status. This can be the result of a user interaction,
- or because setChecked() was called. As setChecked() changes the
- QAction, it emits changed() in addition to toggled().
-
- \a checked is true if the action is checked, or false if the
- action is unchecked.
-
- \sa QAction::activate(), QAction::triggered(), checked
-*/
-
-/*!
- \fn void QAction::hovered()
-
- This signal is emitted when an action is highlighted by the user;
- for example, when the user pauses with the cursor over a menu option,
- toolbar button, or presses an action's shortcut key combination.
-
- \sa QAction::activate()
-*/
-
-/*!
- \fn void QAction::changed()
-
- This signal is emitted when an action has changed. If you
- are only interested in actions in a given widget, you can
- watch for QWidget::actionEvent() sent with an
- QEvent::ActionChanged.
-
- \sa QWidget::actionEvent()
-*/
-
-/*!
- \enum QAction::ActionEvent
-
- This enum type is used when calling QAction::activate()
-
- \value Trigger this will cause the QAction::triggered() signal to be emitted.
-
- \value Hover this will cause the QAction::hovered() signal to be emitted.
-*/
-
-/*!
- \property QAction::menuRole
- \brief the action's menu role
- \since 4.2
-
- This indicates what role the action serves in the application menu on
- \macos. By default all actions have the TextHeuristicRole, which means that
- the action is added based on its text (see QMenuBar for more information).
-
- The menu role can only be changed before the actions are put into the menu
- bar in \macos (usually just before the first application window is
- shown).
-*/
-void QAction::setMenuRole(MenuRole menuRole)
-{
- Q_D(QAction);
- if (d->menuRole == menuRole)
- return;
-
- d->menuRole = menuRole;
- d->sendDataChanged();
-}
-
-QAction::MenuRole QAction::menuRole() const
-{
- Q_D(const QAction);
- return d->menuRole;
-}
-
-/*!
- \property QAction::iconVisibleInMenu
- \brief Whether or not an action should show an icon in a menu
- \since 4.4
-
- In some applications, it may make sense to have actions with icons in the
- toolbar, but not in menus. If true, the icon (if valid) is shown in the menu, when it
- is false, it is not shown.
-
- The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute
- is set for the application. Explicitly settings this property overrides
- the presence (or abscence) of the attribute.
-
- For example:
- \snippet code/src_gui_kernel_qaction.cpp 0
-
- \sa QAction::icon, QCoreApplication::setAttribute()
-*/
-void QAction::setIconVisibleInMenu(bool visible)
-{
- Q_D(QAction);
- if (d->iconVisibleInMenu == -1 || visible != bool(d->iconVisibleInMenu)) {
- int oldValue = d->iconVisibleInMenu;
- d->iconVisibleInMenu = visible;
- // Only send data changed if we really need to.
- if (oldValue != -1
- || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus)) {
- d->sendDataChanged();
- }
- }
-}
-
-bool QAction::isIconVisibleInMenu() const
-{
- Q_D(const QAction);
- if (d->iconVisibleInMenu == -1) {
- return !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus);
- }
- return d->iconVisibleInMenu;
-}
-
-/*!
- \property QAction::shortcutVisibleInContextMenu
- \brief Whether or not an action should show a shortcut in a context menu
- \since 5.10
-
- In some applications, it may make sense to have actions with shortcuts in
- context menus. If true, the shortcut (if valid) is shown when the action is
- shown via a context menu, when it is false, it is not shown.
-
- The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute
- is set for the application, falling back to the widget style hint.
- Explicitly setting this property overrides the presence (or abscence) of the attribute.
-
- \sa QAction::shortcut, QCoreApplication::setAttribute()
-*/
-void QAction::setShortcutVisibleInContextMenu(bool visible)
-{
- Q_D(QAction);
- if (d->shortcutVisibleInContextMenu == -1 || visible != bool(d->shortcutVisibleInContextMenu)) {
- int oldValue = d->shortcutVisibleInContextMenu;
- d->shortcutVisibleInContextMenu = visible;
- // Only send data changed if we really need to.
- if (oldValue != -1
- || visible == !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) {
- d->sendDataChanged();
- }
- }
-}
-
-bool QAction::isShortcutVisibleInContextMenu() const
-{
- Q_D(const QAction);
- if (d->shortcutVisibleInContextMenu == -1) {
- return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)
- && QGuiApplication::styleHints()->showShortcutsInContextMenus();
- }
- return d->shortcutVisibleInContextMenu;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action)
-{
- QDebugStateSaver saver(d);
- d.nospace();
- d << "QAction(" << static_cast<const void *>(action);
- if (action) {
- d << " text=" << action->text();
- if (!action->toolTip().isEmpty())
- d << " toolTip=" << action->toolTip();
- if (action->isCheckable())
- d << " checked=" << action->isChecked();
-#if QT_CONFIG(shortcut)
- if (!action->shortcut().isEmpty())
- d << " shortcut=" << action->shortcut();
-#endif
- d << " menuRole=";
- QtDebugUtils::formatQEnum(d, action->menuRole());
- d << " visible=" << action->isVisible();
- } else {
- d << '0';
- }
- d << ')';
- return d;
-}
-#endif // QT_NO_DEBUG_STREAM
-
QT_END_NAMESPACE
-
-#include "moc_qaction.cpp"
-
-#endif // QT_NO_ACTION
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 258a1ea0a0..808ee9065d 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -41,137 +41,39 @@
#define QACTION_H
#include <QtWidgets/qtwidgetsglobal.h>
-#include <QtGui/qkeysequence.h>
+#include <QtGui/qguiaction.h>
#include <QtCore/qstring.h>
#include <QtWidgets/qwidget.h>
#include <QtCore/qvariant.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(action);
-#ifndef QT_NO_ACTION
+QT_BEGIN_NAMESPACE
class QMenu;
class QActionGroup;
class QActionPrivate;
class QGraphicsWidget;
-class Q_WIDGETS_EXPORT QAction : public QObject
+class Q_WIDGETS_EXPORT QAction : public QGuiAction
{
Q_OBJECT
Q_DECLARE_PRIVATE(QAction)
-
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed)
- Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed)
- Q_PROPERTY(QString iconText READ iconText WRITE setIconText NOTIFY changed)
- Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY changed)
- Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed)
- Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
-#if QT_CONFIG(shortcut)
- Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed)
- Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed)
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed)
-#endif
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed)
- Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
- Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
- Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
- Q_PROPERTY(Priority priority READ priority WRITE setPriority)
-
public:
- // note this is copied into qplatformmenu.h, which must stay in sync
- enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
- AboutRole, PreferencesRole, QuitRole };
- Q_ENUM(MenuRole)
- enum Priority { LowPriority = 0,
- NormalPriority = 128,
- HighPriority = 256};
- Q_ENUM(Priority)
- explicit QAction(QObject *parent = nullptr);
- explicit QAction(const QString &text, QObject *parent = nullptr);
- explicit QAction(const QIcon &icon, const QString &text, QObject *parent = nullptr);
-
+ QAction(QObject* parent = nullptr);
+ QAction(const QString &text, QObject* parent = nullptr);
+ QAction(const QIcon &icon, const QString &text, QObject* parent);
~QAction();
- void setActionGroup(QActionGroup *group);
QActionGroup *actionGroup() const;
- void setIcon(const QIcon &icon);
- QIcon icon() const;
-
- void setText(const QString &text);
- QString text() const;
-
- void setIconText(const QString &text);
- QString iconText() const;
-
- void setToolTip(const QString &tip);
- QString toolTip() const;
-
- void setStatusTip(const QString &statusTip);
- QString statusTip() const;
-
- void setWhatsThis(const QString &what);
- QString whatsThis() const;
-
- void setPriority(Priority priority);
- Priority priority() const;
#if QT_CONFIG(menu)
QMenu *menu() const;
void setMenu(QMenu *menu);
#endif
- void setSeparator(bool b);
- bool isSeparator() const;
-
-#if QT_CONFIG(shortcut)
- void setShortcut(const QKeySequence &shortcut);
- QKeySequence shortcut() const;
-
- void setShortcuts(const QList<QKeySequence> &shortcuts);
- void setShortcuts(QKeySequence::StandardKey);
- QList<QKeySequence> shortcuts() const;
-
- void setShortcutContext(Qt::ShortcutContext context);
- Qt::ShortcutContext shortcutContext() const;
-
- void setAutoRepeat(bool);
- bool autoRepeat() const;
-#endif
-
- void setFont(const QFont &font);
- QFont font() const;
-
- void setCheckable(bool);
- bool isCheckable() const;
-
- QVariant data() const;
- void setData(const QVariant &var);
-
- bool isChecked() const;
-
- bool isEnabled() const;
-
- bool isVisible() const;
-
- enum ActionEvent { Trigger, Hover };
- void activate(ActionEvent event);
bool showStatusText(QWidget *widget = nullptr);
- void setMenuRole(MenuRole menuRole);
- MenuRole menuRole() const;
-
- void setIconVisibleInMenu(bool visible);
- bool isIconVisibleInMenu() const;
-
- void setShortcutVisibleInContextMenu(bool show);
- bool isShortcutVisibleInContextMenu() const;
-
QWidget *parentWidget() const;
QList<QWidget *> associatedWidgets() const;
@@ -180,30 +82,14 @@ public:
#endif
protected:
- bool event(QEvent *) override;
QAction(QActionPrivate &dd, QObject *parent);
-
-public Q_SLOTS:
- void trigger() { activate(Trigger); }
- void hover() { activate(Hover); }
- void setChecked(bool);
- void toggle();
- void setEnabled(bool);
- inline void setDisabled(bool b) { setEnabled(!b); }
- void setVisible(bool);
-
-Q_SIGNALS:
- void changed();
- void triggered(bool checked = false);
- void hovered();
- void toggled(bool);
+ bool event(QEvent *) override;
private:
Q_DISABLE_COPY(QAction)
friend class QGraphicsWidget;
friend class QWidget;
- friend class QActionGroup;
friend class QMenu;
friend class QMenuPrivate;
friend class QMenuBar;
@@ -221,8 +107,6 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include <QtWidgets/qactiongroup.h>
QT_END_INCLUDE_NAMESPACE
-#endif // QT_NO_ACTION
-
QT_END_NAMESPACE
#endif // QACTION_H
diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h
index 6b6ca8076f..b865769372 100644
--- a/src/widgets/kernel/qaction_p.h
+++ b/src/widgets/kernel/qaction_p.h
@@ -52,6 +52,7 @@
//
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include <QtGui/private/qguiaction_p.h>
#include "QtWidgets/qaction.h"
#if QT_CONFIG(menu)
#include "QtWidgets/qmenu.h"
@@ -68,12 +69,15 @@ QT_BEGIN_NAMESPACE
class QShortcutMap;
-class Q_WIDGETS_EXPORT QActionPrivate : public QObjectPrivate
+class Q_WIDGETS_EXPORT QActionPrivate : public QGuiActionPrivate
{
Q_DECLARE_PUBLIC(QAction)
public:
- QActionPrivate();
- ~QActionPrivate();
+ QActionPrivate() = default;
+
+#if QT_CONFIG(shortcut)
+ QShortcutMap::ContextMatcher contextMatcher() const override;
+#endif
static QActionPrivate *get(QAction *q)
{
@@ -82,50 +86,11 @@ public:
bool showStatusText(QWidget *w, const QString &str);
- QPointer<QActionGroup> group;
- QString text;
- QString iconText;
- QIcon icon;
- QString tooltip;
- QString statustip;
- QString whatsthis;
-#if QT_CONFIG(shortcut)
- QKeySequence shortcut;
- QList<QKeySequence> alternateShortcuts;
-#endif
- QVariant userData;
-#if QT_CONFIG(shortcut)
- int shortcutId = 0;
- QVector<int> alternateShortcutIds;
- Qt::ShortcutContext shortcutContext = Qt::WindowShortcut;
- uint autorepeat : 1;
-#endif
- QFont font;
QPointer<QMenu> menu;
- uint enabled : 1, forceDisabled : 1;
- uint visible : 1, forceInvisible : 1;
- uint checkable : 1;
- uint checked : 1;
- uint separator : 1;
- uint fontSet : 1;
-
- int iconVisibleInMenu : 2; // Only has values -1, 0, and 1
- int shortcutVisibleInContextMenu : 2; // Only has values -1, 0, and 1
-
- QAction::MenuRole menuRole = QAction::TextHeuristicRole;
- QAction::Priority priority = QAction::NormalPriority;
-
QWidgetList widgets;
#if QT_CONFIG(graphicsview)
QList<QGraphicsWidget *> graphicsWidgets;
#endif
-#if QT_CONFIG(shortcut)
- void redoGrab(QShortcutMap &map);
- void redoGrabAlternate(QShortcutMap &map);
- void setShortcutEnabled(bool enable, QShortcutMap &map);
-#endif // QT_NO_SHORTCUT
-
- void sendDataChanged();
};
#endif // QT_NO_ACTION
diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp
index 1d9213de0c..cc900cbb0f 100644
--- a/src/widgets/kernel/qactiongroup.cpp
+++ b/src/widgets/kernel/qactiongroup.cpp
@@ -38,70 +38,32 @@
****************************************************************************/
#include "qactiongroup.h"
+#include <QtGui/private/qguiactiongroup_p.h>
-#ifndef QT_NO_ACTION
-
-#include "qaction_p.h"
-#include "qevent.h"
-#include "qlist.h"
+#include "qaction.h"
QT_BEGIN_NAMESPACE
-class QActionGroupPrivate : public QObjectPrivate
+class QActionGroupPrivate : public QGuiActionGroupPrivate
{
Q_DECLARE_PUBLIC(QActionGroup)
public:
- QActionGroupPrivate() : enabled(1),
- visible(1),
- exclusionPolicy(QActionGroup::ExclusionPolicy::Exclusive)
- {
- }
- QList<QAction *> actions;
- QPointer<QAction> current;
- uint enabled : 1;
- uint visible : 1;
- QActionGroup::ExclusionPolicy exclusionPolicy;
-
-private:
- void _q_actionTriggered(); //private slot
- void _q_actionChanged(); //private slot
- void _q_actionHovered(); //private slot
+ void emitSignal(Signal, QGuiAction *) override;
};
-void QActionGroupPrivate::_q_actionChanged()
+void QActionGroupPrivate::emitSignal(Signal s, QGuiAction *action)
{
Q_Q(QActionGroup);
- QAction *action = qobject_cast<QAction*>(q->sender());
- Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionChanged", "internal error");
- if (exclusionPolicy != QActionGroup::ExclusionPolicy::None) {
- if (action->isChecked()) {
- if (action != current) {
- if(current)
- current->setChecked(false);
- current = action;
- }
- } else if (action == current) {
- current = 0;
- }
+ switch (s) {
+ case QGuiActionGroupPrivate::Triggered:
+ emit q->triggered(static_cast<QAction *>(action));
+ break;
+ case QGuiActionGroupPrivate::Hovered:
+ emit q->hovered(static_cast<QAction *>(action));
+ break;
}
}
-void QActionGroupPrivate::_q_actionTriggered()
-{
- Q_Q(QActionGroup);
- QAction *action = qobject_cast<QAction*>(q->sender());
- Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionTriggered", "internal error");
- emit q->triggered(action);
-}
-
-void QActionGroupPrivate::_q_actionHovered()
-{
- Q_Q(QActionGroup);
- QAction *action = qobject_cast<QAction*>(q->sender());
- Q_ASSERT_X(action != nullptr, "QActionGroup::_q_actionHovered", "internal error");
- emit q->hovered(action);
-}
-
/*!
\class QActionGroup
\brief The QActionGroup class groups actions together.
@@ -154,27 +116,6 @@ void QActionGroupPrivate::_q_actionHovered()
*/
/*!
- \enum QActionGroup::ExclusionPolicy
-
- This enum specifies the different policies that can be used to
- control how the group performs exclusive checking on checkable actions.
-
- \value None
- The actions in the group can be checked independently of each other.
-
- \value Exclusive
- Exactly one action can be checked at any one time.
- This is the default policy.
-
- \value ExclusiveOptional
- At most one action can be checked at any one time. The actions
- can also be all unchecked.
-
- \sa exclusionPolicy
- \since 5.14
-*/
-
-/*!
Constructs an action group for the \a parent object.
The action group is exclusive by default. Call setExclusive(false)
@@ -182,53 +123,24 @@ void QActionGroupPrivate::_q_actionHovered()
but allow unchecking the active action call instead
setExclusionPolicy(QActionGroup::ExclusionPolicy::ExclusiveOptional)
*/
-QActionGroup::QActionGroup(QObject* parent) : QObject(*new QActionGroupPrivate, parent)
+QActionGroup::QActionGroup(QObject* parent) :
+ QGuiActionGroup(*new QActionGroupPrivate, parent)
{
}
/*!
Destroys the action group.
*/
-QActionGroup::~QActionGroup()
+QActionGroup::~QActionGroup() = default;
+
+QAction *QActionGroup::checkedAction() const
{
+ return static_cast<QAction *>(checkedGuiAction());
}
-/*!
- \fn QAction *QActionGroup::addAction(QAction *action)
-
- Adds the \a action to this group, and returns it.
-
- Normally an action is added to a group by creating it with the
- group as its parent, so this function is not usually used.
-
- \sa QAction::setActionGroup()
-*/
-QAction *QActionGroup::addAction(QAction* a)
+QAction *QActionGroup::addAction(QAction *a)
{
- Q_D(QActionGroup);
- if(!d->actions.contains(a)) {
- d->actions.append(a);
- QObject::connect(a, SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
- QObject::connect(a, SIGNAL(changed()), this, SLOT(_q_actionChanged()));
- QObject::connect(a, SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
- }
- if(!a->d_func()->forceDisabled) {
- a->setEnabled(d->enabled);
- a->d_func()->forceDisabled = false;
- }
- if(!a->d_func()->forceInvisible) {
- a->setVisible(d->visible);
- a->d_func()->forceInvisible = false;
- }
- if(a->isChecked())
- d->current = a;
- QActionGroup *oldGroup = a->d_func()->group;
- if(oldGroup != this) {
- if (oldGroup)
- oldGroup->removeAction(a);
- a->d_func()->group = this;
- a->d_func()->sendDataChanged();
- }
+ QGuiActionGroup::addAction(a);
return a;
}
@@ -261,184 +173,16 @@ QAction *QActionGroup::addAction(const QIcon &icon, const QString &text)
}
/*!
- Removes the \a action from this group. The action will have no
- parent as a result.
-
- \sa QAction::setActionGroup()
-*/
-void QActionGroup::removeAction(QAction *action)
-{
- Q_D(QActionGroup);
- if (d->actions.removeAll(action)) {
- if (action == d->current)
- d->current = 0;
- QObject::disconnect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
- QObject::disconnect(action, SIGNAL(changed()), this, SLOT(_q_actionChanged()));
- QObject::disconnect(action, SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
- action->d_func()->group = 0;
- }
-}
-
-/*!
Returns the list of this groups's actions. This may be empty.
*/
QList<QAction*> QActionGroup::actions() const
{
- Q_D(const QActionGroup);
- return d->actions;
+ QList<QAction*> result;
+ const auto baseActions = guiActions();
+ result.reserve(baseActions.size());
+ for (auto baseAction : baseActions)
+ result.append(static_cast<QAction*>(baseAction));
+ return result;
}
-/*!
- \brief Enable or disable the group exclusion checking
-
- This is a convenience method that calls
- setExclusionPolicy(ExclusionPolicy::Exclusive).
-
- \sa QActionGroup::exclusionPolicy
-*/
-void QActionGroup::setExclusive(bool b)
-{
- setExclusionPolicy(b ? QActionGroup::ExclusionPolicy::Exclusive
- : QActionGroup::ExclusionPolicy::None);
-}
-
-/*!
- \brief Returs true if the group is exclusive
-
- The group is exclusive if the ExclusionPolicy is either Exclusive
- or ExclusionOptional.
-
-*/
-bool QActionGroup::isExclusive() const
-{
- return exclusionPolicy() != QActionGroup::ExclusionPolicy::None;
-}
-
-/*!
- \property QActionGroup::exclusionPolicy
- \brief This property holds the group exclusive checking policy
-
- If exclusionPolicy is set to Exclusive, only one checkable
- action in the action group can ever be active at any time. If the user
- chooses another checkable action in the group, the one they chose becomes
- active and the one that was active becomes inactive. If exclusionPolicy is
- set to ExclusionOptional the group is exclusive but the active checkable
- action in the group can be unchecked leaving the group with no actions
- checked.
-
- \sa QAction::checkable
- \since 5.14
-*/
-void QActionGroup::setExclusionPolicy(QActionGroup::ExclusionPolicy policy)
-{
- Q_D(QActionGroup);
- d->exclusionPolicy = policy;
-}
-
-QActionGroup::ExclusionPolicy QActionGroup::exclusionPolicy() const
-{
- Q_D(const QActionGroup);
- return d->exclusionPolicy;
-}
-
-/*!
- \fn void QActionGroup::setDisabled(bool b)
-
- This is a convenience function for the \l enabled property, that
- is useful for signals--slots connections. If \a b is true the
- action group is disabled; otherwise it is enabled.
-*/
-
-/*!
- \property QActionGroup::enabled
- \brief whether the action group is enabled
-
- Each action in the group will be enabled or disabled unless it
- has been explicitly disabled.
-
- \sa QAction::setEnabled()
-*/
-void QActionGroup::setEnabled(bool b)
-{
- Q_D(QActionGroup);
- d->enabled = b;
- for (auto action : qAsConst(d->actions)) {
- if (!action->d_func()->forceDisabled) {
- action->setEnabled(b);
- action->d_func()->forceDisabled = false;
- }
- }
-}
-
-bool QActionGroup::isEnabled() const
-{
- Q_D(const QActionGroup);
- return d->enabled;
-}
-
-/*!
- Returns the currently checked action in the group, or \nullptr if
- none are checked.
-*/
-QAction *QActionGroup::checkedAction() const
-{
- Q_D(const QActionGroup);
- return d->current;
-}
-
-/*!
- \property QActionGroup::visible
- \brief whether the action group is visible
-
- Each action in the action group will match the visible state of
- this group unless it has been explicitly hidden.
-
- \sa QAction::setEnabled()
-*/
-void QActionGroup::setVisible(bool b)
-{
- Q_D(QActionGroup);
- d->visible = b;
- for (auto action : qAsConst(d->actions)) {
- if (!action->d_func()->forceInvisible) {
- action->setVisible(b);
- action->d_func()->forceInvisible = false;
- }
- }
-}
-
-bool QActionGroup::isVisible() const
-{
- Q_D(const QActionGroup);
- return d->visible;
-}
-
-/*!
- \fn void QActionGroup::triggered(QAction *action)
-
- This signal is emitted when the given \a action in the action
- group is activated by the user; for example, when the user clicks
- a menu option, toolbar button, or presses an action's shortcut key
- combination.
-
- Connect to this signal for command actions.
-
- \sa QAction::activate()
-*/
-
-/*!
- \fn void QActionGroup::hovered(QAction *action)
-
- This signal is emitted when the given \a action in the action
- group is highlighted by the user; for example, when the user
- pauses with the cursor over a menu option, toolbar button, or
- presses an action's shortcut key combination.
-
- \sa QAction::activate()
-*/
-
QT_END_NAMESPACE
-
-#include "moc_qactiongroup.cpp"
-
-#endif // QT_NO_ACTION
diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h
index 90f488bedb..0a6a85f093 100644
--- a/src/widgets/kernel/qactiongroup.h
+++ b/src/widgets/kernel/qactiongroup.h
@@ -41,54 +41,31 @@
#define QACTIONGROUP_H
#include <QtWidgets/qtwidgetsglobal.h>
+#include <QtGui/qguiactiongroup.h>
#include <QtWidgets/qaction.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(action);
-#ifndef QT_NO_ACTION
+QT_BEGIN_NAMESPACE
class QActionGroupPrivate;
-class Q_WIDGETS_EXPORT QActionGroup : public QObject
+class Q_WIDGETS_EXPORT QActionGroup : public QGuiActionGroup
{
Q_OBJECT
Q_DECLARE_PRIVATE(QActionGroup)
- Q_PROPERTY(QActionGroup::ExclusionPolicy exclusionPolicy READ exclusionPolicy WRITE setExclusionPolicy)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
-
public:
- enum class ExclusionPolicy {
- None,
- Exclusive,
- ExclusiveOptional
- };
- Q_ENUM(ExclusionPolicy)
-
explicit QActionGroup(QObject* parent);
~QActionGroup();
- QAction *addAction(QAction* a);
- QAction *addAction(const QString &text);
- QAction *addAction(const QIcon &icon, const QString &text);
- void removeAction(QAction *a);
- QList<QAction*> actions() const;
-
QAction *checkedAction() const;
- bool isExclusive() const;
- bool isEnabled() const;
- bool isVisible() const;
- ExclusionPolicy exclusionPolicy() const;
+ QAction *addAction(QAction *a);
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QIcon &icon, const QString &text);
-public Q_SLOTS:
- void setEnabled(bool);
- inline void setDisabled(bool b) { setEnabled(!b); }
- void setVisible(bool);
- void setExclusive(bool);
- void setExclusionPolicy(ExclusionPolicy policy);
+ QList<QAction*> actions() const;
Q_SIGNALS:
void triggered(QAction *);
@@ -96,13 +73,8 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(QActionGroup)
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
- Q_PRIVATE_SLOT(d_func(), void _q_actionChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
};
-#endif // QT_NO_ACTION
-
QT_END_NAMESPACE
#endif // QACTIONGROUP_H
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 6d4baacfef..6473669c95 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1395,7 +1395,9 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
else
*QApplicationPrivate::set_pal = palette;
QCoreApplication::setAttribute(Qt::AA_SetPalette);
- emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
+
+ if (qGuiApp && QGuiApplicationPrivate::app_pal)
+ emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
}
}
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 27e743a28d..d7cc4489c4 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -58,7 +58,6 @@ class QDesktopWidget;
class QStyle;
class QEventLoop;
class QIcon;
-template <typename T> class QList;
class QLocale;
class QPlatformNativeInterface;
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index d469279ea5..4a2f8d66c2 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -40,7 +40,6 @@
#include "qshortcut.h"
#include "private/qwidget_p.h"
-#ifndef QT_NO_SHORTCUT
#include <qevent.h>
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
@@ -53,25 +52,21 @@
#endif
#include <qapplication.h>
#include <private/qapplication_p.h>
+#include "private/qguishortcut_p.h"
#include <private/qshortcutmap_p.h>
-#include <private/qaction_p.h>
+#if QT_CONFIG(action)
+# include <private/qaction_p.h>
+#endif
#include <private/qwidgetwindow_p.h>
#include <qpa/qplatformmenu.h>
QT_BEGIN_NAMESPACE
-#define QAPP_CHECK(functionName) \
- if (Q_UNLIKELY(!qApp)) { \
- qWarning("QShortcut: Initialize QApplication before calling '" functionName "'."); \
- return; \
- }
-
-
static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window);
#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
@@ -108,7 +103,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<QAction *>(object))
return correctActionContext(context, a, active_window);
#endif
@@ -284,7 +279,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<QActionPrivate *>(QObjectPrivate::get(a))->widgets;
@@ -332,7 +327,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
#endif
return false;
}
-#endif // QT_NO_ACTION
+#endif // QT_CONFIG(action)
/*!
@@ -395,29 +390,62 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
Returns the shortcut's parent widget.
*/
-/*!
- \fn void QShortcut::activated()
+/*
+ \internal
+ Private data accessed through d-pointer.
+*/
+class QShortcutPrivate : public QGuiShortcutPrivate
+{
+ Q_DECLARE_PUBLIC(QShortcut)
+public:
+ QShortcutPrivate() = default;
- This signal is emitted when the user types the shortcut's key
- sequence.
+ QShortcutMap::ContextMatcher contextMatcher() const override
+ { return qWidgetShortcutContextMatcher; }
- \sa activatedAmbiguously()
-*/
+ bool handleWhatsThis() override;
-/*!
- \fn void QShortcut::activatedAmbiguously()
+ QString sc_whatsthis;
+};
+
+bool QShortcutPrivate::handleWhatsThis()
+{
+#if QT_CONFIG(whatsthis)
+ const bool result = QWhatsThis::inWhatsThisMode();
+ if (result)
+ QWhatsThis::showText(QCursor::pos(), sc_whatsthis);
+ return result;
+#else
+ return false;
+#endif
+}
- When a key sequence is being typed at the keyboard, it is said to
- be ambiguous as long as it matches the start of more than one
- shortcut.
+/*!
+ Constructs a QShortcut object for the \a parent widget. Since no
+ shortcut key sequence is specified, the shortcut will not emit any
+ signals.
- When a shortcut's key sequence is completed,
- activatedAmbiguously() is emitted if the key sequence is still
- ambiguous (i.e., it is the start of one or more other shortcuts).
- The activated() signal is not emitted in this case.
+ \sa setKey()
+*/
+QShortcut::QShortcut(QWidget *parent)
+ : QGuiShortcut(*new QShortcutPrivate, parent)
+{
+}
- \sa activated()
+/*!
+ Constructs a QShortcut object for the \a parent widget. The shortcut
+ operates on its parent, listening for \l{QShortcutEvent}s that
+ match the \a key sequence. Depending on the ambiguity of the
+ event, the shortcut will call the \a member function, or the \a
+ ambiguousMember function, if the key press was in the shortcut's
+ \a shortcutContext.
*/
+QShortcut::QShortcut(const QKeySequence &key, QWidget *parent,
+ const char *member, const char *ambiguousMember,
+ Qt::ShortcutContext shortcutContext)
+ : QGuiShortcut(*new QShortcutPrivate, key, parent, member, ambiguousMember, shortcutContext)
+{
+}
/*!
\fn template<typename Functor>
@@ -489,177 +517,6 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
will not be called.
*/
-/*
- \internal
- Private data accessed through d-pointer.
-*/
-class QShortcutPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QShortcut)
-public:
- QShortcutPrivate() = default;
- QKeySequence sc_sequence;
- Qt::ShortcutContext sc_context = Qt::WindowShortcut;
- bool sc_enabled = true;
- bool sc_autorepeat = true;
- int sc_id = 0;
- QString sc_whatsthis;
- void redoGrab(QShortcutMap &map);
-};
-
-void QShortcutPrivate::redoGrab(QShortcutMap &map)
-{
- Q_Q(QShortcut);
- if (Q_UNLIKELY(!parent)) {
- qWarning("QShortcut: No widget parent defined");
- return;
- }
-
- if (sc_id)
- map.removeShortcut(sc_id, q);
- if (sc_sequence.isEmpty())
- return;
- sc_id = map.addShortcut(q, sc_sequence, sc_context, qWidgetShortcutContextMatcher);
- if (!sc_enabled)
- map.setShortcutEnabled(false, sc_id, q);
- if (!sc_autorepeat)
- map.setShortcutAutoRepeat(false, sc_id, q);
-}
-
-/*!
- Constructs a QShortcut object for the \a parent widget. Since no
- shortcut key sequence is specified, the shortcut will not emit any
- signals.
-
- \sa setKey()
-*/
-QShortcut::QShortcut(QWidget *parent)
- : QObject(*new QShortcutPrivate, parent)
-{
- Q_ASSERT(parent != nullptr);
-}
-
-/*!
- Constructs a QShortcut object for the \a parent widget. The shortcut
- operates on its parent, listening for \l{QShortcutEvent}s that
- match the \a key sequence. Depending on the ambiguity of the
- event, the shortcut will call the \a member function, or the \a
- ambiguousMember function, if the key press was in the shortcut's
- \a context.
-*/
-QShortcut::QShortcut(const QKeySequence &key, QWidget *parent,
- const char *member, const char *ambiguousMember,
- Qt::ShortcutContext shortcutContext)
- : QShortcut(parent)
-{
- QAPP_CHECK("QShortcut");
-
- Q_D(QShortcut);
- d->sc_context = shortcutContext;
- d->sc_sequence = key;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
- if (member)
- connect(this, SIGNAL(activated()), parent, member);
- if (ambiguousMember)
- connect(this, SIGNAL(activatedAmbiguously()), parent, ambiguousMember);
-}
-
-/*!
- Destroys the shortcut.
-*/
-QShortcut::~QShortcut()
-{
- Q_D(QShortcut);
- if (qApp)
- QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->sc_id, this);
-}
-
-/*!
- \property QShortcut::key
- \brief the shortcut's key sequence
-
- This is a key sequence with an optional combination of Shift, Ctrl,
- and Alt. The key sequence may be supplied in a number of ways:
-
- \snippet code/src_gui_kernel_qshortcut.cpp 1
-
- By default, this property contains an empty key sequence.
-*/
-void QShortcut::setKey(const QKeySequence &key)
-{
- Q_D(QShortcut);
- if (d->sc_sequence == key)
- return;
- QAPP_CHECK("setKey");
- d->sc_sequence = key;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
-}
-
-QKeySequence QShortcut::key() const
-{
- Q_D(const QShortcut);
- return d->sc_sequence;
-}
-
-/*!
- \property QShortcut::enabled
- \brief whether the shortcut is enabled
-
- An enabled shortcut emits the activated() or activatedAmbiguously()
- signal when a QShortcutEvent occurs that matches the shortcut's
- key() sequence.
-
- If the application is in \c WhatsThis mode the shortcut will not emit
- the signals, but will show the "What's This?" text instead.
-
- By default, this property is \c true.
-
- \sa whatsThis
-*/
-void QShortcut::setEnabled(bool enable)
-{
- Q_D(QShortcut);
- if (d->sc_enabled == enable)
- return;
- QAPP_CHECK("setEnabled");
- d->sc_enabled = enable;
- QGuiApplicationPrivate::instance()->shortcutMap.setShortcutEnabled(enable, d->sc_id, this);
-}
-
-bool QShortcut::isEnabled() const
-{
- Q_D(const QShortcut);
- return d->sc_enabled;
-}
-
-/*!
- \property QShortcut::context
- \brief the context in which the shortcut is valid
-
- A shortcut's context decides in which circumstances a shortcut is
- allowed to be triggered. The normal context is Qt::WindowShortcut,
- which allows the shortcut to trigger if the parent (the widget
- containing the shortcut) is a subwidget of the active top-level
- window.
-
- By default, this property is set to Qt::WindowShortcut.
-*/
-void QShortcut::setContext(Qt::ShortcutContext context)
-{
- Q_D(QShortcut);
- if(d->sc_context == context)
- return;
- QAPP_CHECK("setContext");
- d->sc_context = context;
- d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap);
-}
-
-Qt::ShortcutContext QShortcut::context() const
-{
- Q_D(const QShortcut);
- return d->sc_context;
-}
-
/*!
\property QShortcut::whatsThis
\brief the shortcut's "What's This?" help text
@@ -687,67 +544,8 @@ QString QShortcut::whatsThis() const
}
/*!
- \property QShortcut::autoRepeat
- \brief whether the shortcut can auto repeat
- \since 4.2
-
- If true, the shortcut will auto repeat when the keyboard shortcut
- combination is held down, provided that keyboard auto repeat is
- enabled on the system.
- The default value is true.
-*/
-void QShortcut::setAutoRepeat(bool on)
-{
- Q_D(QShortcut);
- if (d->sc_autorepeat == on)
- return;
- QAPP_CHECK("setAutoRepeat");
- d->sc_autorepeat = on;
- QGuiApplicationPrivate::instance()->shortcutMap.setShortcutAutoRepeat(on, d->sc_id, this);
-}
-
-bool QShortcut::autoRepeat() const
-{
- Q_D(const QShortcut);
- return d->sc_autorepeat;
-}
-
-/*!
- Returns the shortcut's ID.
-
- \sa QShortcutEvent::shortcutId()
+ Destroys the shortcut.
*/
-int QShortcut::id() const
-{
- Q_D(const QShortcut);
- return d->sc_id;
-}
-
-/*!
- \internal
-*/
-bool QShortcut::event(QEvent *e)
-{
- Q_D(QShortcut);
- if (d->sc_enabled && e->type() == QEvent::Shortcut) {
- auto se = static_cast<QShortcutEvent *>(e);
- if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){
-#if QT_CONFIG(whatsthis)
- if (QWhatsThis::inWhatsThisMode()) {
- QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis);
- } else
-#endif
- if (se->isAmbiguous())
- emit activatedAmbiguously();
- else
- emit activated();
- return true;
- }
- }
- return QObject::event(e);
-}
-#endif // QT_NO_SHORTCUT
+QShortcut::~QShortcut() = default;
QT_END_NAMESPACE
-
-#include "moc_qshortcut.cpp"
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index 4f9c5ba0f7..6c92f87c46 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
@@ -42,28 +42,23 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
-#include <QtGui/qkeysequence.h>
-
-QT_BEGIN_NAMESPACE
+#include <QtGui/qguishortcut.h>
+QT_REQUIRE_CONFIG(shortcut);
-#ifndef QT_NO_SHORTCUT
+QT_BEGIN_NAMESPACE
class QShortcutPrivate;
-class Q_WIDGETS_EXPORT QShortcut : public QObject
+class Q_WIDGETS_EXPORT QShortcut : public QGuiShortcut
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QShortcut)
- Q_PROPERTY(QKeySequence key READ key WRITE setKey)
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
- Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext)
+ Q_DECLARE_PRIVATE(QShortcut)
public:
explicit QShortcut(QWidget *parent);
- QShortcut(const QKeySequence &key, QWidget *parent,
- const char *member = nullptr, const char *ambiguousMember = nullptr,
- Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
+ explicit QShortcut(const QKeySequence& key, QWidget *parent,
+ const char *member = nullptr, const char *ambiguousMember = nullptr,
+ Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
#ifdef Q_CLANG_QDOC
template<typename Functor>
QShortcut(const QKeySequence &key, QWidget *parent,
@@ -122,36 +117,13 @@ public:
#endif
~QShortcut();
- void setKey(const QKeySequence& key);
- QKeySequence key() const;
-
- void setEnabled(bool enable);
- bool isEnabled() const;
-
- void setContext(Qt::ShortcutContext context);
- Qt::ShortcutContext context() const;
-
void setWhatsThis(const QString &text);
QString whatsThis() const;
- void setAutoRepeat(bool on);
- bool autoRepeat() const;
-
- int id() const;
-
inline QWidget *parentWidget() const
{ return static_cast<QWidget *>(QObject::parent()); }
-
-Q_SIGNALS:
- void activated();
- void activatedAmbiguously();
-
-protected:
- bool event(QEvent *e) override;
};
-#endif // QT_NO_SHORTCUT
-
QT_END_NAMESPACE
#endif // QSHORTCUT_H
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 <qabstractbutton.h>
#include <qabstractscrollarea.h>
#include <qabstractslider.h>
-#include <qaction.h>
+#if QT_CONFIG(action)
+# include <qaction.h>
+#endif
#include <qcommonstyle.h>
#include <qlayout.h>
#include <qstyle.h>
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index e96e06d874..b2653878c1 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -88,7 +88,9 @@
#include "qwidget_p.h"
#include <QtGui/private/qwindow_p.h>
-#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"
@@ -1513,13 +1515,8 @@ QWidget::~QWidget()
if (d->declarativeData) {
d->wasDeleted = true; // needed, so that destroying the declarative data does the right thing
- if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
- if (QAbstractDeclarativeData::destroyed_qml1)
- QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
- } else {
- if (QAbstractDeclarativeData::destroyed)
- QAbstractDeclarativeData::destroyed(d->declarativeData, this);
- }
+ if (QAbstractDeclarativeData::destroyed)
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
d->declarativeData = 0; // don't activate again in ~QObject
d->wasDeleted = false;
}
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 415a738eb4..5117fa94c8 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -53,7 +53,9 @@
#include <QtGui/qregion.h>
#include <QtGui/qbrush.h>
#include <QtGui/qcursor.h>
-#include <QtGui/qkeysequence.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/qkeysequence.h>
+#endif
#ifdef QT_INCLUDE_COMPAT
#include <QtGui/qevent.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<QWidget *> 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,10 +43,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qaction.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(action);
-#ifndef QT_NO_ACTION
+QT_BEGIN_NAMESPACE
class QWidgetActionPrivate;
@@ -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 <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qaction_p.h"
+QT_REQUIRE_CONFIG(action);
+
QT_BEGIN_NAMESPACE
class QWidgetActionPrivate : public QActionPrivate
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 0f01a70faa..a732d59e48 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -3238,7 +3238,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
break;
case CT_MenuItem:
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- int w = newSize.width();
+ int w = size.width(); // Don't rely of QCommonStyle's width calculation here
int maxpmw = menuItem->maxIconWidth;
int tabSpacing = 20;
if (menuItem->text.contains(QLatin1Char('\t')))
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index d2f5ac76f9..e462d0696b 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -638,7 +638,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
indicator or button bevel.
\omitvalue PE_IndicatorViewItemCheck
- \value PE_FrameStatusBar Obsolete. Use PE_FrameStatusBarItem instead.
\value PE_PanelButtonCommand Button used to initiate an action, for
example, a QPushButton.
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index ee234457f5..b51bcbe8d6 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -142,9 +142,6 @@ public:
PE_FrameLineEdit,
PE_FrameMenu,
PE_FrameStatusBarItem,
-#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove
- PE_FrameStatusBar Q_DECL_ENUMERATOR_DEPRECATED = PE_FrameStatusBarItem,
-#endif
PE_FrameTabWidget,
PE_FrameWindow,
PE_FrameButtonBevel,
@@ -165,9 +162,6 @@ public:
PE_IndicatorBranch,
PE_IndicatorButtonDropDown,
PE_IndicatorItemViewItemCheck,
-#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove
- PE_IndicatorViewItemCheck Q_DECL_ENUMERATOR_DEPRECATED = PE_IndicatorItemViewItemCheck,
-#endif
PE_IndicatorCheckBox,
PE_IndicatorDockWidgetResizeHandle,
PE_IndicatorHeaderArrow,
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index e5e93ecc66..110ebf29c9 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1760,7 +1760,7 @@ QStyleOptionMenuItem::QStyleOptionMenuItem(int version)
\value Exclusive The item is an exclusive check item (like a radio button).
\value NonExclusive The item is a non-exclusive check item (like a check box).
- \sa checkType, QAction::checkable, QAction::checked, QActionGroup::exclusionPolicy
+ \sa checkType, QGuiAction::checkable, QGuiAction::checked, QGuiActionGroup::exclusionPolicy
*/
/*!
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 <private/qobject_p.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
-#include <QtWidgets/qaction.h>
+#if QT_CONFIG(action)
+# include <QtWidgets/qaction.h>
+#endif
#include "qundostack.h"
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index 19528d61d2..8e6c2cb882 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/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index 50c94654f3..d44da2f4f3 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -42,7 +42,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qicon.h>
-#include <QtGui/qkeysequence.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/qkeysequence.h>
+#endif
#include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(abstractbutton);
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 3be163ff75..751e17b717 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -2307,33 +2307,6 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event)
style()->drawComplexControl(QStyle::CC_ComboBox, &optCombo, &p, this);
}
-/*
- Returns the string for AM and PM markers.
-
- If a translation for "AM" and "PM" is installed, then use that.
- Otherwise, use the default implementation, which uses the locale.
-*/
-QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const
-{
- QString original;
- QString translated;
- if (ap == AmText) {
- original = QLatin1String(cs == UpperCase ? "AM" : "am");
- translated = (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am"));
- } else {
- original = QLatin1String(cs == UpperCase ? "PM" : "pm");
- translated = (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm"));
- }
-
- // This logic fails if a translation exists but doesn't change the string,
- // which we can accept as a corner-case for which a locale-derived answer
- // will be acceptable.
- if (original != translated)
- return translated;
-
- return QDateTimeParser::getAmPmText(ap, cs);
-}
-
int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) const
{
for (int i=0; i<sectionNodes.size(); ++i) {
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
index dcf8863c8b..392bb0c778 100644
--- a/src/widgets/widgets/qdatetimeedit_p.h
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -97,7 +97,6 @@ public:
QDateTime getMinimum() const override { return minimum.toDateTime(); }
QDateTime getMaximum() const override { return maximum.toDateTime(); }
QLocale locale() const override { return q_func()->locale(); }
- QString getAmPmText(AmPm ap, Case cs) const override;
int cursorPosition() const override { return edit ? edit->cursorPosition() : -1; }
int absoluteIndex(QDateTimeEdit::Section s, int index) const;
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 77d117775a..7bd7283adf 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -47,7 +47,6 @@
#include "qstyle.h"
#include "qstyleoption.h"
#include <limits.h>
-#include "qaction.h"
#include "qclipboard.h"
#include <qdebug.h>
#include <qurl.h>
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 92f43a309d..37d2211a00 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)
@@ -78,7 +80,7 @@
#endif
#include "private/qstylesheetstyle_p.h"
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index d2b5f87906..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"
@@ -370,7 +372,7 @@ void QLineEditIconButton::actionEvent(QActionEvent *e)
{
switch (e->type()) {
case QEvent::ActionChanged: {
- const QAction *action = e->action();
+ const auto *action = e->action();
if (isVisibleTo(parentWidget()) != action->isVisible()) {
setVisible(action->isVisible());
if (QLineEditPrivate *lep = lineEditPrivate())
@@ -545,7 +547,8 @@ void QLineEditPrivate::positionSideWidgets()
}
}
-QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(const QAction *a) const
+#if QT_CONFIG(action)
+QLineEditPrivate::SideWidgetLocation QLineEditPrivate::findSideWidget(const QGuiAction *a) const
{
int i = 0;
for (const auto &e : leadingSideWidgets) {
@@ -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<QWidgetAction *>(newAction)) {
if ((w = widgetAction->requestWidget(q)))
flags |= SideWidgetCreatedByWidgetAction;
}
-#endif
if (!w) {
#if QT_CONFIG(toolbutton)
QLineEditIconButton *toolButton = new QLineEditIconButton(q);
@@ -634,9 +635,8 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
return w;
}
-void QLineEditPrivate::removeAction(QAction *action)
+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(QAction *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 &parameters)
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index a11fea6bbe..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(QAction *action);
+ void removeAction(QGuiAction *action);
+#endif
SideWidgetParameters sideWidgetParameters() const;
QIcon clearButtonIcon() const;
void setClearButtonEnabled(bool enabled);
@@ -261,7 +263,9 @@ private:
};
friend class QTypeInfo<SideWidgetLocation>;
- SideWidgetLocation findSideWidget(const QAction *a) const;
+#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 a0286dfcb1..a2254112c2 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -162,7 +162,9 @@
#include <QDebug>
#include <QMdiArea>
#include <QScopedValueRollback>
-#include <QAction>
+#if QT_CONFIG(action)
+# include <qaction.h>
+#endif
#if QT_CONFIG(menu)
#include <QMenu>
#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<QAction *>(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/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 51b458f03a..0fc89ad2e4 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -157,10 +157,11 @@ public:
Q_D(QTornOffMenu);
if(menu != d->causedMenu)
return;
+ auto action = static_cast<QAction *>(act->action());
if (act->type() == QEvent::ActionAdded) {
- insertAction(act->before(), act->action());
+ insertAction(static_cast<QAction *>(act->before()), action);
} else if (act->type() == QEvent::ActionRemoved)
- removeAction(act->action());
+ removeAction(action);
}
void actionEvent(QActionEvent *e) override
{
@@ -403,7 +404,9 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
//calculate size
QFontMetrics qfm = q->fontMetrics();
bool previousWasSeparator = true; // this is true to allow removing the leading separators
+#if QT_CONFIG(shortcut)
const bool contextMenu = isContextMenu();
+#endif
for(int i = 0; i <= lastVisibleAction; i++) {
QAction *action = actions.at(i);
const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
@@ -434,12 +437,12 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
if (t != -1) {
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1)));
s = s.left(t);
- #ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
} else if (action->isShortcutVisibleInContextMenu() || !contextMenu) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(seq.toString(QKeySequence::NativeText)));
- #endif
+#endif
}
sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
sz.setHeight(qMax(fm.height(), qfm.height()));
@@ -1767,12 +1770,14 @@ QAction *QMenu::addAction(const QIcon &icon, const QString &text)
\sa QWidget::addAction()
*/
-QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
+QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut
+#endif
+ )
{
QAction *action = new QAction(text, this);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut);
-#else
+#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
@@ -1860,12 +1865,14 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
\sa QWidget::addAction()
*/
QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver,
- const char* member, const QKeySequence &shortcut)
+ const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut
+#endif
+ )
{
QAction *action = new QAction(icon, text, this);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut);
-#else
+#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
@@ -3541,15 +3548,16 @@ void QMenu::actionEvent(QActionEvent *e)
wa->releaseWidget(widget);
}
}
- d->widgetItems.remove(e->action());
+ d->widgetItems.remove(static_cast<QAction *>(e->action()));
}
if (!d->platformMenu.isNull()) {
+ auto action = static_cast<QAction *>(e->action());
if (e->type() == QEvent::ActionAdded) {
QPlatformMenuItem *beforeItem = e->before()
? d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()))
: nullptr;
- d->insertActionInPlatformMenu(e->action(), beforeItem);
+ d->insertActionInPlatformMenu(action, beforeItem);
} else if (e->type() == QEvent::ActionRemoved) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
d->platformMenu->removeMenuItem(menuItem);
@@ -3557,7 +3565,7 @@ void QMenu::actionEvent(QActionEvent *e)
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
if (menuItem) {
- d->copyActionToPlatformItem(e->action(), menuItem);
+ d->copyActionToPlatformItem(action, menuItem);
d->platformMenu->syncMenuItem(menuItem);
}
}
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 84ab9e027a..35d5a865ff 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -78,8 +78,17 @@ public:
using QWidget::addAction;
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
- QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+
+ QAction *addAction(const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ );
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ );
#ifdef Q_CLANG_QDOC
template<typename Functor>
@@ -95,12 +104,14 @@ public:
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
- addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ addAction(const QString &text, const Obj *object, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
@@ -108,12 +119,14 @@ public:
}
// addAction(QString): Connect to a functor or function pointer (without context)
template <typename Func1>
- inline QAction *addAction(const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ inline QAction *addAction(const QString &text, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
@@ -123,12 +136,15 @@ public:
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
- addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
+
{
QAction *result = addAction(actionIcon, text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
@@ -136,12 +152,14 @@ public:
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
template <typename Func1>
- inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(actionIcon, text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index afa5ca7142..97816cc889 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1288,21 +1288,22 @@ void QMenuBar::actionEvent(QActionEvent *e)
if (!nativeMenuBar)
return;
+ auto action = static_cast<QAction *>(e->action());
if (e->type() == QEvent::ActionAdded) {
- QPlatformMenu *menu = d->getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(action);
if (menu) {
- d->copyActionToPlatformMenu(e->action(), menu);
+ d->copyActionToPlatformMenu(action, menu);
- QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(e->action());
+ QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(action);
d->platformMenuBar->insertMenu(menu, beforeMenu);
}
} else if (e->type() == QEvent::ActionRemoved) {
- QPlatformMenu *menu = d->getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(action);
if (menu)
d->platformMenuBar->removeMenu(menu);
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenu *cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));
- QPlatformMenu *menu = d->getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(action);
// the menu associated with the action can change, need to
// remove and/or insert the new platform menu
@@ -1310,13 +1311,13 @@ void QMenuBar::actionEvent(QActionEvent *e)
if (cur)
d->platformMenuBar->removeMenu(cur);
if (menu) {
- d->copyActionToPlatformMenu(e->action(), menu);
+ d->copyActionToPlatformMenu(action, menu);
- QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(e->action());
+ QPlatformMenu *beforeMenu = d->findInsertionPlatformMenu(action);
d->platformMenuBar->insertMenu(menu, beforeMenu);
}
} else if (menu) {
- d->copyActionToPlatformMenu(e->action(), menu);
+ d->copyActionToPlatformMenu(action, menu);
d->platformMenuBar->syncMenu(menu);
}
}
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index ec980d9ee3..658914ae39 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE
class QSplitterPrivate;
class QTextStream;
-template <typename T> class QList;
class QSplitterHandle;
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 79182dfa33..bed5c3ec3e 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -961,7 +961,7 @@ QAction *QToolBar::actionAt(const QPoint &p) const
void QToolBar::actionEvent(QActionEvent *event)
{
Q_D(QToolBar);
- QAction *action = event->action();
+ auto action = static_cast<QAction *>(event->action());
QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);
switch (event->type()) {
diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index ec60309806..03368fd5c2 100644
--- a/src/widgets/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
@@ -207,7 +207,7 @@ void QToolBarLayout::insertAction(int index, QAction *action)
}
}
-int QToolBarLayout::indexOf(QAction *action) const
+int QToolBarLayout::indexOf(const QGuiAction *action) const
{
for (int i = 0; i < items.count(); ++i) {
if (items.at(i)->action == action)
diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h
index b5dc121b93..1a406a3d29 100644
--- a/src/widgets/widgets/qtoolbarlayout_p.h
+++ b/src/widgets/widgets/qtoolbarlayout_p.h
@@ -96,7 +96,7 @@ public:
QSize sizeHint() const override;
void insertAction(int index, QAction *action);
- int indexOf(QAction *action) const;
+ int indexOf(const QGuiAction *action) const;
using QLayout::indexOf; // bring back the hidden members
bool layoutActions(const QSize &size);
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index b00b219386..cced36738c 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -466,7 +466,7 @@ void QToolButton::paintEvent(QPaintEvent *)
void QToolButton::actionEvent(QActionEvent *event)
{
Q_D(QToolButton);
- QAction *action = event->action();
+ auto action = static_cast<QAction *>(event->action());
switch (event->type()) {
case QEvent::ActionChanged:
if (action == d->defaultAction)
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 1c169c3325..f5d3f2f9c0 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -92,7 +92,7 @@
#include <QtGui/qaccessible.h>
#include <QtCore/qmetaobject.h>
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>