diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-18 09:07:37 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-25 12:12:39 +0200 |
commit | dff3843d98d52e2c32fea07371f91117de0667e9 (patch) | |
tree | 028199eebf8d92722de91412e32352c54cbd5183 /src/gui | |
parent | 5d5a0842dc87645eab468389198750adc01b0618 (diff) |
QShortcut: Properly port to the new configure system
Move the feature to corelib so that the QMetaType enumeration
values can be properly excluded and there is no need for a
dummy class.
Use QT_REQUIRE_CONFIG in the headers of classes to be disabled.
Add headers/source files in the .pro file depending on the configure
feature in libraries and tests.
Add the necessary exclusions and use QT_CONFIG.
Task-number: QTBUG-76493
Change-Id: I02499ebee1a3d6d9a1e5afd02517beed5f4536b7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/configure.json | 6 | ||||
-rw-r--r-- | src/gui/kernel/kernel.pri | 15 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 12 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 7 | ||||
-rw-r--r-- | src/gui/kernel/qguivariant.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qkeymapper_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.h | 16 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence_p.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatformmenu.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 8 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme_p.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qshortcutmap.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qshortcutmap_p.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 4 |
17 files changed, 60 insertions, 68 deletions
diff --git a/src/gui/configure.json b/src/gui/configure.json index 39b8d0c2b8..90d0c8c134 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1637,12 +1637,6 @@ "condition": "features.imageformat_xpm", "output": [ "publicFeature", "feature" ] }, - "shortcut": { - "label": "QShortcut", - "purpose": "Provides keyboard accelerators and shortcuts.", - "section": "Kernel", - "output": [ "publicFeature", "feature" ] - }, "action": { "label": "QAction", "purpose": "Provides widget actions.", diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 9c80f1e2cc..237a1c0a3f 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -48,11 +48,8 @@ HEADERS += \ kernel/qinputmethod.h \ kernel/qinputmethod_p.h \ kernel/qinternalmimedata_p.h \ - kernel/qkeysequence.h \ - kernel/qkeysequence_p.h \ kernel/qkeymapper_p.h \ kernel/qpalette.h \ - kernel/qshortcutmap_p.h \ kernel/qsessionmanager.h \ kernel/qsessionmanager_p.h \ kernel/qwindowdefs.h \ @@ -108,12 +105,10 @@ SOURCES += \ kernel/qevent.cpp \ kernel/qinputmethod.cpp \ kernel/qinternalmimedata.cpp \ - kernel/qkeysequence.cpp \ kernel/qkeymapper.cpp \ kernel/qpalette.cpp \ kernel/qguivariant.cpp \ kernel/qscreen.cpp \ - kernel/qshortcutmap.cpp \ kernel/qstylehints.cpp \ kernel/qtouchdevice.cpp \ kernel/qplatformsharedgraphicscache.cpp \ @@ -160,4 +155,14 @@ qtConfig(opengl) { kernel/qopenglwindow.cpp } +qtConfig(shortcut) { + HEADERS += \ + kernel/qshortcutmap_p.h \ + kernel/qkeysequence.h \ + kernel/qkeysequence_p.h + SOURCES += \ + kernel/qshortcutmap.cpp \ + kernel/qkeysequence.cpp +} + win32:HEADERS+=kernel/qwindowdefs_win.h diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f2f083c277..54502bc6a3 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1224,7 +1224,7 @@ Qt::KeyboardModifiers QKeyEvent::modifiers() const return QInputEvent::modifiers(); } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) /*! \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const \since 4.2 @@ -1240,7 +1240,7 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey); return bindings.contains(QKeySequence(searchkey)); } -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) /*! @@ -3581,7 +3581,7 @@ QToolBarChangeEvent::~QToolBarChangeEvent() #endif // QT_NO_TOOLBAR -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) /*! Constructs a shortcut event for the given \a key press, @@ -3602,7 +3602,7 @@ QShortcutEvent::~QShortcutEvent() { } -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) #ifndef QT_NO_DEBUG_STREAM @@ -3956,7 +3956,7 @@ QT_WARNING_POP dbg << ')'; } break; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) case QEvent::Shortcut: { const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e); dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId(); diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 8a0e42f592..28aa78a420 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -45,7 +45,9 @@ #include <QtGui/qregion.h> #include <QtCore/qnamespace.h> #include <QtCore/qstring.h> -#include <QtGui/qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <QtGui/qkeysequence.h> +#endif #include <QtCore/qcoreevent.h> #include <QtCore/qvariant.h> #include <QtCore/qmap.h> // ### Qt 6: Remove @@ -375,7 +377,7 @@ public: ~QKeyEvent(); int key() const { return k; } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) bool matches(QKeySequence::StandardKey key) const; #endif Qt::KeyboardModifiers modifiers() const; @@ -792,7 +794,7 @@ private: }; #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) class Q_GUI_EXPORT QShortcutEvent : public QEvent { public: @@ -827,10 +829,10 @@ private: Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *); #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);} inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) class Q_GUI_EXPORT QPointingDeviceUniqueId { diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index e28607bad6..73d137619e 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -62,7 +62,10 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface_p.h> -#include "private/qshortcutmap_p.h" +#if QT_CONFIG(shortcut) +# include "private/qshortcutmap_p.h" +#endif + #include <qicon.h> QT_BEGIN_NAMESPACE @@ -261,7 +264,7 @@ public: QIcon forcedWindowIcon; static QList<QObject *> generic_plugin_list; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) QShortcutMap shortcutMap; #endif diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index edca8d9423..2d6d12cc21 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -44,7 +44,9 @@ #include "qcursor.h" #include "qfont.h" #include "qimage.h" -#include "qkeysequence.h" +#if QT_CONFIG(shortcut) +# include "qkeysequence.h" +#endif #include "qtransform.h" #include "qmatrix.h" #include "qpalette.h" @@ -188,7 +190,7 @@ static bool convert(const QVariant::Private *d, int t, case QVariant::String: { QString *str = static_cast<QString *>(result); switch (d->type) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) case QVariant::KeySequence: *str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText); return true; @@ -238,7 +240,7 @@ static bool convert(const QVariant::Private *d, int t, return true; } break; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) case QVariant::Int: if (d->type == QVariant::KeySequence) { const QKeySequence &seq = *v_cast<QKeySequence>(d); @@ -277,7 +279,7 @@ static bool convert(const QVariant::Private *d, int t, return true; } break; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) case QVariant::KeySequence: { QKeySequence *seq = static_cast<QKeySequence *>(result); switch (d->type) { diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 8364557020..fd53747fdd 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -53,7 +53,6 @@ #include <QtGui/private/qtguiglobal_p.h> #include <qobject.h> #include <private/qobject_p.h> -#include <qkeysequence.h> #include <qlist.h> #include <qlocale.h> #include <qevent.h> diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 2a86b340af..25766467eb 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -42,8 +42,6 @@ #include <qpa/qplatformtheme.h> #include "private/qguiapplication_p.h" -#if !defined(QT_NO_SHORTCUT) || defined(Q_CLANG_QDOC) - #include "qdebug.h" #include <QtCore/qhashfunctions.h> #ifndef QT_NO_DATASTREAM @@ -1673,9 +1671,6 @@ QDebug operator<<(QDebug dbg, const QKeySequence &p) } #endif -#endif // QT_NO_SHORTCUT - - /*! \typedef QKeySequence::DataPtr \internal diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h index 3dcbbe5941..68f256c37a 100644 --- a/src/gui/kernel/qkeysequence.h +++ b/src/gui/kernel/qkeysequence.h @@ -44,10 +44,9 @@ #include <QtCore/qstring.h> #include <QtCore/qobjectdefs.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(shortcut); -#if !defined(QT_NO_SHORTCUT) || defined(Q_CLANG_QDOC) +QT_BEGIN_NAMESPACE class QKeySequence; @@ -227,17 +226,6 @@ Q_DECLARE_SHARED(QKeySequence) Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &); #endif -#else - -class Q_GUI_EXPORT QKeySequence -{ -public: - QKeySequence() {} - QKeySequence(int) {} -}; - -#endif // QT_NO_SHORTCUT - QT_END_NAMESPACE #endif // QKEYSEQUENCE_H diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h index fbcab5d34e..8c59505561 100644 --- a/src/gui/kernel/qkeysequence_p.h +++ b/src/gui/kernel/qkeysequence_p.h @@ -56,9 +56,10 @@ #include <algorithm> +QT_REQUIRE_CONFIG(shortcut); + QT_BEGIN_NAMESPACE -#ifndef QT_NO_SHORTCUT struct QKeyBinding { QKeySequence::StandardKey standardKey; @@ -87,7 +88,6 @@ public: Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format); static int decodeString(QString accel, QKeySequence::SequenceFormat format); }; -#endif // QT_NO_SHORTCUT QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index 28c29a704c..8e470aefd3 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -52,7 +52,9 @@ #include <QtGui/qtguiglobal.h> #include <QtCore/qpointer.h> #include <QtGui/QFont> -#include <QtGui/QKeySequence> +#if QT_CONFIG(shortcut) +# include <QtGui/QKeySequence> +#endif #include <QtGui/QIcon> QT_BEGIN_NAMESPACE @@ -85,7 +87,7 @@ public: virtual void setRole(MenuRole role) = 0; virtual void setCheckable(bool checkable) = 0; virtual void setChecked(bool isChecked) = 0; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) virtual void setShortcut(const QKeySequence& shortcut) = 0; #endif virtual void setEnabled(bool enabled) = 0; diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index f906f808d8..ff6f32de10 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -167,7 +167,7 @@ QT_BEGIN_NAMESPACE */ -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) // Table of key bindings. It must be sorted on key sequence: // The integer value of VK_KEY | Modifier Keys (e.g., VK_META, and etc.) // A priority of 1 indicates that this is the primary key binding when multiple are defined. @@ -623,7 +623,7 @@ static inline int maybeSwapShortcut(int shortcut) } #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) // mixed-mode predicate: all of these overloads are actually needed (but not all for every compiler) struct ByStandardKey { typedef bool result_type; @@ -688,6 +688,7 @@ QString QPlatformTheme::standardButtonText(int button) const return QPlatformTheme::defaultStandardButtonText(button); } +#if QT_CONFIG(shortcut) /*! Returns the mnemonic that should be used for a standard \a button. @@ -700,6 +701,7 @@ QKeySequence QPlatformTheme::standardButtonShortcut(int button) const Q_UNUSED(button) return QKeySequence(); } +#endif // QT_CONFIG(shortcut) QString QPlatformTheme::defaultStandardButtonText(int button) { @@ -784,7 +786,7 @@ unsigned QPlatformThemePrivate::currentKeyPlatforms() { const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt(); unsigned result = 1u << keyboardScheme; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme || keyboardScheme == QPlatformTheme::CdeKeyboardScheme) diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 356c4ea3ea..7b88af954c 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -51,7 +51,9 @@ #include <QtGui/qtguiglobal.h> #include <QtCore/QScopedPointer> -#include <QtGui/QKeySequence> +#if QT_CONFIG(shortcut) +# include <QtGui/QKeySequence> +#endif QT_BEGIN_NAMESPACE @@ -312,12 +314,14 @@ public: QPlatformTheme::IconOptions iconOptions = nullptr) const; virtual QIconEngine *createIconEngine(const QString &iconName) const; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const; #endif virtual QString standardButtonText(int button) const; +#if QT_CONFIG(shortcut) virtual QKeySequence standardButtonShortcut(int button) const; +#endif static QVariant defaultThemeHint(ThemeHint hint); static QString defaultStandardButtonText(int button); diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h index 73deb890bb..2c16fec141 100644 --- a/src/gui/kernel/qplatformtheme_p.h +++ b/src/gui/kernel/qplatformtheme_p.h @@ -52,7 +52,9 @@ // #include <QtGui/private/qtguiglobal_p.h> -#include "private/qkeysequence_p.h" +#if QT_CONFIG(shortcut) +# include "private/qkeysequence_p.h" +#endif QT_BEGIN_NAMESPACE @@ -67,7 +69,7 @@ public: void initializeSystemPalette(); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) static const QKeyBinding keyBindings[]; static const uint numberOfKeyBindings; #endif diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 0395c1db38..b5cd342138 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -48,8 +48,6 @@ #include <algorithm> -#ifndef QT_NO_SHORTCUT - QT_BEGIN_NAMESPACE // To enable verbose output uncomment below @@ -714,5 +712,3 @@ void QShortcutMap::dumpMap() const #endif QT_END_NAMESPACE - -#endif // QT_NO_SHORTCUT diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h index 8fc68229fb..aa3dd969f0 100644 --- a/src/gui/kernel/qshortcutmap_p.h +++ b/src/gui/kernel/qshortcutmap_p.h @@ -56,9 +56,9 @@ #include "QtCore/qvector.h" #include "QtCore/qscopedpointer.h" -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(shortcut); -#ifndef QT_NO_SHORTCUT +QT_BEGIN_NAMESPACE // To enable dump output uncomment below //#define Dump_QShortcutMap @@ -106,8 +106,6 @@ private: QScopedPointer<QShortcutMapPrivate> d_ptr; }; -#endif // QT_NO_SHORTCUT - QT_END_NAMESPACE #endif // QSHORTCUTMAP_P_H diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 5f61853a6d..5ae8013b82 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -434,7 +434,7 @@ void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong t bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text, bool autorepeat, ushort count) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (!window) window = QGuiApplication::focusWindow(); @@ -1238,7 +1238,7 @@ Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt:: Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) // FIXME: This method should not allow targeting a specific object, but should // instead forward the event to a window, which then takes care of normal event |