diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-11-21 11:32:01 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2019-11-21 11:32:01 +0100 |
commit | 546539562f2aff985e78f3c2426cb711a865ad65 (patch) | |
tree | a4fac78b563b8b1d4bd40ee13bf5db3f4afdade8 | |
parent | 9c054dd5d2925adbb1ac9745013011a16f78023f (diff) | |
parent | 49b1e3ff2ac20d8aa8b3889fc76ab4e6907817fd (diff) |
Merge 5.14 into 5.14.0
Change-Id: I579dc498300e06d747bdc4dba12f7ecd617b6608
-rw-r--r-- | src/imports/controls/SwipeView.qml | 1 | ||||
-rw-r--r-- | src/imports/controls/ToolTip.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/fusion/ToolTip.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/imagine/SwipeView.qml | 1 | ||||
-rw-r--r-- | src/imports/controls/imagine/ToolTip.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/material/SwipeView.qml | 1 | ||||
-rw-r--r-- | src/imports/controls/material/ToolTip.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/universal/ToolTip.qml | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquicksplitview.cpp | 77 | ||||
-rw-r--r-- | src/quicktemplates2/qquicksplitview_p_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktheme.cpp | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktheme_p_p.h | 3 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_swipeview.qml | 49 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tooltip.qml | 22 | ||||
-rw-r--r-- | tests/auto/qquickpopup/tst_qquickpopup.cpp | 3 |
15 files changed, 119 insertions, 52 deletions
diff --git a/src/imports/controls/SwipeView.qml b/src/imports/controls/SwipeView.qml index ad242e1a..7722d258 100644 --- a/src/imports/controls/SwipeView.qml +++ b/src/imports/controls/SwipeView.qml @@ -50,6 +50,7 @@ T.SwipeView { model: control.contentModel interactive: control.interactive currentIndex: control.currentIndex + focus: control.focus spacing: control.spacing orientation: control.orientation diff --git a/src/imports/controls/ToolTip.qml b/src/imports/controls/ToolTip.qml index ae903e4c..e0389903 100644 --- a/src/imports/controls/ToolTip.qml +++ b/src/imports/controls/ToolTip.qml @@ -58,8 +58,8 @@ T.ToolTip { contentItem: Text { text: control.text font: control.font + wrapMode: Text.Wrap color: control.palette.toolTipText - // TODO: wrapMode: Label.Wrap } background: Rectangle { diff --git a/src/imports/controls/fusion/ToolTip.qml b/src/imports/controls/fusion/ToolTip.qml index 73f561e4..b505e2c9 100644 --- a/src/imports/controls/fusion/ToolTip.qml +++ b/src/imports/controls/fusion/ToolTip.qml @@ -60,8 +60,8 @@ T.ToolTip { contentItem: Text { text: control.text font: control.font + wrapMode: Text.Wrap color: control.palette.toolTipText - // TODO: wrapMode: Label.Wrap } background: Rectangle { diff --git a/src/imports/controls/imagine/SwipeView.qml b/src/imports/controls/imagine/SwipeView.qml index 4998edb7..70d65fef 100644 --- a/src/imports/controls/imagine/SwipeView.qml +++ b/src/imports/controls/imagine/SwipeView.qml @@ -61,6 +61,7 @@ T.SwipeView { model: control.contentModel interactive: control.interactive currentIndex: control.currentIndex + focus: control.focus spacing: control.spacing orientation: control.orientation diff --git a/src/imports/controls/imagine/ToolTip.qml b/src/imports/controls/imagine/ToolTip.qml index 250452d8..21d75ebc 100644 --- a/src/imports/controls/imagine/ToolTip.qml +++ b/src/imports/controls/imagine/ToolTip.qml @@ -70,7 +70,7 @@ T.ToolTip { contentItem: Text { text: control.text font: control.font - // TODO: wrapMode: Label.Wrap + wrapMode: Text.Wrap color: control.palette.toolTipText } diff --git a/src/imports/controls/material/SwipeView.qml b/src/imports/controls/material/SwipeView.qml index 12ea36ae..a84f16c5 100644 --- a/src/imports/controls/material/SwipeView.qml +++ b/src/imports/controls/material/SwipeView.qml @@ -50,6 +50,7 @@ T.SwipeView { model: control.contentModel interactive: control.interactive currentIndex: control.currentIndex + focus: control.focus spacing: control.spacing orientation: control.orientation diff --git a/src/imports/controls/material/ToolTip.qml b/src/imports/controls/material/ToolTip.qml index fb705367..83afe4b1 100644 --- a/src/imports/controls/material/ToolTip.qml +++ b/src/imports/controls/material/ToolTip.qml @@ -70,7 +70,7 @@ T.ToolTip { contentItem: Text { text: control.text font: control.font - // TODO: wrapMode: Label.Wrap + wrapMode: Text.Wrap color: control.Material.foreground } diff --git a/src/imports/controls/universal/ToolTip.qml b/src/imports/controls/universal/ToolTip.qml index cf7325b6..431cdf7c 100644 --- a/src/imports/controls/universal/ToolTip.qml +++ b/src/imports/controls/universal/ToolTip.qml @@ -59,7 +59,7 @@ T.ToolTip { contentItem: Text { text: control.text font: control.font - // TODO: wrapMode: Label.Wrap + wrapMode: Text.Wrap opacity: enabled ? 1.0 : 0.2 color: control.Universal.foreground } diff --git a/src/quicktemplates2/qquicksplitview.cpp b/src/quicktemplates2/qquicksplitview.cpp index 56392e9a..ba7644a1 100644 --- a/src/quicktemplates2/qquicksplitview.cpp +++ b/src/quicktemplates2/qquicksplitview.cpp @@ -909,6 +909,40 @@ void QQuickSplitViewPrivate::updateHandleVisibilities() } } +void QQuickSplitViewPrivate::updateHoveredHandle(QQuickItem *hoveredItem) +{ + Q_Q(QQuickSplitView); + const int oldHoveredHandleIndex = m_hoveredHandleIndex; + m_hoveredHandleIndex = m_handleItems.indexOf(hoveredItem); + if (m_hoveredHandleIndex == oldHoveredHandleIndex) + return; + + // First, clear the hovered flag of any previously-hovered handle. + if (oldHoveredHandleIndex != -1) { + QQuickItem *oldHoveredHandle = m_handleItems.at(oldHoveredHandleIndex); + QQuickSplitHandleAttached *oldHoveredHandleAttached = qobject_cast<QQuickSplitHandleAttached*>( + qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(oldHoveredHandle, true)); + QQuickSplitHandleAttachedPrivate::get(oldHoveredHandleAttached)->setHovered(false); + qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << oldHoveredHandleIndex << "is no longer hovered"; + } + + if (m_hoveredHandleIndex != -1) { + QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>( + qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(hoveredItem, true)); + QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(true); + qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << m_hoveredHandleIndex << "is now hovered"; + } else { + qCDebug(qlcQQuickSplitViewMouse) << "either there is no hovered item or" << hoveredItem << "is not a handle"; + } + +#if QT_CONFIG(cursor) + if (m_hoveredHandleIndex != -1) + q->setCursor(m_orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); + else + q->setCursor(Qt::ArrowCursor); +#endif +} + void QQuickSplitViewPrivate::setResizing(bool resizing) { Q_Q(QQuickSplitView); @@ -1327,48 +1361,7 @@ void QQuickSplitView::hoverMoveEvent(QHoverEvent *event) QQuickContainer::hoverMoveEvent(event); QQuickItem *hoveredItem = childAt(event->pos().x(), event->pos().y()); - if (!hoveredItem) { - // No handle is hovered. - if (d->m_hoveredHandleIndex != -1) { - // The previously-hovered handle is no longer hovered. - QQuickItem *oldHoveredHandle = d->m_handleItems.at(d->m_hoveredHandleIndex); - QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>( - qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(oldHoveredHandle, true)); - QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(false); - } - - qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << d->m_hoveredHandleIndex << "is no longer hovered"; - - d->m_hoveredHandleIndex = -1; - } else { - // A child item of ours is hovered. - - // First, clear the hovered flag of any previously-hovered handle. - if (d->m_hoveredHandleIndex != -1) { - QQuickItem *oldHoveredHandle = d->m_handleItems.at(d->m_hoveredHandleIndex); - QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>( - qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(oldHoveredHandle, true)); - QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(false); - } - - // Now check if the newly hovered item is actually a handle. - d->m_hoveredHandleIndex = d->m_handleItems.indexOf(hoveredItem); - - if (d->m_hoveredHandleIndex != -1) { - QQuickSplitHandleAttached *handleAttached = qobject_cast<QQuickSplitHandleAttached*>( - qmlAttachedPropertiesObject<QQuickSplitHandleAttached>(hoveredItem, true)); - QQuickSplitHandleAttachedPrivate::get(handleAttached)->setHovered(true); - - qCDebug(qlcQQuickSplitViewMouse) << "handle item at index" << d->m_hoveredHandleIndex << "is now hovered"; - } - } - -#if QT_CONFIG(cursor) - if (d->m_hoveredHandleIndex != -1) - setCursor(d->m_orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); - else - setCursor(Qt::ArrowCursor); -#endif + d->updateHoveredHandle(hoveredItem); } void QQuickSplitView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquicksplitview_p_p.h b/src/quicktemplates2/qquicksplitview_p_p.h index 5d71d461..ccefe5ec 100644 --- a/src/quicktemplates2/qquicksplitview_p_p.h +++ b/src/quicktemplates2/qquicksplitview_p_p.h @@ -74,6 +74,7 @@ public: void resizeHandle(QQuickItem *handleItem); void resizeHandles(); void updateHandleVisibilities(); + void updateHoveredHandle(QQuickItem *hoveredItem); void setResizing(bool resizing); bool isHorizontal() const; diff --git a/src/quicktemplates2/qquicktheme.cpp b/src/quicktemplates2/qquicktheme.cpp index af49ffc9..f8c4a251 100644 --- a/src/quicktemplates2/qquicktheme.cpp +++ b/src/quicktemplates2/qquicktheme.cpp @@ -109,7 +109,6 @@ static QPlatformTheme::Palette platformPalette(QQuickTheme::Scope scope) QQuickTheme::QQuickTheme() : d_ptr(new QQuickThemePrivate) { - d_ptr->q_ptr = this; } QQuickTheme::~QQuickTheme() @@ -167,6 +166,8 @@ void QQuickTheme::setFont(Scope scope, const QFont &font) { Q_D(QQuickTheme); d->fonts[scope] = QSharedPointer<QFont>::create(d->defaultFont ? d->defaultFont->resolve(font) : font); + // See comment in QQuickControlPrivate::inheritFont + d->fonts[scope]->setFamilies(QStringList()); } void QQuickTheme::setPalette(Scope scope, const QPalette &palette) diff --git a/src/quicktemplates2/qquicktheme_p_p.h b/src/quicktemplates2/qquicktheme_p_p.h index c7421677..29058bc8 100644 --- a/src/quicktemplates2/qquicktheme_p_p.h +++ b/src/quicktemplates2/qquicktheme_p_p.h @@ -54,8 +54,6 @@ QT_BEGIN_NAMESPACE class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickThemePrivate { - Q_DECLARE_PUBLIC(QQuickTheme) - public: static QQuickThemePrivate *get(QQuickTheme *theme) { @@ -70,7 +68,6 @@ public: QScopedPointer<const QPalette> defaultPalette; QSharedPointer<QFont> fonts[NScopes]; QSharedPointer<QPalette> palettes[NScopes]; - QQuickTheme *q_ptr = nullptr; }; QT_END_NAMESPACE diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml index 38af37f7..5775491c 100644 --- a/tests/auto/controls/data/tst_swipeview.qml +++ b/tests/auto/controls/data/tst_swipeview.qml @@ -574,4 +574,53 @@ TestCase { compare(control.itemAt(i).x, 0) } } + + Component { + id: focusSwipeViewComponent + + SwipeView { + id: swipeView + anchors.fill: parent + focus: true + + property int pressCount + property int releaseCount + property int rectanglePressCount + property int rectangleReleaseCount + + Rectangle { + focus: true + + Keys.onPressed: ++swipeView.rectanglePressCount + Keys.onReleased: ++swipeView.rectangleReleaseCount + } + + Keys.onPressed: ++pressCount + Keys.onReleased: ++releaseCount + } + } + + function test_focus() { + if (Qt.styleHints.tabFocusBehavior !== Qt.TabFocusAllControls) + skip("This platform only allows tab focus for text controls") + + var control = createTemporaryObject(focusSwipeViewComponent, testCase) + verify(control) + compare(control.focus, true) + compare(control.contentItem.focus, true) + compare(control.itemAt(0).focus, true) + compare(control.itemAt(0).activeFocus, true) + + keyPress(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 0) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 0) + + keyRelease(Qt.Key_A) + compare(control.pressCount, 1) + compare(control.releaseCount, 1) + compare(control.rectanglePressCount, 1) + compare(control.rectangleReleaseCount, 1) + } } diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index 70579c70..d98a7cc8 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -421,4 +421,26 @@ TestCase { compare(button2.down, false) tryCompare(button2.ToolTip, "visible", false) } + + Component { + id: wrapComponent + + Item { + ToolTip.text: "This is some very very very very very very very very very very very very" + + " very very very very very very very very very very very very very very" + + " very very very very very very very very very very very very long text" + } + } + + // QTBUG-62350 + function test_wrap() { + var item = createTemporaryObject(wrapComponent, testCase) + verify(item) + + // Avoid "cannot find window to popup in" warning that can occur if it's made visible too early. + item.ToolTip.visible = true + tryCompare(item.ToolTip.toolTip, "opened", true) + compare(item.ToolTip.toolTip.contentItem.wrapMode, Text.Wrap) + verify(item.ToolTip.toolTip.contentItem.width < item.ToolTip.toolTip.contentItem.implicitWidth) + } } diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index 7da20c37..b5c59e02 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -1026,12 +1026,13 @@ void tst_QQuickPopup::closeOnEscapeWithVisiblePopup() QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithVisiblePopup.qml")); QQuickWindow *window = helper.window; window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); + QVERIFY(QTest::qWaitForWindowActive(window)); QQuickPopup *popup = window->findChild<QQuickPopup *>("popup"); QVERIFY(popup); QTRY_VERIFY(popup->isOpened()); + QTRY_VERIFY(window->activeFocusItem()); QTest::keyClick(window, Qt::Key_Escape); QTRY_VERIFY(!popup->isVisible()); } |