Merge remote-tracking branch 'origin/5.7' into 5.8

Conflicts:
	tests/auto/quick/qquicktextedit/BLACKLIST

Change-Id: I0b9e5bea5da5d2666887c202e62d889b4aa56900
This commit is contained in:
Liang Qi 2016-10-27 12:27:54 +02:00
commit 9d085bf002
14 changed files with 139 additions and 48 deletions

View File

@ -52,8 +52,8 @@ remain with C++ by invoking QQmlEngine::setObjectOwnership() with
QQmlEngine::CppOwnership specified.
Additionally, the QML engine respects the normal QObject parent ownership
semantics of Qt C++ objects, and will not ever take ownership of a QObject
instance which already has a parent.
semantics of Qt C++ objects, and will never delete a QObject instance which
has a parent.
\section1 Basic Qt Data Types

View File

@ -175,10 +175,7 @@ public:
Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
#if defined(V4_BOOTSTRAP)
Q_ALWAYS_INLINE Heap::Base *m() const { Q_UNREACHABLE(); return Q_NULLPTR; }
Q_ALWAYS_INLINE void setM(Heap::Base *b) { Q_UNUSED(b); Q_UNREACHABLE(); }
#elif defined(QV4_USE_64_BIT_VALUE_ENCODING)
#if defined(QV4_USE_64_BIT_VALUE_ENCODING)
Q_ALWAYS_INLINE Heap::Base *m() const
{
Heap::Base *b;

View File

@ -67,10 +67,6 @@ int QAccessibleQuickItem::childCount() const
QRect QAccessibleQuickItem::rect() const
{
const QRect r = itemScreenRect(item());
if (!r.isValid()) {
qWarning() << item()->metaObject()->className() << item()->property("accessibleText") << r;
}
return r;
}

View File

@ -749,7 +749,7 @@ void QQuickDragAttached::cancel()
*/
/*!
\qmlattachedsignal QtQuick::Drag::dragFinished(DropAction action)
\qmlattachedsignal QtQuick::Drag::dragFinished(DropAction dropAction)
This signal is emitted when a drag finishes and the drag was started with the
\l startDrag() method or started automatically using the \l dragType property.

View File

@ -2340,8 +2340,8 @@ QString QQuickTextInput::preeditText() const
If true, the user can use the mouse to select text in some
platform-specific way. Note that for some platforms this may
not be an appropriate interaction (eg. may conflict with how
the text needs to behave inside a Flickable.
not be an appropriate interaction (it may conflict with how
the text needs to behave inside a \l Flickable, for example).
*/
bool QQuickTextInput::selectByMouse() const
{

View File

@ -1799,6 +1799,7 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event
if (item->contains(p)) {
QWheelEvent wheel(p, p, event->pixelDelta(), event->angleDelta(), event->delta(),
event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
wheel.setTimestamp(event->timestamp());
wheel.accept();
QCoreApplication::sendEvent(item, &wheel);
if (wheel.isAccepted()) {

View File

@ -240,7 +240,8 @@ bool QSG24BitTextMaskShader::useSRGB() const
// m_useSRGB is true, but if some QOGLFBO was bound check it's texture format:
QOpenGLContext *ctx = QOpenGLContext::currentContext();
QOpenGLFramebufferObject *qfbo = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo;
return !qfbo || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
bool fboInvalid = QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid;
return !qfbo || fboInvalid || qfbo->format().internalTextureFormat() == GL_SRGB8_ALPHA8_EXT;
#else
return m_useSRGB;
#endif

View File

@ -41,10 +41,9 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
#include <QtQuick/private/qtquickglobal_p.h>
#include <QtGui/private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
/*!
\qmltype Shortcut
\instantiates QQuickShortcut
@ -89,6 +88,39 @@ QT_BEGIN_NAMESPACE
The corresponding handler is \c onActivatedAmbiguously.
*/
static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext context)
{
switch (context) {
case Qt::ApplicationShortcut:
return true;
case Qt::WindowShortcut:
while (obj && !obj->isWindowType()) {
obj = obj->parent();
if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
obj = item->window();
}
return obj && obj == QGuiApplication::focusWindow();
default:
return false;
}
}
typedef bool (*ContextMatcher)(QObject *, Qt::ShortcutContext);
Q_GLOBAL_STATIC_WITH_ARGS(ContextMatcher, ctxMatcher, (qQuickShortcutContextMatcher))
Q_QUICK_PRIVATE_EXPORT ContextMatcher qt_quick_shortcut_context_matcher()
{
return *ctxMatcher();
}
Q_QUICK_PRIVATE_EXPORT void qt_quick_set_shortcut_context_matcher(ContextMatcher matcher)
{
*ctxMatcher() = matcher;
}
QT_BEGIN_NAMESPACE
QQuickShortcut::QQuickShortcut(QObject *parent) : QObject(parent), m_id(0),
m_enabled(true), m_completed(false), m_autorepeat(true), m_context(Qt::WindowShortcut)
{
@ -278,30 +310,13 @@ bool QQuickShortcut::event(QEvent *event)
return false;
}
static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext context)
{
switch (context) {
case Qt::ApplicationShortcut:
return true;
case Qt::WindowShortcut:
while (obj && !obj->isWindowType()) {
obj = obj->parent();
if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
obj = item->window();
}
return obj && obj == QGuiApplication::focusWindow();
default:
return false;
}
}
void QQuickShortcut::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)
{
ungrabShortcut();
if (m_completed && !sequence.isEmpty()) {
QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
m_id = pApp->shortcutMap.addShortcut(this, sequence, context, qQuickShortcutContextMatcher);
m_id = pApp->shortcutMap.addShortcut(this, sequence, context, *ctxMatcher());
if (!m_enabled)
pApp->shortcutMap.setShortcutEnabled(false, m_id, this);
if (!m_autorepeat)

View File

@ -48,7 +48,7 @@ public:
TestItem(QQuickItem *parent = 0)
: QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
, wheelCount(0), acceptIncomingTouchEvents(true)
, touchEventReached(false) {}
, touchEventReached(false), timestamp(0) {}
bool focused;
int pressCount;
@ -56,6 +56,7 @@ public:
int wheelCount;
bool acceptIncomingTouchEvents;
bool touchEventReached;
ulong timestamp;
protected:
virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
@ -65,7 +66,7 @@ protected:
touchEventReached = true;
event->setAccepted(acceptIncomingTouchEvents);
}
virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; }
virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; timestamp = event->timestamp(); }
};
class TestWindow: public QQuickWindow
@ -1432,12 +1433,14 @@ void tst_qquickitem::wheelEvent()
item->setVisible(visible);
QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
event.setTimestamp(123456UL);
event.setAccepted(false);
QGuiApplication::sendEvent(&window, &event);
if (shouldReceiveWheelEvents) {
QVERIFY(event.isAccepted());
QCOMPARE(item->wheelCount, 1);
QCOMPARE(item->timestamp, 123456UL);
} else {
QVERIFY(!event.isAccepted());
QCOMPARE(item->wheelCount, 0);

View File

@ -43,6 +43,8 @@ private slots:
void sequence();
void context_data();
void context();
void matcher_data();
void matcher();
};
Q_DECLARE_METATYPE(Qt::Key)
@ -344,6 +346,68 @@ void tst_QQuickShortcut::context()
|| inactiveWindow->property("ambiguousShortcut").toString() == ambiguousShortcut);
}
typedef bool (*ShortcutContextMatcher)(QObject *, Qt::ShortcutContext);
extern ShortcutContextMatcher qt_quick_shortcut_context_matcher();
extern void qt_quick_set_shortcut_context_matcher(ShortcutContextMatcher matcher);
static ShortcutContextMatcher lastMatcher = nullptr;
static bool trueMatcher(QObject *, Qt::ShortcutContext)
{
lastMatcher = trueMatcher;
return true;
}
static bool falseMatcher(QObject *, Qt::ShortcutContext)
{
lastMatcher = falseMatcher;
return false;
}
Q_DECLARE_METATYPE(ShortcutContextMatcher)
void tst_QQuickShortcut::matcher_data()
{
QTest::addColumn<ShortcutContextMatcher>("matcher");
QTest::addColumn<Qt::Key>("key");
QTest::addColumn<QVariant>("shortcut");
QTest::addColumn<QString>("activatedShortcut");
ShortcutContextMatcher tm = trueMatcher;
ShortcutContextMatcher fm = falseMatcher;
QTest::newRow("F1") << tm << Qt::Key_F1 << shortcutMap("F1", Qt::ApplicationShortcut) << "F1";
QTest::newRow("F2") << fm << Qt::Key_F2 << shortcutMap("F2", Qt::ApplicationShortcut) << "";
}
void tst_QQuickShortcut::matcher()
{
QFETCH(ShortcutContextMatcher, matcher);
QFETCH(Qt::Key, key);
QFETCH(QVariant, shortcut);
QFETCH(QString, activatedShortcut);
ShortcutContextMatcher defaultMatcher = qt_quick_shortcut_context_matcher();
QVERIFY(defaultMatcher);
qt_quick_set_shortcut_context_matcher(matcher);
QVERIFY(qt_quick_shortcut_context_matcher() == matcher);
QQmlApplicationEngine engine(testFileUrl("shortcuts.qml"));
QQuickWindow *window = qobject_cast<QQuickWindow *>(engine.rootObjects().value(0));
QVERIFY(window);
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
window->setProperty("shortcuts", QVariantList() << shortcut);
QTest::keyClick(window, key);
QVERIFY(lastMatcher == matcher);
QCOMPARE(window->property("activatedShortcut").toString(), activatedShortcut);
qt_quick_set_shortcut_context_matcher(defaultMatcher);
}
QTEST_MAIN(tst_QQuickShortcut)
#include "tst_qquickshortcut.moc"

