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>
This commit is contained in:
Friedemann Kleint 2019-10-18 09:07:37 +02:00
parent 5d5a0842dc
commit dff3843d98
64 changed files with 416 additions and 143 deletions

View File

@ -826,6 +826,12 @@
], ],
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"shortcut": {
"label": "QShortcut",
"purpose": "Provides keyboard accelerators and shortcuts.",
"section": "Kernel",
"output": [ "publicFeature", "feature" ]
},
"systemsemaphore": { "systemsemaphore": {
"label": "QSystemSemaphore", "label": "QSystemSemaphore",
"purpose": "Provides a general counting system semaphore.", "purpose": "Provides a general counting system semaphore.",

View File

@ -110,6 +110,7 @@
# define QT_FEATURE_renameat2 -1 # define QT_FEATURE_renameat2 -1
#endif #endif
#define QT_FEATURE_sharedmemory -1 #define QT_FEATURE_sharedmemory -1
#define QT_FEATURE_shortcut -1
#define QT_FEATURE_signaling_nan -1 #define QT_FEATURE_signaling_nan -1
#define QT_FEATURE_slog2 -1 #define QT_FEATURE_slog2 -1
#ifdef __GLIBC_PREREQ #ifdef __GLIBC_PREREQ

View File

@ -420,7 +420,10 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
case QVariant::UInt: case QVariant::UInt:
case QVariant::Bool: case QVariant::Bool:
case QVariant::Double: case QVariant::Double:
case QVariant::KeySequence: { #if QT_CONFIG(shortcut)
case QVariant::KeySequence:
#endif
{
result = v.toString(); result = v.toString();
if (result.contains(QChar::Null)) if (result.contains(QChar::Null))
result = QLatin1String("@String(") + result + QLatin1Char(')'); result = QLatin1String("@String(") + result + QLatin1Char(')');

View File

@ -151,6 +151,13 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QVariantHash, 28, QVariantHash) \ F(QVariantHash, 28, QVariantHash) \
F(QByteArrayList, 49, QByteArrayList) \ F(QByteArrayList, 49, QByteArrayList) \
#if QT_CONFIG(shortcut)
#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\
F(QKeySequence, 75, QKeySequence)
#else
#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)
#endif
#define QT_FOR_EACH_STATIC_GUI_CLASS(F)\ #define QT_FOR_EACH_STATIC_GUI_CLASS(F)\
F(QFont, 64, QFont) \ F(QFont, 64, QFont) \
F(QPixmap, 65, QPixmap) \ F(QPixmap, 65, QPixmap) \
@ -163,7 +170,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QRegion, 72, QRegion) \ F(QRegion, 72, QRegion) \
F(QBitmap, 73, QBitmap) \ F(QBitmap, 73, QBitmap) \
F(QCursor, 74, QCursor) \ F(QCursor, 74, QCursor) \
F(QKeySequence, 75, QKeySequence) \ QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F) \
F(QPen, 76, QPen) \ F(QPen, 76, QPen) \
F(QTextLength, 77, QTextLength) \ F(QTextLength, 77, QTextLength) \
F(QTextFormat, 78, QTextFormat) \ F(QTextFormat, 78, QTextFormat) \

View File

@ -2469,7 +2469,9 @@ static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] =
QVariant::DateTime, QVariant::DateTime,
QVariant::ByteArray, QVariant::ByteArray,
QVariant::BitArray, QVariant::BitArray,
#if QT_CONFIG(shortcut)
QVariant::KeySequence, QVariant::KeySequence,
#endif
QVariant::Pen, QVariant::Pen,
QVariant::LongLong, QVariant::LongLong,
QVariant::ULongLong, QVariant::ULongLong,
@ -2574,7 +2576,11 @@ void QVariant::save(QDataStream &s) const
typeId += 97; typeId += 97;
} else if (typeId == QMetaType::QSizePolicy) { } else if (typeId == QMetaType::QSizePolicy) {
typeId = 75; typeId = 75;
#if QT_CONFIG(shortcut)
} else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) {
#else
} else if (typeId >= QMetaType::QPen && typeId <= QMetaType::QQuaternion) {
#endif
// and as a result these types received lower ids too // and as a result these types received lower ids too
typeId +=1; typeId +=1;
} else if (typeId == QMetaType::QPolygonF) { } else if (typeId == QMetaType::QPolygonF) {
@ -3647,9 +3653,11 @@ bool QVariant::canConvert(int targetTypeId) const
if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
switch (uint(targetTypeId)) { switch (uint(targetTypeId)) {
case QVariant::Int: case QVariant::Int:
#if QT_CONFIG(shortcut)
if (currentType == QVariant::KeySequence) if (currentType == QVariant::KeySequence)
return true; return true;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
#endif
case QVariant::UInt: case QVariant::UInt:
case QVariant::LongLong: case QVariant::LongLong:
case QVariant::ULongLong: case QVariant::ULongLong:
@ -3672,11 +3680,16 @@ bool QVariant::canConvert(int targetTypeId) const
return currentType == QVariant::Color || currentType == QMetaType::Nullptr return currentType == QVariant::Color || currentType == QMetaType::Nullptr
|| ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));
case QVariant::String: case QVariant::String:
return currentType == QVariant::KeySequence || currentType == QVariant::Font return currentType == QVariant::Font
|| currentType == QVariant::Color || currentType == QMetaType::Nullptr || currentType == QVariant::Color || currentType == QMetaType::Nullptr
#if QT_CONFIG(shortcut)
|| currentType == QVariant::KeySequence
#endif
|| ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType));
#if QT_CONFIG(shortcut)
case QVariant::KeySequence: case QVariant::KeySequence:
return currentType == QVariant::String || currentType == QVariant::Int; return currentType == QVariant::String || currentType == QVariant::Int;
#endif
case QVariant::Font: case QVariant::Font:
return currentType == QVariant::String; return currentType == QVariant::String;
case QVariant::Color: case QVariant::Color:

View File

@ -184,7 +184,9 @@ class Q_CORE_EXPORT QVariant
Region = QMetaType::QRegion, Region = QMetaType::QRegion,
Bitmap = QMetaType::QBitmap, Bitmap = QMetaType::QBitmap,
Cursor = QMetaType::QCursor, Cursor = QMetaType::QCursor,
#if QT_CONFIG(shortcut)
KeySequence = QMetaType::QKeySequence, KeySequence = QMetaType::QKeySequence,
#endif
Pen = QMetaType::QPen, Pen = QMetaType::QPen,
TextLength = QMetaType::QTextLength, TextLength = QMetaType::QTextLength,
TextFormat = QMetaType::QTextFormat, TextFormat = QMetaType::QTextFormat,

View File

