From cff492fed1d98f45c4c1f4011f1451120c0d1c23 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 19 Jun 2019 13:00:11 +0200 Subject: Extract QGuiAction(Group) from QAction(Group) into QtGui Simply moving QAction to QtGui was not deemed possible since it operates on a set of controls of some kind. The approach to extract a base class was taken instead, named QGuiAction following the QGuiApplication scheme. QAction remains in widgets, but changes base class. For QActionGroup, the functions addAction(text/icon), which create an action, cannot be implemented in QtGui, hence a base class is needed, too (unless they are deprecated and removed). - Extract base classes providing functionality not based on QtWidgets, using virtuals in QGuiActionPrivate to provide customization points - Change QActionEvent to take QGuiAction, removing the need to forward declare QAction in QtGui [ChangeLog][QtGui] Added QGuiAction(Group) and made the equivalent existing classes in Qt Widgets derive from them. This provides basic functionality for implementing actions in QML. Task-number: QTBUG-69478 Change-Id: Ic490a5e3470939ee8af612d46ff41d4c8c91fbdf Reviewed-by: Lars Knoll Reviewed-by: Mitch Curtis Reviewed-by: Oliver Wolff Reviewed-by: Allan Sandfeld Jensen --- src/widgets/kernel/qaction_p.h | 49 ++++++------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) (limited to 'src/widgets/kernel/qaction_p.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 +#include #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 group; - QString text; - QString iconText; - QIcon icon; - QString tooltip; - QString statustip; - QString whatsthis; -#if QT_CONFIG(shortcut) - QKeySequence shortcut; - QList alternateShortcuts; -#endif - QVariant userData; -#if QT_CONFIG(shortcut) - int shortcutId = 0; - QVector alternateShortcutIds; - Qt::ShortcutContext shortcutContext = Qt::WindowShortcut; - uint autorepeat : 1; -#endif - QFont font; QPointer 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 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 -- cgit v1.2.3