View File

@ -1,7 +1,5 @@
[dependentImplicitSizes]
*
[mouseSelection]
*
[lineLaidOutRelayout]
msvc-2015
[fontSizeMode]

View File

@ -1,2 +0,0 @@
[mouseSelection]
*

View File

@ -2072,12 +2072,18 @@ void tst_qquicktextedit::mouseSelection()
else if (clicks == 3)
QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1);
if (clicks == 2) {
// QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating
// double click events by adding 500ms delta to release event timestamps.
// Send a double click event by hand to ensure the correct sequence:
// press, release, press, _dbl click_, move, release.
QMouseEvent dblClickEvent(QEvent::MouseButtonDblClick, p1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QGuiApplication::sendEvent(textEditObject, &dblClickEvent);
}
QTest::mouseMove(&window, p2);
QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2);
QTRY_COMPARE(textEditObject->selectedText(), selectedText);
QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
// Clicking and shift to clicking between the same points should select the same text.
textEditObject->setCursorPosition(0);
if (clicks > 1)
@ -2086,9 +2092,6 @@ void tst_qquicktextedit::mouseSelection()
QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1);
QTest::mouseClick(&window, Qt::LeftButton, Qt::ShiftModifier, p2);
QTRY_COMPARE(textEditObject->selectedText(), selectedText);
// ### This is to prevent double click detection from carrying over to the next test.
QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
}
void tst_qquicktextedit::dragMouseSelection()
@ -3029,9 +3032,6 @@ void tst_qquicktextedit::middleClickPaste()
// Middle click pastes the selected text, assuming the platform supports it.
QTest::mouseClick(&window, Qt::MiddleButton, Qt::NoModifier, p3);
// ### This is to prevent double click detection from carrying over to the next test.
QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10);
if (QGuiApplication::clipboard()->supportsSelection())
QCOMPARE(textEditObject->text().mid(1, selectedText.length()), selectedText);
else

View File

@ -0,0 +1,18 @@
// test use of Fixedsys font on Windows
import QtQuick 2.0
Item {
width: 320
height: 480
Text {
anchors.fill: parent
wrapMode: Text.Wrap
font.family: "Fixedsys"
font.pixelSize: 20
text: "Foobar"
}
}