Handle -no-feature-shortcut

Preparing for the extraction of QGuiShortcut, the shortcut
feature will changed to follow the convention of using
QT_REQUIRE_CONFIG(shortcut) in the affected class headers.

Add the required exclusions to prevent compile errors
when disabling shortcuts.

Task-number: QTBUG-76493
Change-Id: Icad95584ae12aa97a56b56ef27206cef1b1ba48f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Friedemann Kleint 2019-10-18 11:00:53 +02:00
parent 77a433a21c
commit 164a890573
6 changed files with 59 additions and 8 deletions

View File

@ -138,6 +138,8 @@ bool QuickTestEvent::keySequence(const QVariant &keySequence)
return false;
#if QT_CONFIG(shortcut)
QTest::keySequence(window, valueToKeySequence(keySequence));
#else
Q_UNUSED(keySequence);
#endif
return true;
}

View File

@ -58,7 +58,9 @@
#include <QtCore/qpointer.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qevent.h>
#include <QtGui/qkeysequence.h>
#if QT_CONFIG(shortcut)
# include <QtGui/qkeysequence.h>
#endif
#include <QtQuick/qquickitem.h>
QT_BEGIN_NAMESPACE

View File

@ -76,8 +76,10 @@ private slots:
void qtbug_50516_2();
void keys();
#if QT_CONFIG(shortcut)
void standardKeys_data();
void standardKeys();
#endif
void keysProcessingOrder();
void keysim();
void keysForward();
@ -1429,6 +1431,8 @@ void tst_QQuickItem::keys()
delete testObject;
}
#if QT_CONFIG(shortcut)
Q_DECLARE_METATYPE(QEvent::Type);
Q_DECLARE_METATYPE(QKeySequence::StandardKey);
@ -1487,6 +1491,8 @@ void tst_QQuickItem::standardKeys()
QCOMPARE(item->property("released").toBool(), released);
}
#endif // QT_CONFIG(shortcut)
void tst_QQuickItem::keysProcessingOrder()
{
QQuickView *window = new QQuickView(nullptr);

View File

@ -131,8 +131,10 @@ private slots:
void mouseSelectionMode_accessors();
void selectByMouse();
void selectByKeyboard();
#if QT_CONFIG(shortcut)
void keyboardSelection_data();
void keyboardSelection();
#endif
void renderType();
void inputMethodHints();
@ -190,16 +192,19 @@ private slots:
void insert();
void remove_data();
void remove();
#if QT_CONFIG(shortcut)
void keySequence_data();
void keySequence();
#endif
void undo_data();
void undo();
void redo_data();
void redo();
#if QT_CONFIG(shortcut)
void undo_keypressevents_data();
void undo_keypressevents();
#endif
void clear();
void baseUrl();
@ -217,7 +222,9 @@ private slots:
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
#if QT_CONFIG(shortcut)
void simulateKeys(QWindow *window, const QKeySequence &sequence);
#endif
void simulateKey(QWindow *, int key, Qt::KeyboardModifiers modifiers = nullptr);
@ -260,6 +267,8 @@ void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
}
}
#if QT_CONFIG(shortcut)
void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
{
for (int i = 0; i < sequence.count(); ++i) {
@ -277,6 +286,8 @@ QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
return keys;
}
#endif // QT_CONFIG(shortcut)
template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
{
for (int i = 0; i < N - 1; ++i) {
@ -2307,6 +2318,8 @@ void tst_qquicktextedit::selectByKeyboard()
QCOMPARE(spy.at(2).at(0).toBool(), false);
}
#if QT_CONFIG(shortcut)
Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void tst_qquicktextedit::keyboardSelection_data()
@ -2391,6 +2404,8 @@ void tst_qquicktextedit::keyboardSelection()
QCOMPARE(edit->selectedText(), selectedText);
}
#endif // QT_CONFIG(shortcut)
void tst_qquicktextedit::renderType()
{
QQmlComponent component(&engine);
@ -4820,6 +4835,7 @@ void tst_qquicktextedit::remove()
QVERIFY(cursorPositionSpy.count() > 0);
}
#if QT_CONFIG(shortcut)
void tst_qquicktextedit::keySequence_data()
{
@ -4984,6 +5000,8 @@ void tst_qquicktextedit::keySequence()
QCOMPARE(textEdit->selectedText(), selectedText);
}
#endif // QT_CONFIG(shortcut)
#define NORMAL 0
#define REPLACE_UNTIL_END 1
@ -5257,6 +5275,8 @@ void tst_qquicktextedit::redo()
QCOMPARE(spy.count(), 2);
}
#if QT_CONFIG(shortcut)
void tst_qquicktextedit::undo_keypressevents_data()
{
QTest::addColumn<KeyList>("keys");
@ -5450,6 +5470,8 @@ void tst_qquicktextedit::undo_keypressevents()
QVERIFY(textEdit->text().isEmpty());
}
#endif // QT_CONFIG(shortcut)
void tst_qquicktextedit::clear()
{
QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";

View File

@ -146,7 +146,7 @@ private slots:
void cursorRectangle();
void navigation();
void navigation_RTL();
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void copyAndPaste();
void copyAndPasteKeySequence();
void canPasteEmpty();
@ -181,15 +181,19 @@ private slots:
void remove_data();
void remove();
#if QT_CONFIG(shortcut)
void keySequence_data();
void keySequence();
#endif
void undo_data();
void undo();
void redo_data();
void redo();
#if QT_CONFIG(shortcut)
void undo_keypressevents_data();
void undo_keypressevents();
#endif
void clear();
void backspaceSurrogatePairs();
@ -236,7 +240,9 @@ private:
void simulateKey(QWindow *, int key);
void simulateKeys(QWindow *window, const QList<Key> &keys);
#if QT_CONFIG(shortcut)
void simulateKeys(QWindow *window, const QKeySequence &sequence);
#endif
QQmlEngine engine;
QStringList standard;
@ -264,6 +270,8 @@ void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
}
}
#if QT_CONFIG(shortcut)
void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
{
for (int i = 0; i < sequence.count(); ++i) {
@ -281,6 +289,8 @@ QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
return keys;
}
#endif // QT_CONFIG(shortcut)
template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
{
for (int i = 0; i < N - 1; ++i) {
@ -2586,7 +2596,7 @@ void tst_qquicktextinput::navigation_RTL()
QVERIFY(input->hasActiveFocus());
}
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::copyAndPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@ -2684,7 +2694,7 @@ void tst_qquicktextinput::copyAndPaste()
}
#endif
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::copyAndPasteKeySequence()
{
if (!PlatformQuirks::isClipboardAvailable())
@ -2752,7 +2762,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence()
}
#endif
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::canPasteEmpty()
{
QGuiApplication::clipboard()->clear();
@ -2768,7 +2778,7 @@ void tst_qquicktextinput::canPasteEmpty()
}
#endif
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::canPaste()
{
QGuiApplication::clipboard()->setText("Some text");
@ -2784,7 +2794,7 @@ void tst_qquicktextinput::canPaste()
}
#endif
#if QT_CONFIG(clipboard)
#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::middleClickPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@ -5098,6 +5108,7 @@ void tst_qquicktextinput::remove()
QVERIFY(cursorPositionSpy.count() > 0);
}
#if QT_CONFIG(shortcut)
void tst_qquicktextinput::keySequence_data()
{
QTest::addColumn<QString>("text");
@ -5283,6 +5294,8 @@ void tst_qquicktextinput::keySequence()
QCOMPARE(textInput->selectedText(), selectedText);
}
#endif // QT_CONFIG(shortcut)
#define NORMAL 0
#define REPLACE_UNTIL_END 1
@ -5556,6 +5569,8 @@ void tst_qquicktextinput::redo()
QCOMPARE(spy.count(), 2);
}
#if QT_CONFIG(shortcut)
void tst_qquicktextinput::undo_keypressevents_data()
{
QTest::addColumn<KeyList>("keys");
@ -5860,6 +5875,8 @@ void tst_qquicktextinput::undo_keypressevents()
QVERIFY(textInput->text().isEmpty());
}
#endif // QT_CONFIG(shortcut)
void tst_qquicktextinput::clear()
{
QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";

View File

@ -96,6 +96,8 @@ boot2qt: QUICKTESTS -= qquickgridview qquicklistview qquicktableview qquickposit
!qtConfig(accessibility):QUICKTESTS -= qquickaccessible
!qtConfig(shortcut):QUICKTESTS -= qquickshortcut
qtConfig(private_tests) {
SUBDIRS += $$PRIVATETESTS
SUBDIRS += $$QUICKTESTS