@ -1637,12 +1637,6 @@
"condition": "features.imageformat_xpm", "condition": "features.imageformat_xpm",
"output": [ "publicFeature", "feature" ] "output": [ "publicFeature", "feature" ]
}, },
"shortcut": {
"label": "QShortcut",
"purpose": "Provides keyboard accelerators and shortcuts.",
"section": "Kernel",
"output": [ "publicFeature", "feature" ]
},
"action": { "action": {
"label": "QAction", "label": "QAction",
"purpose": "Provides widget actions.", "purpose": "Provides widget actions.",

View File

@ -48,11 +48,8 @@ HEADERS += \
kernel/qinputmethod.h \ kernel/qinputmethod.h \
kernel/qinputmethod_p.h \ kernel/qinputmethod_p.h \
kernel/qinternalmimedata_p.h \ kernel/qinternalmimedata_p.h \
kernel/qkeysequence.h \
kernel/qkeysequence_p.h \
kernel/qkeymapper_p.h \ kernel/qkeymapper_p.h \
kernel/qpalette.h \ kernel/qpalette.h \
kernel/qshortcutmap_p.h \
kernel/qsessionmanager.h \ kernel/qsessionmanager.h \
kernel/qsessionmanager_p.h \ kernel/qsessionmanager_p.h \
kernel/qwindowdefs.h \ kernel/qwindowdefs.h \
@ -108,12 +105,10 @@ SOURCES += \
kernel/qevent.cpp \ kernel/qevent.cpp \
kernel/qinputmethod.cpp \ kernel/qinputmethod.cpp \
kernel/qinternalmimedata.cpp \ kernel/qinternalmimedata.cpp \
kernel/qkeysequence.cpp \
kernel/qkeymapper.cpp \ kernel/qkeymapper.cpp \
kernel/qpalette.cpp \ kernel/qpalette.cpp \
kernel/qguivariant.cpp \ kernel/qguivariant.cpp \
kernel/qscreen.cpp \ kernel/qscreen.cpp \
kernel/qshortcutmap.cpp \
kernel/qstylehints.cpp \ kernel/qstylehints.cpp \
kernel/qtouchdevice.cpp \ kernel/qtouchdevice.cpp \
kernel/qplatformsharedgraphicscache.cpp \ kernel/qplatformsharedgraphicscache.cpp \
@ -160,4 +155,14 @@ qtConfig(opengl) {
kernel/qopenglwindow.cpp 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 win32:HEADERS+=kernel/qwindowdefs_win.h

View File

@ -1224,7 +1224,7 @@ Qt::KeyboardModifiers QKeyEvent::modifiers() const
return QInputEvent::modifiers(); return QInputEvent::modifiers();
} }
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
/*! /*!
\fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
\since 4.2 \since 4.2
@ -1240,7 +1240,7 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey); const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey);
return bindings.contains(QKeySequence(searchkey)); return bindings.contains(QKeySequence(searchkey));
} }
#endif // QT_NO_SHORTCUT #endif // QT_CONFIG(shortcut)
/*! /*!
@ -3581,7 +3581,7 @@ QToolBarChangeEvent::~QToolBarChangeEvent()
#endif // QT_NO_TOOLBAR #endif // QT_NO_TOOLBAR
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
/*! /*!
Constructs a shortcut event for the given \a key press, 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 #ifndef QT_NO_DEBUG_STREAM
@ -3956,7 +3956,7 @@ QT_WARNING_POP
dbg << ')'; dbg << ')';
} }
break; break;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
case QEvent::Shortcut: { case QEvent::Shortcut: {
const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e); const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e);
dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId(); dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId();

View File

@ -45,7 +45,9 @@
#include <QtGui/qregion.h> #include <QtGui/qregion.h>
#include <QtCore/qnamespace.h> #include <QtCore/qnamespace.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h> # include <QtGui/qkeysequence.h>
#endif
#include <QtCore/qcoreevent.h> #include <QtCore/qcoreevent.h>
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
#include <QtCore/qmap.h> // ### Qt 6: Remove #include <QtCore/qmap.h> // ### Qt 6: Remove
@ -375,7 +377,7 @@ public:
~QKeyEvent(); ~QKeyEvent();
int key() const { return k; } int key() const { return k; }
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
bool matches(QKeySequence::StandardKey key) const; bool matches(QKeySequence::StandardKey key) const;
#endif #endif
Qt::KeyboardModifiers modifiers() const; Qt::KeyboardModifiers modifiers() const;
@ -792,7 +794,7 @@ private:
}; };
#endif #endif
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
class Q_GUI_EXPORT QShortcutEvent : public QEvent class Q_GUI_EXPORT QShortcutEvent : public QEvent
{ {
public: public:
@ -827,10 +829,10 @@ private:
Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *); Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
#endif #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==(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);} 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 class Q_GUI_EXPORT QPointingDeviceUniqueId
{ {

View File

@ -62,7 +62,10 @@
#include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h> #include <qpa/qwindowsysteminterface_p.h>
#if QT_CONFIG(shortcut)
# include "private/qshortcutmap_p.h" # include "private/qshortcutmap_p.h"
#endif
#include <qicon.h> #include <qicon.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -261,7 +264,7 @@ public:
QIcon forcedWindowIcon; QIcon forcedWindowIcon;
static QList<QObject *> generic_plugin_list; static QList<QObject *> generic_plugin_list;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
QShortcutMap shortcutMap; QShortcutMap shortcutMap;
#endif #endif

View File

@ -44,7 +44,9 @@
#include "qcursor.h" #include "qcursor.h"
#include "qfont.h" #include "qfont.h"
#include "qimage.h" #include "qimage.h"
#if QT_CONFIG(shortcut)
# include "qkeysequence.h" # include "qkeysequence.h"
#endif
#include "qtransform.h" #include "qtransform.h"
#include "qmatrix.h" #include "qmatrix.h"
#include "qpalette.h" #include "qpalette.h"
@ -188,7 +190,7 @@ static bool convert(const QVariant::Private *d, int t,
case QVariant::String: { case QVariant::String: {
QString *str = static_cast<QString *>(result); QString *str = static_cast<QString *>(result);
switch (d->type) { switch (d->type) {
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
case QVariant::KeySequence: case QVariant::KeySequence:
*str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText); *str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText);
return true; return true;
@ -238,7 +240,7 @@ static bool convert(const QVariant::Private *d, int t,
return true; return true;
} }
break; break;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
case QVariant::Int: case QVariant::Int:
if (d->type == QVariant::KeySequence) { if (d->type == QVariant::KeySequence) {
const QKeySequence &seq = *v_cast<QKeySequence>(d); const QKeySequence &seq = *v_cast<QKeySequence>(d);
@ -277,7 +279,7 @@ static bool convert(const QVariant::Private *d, int t,
return true; return true;
} }
break; break;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
case QVariant::KeySequence: { case QVariant::KeySequence: {
QKeySequence *seq = static_cast<QKeySequence *>(result); QKeySequence *seq = static_cast<QKeySequence *>(result);
switch (d->type) { switch (d->type) {

View File

@ -53,7 +53,6 @@
#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/private/qtguiglobal_p.h>
#include <qobject.h> #include <qobject.h>
#include <private/qobject_p.h> #include <private/qobject_p.h>
#include <qkeysequence.h>
#include <qlist.h> #include <qlist.h>
#include <qlocale.h> #include <qlocale.h>
#include <qevent.h> #include <qevent.h>

View File

@ -42,8 +42,6 @@
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
#include "private/qguiapplication_p.h" #include "private/qguiapplication_p.h"
#if !defined(QT_NO_SHORTCUT) || defined(Q_CLANG_QDOC)
#include "qdebug.h" #include "qdebug.h"
#include <QtCore/qhashfunctions.h> #include <QtCore/qhashfunctions.h>
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
@ -1673,9 +1671,6 @@ QDebug operator<<(QDebug dbg, const QKeySequence &p)
} }
#endif #endif
#endif // QT_NO_SHORTCUT
/*! /*!
\typedef QKeySequence::DataPtr \typedef QKeySequence::DataPtr
\internal \internal

View File

@ -44,11 +44,10 @@
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h> #include <QtCore/qobjectdefs.h>
QT_REQUIRE_CONFIG(shortcut);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if !defined(QT_NO_SHORTCUT) || defined(Q_CLANG_QDOC)
class QKeySequence; class QKeySequence;
/***************************************************************************** /*****************************************************************************
@ -227,17 +226,6 @@ Q_DECLARE_SHARED(QKeySequence)
Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &); Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
#endif #endif
#else
class Q_GUI_EXPORT QKeySequence
{
public:
QKeySequence() {}
QKeySequence(int) {}
};
#endif // QT_NO_SHORTCUT
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QKEYSEQUENCE_H #endif // QKEYSEQUENCE_H

View File

@ -56,9 +56,10 @@
#include <algorithm> #include <algorithm>
QT_REQUIRE_CONFIG(shortcut);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHORTCUT
struct QKeyBinding struct QKeyBinding
{ {
QKeySequence::StandardKey standardKey; QKeySequence::StandardKey standardKey;
@ -87,7 +88,6 @@ public:
Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format); Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format);
static int decodeString(QString accel, QKeySequence::SequenceFormat format); static int decodeString(QString accel, QKeySequence::SequenceFormat format);
}; };
#endif // QT_NO_SHORTCUT
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -52,7 +52,9 @@
#include <QtGui/qtguiglobal.h> #include <QtGui/qtguiglobal.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtGui/QFont> #include <QtGui/QFont>
#if QT_CONFIG(shortcut)
# include <QtGui/QKeySequence> # include <QtGui/QKeySequence>
#endif
#include <QtGui/QIcon> #include <QtGui/QIcon>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -85,7 +87,7 @@ public:
virtual void setRole(MenuRole role) = 0; virtual void setRole(MenuRole role) = 0;
virtual void setCheckable(bool checkable) = 0; virtual void setCheckable(bool checkable) = 0;
virtual void setChecked(bool isChecked) = 0; virtual void setChecked(bool isChecked) = 0;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
virtual void setShortcut(const QKeySequence& shortcut) = 0; virtual void setShortcut(const QKeySequence& shortcut) = 0;
#endif #endif
virtual void setEnabled(bool enabled) = 0; virtual void setEnabled(bool enabled) = 0;

View File

@ -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: // 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.) // 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. // 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 #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) // mixed-mode predicate: all of these overloads are actually needed (but not all for every compiler)
struct ByStandardKey { struct ByStandardKey {
typedef bool result_type; typedef bool result_type;
@ -688,6 +688,7 @@ QString QPlatformTheme::standardButtonText(int button) const
return QPlatformTheme::defaultStandardButtonText(button); return QPlatformTheme::defaultStandardButtonText(button);
} }
#if QT_CONFIG(shortcut)
/*! /*!
Returns the mnemonic that should be used for a standard \a button. 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) Q_UNUSED(button)
return QKeySequence(); return QKeySequence();
} }
#endif // QT_CONFIG(shortcut)
QString QPlatformTheme::defaultStandardButtonText(int button) QString QPlatformTheme::defaultStandardButtonText(int button)
{ {
@ -784,7 +786,7 @@ unsigned QPlatformThemePrivate::currentKeyPlatforms()
{ {
const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt(); const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
unsigned result = 1u << keyboardScheme; unsigned result = 1u << keyboardScheme;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
|| keyboardScheme == QPlatformTheme::GnomeKeyboardScheme || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
|| keyboardScheme == QPlatformTheme::CdeKeyboardScheme) || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)

View File

@ -51,7 +51,9 @@
#include <QtGui/qtguiglobal.h> #include <QtGui/qtguiglobal.h>
#include <QtCore/QScopedPointer> #include <QtCore/QScopedPointer>
#if QT_CONFIG(shortcut)
# include <QtGui/QKeySequence> # include <QtGui/QKeySequence>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -312,12 +314,14 @@ public:
QPlatformTheme::IconOptions iconOptions = nullptr) const; QPlatformTheme::IconOptions iconOptions = nullptr) const;
virtual QIconEngine *createIconEngine(const QString &iconName) const; virtual QIconEngine *createIconEngine(const QString &iconName) const;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const; virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
#endif #endif
virtual QString standardButtonText(int button) const; virtual QString standardButtonText(int button) const;
#if QT_CONFIG(shortcut)
virtual QKeySequence standardButtonShortcut(int button) const; virtual QKeySequence standardButtonShortcut(int button) const;
#endif
static QVariant defaultThemeHint(ThemeHint hint); static QVariant defaultThemeHint(ThemeHint hint);
static QString defaultStandardButtonText(int button); static QString defaultStandardButtonText(int button);

View File

@ -52,7 +52,9 @@
// //
#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/private/qtguiglobal_p.h>
#if QT_CONFIG(shortcut)
# include "private/qkeysequence_p.h" # include "private/qkeysequence_p.h"
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -67,7 +69,7 @@ public:
void initializeSystemPalette(); void initializeSystemPalette();
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
static const QKeyBinding keyBindings[]; static const QKeyBinding keyBindings[];
static const uint numberOfKeyBindings; static const uint numberOfKeyBindings;
#endif #endif

View File

@ -48,8 +48,6 @@
#include <algorithm> #include <algorithm>
#ifndef QT_NO_SHORTCUT
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
// To enable verbose output uncomment below // To enable verbose output uncomment below
@ -714,5 +712,3 @@ void QShortcutMap::dumpMap() const
#endif #endif
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QT_NO_SHORTCUT

View File

@ -56,9 +56,9 @@
#include "QtCore/qvector.h" #include "QtCore/qvector.h"
#include "QtCore/qscopedpointer.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 // To enable dump output uncomment below
//#define Dump_QShortcutMap //#define Dump_QShortcutMap
@ -106,8 +106,6 @@ private:
QScopedPointer<QShortcutMapPrivate> d_ptr; QScopedPointer<QShortcutMapPrivate> d_ptr;
}; };
#endif // QT_NO_SHORTCUT
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QSHORTCUTMAP_P_H #endif // QSHORTCUTMAP_P_H

View File

@ -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, 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) quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text, bool autorepeat, ushort count)
{ {
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
if (!window) if (!window)
window = QGuiApplication::focusWindow(); 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) 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 // 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 // instead forward the event to a window, which then takes care of normal event

View File

@ -48,7 +48,9 @@
#include <QDebug> #include <QDebug>
#include <QtEndian> #include <QtEndian>
#include <QBuffer> #include <QBuffer>
#if QT_CONFIG(shortcut)
# include <private/qkeysequence_p.h> # include <private/qkeysequence_p.h>
#endif
#include <qpa/qplatformmenu.h> #include <qpa/qplatformmenu.h>
#include "qdbusplatformmenu_p.h" #include "qdbusplatformmenu_p.h"

View File

@ -96,7 +96,7 @@ public:
void setChecked(bool isChecked) override; void setChecked(bool isChecked) override;
bool hasExclusiveGroup() const { return m_hasExclusiveGroup; } bool hasExclusiveGroup() const { return m_hasExclusiveGroup; }
void setHasExclusiveGroup(bool hasExclusiveGroup) override; void setHasExclusiveGroup(bool hasExclusiveGroup) override;
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
QKeySequence shortcut() const { return m_shortcut; } QKeySequence shortcut() const { return m_shortcut; }
void setShortcut(const QKeySequence& shortcut) override; void setShortcut(const QKeySequence& shortcut) override;
#endif #endif
@ -123,7 +123,9 @@ private:
bool m_hasExclusiveGroup : 1; bool m_hasExclusiveGroup : 1;
short /*unused*/ : 6; short /*unused*/ : 6;
short m_dbusID : 16; short m_dbusID : 16;
#if QT_CONFIG(shortcut)
QKeySequence m_shortcut; QKeySequence m_shortcut;
#endif
}; };
class QDBusPlatformMenu : public QPlatformMenu class QDBusPlatformMenu : public QPlatformMenu

