diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | examples/quickcontrols2/contactlist/ContactView.ui.qml | 6 | ||||
-rw-r--r-- | src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/material/CursorDelegate.qml | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton.cpp | 8 | ||||
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton_p_p.h | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickaction.cpp | 17 | ||||
-rw-r--r-- | src/quicktemplates2/qquickaction_p_p.h | 6 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 86 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdeferredexecute.cpp | 10 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopupitem.cpp | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickstackelement.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qquickpopup/data/tabFence.qml | 97 | ||||
-rw-r--r-- | tests/auto/qquickpopup/tst_qquickpopup.cpp | 57 |
16 files changed, 214 insertions, 97 deletions
diff --git a/.qmake.conf b/.qmake.conf index 0e68ba10..31431340 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -5,4 +5,4 @@ DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST QQC2_SOURCE_TREE = $$PWD -MODULE_VERSION = 5.14.0 +MODULE_VERSION = 5.15.0 diff --git a/examples/quickcontrols2/contactlist/ContactView.ui.qml b/examples/quickcontrols2/contactlist/ContactView.ui.qml index 747f3042..984fc787 100644 --- a/examples/quickcontrols2/contactlist/ContactView.ui.qml +++ b/examples/quickcontrols2/contactlist/ContactView.ui.qml @@ -72,11 +72,7 @@ ListView { delegate: ContactDelegate { id: delegate width: listView.width - - Connections { - target: delegate - onPressAndHold: listView.pressAndHold(index) - } + onPressAndHold: listView.pressAndHold(index) } model: ContactModel { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml index 1bb68bdf..b902dab1 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml @@ -55,7 +55,7 @@ ComboBox { Connections { target: control - onPressedChanged: canvas.requestPaint() + function onPressedChanged() { canvas.requestPaint(); } } onPaint: { diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml index 86c6a0b7..4bcbaa67 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml @@ -62,7 +62,7 @@ DelayButton { Connections { target: control - onProgressChanged: canvas.requestPaint() + function onProgressChanged() { canvas.requestPaint(); } } onPaint: { diff --git a/src/imports/controls/material/CursorDelegate.qml b/src/imports/controls/material/CursorDelegate.qml index 1626a6fb..fe2d25c6 100644 --- a/src/imports/controls/material/CursorDelegate.qml +++ b/src/imports/controls/material/CursorDelegate.qml @@ -46,7 +46,7 @@ Rectangle { Connections { target: cursor.parent - onCursorPositionChanged: { + function onCursorPositionChanged() { // keep a moving cursor visible cursor.opacity = 1 timer.restart() diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 2099f2db..bb07d13e 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -44,7 +44,9 @@ #include <QtGui/qstylehints.h> #include <QtGui/qguiapplication.h> -#include <QtGui/private/qshortcutmap_p.h> +#if QT_CONFIG(shortcut) +# include <QtGui/private/qshortcutmap_p.h> +#endif #include <QtGui/private/qguiapplication_p.h> #include <QtQuick/private/qquickevents_p_p.h> #include <QtQml/qqmllist.h> @@ -1015,8 +1017,8 @@ void QQuickAbstractButton::componentComplete() bool QQuickAbstractButton::event(QEvent *event) { - Q_D(QQuickAbstractButton); #if QT_CONFIG(shortcut) + Q_D(QQuickAbstractButton); if (event->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast<QShortcutEvent *>(event); if (se->shortcutId() == d->shortcutId) { @@ -1101,9 +1103,9 @@ void QQuickAbstractButton::timerEvent(QTimerEvent *event) void QQuickAbstractButton::itemChange(ItemChange change, const ItemChangeData &value) { - Q_D(QQuickAbstractButton); QQuickControl::itemChange(change, value); #if QT_CONFIG(shortcut) + Q_D(QQuickAbstractButton); if (change == ItemVisibleHasChanged) { if (value.boolValue) d->grabShortcut(); diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h index 7394f115..8ad479e2 100644 --- a/src/quicktemplates2/qquickabstractbutton_p_p.h +++ b/src/quicktemplates2/qquickabstractbutton_p_p.h @@ -50,7 +50,9 @@ #include <QtQuickTemplates2/private/qquickabstractbutton_p.h> #include <QtQuickTemplates2/private/qquickcontrol_p_p.h> -#include <QtGui/qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <QtGui/qkeysequence.h> +#endif QT_BEGIN_NAMESPACE diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp index 9120db37..559c5fc3 100644 --- a/src/quicktemplates2/qquickaction.cpp +++ b/src/quicktemplates2/qquickaction.cpp @@ -40,7 +40,9 @@ #include "qquickshortcutcontext_p_p.h" #include <QtGui/qevent.h> -#include <QtGui/private/qshortcutmap_p.h> +#if QT_CONFIG(shortcut) +# include <QtGui/private/qshortcutmap_p.h> +#endif #include <QtGui/private/qguiapplication_p.h> #include <QtQuick/private/qquickitem_p.h> @@ -261,6 +263,8 @@ void QQuickActionPrivate::unregisterItem(QQuickItem *item) delete entry; updateDefaultShortcutEntry(); +#else + Q_UNUSED(item); #endif } @@ -277,6 +281,8 @@ void QQuickActionPrivate::itemVisibilityChanged(QQuickItem *item) entry->ungrab(); updateDefaultShortcutEntry(); +#else + Q_UNUSED(item); #endif } @@ -332,8 +338,8 @@ void QQuickActionPrivate::updateDefaultShortcutEntry() QQuickAction::QQuickAction(QObject *parent) : QObject(*(new QQuickActionPrivate), parent) { - Q_D(QQuickAction); #if QT_CONFIG(shortcut) + Q_D(QQuickAction); d->defaultShortcutEntry = new QQuickActionPrivate::ShortcutEntry(this); #endif } @@ -554,8 +560,8 @@ void QQuickActionPrivate::trigger(QObject* source, bool doToggle) bool QQuickAction::event(QEvent *event) { - Q_D(QQuickAction); #if QT_CONFIG(shortcut) + Q_D(QQuickAction); if (event->type() == QEvent::Shortcut) return d->handleShortcutEvent(this, static_cast<QShortcutEvent *>(event)); #endif @@ -564,10 +570,13 @@ bool QQuickAction::event(QEvent *event) bool QQuickAction::eventFilter(QObject *object, QEvent *event) { - Q_D(QQuickAction); #if QT_CONFIG(shortcut) + Q_D(QQuickAction); if (event->type() == QEvent::Shortcut) return d->handleShortcutEvent(object, static_cast<QShortcutEvent *>(event)); +#else + Q_UNUSED(object); + Q_UNUSED(event); #endif return false; } diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h index 7c70bab1..252b0075 100644 --- a/src/quicktemplates2/qquickaction_p_p.h +++ b/src/quicktemplates2/qquickaction_p_p.h @@ -51,7 +51,9 @@ #include <QtCore/private/qobject_p.h> #include <QtCore/qvariant.h> #include <QtCore/qstring.h> -#include <QtGui/qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <QtGui/qkeysequence.h> +#endif #include <QtQuick/private/qquickitemchangelistener_p.h> QT_BEGIN_NAMESPACE @@ -119,8 +121,8 @@ public: bool checkable = false; QString text; QQuickIcon icon; - QKeySequence keySequence; #if QT_CONFIG(shortcut) + QKeySequence keySequence; QVariant vshortcut; ShortcutEntry *defaultShortcutEntry = nullptr; QVector<ShortcutEntry *> shortcutEntries; diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 21eecfe1..6b03bbf2 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -232,13 +232,9 @@ public: void updateEditText(); void updateCurrentText(); void updateCurrentValue(); - void updateCurrentText(bool hasDelegateModelObject); - void updateCurrentValue(bool hasDelegateModelObject); void updateCurrentTextAndValue(); bool isValidIndex(int index) const; - QString fastTextAt(int index) const; - QVariant fastValueAt(int index) const; void acceptInput(); QString tryComplete(const QString &inputText); @@ -441,34 +437,10 @@ void QQuickComboBoxPrivate::updateEditText() q->setEditText(text); } -// We have these two rather than just using default arguments -// because QObjectPrivate::connect() doesn't accept lambdas. void QQuickComboBoxPrivate::updateCurrentText() { - updateCurrentText(false); -} - -void QQuickComboBoxPrivate::updateCurrentValue() -{ - updateCurrentValue(false); -} - -void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject) -{ Q_Q(QQuickComboBox); - QString text; - // If a delegate model object was passed in, it means the calling code - // has decided to reuse it for several function calls to speed things up. - // So, use the faster (private) version in that case. - // For other cases, we use the version that creates the delegate model object - // itself in order to have neater, more convenient calling code. - if (isValidIndex(currentIndex)) { - if (hasDelegateModelObject) - text = fastTextAt(currentIndex); - else - text = q->textAt(currentIndex); - } - + const QString text = q->textAt(currentIndex); if (currentText != text) { currentText = text; if (!hasDisplayText) @@ -483,19 +455,10 @@ void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject) q->setEditText(currentText); } -void QQuickComboBoxPrivate::updateCurrentValue(bool hasDelegateModelObject) +void QQuickComboBoxPrivate::updateCurrentValue() { Q_Q(QQuickComboBox); - QVariant value; - // If a delegate model object was passed in, it means the calling code - // has decided to reuse it for several function calls to speed things up. - // So, use the faster (private) version in that case. - if (isValidIndex(currentIndex)) { - if (hasDelegateModelObject) - value = fastValueAt(currentIndex); - else - value = q->valueAt(currentIndex); - } + const QVariant value = q->valueAt(currentIndex); if (currentValue == value) return; @@ -505,15 +468,8 @@ void QQuickComboBoxPrivate::updateCurrentValue(bool hasDelegateModelObject) void QQuickComboBoxPrivate::updateCurrentTextAndValue() { - QObject *object = nullptr; - // For performance reasons, we reuse the same delegate model object: QTBUG-76029. - if (isValidIndex(currentIndex)) - object = delegateModel->object(currentIndex); - const bool hasDelegateModelObject = object != nullptr; - updateCurrentText(hasDelegateModelObject); - updateCurrentValue(hasDelegateModelObject); - if (object) - delegateModel->release(object); + updateCurrentText(); + updateCurrentValue(); } bool QQuickComboBoxPrivate::isValidIndex(int index) const @@ -521,20 +477,6 @@ bool QQuickComboBoxPrivate::isValidIndex(int index) const return delegateModel && index >= 0 && index < delegateModel->count(); } -// For performance reasons (QTBUG-76029), both this and valueAt assume that -// the index is valid and delegateModel->object(index) has been called. -QString QQuickComboBoxPrivate::fastTextAt(int index) const -{ - const QString effectiveTextRole = textRole.isEmpty() ? QStringLiteral("modelData") : textRole; - return delegateModel->stringValue(index, effectiveTextRole); -} - -QVariant QQuickComboBoxPrivate::fastValueAt(int index) const -{ - const QString effectiveValueRole = valueRole.isEmpty() ? QStringLiteral("modelData") : valueRole; - return delegateModel->variantValue(index, effectiveValueRole); -} - void QQuickComboBoxPrivate::acceptInput() { Q_Q(QQuickComboBox); @@ -1583,13 +1525,8 @@ QVariant QQuickComboBox::valueAt(int index) const if (!d->isValidIndex(index)) return QVariant(); - QObject *object = d->delegateModel->object(index); - QVariant value; - if (object) { - value = d->fastValueAt(index); - d->delegateModel->release(object); - } - return value; + const QString effectiveValueRole = d->valueRole.isEmpty() ? QStringLiteral("modelData") : d->valueRole; + return d->delegateModel->variantValue(index, effectiveValueRole); } /*! @@ -1626,13 +1563,8 @@ QString QQuickComboBox::textAt(int index) const if (!d->isValidIndex(index)) return QString(); - QObject *object = d->delegateModel->object(index); - QString text; - if (object) { - text = d->fastTextAt(index); - d->delegateModel->release(object); - } - return text; + const QString effectiveTextRole = d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole; + return d->delegateModel->stringValue(index, effectiveTextRole); } /*! diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp index 800dcedb..d56131e4 100644 --- a/src/quicktemplates2/qquickdeferredexecute.cpp +++ b/src/quicktemplates2/qquickdeferredexecute.cpp @@ -92,11 +92,21 @@ static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro typedef QMultiHash<int, const QV4::CompiledData::Binding *> QV4PropertyBindingHash; auto it = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.second); auto last = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.first); +#if Q_QML_PRIVATE_API_VERSION < 7 while (it != last) { if (!state->creator->populateDeferredBinding(property, deferData, *it)) state->errors << state->creator->errors; ++it; } +#else + state->creator->beginPopulateDeferred(deferData->context); + while (it != last) { + state->creator->populateDeferredBinding(property, deferData->deferredIdx, *it); + ++it; + } + state->creator->finalizePopulateDeferred(); + state->errors << state->creator->errors; +#endif deferredState->constructionStates += state; diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index f272c5cf..d83bb8aa 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -1836,6 +1836,8 @@ void QQuickPopup::setModal(bool modal) d->toggleOverlay(); emit modalChanged(); + QQuickItemPrivate::get(d->popupItem)->isTabFence = modal; + if (!d->hasDim) { setDim(modal); d->hasDim = false; diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 16d8c4f6..28ddde66 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -42,7 +42,9 @@ #include "qquickpopup_p_p.h" #include "qquickdeferredexecute_p_p.h" -#include <QtGui/private/qshortcutmap_p.h> +#if QT_CONFIG(shortcut) +# include <QtGui/private/qshortcutmap_p.h> +#endif #include <QtGui/private/qguiapplication_p.h> QT_BEGIN_NAMESPACE diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp index 7ae5c495..4c14022a 100644 --- a/src/quicktemplates2/qquickstackelement.cpp +++ b/src/quicktemplates2/qquickstackelement.cpp @@ -44,6 +44,7 @@ #include <QtQml/private/qv4qobjectwrapper_p.h> #include <QtQml/private/qqmlcomponent_p.h> #include <QtQml/private/qqmlengine_p.h> +#include <QtQml/private/qqmlapiversion_p.h> QT_BEGIN_NAMESPACE @@ -210,7 +211,12 @@ void QQuickStackElement::initialize() QV4::ScopedValue ipv(scope, properties.value()); QV4::Scoped<QV4::QmlContext> qmlContext(scope, qmlCallingContext.value()); QV4::ScopedValue qmlObject(scope, QV4::QObjectWrapper::wrap(v4, item)); +#if Q_QML_PRIVATE_API_VERSION >= 6 + RequiredProperties requiredPropertiesCurrentlyNotSupported; + QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv, requiredPropertiesCurrentlyNotSupported, item); +#else QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv); +#endif properties.clear(); } diff --git a/tests/auto/qquickpopup/data/tabFence.qml b/tests/auto/qquickpopup/data/tabFence.qml new file mode 100644 index 00000000..2cf408e9 --- /dev/null +++ b/tests/auto/qquickpopup/data/tabFence.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Window 2.15 +import QtQuick.Controls 2.15 + +ApplicationWindow { + width: 400 + height: 400 + objectName: "Rectangle" + + property alias dialog: dialog + property alias outsideButton1: outsideButton1 + property alias outsideButton2: outsideButton2 + property alias dialogButton1: dialogButton1 + property alias dialogButton2: dialogButton2 + + ColumnLayout { + Button { + id: outsideButton1 + text: "Button1" + } + Button { + id: outsideButton2 + text: "Button2" + } + } + + Dialog { + id: dialog + objectName: "Dialog" + width: 200 + height: 200 + anchors.centerIn: parent + visible: true + + ColumnLayout { + Button { + id: dialogButton1 + text: "Button3" + } + Button { + id: dialogButton2 + text: "Button4" + } + } + } +} diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 7da20c37..76c38ea8 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -92,6 +92,7 @@ private slots: void countChanged(); void toolTipCrashOnClose(); void setOverlayParentToNull(); + void tabFence(); }; void tst_QQuickPopup::initTestCase() @@ -1249,6 +1250,62 @@ void tst_QQuickPopup::setOverlayParentToNull() // While nullifying the overlay parent doesn't make much sense, it shouldn't crash. } +void tst_QQuickPopup::tabFence() +{ + if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) + QSKIP("This platform only allows tab focus for text controls"); + + QQuickApplicationHelper helper(this, "tabFence.qml"); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("dialog").value<QQuickPopup*>(); + QVERIFY(popup); + popup->open(); + popup->setModal(true); + + QQuickButton *outsideButton1 = window->property("outsideButton1").value<QQuickButton*>(); + QVERIFY(outsideButton1); + QQuickButton *outsideButton2 = window->property("outsideButton2").value<QQuickButton*>(); + QVERIFY(outsideButton2); + QQuickButton *dialogButton1 = window->property("dialogButton1").value<QQuickButton*>(); + QVERIFY(dialogButton1); + QQuickButton *dialogButton2 = window->property("dialogButton2").value<QQuickButton*>(); + QVERIFY(dialogButton2); + + // When modal, focus loops between the two external buttons + outsideButton1->forceActiveFocus(); + QVERIFY(outsideButton1->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(outsideButton2->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(outsideButton1->hasActiveFocus()); + + // Same thing for dialog's buttons + dialogButton1->forceActiveFocus(); + QVERIFY(dialogButton1->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(dialogButton2->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(dialogButton1->hasActiveFocus()); + + popup->setModal(false); + + // When not modal, focus goes in and out of the dialog + outsideButton1->forceActiveFocus(); + QVERIFY(outsideButton1->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(outsideButton2->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(dialogButton1->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(dialogButton2->hasActiveFocus()); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(outsideButton1->hasActiveFocus()); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" |