View File

@ -54,7 +54,9 @@
#include <QtGui/qguiapplication.h> #include <QtGui/qguiapplication.h>
#include <QtGui/qwindow.h> #include <QtGui/qwindow.h>
#include <QtGui/qevent.h> #include <QtGui/qevent.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h> # include <QtGui/qkeysequence.h>
#endif
#ifdef QT_WIDGETS_LIB #ifdef QT_WIDGETS_LIB
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>

View File

@ -49,7 +49,9 @@
#include <qfontmetrics.h> #include <qfontmetrics.h>
#include <qaction.h> #include <qaction.h>
#include <qheaderview.h> #include <qheaderview.h>
#if QT_CONFIG(shortcut)
# include <qshortcut.h> # include <qshortcut.h>
#endif
#include <qgridlayout.h> #include <qgridlayout.h>
#if QT_CONFIG(menu) #if QT_CONFIG(menu)
#include <qmenu.h> #include <qmenu.h>
@ -344,7 +346,9 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
QT_BEGIN_INCLUDE_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE
#include <QMetaEnum> #include <QMetaEnum>
#if QT_CONFIG(shortcut)
# include <qshortcut.h> # include <qshortcut.h>
#endif
QT_END_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE
/*! /*!

View File

@ -39,7 +39,9 @@
#include "qprogressdialog.h" #include "qprogressdialog.h"
#if QT_CONFIG(shortcut)
# include "qshortcut.h" # include "qshortcut.h"
#endif
#include "qpainter.h" #include "qpainter.h"
#include "qdrawutil.h" #include "qdrawutil.h"
#include "qlabel.h" #include "qlabel.h"

View File

@ -20,7 +20,6 @@ HEADERS += \
kernel/qlayout_p.h \ kernel/qlayout_p.h \
kernel/qlayoutengine_p.h \ kernel/qlayoutengine_p.h \
kernel/qlayoutitem.h \ kernel/qlayoutitem.h \
kernel/qshortcut.h \
kernel/qsizepolicy.h \ kernel/qsizepolicy.h \
kernel/qstackedlayout.h \ kernel/qstackedlayout.h \
kernel/qwidget.h \ kernel/qwidget.h \
@ -47,7 +46,6 @@ SOURCES += \
kernel/qlayout.cpp \ kernel/qlayout.cpp \
kernel/qlayoutengine.cpp \ kernel/qlayoutengine.cpp \
kernel/qlayoutitem.cpp \ kernel/qlayoutitem.cpp \
kernel/qshortcut.cpp \
kernel/qsizepolicy.cpp \ kernel/qsizepolicy.cpp \
kernel/qstackedlayout.cpp \ kernel/qstackedlayout.cpp \
kernel/qwidget.cpp \ kernel/qwidget.cpp \
@ -77,6 +75,11 @@ qtConfig(formlayout) {
SOURCES += kernel/qformlayout.cpp SOURCES += kernel/qformlayout.cpp
} }
qtConfig(shortcut) {
HEADERS += kernel/qshortcut.h
SOURCES += kernel/qshortcut.cpp
}
qtConfig(tooltip) { qtConfig(tooltip) {
HEADERS += kernel/qtooltip.h HEADERS += kernel/qtooltip.h
SOURCES += kernel/qtooltip.cpp SOURCES += kernel/qtooltip.cpp

View File

@ -46,7 +46,9 @@
#include "qevent.h" #include "qevent.h"
#include "qlist.h" #include "qlist.h"
#include "qstylehints.h" #include "qstylehints.h"
#if QT_CONFIG(shortcut)
# include <private/qshortcutmap_p.h> # include <private/qshortcutmap_p.h>
#endif
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#if QT_CONFIG(menu) #if QT_CONFIG(menu)
#include <private/qmenu_p.h> #include <private/qmenu_p.h>

View File

@ -41,7 +41,9 @@
#define QACTION_H #define QACTION_H
#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h> # include <QtGui/qkeysequence.h>
#endif
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>

View File

@ -40,7 +40,6 @@
#include "qshortcut.h" #include "qshortcut.h"
#include "private/qwidget_p.h" #include "private/qwidget_p.h"
#ifndef QT_NO_SHORTCUT
#include <qevent.h> #include <qevent.h>
#if QT_CONFIG(whatsthis) #if QT_CONFIG(whatsthis)
#include <qwhatsthis.h> #include <qwhatsthis.h>
@ -676,7 +675,6 @@ bool QShortcut::event(QEvent *e)
} }
return QObject::event(e); return QObject::event(e);
} }
#endif // QT_NO_SHORTCUT
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -44,11 +44,10 @@
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
#include <QtGui/qkeysequence.h> #include <QtGui/qkeysequence.h>
QT_REQUIRE_CONFIG(shortcut);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#ifndef QT_NO_SHORTCUT
class QShortcutPrivate; class QShortcutPrivate;
class Q_WIDGETS_EXPORT QShortcut : public QObject class Q_WIDGETS_EXPORT QShortcut : public QObject
{ {
@ -94,8 +93,6 @@ protected:
bool event(QEvent *e) override; bool event(QEvent *e) override;
}; };
#endif // QT_NO_SHORTCUT
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QSHORTCUT_H #endif // QSHORTCUT_H

View File

@ -53,7 +53,9 @@
#include <QtGui/qregion.h> #include <QtGui/qregion.h>
#include <QtGui/qbrush.h> #include <QtGui/qbrush.h>
#include <QtGui/qcursor.h> #include <QtGui/qcursor.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h> # include <QtGui/qkeysequence.h>
#endif
#ifdef QT_INCLUDE_COMPAT #ifdef QT_INCLUDE_COMPAT
#include <QtGui/qevent.h> #include <QtGui/qevent.h>

View File

@ -42,7 +42,9 @@
#include <QtWidgets/qtwidgetsglobal.h> #include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qicon.h> #include <QtGui/qicon.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h> # include <QtGui/qkeysequence.h>
#endif
#include <QtWidgets/qwidget.h> #include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(abstractbutton); QT_REQUIRE_CONFIG(abstractbutton);

View File

@ -78,7 +78,7 @@
#endif #endif
#include "private/qstylesheetstyle_p.h" #include "private/qstylesheetstyle_p.h"
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
#include "private/qapplication_p.h" #include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h" #include "private/qshortcutmap_p.h"
#include "qkeysequence.h" #include "qkeysequence.h"

View File

@ -403,7 +403,9 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
//calculate size //calculate size
QFontMetrics qfm = q->fontMetrics(); QFontMetrics qfm = q->fontMetrics();
bool previousWasSeparator = true; // this is true to allow removing the leading separators bool previousWasSeparator = true; // this is true to allow removing the leading separators
#if QT_CONFIG(shortcut)
const bool contextMenu = isContextMenu(); const bool contextMenu = isContextMenu();
#endif
for(int i = 0; i <= lastVisibleAction; i++) { for(int i = 0; i <= lastVisibleAction; i++) {
QAction *action = actions.at(i); QAction *action = actions.at(i);
const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull()); const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
@ -434,7 +436,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
if (t != -1) { if (t != -1) {
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1))); tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1)));
s = s.left(t); s = s.left(t);
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
} else if (action->isShortcutVisibleInContextMenu() || !contextMenu) { } else if (action->isShortcutVisibleInContextMenu() || !contextMenu) {
QKeySequence seq = action->shortcut(); QKeySequence seq = action->shortcut();
if (!seq.isEmpty()) if (!seq.isEmpty())
@ -1767,12 +1769,14 @@ QAction *QMenu::addAction(const QIcon &icon, const QString &text)
\sa QWidget::addAction() \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); QAction *action = new QAction(text, this);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut);
#else
action->setShortcut(shortcut); action->setShortcut(shortcut);
#endif #endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
@ -1860,12 +1864,14 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
\sa QWidget::addAction() \sa QWidget::addAction()
*/ */
QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, 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); QAction *action = new QAction(icon, text, this);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut);
#else
action->setShortcut(shortcut); action->setShortcut(shortcut);
#endif #endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);

View File

@ -78,8 +78,17 @@ public:
using QWidget::addAction; using QWidget::addAction;
QAction *addAction(const QString &text); QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, 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 #ifdef Q_CLANG_QDOC
template<typename Functor> template<typename Functor>
@ -95,12 +104,14 @@ public:
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type && 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); QAction *result = addAction(text);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut)
#else
result->setShortcut(shortcut); result->setShortcut(shortcut);
#endif #endif
connect(result, &QAction::triggered, object, std::move(slot)); connect(result, &QAction::triggered, object, std::move(slot));
@ -108,12 +119,14 @@ public:
} }
// addAction(QString): Connect to a functor or function pointer (without context) // addAction(QString): Connect to a functor or function pointer (without context)
template <typename Func1> 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); QAction *result = addAction(text);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut)
#else
result->setShortcut(shortcut); result->setShortcut(shortcut);
#endif #endif
connect(result, &QAction::triggered, std::move(slot)); connect(result, &QAction::triggered, std::move(slot));
@ -123,12 +136,15 @@ public:
template<class Obj, typename Func1> template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type && 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); QAction *result = addAction(actionIcon, text);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut)
#else
result->setShortcut(shortcut); result->setShortcut(shortcut);
#endif #endif
connect(result, &QAction::triggered, object, std::move(slot)); 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) // addAction(QIcon, QString): Connect to a functor or function pointer (without context)
template <typename Func1> 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); QAction *result = addAction(actionIcon, text);
#ifdef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
Q_UNUSED(shortcut)
#else
result->setShortcut(shortcut); result->setShortcut(shortcut);
#endif #endif
connect(result, &QAction::triggered, std::move(slot)); connect(result, &QAction::triggered, std::move(slot));

View File

@ -92,7 +92,7 @@
#include <QtGui/qaccessible.h> #include <QtGui/qaccessible.h>
#include <QtCore/qmetaobject.h> #include <QtCore/qmetaobject.h>
#ifndef QT_NO_SHORTCUT #if QT_CONFIG(shortcut)
#include "private/qapplication_p.h" #include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h" #include "private/qshortcutmap_p.h"
#include <qkeysequence.h> #include <qkeysequence.h>

View File

@ -39,7 +39,9 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QThread> #include <QtCore/QThread>
#include <QtCore/QSysInfo> #include <QtCore/QSysInfo>
#if QT_CONFIG(shortcut)
# include <QtGui/QKeySequence> # include <QtGui/QKeySequence>
#endif
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
@ -1364,6 +1366,7 @@ void tst_QSettings::testVariantTypes()
dt.setOffsetFromUtc(3600); dt.setOffsetFromUtc(3600);
testVal("key14", dt, QDateTime, DateTime); testVal("key14", dt, QDateTime, DateTime);
#if QT_CONFIG(shortcut)
// We store key sequences as strings instead of binary variant blob, for improved // We store key sequences as strings instead of binary variant blob, for improved
// readability in the resulting format. // readability in the resulting format.
if (format >= QSettings::InvalidFormat) { if (format >= QSettings::InvalidFormat) {
@ -1373,6 +1376,7 @@ void tst_QSettings::testVariantTypes()
QKeySequence(Qt::ControlModifier + Qt::Key_F1).toString(QKeySequence::NativeText), QKeySequence(Qt::ControlModifier + Qt::Key_F1).toString(QKeySequence::NativeText),
QString, String); QString, String);
} }
#endif // QT_CONFIG(shortcut)
#undef testVal #undef testVal
} }

View File

@ -2327,6 +2327,7 @@ void tst_QDataStream::setVersion()
QDataStream latest; QDataStream latest;
QFETCH(int, vers); QFETCH(int, vers);
#if QT_CONFIG(shortcut)
/* /*
Test QKeySequence. Test QKeySequence.
*/ */
@ -2351,6 +2352,7 @@ void tst_QDataStream::setVersion()
} }
QCOMPARE(deadbeef, 0xDEADBEEF); QCOMPARE(deadbeef, 0xDEADBEEF);
} }
#endif // QT_CONFIG(shortcut)
/* /*
Test QPalette. Test QPalette.

View File

@ -29,6 +29,11 @@ SUBDIRS=\
win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop
!qtConfig(shortcut): SUBDIRS -= \
qkeysequence \
qguimetatype \
qguivariant
!qtHaveModule(widgets): SUBDIRS -= \ !qtHaveModule(widgets): SUBDIRS -= \
qmouseevent_modal \ qmouseevent_modal \
qtouchevent qtouchevent

View File

@ -181,9 +181,13 @@ template<> struct TestValueFactory<QMetaType::QCursor> {
static QCursor *create() { return new QCursor(Qt::WaitCursor); } static QCursor *create() { return new QCursor(Qt::WaitCursor); }
}; };
#endif #endif
#if QT_CONFIG(shortcut)
template<> struct TestValueFactory<QMetaType::QKeySequence> { template<> struct TestValueFactory<QMetaType::QKeySequence> {
static QKeySequence *create() { return new QKeySequence(QKeySequence::Close); } static QKeySequence *create() { return new QKeySequence(QKeySequence::Close); }
}; };
#endif
template<> struct TestValueFactory<QMetaType::QPen> { template<> struct TestValueFactory<QMetaType::QPen> {
static QPen *create() { return new QPen(Qt::DashDotDotLine); } static QPen *create() { return new QPen(Qt::DashDotDotLine); }
}; };

View File

@ -64,8 +64,10 @@ public:
private slots: private slots:
void basicEventDelivery(); void basicEventDelivery();
#if QT_CONFIG(shortcut)
void modifiers_data(); void modifiers_data();
void modifiers(); void modifiers();
#endif
}; };
tst_QKeyEvent::tst_QKeyEvent() tst_QKeyEvent::tst_QKeyEvent()
@ -128,6 +130,8 @@ static QByteArray modifiersTestRowName(const QString &keySequence)
return result; return result;
} }
#if QT_CONFIG(shortcut)
void tst_QKeyEvent::modifiers_data() void tst_QKeyEvent::modifiers_data()
{ {
struct Modifier struct Modifier
@ -198,5 +202,7 @@ void tst_QKeyEvent::modifiers()
} }
} }
#endif // QT_CONFIG(shortcut)
QTEST_MAIN(tst_QKeyEvent) QTEST_MAIN(tst_QKeyEvent)
#include "tst_qkeyevent.moc" #include "tst_qkeyevent.moc"

View File

@ -203,11 +203,15 @@ private slots:
void applicationTest(); void applicationTest();
void mainWindowTest(); void mainWindowTest();
void subWindowTest(); void subWindowTest();
#if QT_CONFIG(shortcut)
void buttonTest(); void buttonTest();
#endif
void scrollBarTest(); void scrollBarTest();
void tabTest(); void tabTest();
void tabWidgetTest(); void tabWidgetTest();
#if QT_CONFIG(shortcut)
void menuTest(); void menuTest();
#endif
void spinBoxTest(); void spinBoxTest();
void doubleSpinBoxTest(); void doubleSpinBoxTest();
void textEditTest(); void textEditTest();
@ -234,8 +238,10 @@ private slots:
void dockWidgetTest(); void dockWidgetTest();
void comboBoxTest(); void comboBoxTest();
void accessibleName(); void accessibleName();
#if QT_CONFIG(shortcut)
void labelTest(); void labelTest();
void accelerators(); void accelerators();
#endif
void bridgeTest(); void bridgeTest();
protected slots: protected slots:
@ -1026,6 +1032,8 @@ public Q_SLOTS:
} }
}; };
#if QT_CONFIG(shortcut)
void tst_QAccessibility::buttonTest() void tst_QAccessibility::buttonTest()
{ {
QWidget window; QWidget window;
@ -1198,6 +1206,8 @@ void tst_QAccessibility::buttonTest()
// test->release(); // test->release();
} }
#endif // QT_CONFIG(shortcut)
void tst_QAccessibility::scrollBarTest() void tst_QAccessibility::scrollBarTest()
{ {
QScrollBar *scrollBar = new QScrollBar(Qt::Horizontal); QScrollBar *scrollBar = new QScrollBar(Qt::Horizontal);
@ -1407,6 +1417,8 @@ void tst_QAccessibility::tabWidgetTest()
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
} }
#if QT_CONFIG(shortcut)
void tst_QAccessibility::menuTest() void tst_QAccessibility::menuTest()
{ {
{ {
@ -1617,6 +1629,8 @@ void tst_QAccessibility::menuTest()
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
} }
#endif // QT_CONFIG(shortcut)
void tst_QAccessibility::spinBoxTest() void tst_QAccessibility::spinBoxTest()
{ {
QSpinBox * const spinBox = new QSpinBox(); QSpinBox * const spinBox = new QSpinBox();
@ -3629,6 +3643,8 @@ void tst_QAccessibility::comboBoxTest()
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
} }
#if QT_CONFIG(shortcut)
void tst_QAccessibility::labelTest() void tst_QAccessibility::labelTest()
{ {
QWidget *window = new QWidget; QWidget *window = new QWidget;
@ -3729,6 +3745,8 @@ void tst_QAccessibility::accelerators()
QTestAccessibility::clearEvents(); QTestAccessibility::clearEvents();
} }
#endif // QT_CONFIG(shortcut)
#ifdef QT_SUPPORTS_IACCESSIBLE2 #ifdef QT_SUPPORTS_IACCESSIBLE2
static IUnknown *queryIA2(IAccessible *acc, const IID &iid) static IUnknown *queryIA2(IAccessible *acc, const IID &iid)
{ {

View File

@ -91,7 +91,9 @@ private slots:
void checkReason_BackTab(); void checkReason_BackTab();
void checkReason_Popup(); void checkReason_Popup();
void checkReason_focusWidget(); void checkReason_focusWidget();
#if QT_CONFIG(shortcut)
void checkReason_Shortcut(); void checkReason_Shortcut();
#endif
void checkReason_ActiveWindow(); void checkReason_ActiveWindow();
private: private:
@ -250,6 +252,8 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE QT_END_NAMESPACE
#endif #endif
#if QT_CONFIG(shortcut)
void tst_QFocusEvent::checkReason_Shortcut() void tst_QFocusEvent::checkReason_Shortcut()
{ {
initWidget(); initWidget();
@ -288,6 +292,8 @@ void tst_QFocusEvent::checkReason_Shortcut()
#endif #endif
} }
#endif // QT_CONFIG(shortcut)
void tst_QFocusEvent::checkReason_focusWidget() void tst_QFocusEvent::checkReason_focusWidget()
{ {
// This test checks that a widget doesn't loose // This test checks that a widget doesn't loose

View File

@ -96,8 +96,9 @@ private slots:
void task248107_backButton(); void task248107_backButton();
void task255350_fieldObjectDestroyed(); void task255350_fieldObjectDestroyed();
void taskQTBUG_25691_fieldObjectDestroyed2(); void taskQTBUG_25691_fieldObjectDestroyed2();
#if QT_CONFIG(shortcut)
void taskQTBUG_46894_nextButtonShortcut(); void taskQTBUG_46894_nextButtonShortcut();
#endif
/* /*
Things that could be added: Things that could be added:
@ -2703,6 +2704,8 @@ void tst_QWizard::taskQTBUG_25691_fieldObjectDestroyed2()
::taskQTBUG_25691_fieldObjectDestroyed2(); ::taskQTBUG_25691_fieldObjectDestroyed2();
} }
#if QT_CONFIG(shortcut)
void tst_QWizard::taskQTBUG_46894_nextButtonShortcut() void tst_QWizard::taskQTBUG_46894_nextButtonShortcut()
{ {
for (int i = 0; i < QWizard::NStyles; ++i) { for (int i = 0; i < QWizard::NStyles; ++i) {
@ -2717,5 +2720,7 @@ void tst_QWizard::taskQTBUG_46894_nextButtonShortcut()
} }
} }
#endif // QT_CONFIG(shortcut)
QTEST_MAIN(tst_QWizard) QTEST_MAIN(tst_QWizard)
#include "tst_qwizard.moc" #include "tst_qwizard.moc"

View File

@ -450,7 +450,9 @@ private slots:
void modality_keyEvents(); void modality_keyEvents();
void itemIsInFront(); void itemIsInFront();
void scenePosChange(); void scenePosChange();
#if QT_CONFIG(shortcut)
void textItem_shortcuts(); void textItem_shortcuts();
#endif
void scroll(); void scroll();
void focusHandling_data(); void focusHandling_data();
void focusHandling(); void focusHandling();
@ -10813,6 +10815,8 @@ void tst_QGraphicsItem::scenePosChange()
QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
} }
#if QT_CONFIG(shortcut)
void tst_QGraphicsItem::textItem_shortcuts() void tst_QGraphicsItem::textItem_shortcuts()
{ {
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
@ -10852,6 +10856,8 @@ void tst_QGraphicsItem::textItem_shortcuts()
QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText());
} }
#endif // QT_CONFIG(shortcut)
void tst_QGraphicsItem::scroll() void tst_QGraphicsItem::scroll()
{ {
// Create two overlapping rectangles in the scene: // Create two overlapping rectangles in the scene:

View File

@ -331,8 +331,10 @@ private slots:
void selectColumn_data(); void selectColumn_data();
void selectColumn(); void selectColumn();
#if QT_CONFIG(shortcut)
void selectall_data(); void selectall_data();
void selectall(); void selectall();
#endif
void visualRect_data(); void visualRect_data();
void visualRect(); void visualRect();
@ -1842,6 +1844,8 @@ void tst_QTableView::selectColumn()
QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column); QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column);
} }
#if QT_CONFIG(shortcut)
void tst_QTableView::selectall_data() void tst_QTableView::selectall_data()
{ {
QTest::addColumn<int>("rowCount"); QTest::addColumn<int>("rowCount");
@ -1998,6 +2002,8 @@ void tst_QTableView::selectall()
QCOMPARE(view.selectedIndexes().count(), 0); QCOMPARE(view.selectedIndexes().count(), 0);
} }
#endif // QT_CONFIG(shortcut)
void tst_QTableView::visualRect_data() void tst_QTableView::visualRect_data()
{ {
QTest::addColumn<int>("rowCount"); QTest::addColumn<int>("rowCount");

View File

@ -22,3 +22,6 @@ SUBDIRS=\
darwin:SUBDIRS -= \ # Uses native recognizers darwin:SUBDIRS -= \ # Uses native recognizers
qgesturerecognizer \ qgesturerecognizer \
!qtConfig(shortcut): SUBDIRS -= \
qshortcut

View File

@ -57,18 +57,24 @@ private slots:
void setIconText(); void setIconText();
void setUnknownFont(); void setUnknownFont();
void actionEvent(); void actionEvent();
#if QT_CONFIG(shortcut)
void setStandardKeys(); void setStandardKeys();
void alternateShortcuts(); void alternateShortcuts();
void enabledVisibleInteraction(); void enabledVisibleInteraction();
void task200823_tooltip(); void task200823_tooltip();
#endif
void task229128TriggeredSignalWithoutActiongroup(); void task229128TriggeredSignalWithoutActiongroup();
void task229128TriggeredSignalWhenInActiongroup(); void task229128TriggeredSignalWhenInActiongroup();
#if QT_CONFIG(shortcut)
void repeat(); void repeat();
#endif
void setData(); void setData();
#if QT_CONFIG(shortcut)
void keysequence(); // QTBUG-53381 void keysequence(); // QTBUG-53381
void disableShortcutsWithBlockedWidgets_data(); void disableShortcutsWithBlockedWidgets_data();
void disableShortcutsWithBlockedWidgets(); void disableShortcutsWithBlockedWidgets();
void shortcutFromKeyEvent(); // QTBUG-48325 void shortcutFromKeyEvent(); // QTBUG-48325
#endif
private: private:
QEvent::Type m_lastEventType; QEvent::Type m_lastEventType;
@ -221,6 +227,8 @@ void tst_QAction::actionEvent()
QCOMPARE(m_lastAction, &a); QCOMPARE(m_lastAction, &a);
} }
#if QT_CONFIG(shortcut)
//basic testing of standard keys //basic testing of standard keys
void tst_QAction::setStandardKeys() void tst_QAction::setStandardKeys()
{ {
@ -367,6 +375,8 @@ void tst_QAction::task200823_tooltip()
QCOMPARE(action->toolTip(), ref); QCOMPARE(action->toolTip(), ref);
} }
#endif // QT_CONFIG(shortcut)
void tst_QAction::task229128TriggeredSignalWithoutActiongroup() void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{ {
// test without a group // test without a group
@ -408,6 +418,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
QCOMPARE(actionSpy.count(), 1); QCOMPARE(actionSpy.count(), 1);
} }
#if QT_CONFIG(shortcut)
void tst_QAction::repeat() void tst_QAction::repeat()
{ {
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
@ -452,6 +464,8 @@ void tst_QAction::repeat()
QCOMPARE(spy.count(), 2); QCOMPARE(spy.count(), 2);
} }
#endif // QT_CONFIG(shortcut)
void tst_QAction::setData() // QTBUG-62006 void tst_QAction::setData() // QTBUG-62006
{ {
QAction act(nullptr); QAction act(nullptr);
@ -467,6 +481,8 @@ void tst_QAction::setData() // QTBUG-62006
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
} }
#if QT_CONFIG(shortcut)
void tst_QAction::disableShortcutsWithBlockedWidgets_data() void tst_QAction::disableShortcutsWithBlockedWidgets_data()
{ {
QTest::addColumn<Qt::ShortcutContext>("shortcutContext"); QTest::addColumn<Qt::ShortcutContext>("shortcutContext");
@ -556,5 +572,7 @@ void tst_QAction::shortcutFromKeyEvent()
QCOMPARE(testWidget.shortcutOverrideCount, 1); QCOMPARE(testWidget.shortcutOverrideCount, 1);
} }
#endif // QT_CONFIG(shortcut)
QTEST_MAIN(tst_QAction) QTEST_MAIN(tst_QAction)
#include "tst_qaction.moc" #include "tst_qaction.moc"

View File

@ -99,7 +99,9 @@ class tst_QFormLayout : public QObject
private slots: private slots:
void cleanup(); void cleanup();
void rowCount(); void rowCount();
#if QT_CONFIG(shortcut)
void buddies(); void buddies();
#endif
void getItemPosition(); void getItemPosition();
void wrapping(); void wrapping();
void spacing(); void spacing();
@ -190,6 +192,8 @@ void tst_QFormLayout::rowCount()
//TODO: remove items //TODO: remove items
} }
#if QT_CONFIG(shortcut)
void tst_QFormLayout::buddies() void tst_QFormLayout::buddies()
{ {
QWidget w; QWidget w;
@ -218,6 +222,8 @@ void tst_QFormLayout::buddies()
//TODO: empty label? //TODO: empty label?
} }
#endif // QT_CONFIG(shortcut)
void tst_QFormLayout::getItemPosition() void tst_QFormLayout::getItemPosition()
{ {
QWidget w; QWidget w;
@ -687,17 +693,21 @@ void tst_QFormLayout::insertRow_QString_QWidget()
layout->insertRow(-5, "&Name:", fld1); layout->insertRow(-5, "&Name:", fld1);
QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0); QVERIFY(label1 != 0);
#if QT_CONFIG(shortcut)
QCOMPARE(label1->buddy(), fld1); QCOMPARE(label1->buddy(), fld1);
#endif
layout->insertRow(0, "&Email:", fld2); layout->insertRow(0, "&Email:", fld2);
QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0); QVERIFY(label2 != 0);
#if QT_CONFIG(shortcut)
QCOMPARE(label2->buddy(), fld2); QCOMPARE(label2->buddy(), fld2);
#endif
layout->insertRow(5, "&Age:", fld3); layout->insertRow(5, "&Age:", fld3);
QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0); QVERIFY(label3 != 0);
#if QT_CONFIG(shortcut)
QCOMPARE(label3->buddy(), fld3); QCOMPARE(label3->buddy(), fld3);
#endif
} }
void tst_QFormLayout::insertRow_QString_QLayout() void tst_QFormLayout::insertRow_QString_QLayout()
@ -711,21 +721,27 @@ void tst_QFormLayout::insertRow_QString_QLayout()
layout->insertRow(-5, "&Name:", fld1); layout->insertRow(-5, "&Name:", fld1);
QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0); QVERIFY(label1 != 0);
#if QT_CONFIG(shortcut)
QVERIFY(!label1->buddy()); QVERIFY(!label1->buddy());
#endif
QCOMPARE(layout->rowCount(), 1); QCOMPARE(layout->rowCount(), 1);
layout->insertRow(0, "&Email:", fld2); layout->insertRow(0, "&Email:", fld2);
QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0); QVERIFY(label2 != 0);
#if QT_CONFIG(shortcut)
QVERIFY(!label2->buddy()); QVERIFY(!label2->buddy());
#endif
QCOMPARE(layout->rowCount(), 2); QCOMPARE(layout->rowCount(), 2);
layout->insertRow(5, "&Age:", fld3); layout->insertRow(5, "&Age:", fld3);
QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0); QVERIFY(label3 != 0);
#if QT_CONFIG(shortcut)
QVERIFY(!label3->buddy()); QVERIFY(!label3->buddy());
#endif
QCOMPARE(layout->rowCount(), 3); QCOMPARE(layout->rowCount(), 3);
} }

View File

@ -34,7 +34,9 @@
#include <qapplication.h> #include <qapplication.h>
#include <qpainter.h> #include <qpainter.h>
#include <qstyleoption.h> #include <qstyleoption.h>
#if QT_CONFIG(shortcut)
# include <qkeysequence.h> # include <qkeysequence.h>
#endif
#include <qevent.h> #include <qevent.h>
#include <qgridlayout.h> #include <qgridlayout.h>
#include <qabstractbutton.h> #include <qabstractbutton.h>
@ -59,7 +61,9 @@ private slots:
void setText(); void setText();
void setIcon(); void setIcon();
#if QT_CONFIG(shortcut)
void setShortcut(); void setShortcut();
#endif
void animateClick(); void animateClick();
@ -68,7 +72,9 @@ private slots:
void isChecked(); void isChecked();
void toggled(); void toggled();
void setEnabled(); void setEnabled();
#if QT_CONFIG(shortcut)
void shortcutEvents(); void shortcutEvents();
#endif
void stopRepeatTimer(); void stopRepeatTimer();
void mouseReleased(); // QTBUG-53244 void mouseReleased(); // QTBUG-53244
@ -164,8 +170,10 @@ void tst_QAbstractButton::init()
testWidget->setEnabled( true ); testWidget->setEnabled( true );
testWidget->setDown( false ); testWidget->setDown( false );
testWidget->setAutoRepeat( false ); testWidget->setAutoRepeat( false );
#if QT_CONFIG(shortcut)
QKeySequence seq; QKeySequence seq;
testWidget->setShortcut( seq ); testWidget->setShortcut( seq );
#endif
toggle_count = 0; toggle_count = 0;
press_count = 0; press_count = 0;
@ -336,17 +344,17 @@ void tst_QAbstractButton::setText()
QCOMPARE( testWidget->text(), QString("simple") ); QCOMPARE( testWidget->text(), QString("simple") );
testWidget->setText("&ampersand"); testWidget->setText("&ampersand");
QCOMPARE( testWidget->text(), QString("&ampersand") ); QCOMPARE( testWidget->text(), QString("&ampersand") );
#ifndef Q_OS_MAC // no mneonics on Mac. #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac.
QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A")); QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A"));
#endif #endif
testWidget->setText("te&st"); testWidget->setText("te&st");
QCOMPARE( testWidget->text(), QString("te&st") ); QCOMPARE( testWidget->text(), QString("te&st") );
#ifndef Q_OS_MAC // no mneonics on Mac. #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac.
QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S")); QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S"));
#endif #endif
testWidget->setText("foo"); testWidget->setText("foo");
QCOMPARE( testWidget->text(), QString("foo") ); QCOMPARE( testWidget->text(), QString("foo") );
#ifndef Q_OS_MAC // no mneonics on Mac. #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac.
QCOMPARE( testWidget->shortcut(), QKeySequence()); QCOMPARE( testWidget->shortcut(), QKeySequence());
#endif #endif
} }
@ -471,6 +479,7 @@ void tst_QAbstractButton::toggled()
testWidget->setCheckable(false); testWidget->setCheckable(false);
} }
#if QT_CONFIG(shortcut)
void tst_QAbstractButton::setShortcut() void tst_QAbstractButton::setShortcut()
{ {
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
@ -502,6 +511,7 @@ void tst_QAbstractButton::setShortcut()
// qDebug() << click_count; // qDebug() << click_count;
} }
#endif // QT_CONFIG(shortcut)
void tst_QAbstractButton::animateClick() void tst_QAbstractButton::animateClick()
{ {
@ -512,6 +522,8 @@ void tst_QAbstractButton::animateClick()
QTRY_VERIFY( !testWidget->isDown() ); QTRY_VERIFY( !testWidget->isDown() );
} }
#if QT_CONFIG(shortcut)
void tst_QAbstractButton::shortcutEvents() void tst_QAbstractButton::shortcutEvents()
{ {
MyButton button; MyButton button;
@ -535,6 +547,8 @@ void tst_QAbstractButton::shortcutEvents()
QCOMPARE(clickedSpy.count(), 3); QCOMPARE(clickedSpy.count(), 3);
} }
#endif // QT_CONFIG(shortcut)
void tst_QAbstractButton::stopRepeatTimer() void tst_QAbstractButton::stopRepeatTimer()
{ {
MyButton button; MyButton button;

View File

@ -51,7 +51,9 @@ private slots:
void getSetCheck(); void getSetCheck();
void pressed(); void pressed();
#if QT_CONFIG(shortcut)
void setAccel(); void setAccel();
#endif
void isCheckable(); void isCheckable();
void setDown(); void setDown();
void popupCrash(); void popupCrash();
@ -133,8 +135,10 @@ void tst_QCommandLinkButton::init()
testWidget->setText("Test"); testWidget->setText("Test");
testWidget->setDescription("Description text."); testWidget->setDescription("Description text.");
testWidget->setEnabled( true ); testWidget->setEnabled( true );
#if QT_CONFIG(shortcut)
QKeySequence seq; QKeySequence seq;
testWidget->setShortcut( seq ); testWidget->setShortcut( seq );
#endif
resetCounters(); resetCounters();
} }
@ -327,6 +331,8 @@ void tst_QCommandLinkButton::toggled()
QVERIFY( click_count == 1 ); QVERIFY( click_count == 1 );
} }
#if QT_CONFIG(shortcut)
/* /*
If we press an accelerator key we ONLY get a pressed signal and If we press an accelerator key we ONLY get a pressed signal and
NOT a released or clicked signal. NOT a released or clicked signal.
@ -355,6 +361,8 @@ void tst_QCommandLinkButton::setAccel()
QTest::qWait(200); QTest::qWait(200);
} }
#endif // QT_CONFIG(shortcut)
void tst_QCommandLinkButton::animateClick() void tst_QCommandLinkButton::animateClick()
{ {
QVERIFY( !testWidget->isDown() ); QVERIFY( !testWidget->isDown() );

View File

@ -166,7 +166,9 @@ private slots:
void doubleDot(); void doubleDot();
#if QT_CONFIG(shortcut)
void undoRedo(); void undoRedo();
#endif
void valueFromTextAndValidate_data(); void valueFromTextAndValidate_data();
void valueFromTextAndValidate(); void valueFromTextAndValidate();
@ -1025,6 +1027,8 @@ void tst_QDoubleSpinBox::doubleDot()
QCOMPARE(spin.lineEdit()->cursorPosition(), 2); QCOMPARE(spin.lineEdit()->cursorPosition(), 2);
} }
#if QT_CONFIG(shortcut)
void tst_QDoubleSpinBox::undoRedo() void tst_QDoubleSpinBox::undoRedo()
{ {
//test undo/redo feature (in conjunction with the "undoRedoEnabled" property) //test undo/redo feature (in conjunction with the "undoRedoEnabled" property)
@ -1073,6 +1077,8 @@ void tst_QDoubleSpinBox::undoRedo()
QVERIFY(!spin.lineEdit()->isRedoAvailable()); QVERIFY(!spin.lineEdit()->isRedoAvailable());
} }
#endif // QT_CONFIG(shortcut)
struct task199226_DoubleSpinBox : public QDoubleSpinBox struct task199226_DoubleSpinBox : public QDoubleSpinBox
{ {
task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {} task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {}

View File

@ -68,7 +68,7 @@ private Q_SLOTS:
void setText_data(); void setText_data();
void setText(); void setText();
void setTextFormat(); void setTextFormat();
#ifndef Q_OS_MAC #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN)
void setBuddy(); void setBuddy();
#endif #endif
void setNum(); void setNum();
@ -88,8 +88,10 @@ private Q_SLOTS:
void unicodeText_data(); void unicodeText_data();
void unicodeText(); void unicodeText();
#if QT_CONFIG(shortcut)
void mnemonic_data(); void mnemonic_data();
void mnemonic(); void mnemonic();
#endif
void selection(); void selection();
#ifndef QT_NO_CONTEXTMENU #ifndef QT_NO_CONTEXTMENU
@ -116,6 +118,7 @@ void tst_QLabel::getSetCheck()
obj1.setWordWrap(true); obj1.setWordWrap(true);
QCOMPARE(true, obj1.wordWrap()); QCOMPARE(true, obj1.wordWrap());
#if QT_CONFIG(shortcut)
// QWidget * QLabel::buddy() // QWidget * QLabel::buddy()
// void QLabel::setBuddy(QWidget *) // void QLabel::setBuddy(QWidget *)
QWidget *var2 = new QWidget(); QWidget *var2 = new QWidget();
@ -124,6 +127,7 @@ void tst_QLabel::getSetCheck()
obj1.setBuddy((QWidget *)0); obj1.setBuddy((QWidget *)0);
QCOMPARE((QWidget *)0, obj1.buddy()); QCOMPARE((QWidget *)0, obj1.buddy());
delete var2; delete var2;
#endif // QT_CONFIG(shortcut)
// QMovie * QLabel::movie() // QMovie * QLabel::movie()
// void QLabel::setMovie(QMovie *) // void QLabel::setMovie(QMovie *)
@ -153,7 +157,9 @@ void tst_QLabel::cleanupTestCase()
void tst_QLabel::init() void tst_QLabel::init()
{ {
testWidget->setTextFormat( Qt::AutoText ); testWidget->setTextFormat( Qt::AutoText );
# if QT_CONFIG(shortcut)
testWidget->setBuddy( 0 ); testWidget->setBuddy( 0 );
#endif
testWidget->setIndent( 0 ); testWidget->setIndent( 0 );
testWidget->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); testWidget->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
testWidget->setScaledContents( false ); testWidget->setScaledContents( false );
@ -169,7 +175,7 @@ void tst_QLabel::cleanup()
} }
// Set buddy doesn't make much sense on OS X // Set buddy doesn't make much sense on OS X
#ifndef Q_OS_MAC #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN)
void tst_QLabel::setBuddy() void tst_QLabel::setBuddy()
{ {
testWidget->hide(); testWidget->hide();
@ -204,7 +210,7 @@ void tst_QLabel::setBuddy()
delete test_box; delete test_box;
} }
#endif #endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN
void tst_QLabel::setText_data() void tst_QLabel::setText_data()
{ {
@ -469,6 +475,8 @@ void tst_QLabel::unicodeText()
testWidget->show(); testWidget->show();
} }
#if QT_CONFIG(shortcut)
void tst_QLabel::mnemonic_data() void tst_QLabel::mnemonic_data()
{ {
QTest::addColumn<QString>("text"); QTest::addColumn<QString>("text");
@ -513,6 +521,8 @@ void tst_QLabel::mnemonic()
QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor); QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor);
} }
#endif // QT_CONFIG(shortcut)
void tst_QLabel::selection() void tst_QLabel::selection()
{ {
QLabel label; QLabel label;

View File

@ -56,7 +56,9 @@
#include <qsortfilterproxymodel.h> #include <qsortfilterproxymodel.h>
#include <qdebug.h> #include <qdebug.h>
#include <qscreen.h> #include <qscreen.h>
#if QT_CONFIG(shortcut)
# include <qshortcut.h> # include <qshortcut.h>
#endif
#include "qcommonstyle.h" #include "qcommonstyle.h"
#include "qstyleoption.h" #include "qstyleoption.h"
@ -135,9 +137,11 @@ private slots:
void clearInputMask(); void clearInputMask();
#if QT_CONFIG(shortcut)
void keypress_inputMask_data(); void keypress_inputMask_data();
void keypress_inputMask(); void keypress_inputMask();
void keypress_inputMethod_inputMask(); void keypress_inputMethod_inputMask();
#endif
void inputMaskAndValidator_data(); void inputMaskAndValidator_data();
void inputMaskAndValidator(); void inputMaskAndValidator();
@ -219,7 +223,7 @@ private slots:
void setSelection_data(); void setSelection_data();
void setSelection(); void setSelection();
#ifndef QT_NO_CLIPBOARD #if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void cut(); void cut();
void cutWithoutSelection(); void cutWithoutSelection();
#endif #endif
@ -299,8 +303,10 @@ private slots:
void shouldShowPlaceholderText(); void shouldShowPlaceholderText();
void QTBUG1266_setInputMaskEmittingTextEdited(); void QTBUG1266_setInputMaskEmittingTextEdited();
#if QT_CONFIG(shortcut)
void shortcutOverrideOnReadonlyLineEdit_data(); void shortcutOverrideOnReadonlyLineEdit_data();
void shortcutOverrideOnReadonlyLineEdit(); void shortcutOverrideOnReadonlyLineEdit();
#endif
void QTBUG59957_clearButtonLeftmostAction(); void QTBUG59957_clearButtonLeftmostAction();
void QTBUG_60319_setInputMaskCheckImSurroundingText(); void QTBUG_60319_setInputMaskCheckImSurroundingText();
void testQuickSelectionWithMouse(); void testQuickSelectionWithMouse();
@ -319,7 +325,9 @@ private:
void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
bool unselectingWithLeftOrRightChangesCursorPosition(); bool unselectingWithLeftOrRightChangesCursorPosition();
#if QT_CONFIG(shortcut)
void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey);
#endif
QLineEdit *ensureTestWidget(); QLineEdit *ensureTestWidget();
bool validInput; bool validInput;
@ -715,6 +723,8 @@ void tst_QLineEdit::clearInputMask()
QCOMPARE(testWidget->inputMask(), QString()); QCOMPARE(testWidget->inputMask(), QString());
} }
#if QT_CONFIG(shortcut)
void tst_QLineEdit::keypress_inputMask_data() void tst_QLineEdit::keypress_inputMask_data()
{ {
QTest::addColumn<QString>("mask"); QTest::addColumn<QString>("mask");
@ -832,6 +842,8 @@ void tst_QLineEdit::keypress_inputMethod_inputMask()
QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.EE")); QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.EE"));
} }
#endif // QT_CONFIG(shortcut)
void tst_QLineEdit::hasAcceptableInputMask_data() void tst_QLineEdit::hasAcceptableInputMask_data()
{ {
QTest::addColumn<QString>("optionalMask"); QTest::addColumn<QString>("optionalMask");
@ -1986,6 +1998,8 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo
keys.addKeyClick(key, pressState); keys.addKeyClick(key, pressState);
} }
#if QT_CONFIG(shortcut)
void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key)
{ {
QKeySequence keyseq = QKeySequence(key); QKeySequence keyseq = QKeySequence(key);
@ -1993,6 +2007,8 @@ void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence
keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) );
} }
#endif // QT_CONFIG(shortcut)
void tst_QLineEdit::cursorPosition() void tst_QLineEdit::cursorPosition()
{ {
QLineEdit *testWidget = ensureTestWidget(); QLineEdit *testWidget = ensureTestWidget();
@ -3023,7 +3039,7 @@ void tst_QLineEdit::setSelection()
QCOMPARE(testWidget->cursorPosition(), expectedCursor); QCOMPARE(testWidget->cursorPosition(), expectedCursor);
} }
#ifndef QT_NO_CLIPBOARD #if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_QLineEdit::cut() void tst_QLineEdit::cut()
{ {
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
@ -3124,7 +3140,7 @@ void tst_QLineEdit::cutWithoutSelection()
QCOMPARE(clipboard->text(), origText.left(selectionLength)); QCOMPARE(clipboard->text(), origText.left(selectionLength));
} }
#endif // !QT_NO_CLIPBOARD #endif // QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
class InputMaskValidator : public QValidator class InputMaskValidator : public QValidator
{ {
@ -3969,7 +3985,9 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
le.setReadOnly(true); le.setReadOnly(true);
QAction action(QString::fromLatin1("hello"), &le); QAction action(QString::fromLatin1("hello"), &le);
#if QT_CONFIG(shortcut)
action.setShortcut(QString::fromLatin1("p")); action.setShortcut(QString::fromLatin1("p"));
#endif
QSignalSpy spy(&action, SIGNAL(triggered())); QSignalSpy spy(&action, SIGNAL(triggered()));
le.addAction(&action); le.addAction(&action);
@ -4704,6 +4722,8 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited()
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
} }
#if QT_CONFIG(shortcut)
void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit_data() void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit_data()
{ {
QTest::addColumn<QKeySequence>("keySequence"); QTest::addColumn<QKeySequence>("keySequence");
@ -4763,6 +4783,8 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit()
QCOMPARE(spy.count(), activationCount); QCOMPARE(spy.count(), activationCount);
} }
#endif // QT_CONFIG(shortcut)
void tst_QLineEdit::QTBUG59957_clearButtonLeftmostAction() void tst_QLineEdit::QTBUG59957_clearButtonLeftmostAction()
{ {
#ifndef QT_BUILD_INTERNAL #ifndef QT_BUILD_INTERNAL

View File

@ -481,7 +481,7 @@ void tst_QMenu::overrideMenuAction()
// On Mac and Windows CE, we need to create native key events to test menu // On Mac and Windows CE, we need to create native key events to test menu
// action activation, so skip this part of the test. // action activation, so skip this part of the test.
#if !defined(Q_OS_DARWIN) #if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN)
QAction *aQuit = new QAction("Quit", &w); QAction *aQuit = new QAction("Quit", &w);
aQuit->setShortcut(QKeySequence("Ctrl+X")); aQuit->setShortcut(QKeySequence("Ctrl+X"));
m->addAction(aQuit); m->addAction(aQuit);
@ -499,7 +499,7 @@ void tst_QMenu::overrideMenuAction()
//test if the menu still pops out //test if the menu still pops out
QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
QTRY_VERIFY(m->isVisible()); QTRY_VERIFY(m->isVisible());
#endif #endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN
delete aFileMenu; delete aFileMenu;
@ -1706,10 +1706,13 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts()
QSKIP("Window activation is not supported"); QSKIP("Window activation is not supported");
QAction *actionKamen = new QAction("Action Kamen"); QAction *actionKamen = new QAction("Action Kamen");
#if QT_CONFIG(shortcut)
actionKamen->setShortcut(QKeySequence(QLatin1String("K"))); actionKamen->setShortcut(QKeySequence(QLatin1String("K")));
#endif
QAction *actionJoe = new QAction("Action Joe"); QAction *actionJoe = new QAction("Action Joe");
#if QT_CONFIG(shortcut)
actionJoe->setShortcut(QKeySequence(QLatin1String("Ctrl+J"))); actionJoe->setShortcut(QKeySequence(QLatin1String("Ctrl+J")));
#endif
QMenu menu; QMenu menu;
menu.addAction(actionKamen); menu.addAction(actionKamen);

View File

@ -232,19 +232,25 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) {
connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
QMenu *menu = mb->addMenu(QStringLiteral("&accel")); QMenu *menu = mb->addMenu(QStringLiteral("&accel"));
QAction *action = menu->addAction(QStringLiteral("menu1") ); QAction *action = menu->addAction(QStringLiteral("menu1") );
#if QT_CONFIG(shortcut)
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
#endif
connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
result.menus << menu; result.menus << menu;
result.actions << action; result.actions << action;
menu = mb->addMenu(QStringLiteral("accel1")); menu = mb->addMenu(QStringLiteral("accel1"));
action = menu->addAction(QStringLiteral("&Open...") ); action = menu->addAction(QStringLiteral("&Open...") );
#if QT_CONFIG(shortcut)
action->setShortcut(Qt::Key_O); action->setShortcut(Qt::Key_O);
#endif
result.actions << action; result.actions << action;
action = menu->addAction(QStringLiteral("action")); action = menu->addAction(QStringLiteral("action"));
#if QT_CONFIG(shortcut)
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z)); action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z));
#endif
result.actions << action; result.actions << action;
result.menus << menu; result.menus << menu;
@ -283,7 +289,9 @@ QAction *tst_QMenuBar::createCharacterAction(QMenu *menu, char lowerAscii)
QAction *action = menu->addAction(text); QAction *action = menu->addAction(text);
action->setObjectName(text); action->setObjectName(text);
action->setData(QVariant(int(lowerAscii))); action->setData(QVariant(int(lowerAscii)));
#if QT_CONFIG(shortcut)
action->setShortcut(Qt::CTRL + (lowerAscii - 'a' + Qt::Key_A)); action->setShortcut(Qt::CTRL + (lowerAscii - 'a' + Qt::Key_A));
#endif
connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered()));
return action; return action;
} }
@ -318,7 +326,9 @@ TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb)
QAction *action = mb->addAction(QStringLiteral("M&enu 3")); QAction *action = mb->addAction(QStringLiteral("M&enu 3"));
action->setData(QVariant(3)); action->setData(QVariant(3));
#if QT_CONFIG(shortcut)
action->setShortcut(Qt::ALT + Qt::Key_J); action->setShortcut(Qt::ALT + Qt::Key_J);
#endif
connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered()));
result.actions << action; result.actions << action;
@ -1422,7 +1432,9 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten()
menubar.setNativeMenuBar(false); menubar.setNativeMenuBar(false);
QMenu menu("menu1"); QMenu menu("menu1");
QAction *first = menubar.addMenu(&menu); QAction *first = menubar.addMenu(&menu);
#if QT_CONFIG(shortcut)
menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC"));
#endif
centerOnScreen(&menubar); centerOnScreen(&menubar);
menubar.show(); menubar.show();
QApplication::setActiveWindow(&menubar); QApplication::setActiveWindow(&menubar);

View File

@ -53,7 +53,9 @@ private slots:
void getSetCheck(); void getSetCheck();
void autoRepeat(); void autoRepeat();
void pressed(); void pressed();
#if QT_CONFIG(shortcut)
void setAccel(); void setAccel();
#endif
void isCheckable(); void isCheckable();
void setDown(); void setDown();
void popupCrash(); void popupCrash();
@ -65,7 +67,9 @@ private slots:
void defaultAndAutoDefault(); void defaultAndAutoDefault();
void sizeHint_data(); void sizeHint_data();
void sizeHint(); void sizeHint();
#if QT_CONFIG(shortcut)
void taskQTBUG_20191_shortcutWithKeypadModifer(); void taskQTBUG_20191_shortcutWithKeypadModifer();
#endif
void emitReleasedAfterChange(); void emitReleasedAfterChange();
protected slots: protected slots:
@ -125,8 +129,10 @@ void tst_QPushButton::init()
testWidget->setDown( false ); testWidget->setDown( false );
testWidget->setText("Test"); testWidget->setText("Test");
testWidget->setEnabled( true ); testWidget->setEnabled( true );
#if QT_CONFIG(shortcut)
QKeySequence seq; QKeySequence seq;
testWidget->setShortcut( seq ); testWidget->setShortcut( seq );
#endif
resetCounters(); resetCounters();
} }
@ -318,6 +324,8 @@ void tst_QPushButton::toggled()
QVERIFY( click_count == 1 ); QVERIFY( click_count == 1 );
} }
#if QT_CONFIG(shortcut)
/* /*
If we press an accelerator key we ONLY get a pressed signal and If we press an accelerator key we ONLY get a pressed signal and
NOT a released or clicked signal. NOT a released or clicked signal.
@ -349,6 +357,8 @@ void tst_QPushButton::setAccel()
QTRY_VERIFY( !testWidget->isDown() ); QTRY_VERIFY( !testWidget->isDown() );
} }
#endif // QT_CONFIG(shortcut)
void tst_QPushButton::animateClick() void tst_QPushButton::animateClick()
{ {
QVERIFY( !testWidget->isDown() ); QVERIFY( !testWidget->isDown() );
@ -571,6 +581,8 @@ void tst_QPushButton::sizeHint()
} }
} }
#if QT_CONFIG(shortcut)
void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
{ {
// setup a dialog with two buttons // setup a dialog with two buttons
@ -617,6 +629,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer()
QCOMPARE(spy2.count(), 1); QCOMPARE(spy2.count(), 1);
} }
#endif // QT_CONFIG(shortcut)
void tst_QPushButton::emitReleasedAfterChange() void tst_QPushButton::emitReleasedAfterChange()
{ {
QPushButton *button1 = new QPushButton("A"); QPushButton *button1 = new QPushButton("A");

View File

@ -44,12 +44,16 @@ public:
virtual ~tst_QRadioButton(){}; virtual ~tst_QRadioButton(){};
private slots: private slots:
#if QT_CONFIG(shortcut)
void task190739_focus(); void task190739_focus();
#endif
void minimumSizeHint(); void minimumSizeHint();
private: private:
}; };
#if QT_CONFIG(shortcut)
void tst_QRadioButton::task190739_focus() void tst_QRadioButton::task190739_focus()
{ {
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
@ -84,6 +88,7 @@ void tst_QRadioButton::task190739_focus()
QVERIFY(!radio1.hasFocus()); QVERIFY(!radio1.hasFocus());
} }
#endif // QT_CONFIG(shortcut)
void tst_QRadioButton::minimumSizeHint() void tst_QRadioButton::minimumSizeHint()
{ {

View File

@ -47,7 +47,9 @@
#include <QLocale> #include <QLocale>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QVBoxLayout> #include <QVBoxLayout>
#if QT_CONFIG(shortcut)
# include <QKeySequence> # include <QKeySequence>
#endif
#include <QStackedWidget> #include <QStackedWidget>
#include <QDebug> #include <QDebug>
#include <QStyleOptionSpinBox> #include <QStyleOptionSpinBox>
@ -173,7 +175,10 @@ private slots:
void removeAll(); void removeAll();
void startWithDash(); void startWithDash();
#if QT_CONFIG(shortcut)
void undoRedo(); void undoRedo();
#endif
void specialValue(); void specialValue();
void textFromValue(); void textFromValue();
@ -1024,6 +1029,8 @@ void tst_QSpinBox::startWithDash()
QCOMPARE(spin.text(), QString("0")); QCOMPARE(spin.text(), QString("0"));
} }
#if QT_CONFIG(shortcut)
void tst_QSpinBox::undoRedo() void tst_QSpinBox::undoRedo()
{ {
//test undo/redo feature (in conjunction with the "undoRedoEnabled" property) //test undo/redo feature (in conjunction with the "undoRedoEnabled" property)
@ -1076,6 +1083,8 @@ void tst_QSpinBox::undoRedo()
QVERIFY(!spin.lineEdit()->isRedoAvailable()); QVERIFY(!spin.lineEdit()->isRedoAvailable());
} }
#endif // QT_CONFIG(shortcut)
void tst_QSpinBox::specialValue() void tst_QSpinBox::specialValue()
{ {
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))

View File

@ -40,7 +40,9 @@
#include <qwidgetaction.h> #include <qwidgetaction.h>
#include <qtoolbutton.h> #include <qtoolbutton.h>
#include <qlineedit.h> #include <qlineedit.h>
#if QT_CONFIG(shortcut)
# include <qkeysequence.h> # include <qkeysequence.h>
#endif
#include <qmenu.h> #include <qmenu.h>
#include <qlabel.h> #include <qlabel.h>
#include <private/qtoolbarextension_p.h> #include <private/qtoolbarextension_p.h>

View File

@ -47,6 +47,9 @@ SUBDIRS=\
qtoolbox \ qtoolbox \
qtoolbutton \ qtoolbutton \
!qtConfig(shortcut): SUBDIRS -= \
qkeysequenceedit
# The following tests depend on private API: # The following tests depend on private API:
!qtConfig(private_tests): SUBDIRS -= \ !qtConfig(private_tests): SUBDIRS -= \
qabstractspinbox \ qabstractspinbox \