diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-04 03:05:33 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-04 03:05:33 +0100 |
commit | 64c44f392b3912849e5eb81a98eae60d11c6dddb (patch) | |
tree | 537fac580423a2c75b330dda81e923f48357301c | |
parent | af0566ac7663ef5b7feb2291351e820110f71516 (diff) | |
parent | bbd6c9972206eccc4d2872be44db509ef716c351 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I0d2601b897e4cb8ce7a0d562927f3895d1f08f25
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-cppclasses.qdoc | 2 | ||||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc | 16 | ||||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-index.qdoc | 2 | ||||
-rw-r--r-- | src/imports/controls/fusion/qquickfusionbusyindicator.cpp | 2 | ||||
-rw-r--r-- | src/imports/controls/fusion/qquickfusionstyle.cpp | 2 | ||||
-rw-r--r-- | src/quickcontrols2/qquickcolor.cpp | 3 | ||||
-rw-r--r-- | src/quickcontrols2/qquickiconlabel.cpp | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 20 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdial.cpp | 6 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpane.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollview.cpp | 25 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_scrollview.qml | 49 | ||||
-rw-r--r-- | tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp | 5 |
13 files changed, 115 insertions, 22 deletions
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-cppclasses.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-cppclasses.qdoc index a2a77505..1397e974 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-cppclasses.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-cppclasses.qdoc @@ -30,6 +30,8 @@ \keyword Qt Quick Controls C++ Classes \title Qt Quick Controls 2 C++ Classes \ingroup modules + \qtvariable quickcontrols2 + \brief Provides classes for setting up the controls from C++. The C++ types can be included into your application using the following diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc index 6e5c7981..0b09edf6 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc @@ -27,16 +27,16 @@ /*! \page qtquickcontrols2-differences.html - \title Differences between Qt Quick Controls + \title Differences between Qt Quick Controls 1 - Qt Quick Controls were originally developed to support desktop platforms, + Qt Quick Controls 1 was originally developed to support desktop platforms, with mobile and embedded support coming shortly afterwards. They have a very broad scope, in that they provide a styling system flexible enough to allow the development of applications that have either a platform-dependent or platform-independent style. On embedded systems, where the hardware has limited resources, this approach - can be inefficient. Qt Quick Controls 2 were designed to solve this problem, + can be inefficient. Qt Quick Controls 2 was designed to solve this problem, using \l {https://blog.qt.io/blog/2015/03/31/qt-quick-controls-for-embedded/}{benchmarks} to guide the development. @@ -98,7 +98,7 @@ \table \header \li - \li Qt Quick Controls + \li Qt Quick Controls 1 \li Qt Quick Controls 2 \row \li Stylable delegates @@ -136,15 +136,15 @@ \li Performance may not be optimal \endlist - \section2 Porting Qt Quick Controls Code + \section2 Porting Qt Quick Controls 1 Code - The API of Qt Quick Controls 2 is very similar to Qt Quick Controls, but it + The API of Qt Quick Controls 2 is very similar to Qt Quick Controls 1, but it does come with some changes necessary to facilitate the improvements. The majority of changes are to do with styling; all of a control's delegates are now accessible in the control itself, instead of in a separate style object. - For example, to style a button in Qt Quick Controls: + For example, to style a button in Qt Quick Controls 1: \qml Button { @@ -170,7 +170,7 @@ With this in mind, a good way to prepare for a migration to Qt Quick Controls 2 is to place each control that you have a custom style for in its - own QML file. For example, the Qt Quick Controls button above could be + own QML file. For example, the Qt Quick Controls 1 button above could be moved to a file named \c Button.qml in a directory named \c controls, and used in the following manner: diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index a9916f60..651336ed 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -153,7 +153,7 @@ \li \l{Deploying Qt Quick Controls 2 Applications}{Deployment} \li \l{Qt Quick Controls 2 Configuration File}{Configuration File} \li \l{Supported Environment Variables in Qt Quick Controls 2}{Environment Variables} - \li \l{Differences between Qt Quick Controls} + \li \l{Differences between Qt Quick Controls 1} \endlist \section1 Reference diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp index 81618191..a9b75d27 100644 --- a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp +++ b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp @@ -82,7 +82,7 @@ void QQuickFusionBusyIndicator::paint(QPainter *painter) const qreal sz = qMin(w, h); const qreal dx = (w - sz) / 2; const qreal dy = (h - sz) / 2; - const int hpw = qRound(qMax(1.0, sz / 14)) & -1; + const int hpw = qRound(qMax(qreal(1), sz / 14)) & -1; const int pw = 2 * hpw; const QRectF bounds(dx + hpw, dy + hpw, sz - pw - 1, sz - pw - 1); diff --git a/src/imports/controls/fusion/qquickfusionstyle.cpp b/src/imports/controls/fusion/qquickfusionstyle.cpp index a66665fc..cb3889c8 100644 --- a/src/imports/controls/fusion/qquickfusionstyle.cpp +++ b/src/imports/controls/fusion/qquickfusionstyle.cpp @@ -85,8 +85,6 @@ QColor QQuickFusionStyle::innerContrastLine() QColor QQuickFusionStyle::highlight(const QPalette &palette) { - if (isMacSystemPalette(palette)) - return QColor(60, 140, 230); return palette.color(QPalette::Highlight); } diff --git a/src/quickcontrols2/qquickcolor.cpp b/src/quickcontrols2/qquickcolor.cpp index 66ef21b7..8ae568fc 100644 --- a/src/quickcontrols2/qquickcolor.cpp +++ b/src/quickcontrols2/qquickcolor.cpp @@ -45,7 +45,8 @@ QQuickColor::QQuickColor(QObject *parent) : QColor QQuickColor::transparent(const QColor &color, qreal opacity) const { - return QColor(color.red(), color.green(), color.blue(), qBound(0.0, opacity, 1.0) * 255); + return QColor(color.red(), color.green(), color.blue(), + int(qreal(255) * qBound(qreal(0), opacity, qreal(1)))); } QColor QQuickColor::blend(const QColor &a, const QColor &b, qreal factor) const diff --git a/src/quickcontrols2/qquickiconlabel.cpp b/src/quickcontrols2/qquickiconlabel.cpp index 6232b48c..37e6060a 100644 --- a/src/quickcontrols2/qquickiconlabel.cpp +++ b/src/quickcontrols2/qquickiconlabel.cpp @@ -233,6 +233,7 @@ static QRectF alignedRect(bool mirrored, Qt::Alignment alignment, const QSizeF & void QQuickIconLabelPrivate::layout() { + Q_Q(QQuickIconLabel); if (!componentComplete) return; @@ -327,6 +328,8 @@ void QQuickIconLabelPrivate::layout() } break; } + + q->setBaselineOffset(label ? label->y() + label->baselineOffset() : 0); } static const QQuickItemPrivate::ChangeTypes itemChangeTypes = diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 26e28ebe..1fa70662 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -122,10 +122,20 @@ QT_BEGIN_NAMESPACE \section1 Event Handling All controls, except non-interactive indicators, do not let clicks and - touches through to items below them. For example, if \l Pane is used as the - \l {ApplicationWindow::}{header} or \l {ApplicationWindow::}{footer} of - \l ApplicationWindow, items underneath it will not get mouse or touch - events. + touches through to items below them. For example, the \c console.log() + call in the example below will never be executed when clicking on the + Pane, because the \l MouseArea is below it in the scene: + + \code + MouseArea { + anchors.fill: parent + onClicked: console.log("MouseArea was clicked") + + Pane { + anchors.fill: parent + } + } + \endcode \sa ApplicationWindow, Container */ @@ -413,7 +423,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) delete oldContentItem; if (item) { - connect(contentItem, &QQuickItem::baselineOffsetChanged, this, &QQuickControlPrivate::updateBaselineOffset); + connect(contentItem.data(), &QQuickItem::baselineOffsetChanged, this, &QQuickControlPrivate::updateBaselineOffset); if (!item->parentItem()) item->setParentItem(q); if (componentComplete) diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 123f9b1b..431b25a8 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -191,13 +191,13 @@ qreal QQuickDialPrivate::linearPositionAt(const QPointF &point) const dragDistance = point.y() - pressPoint.y(); } const qreal normalisedDifference = dragDistance / dragArea; - return qBound(0.0, positionBeforePress - normalisedDifference, 1.0); + return qBound(qreal(0), positionBeforePress - normalisedDifference, qreal(1)); } void QQuickDialPrivate::setPosition(qreal pos) { Q_Q(QQuickDial); - pos = qBound<qreal>(0.0, pos, 1.0); + pos = qBound<qreal>(qreal(0), pos, qreal(1)); if (qFuzzyCompare(position, pos)) return; @@ -219,7 +219,7 @@ void QQuickDialPrivate::updatePosition() bool QQuickDialPrivate::isLargeChange(const QPointF &eventPos, qreal proposedPosition) const { - return qAbs(proposedPosition - position) >= 0.5 && eventPos.y() >= height / 2; + return qAbs(proposedPosition - position) >= qreal(0.5) && eventPos.y() >= height / 2; } bool QQuickDialPrivate::isHorizontalOrVertical() const diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index d923267f..3edbce9d 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE \endcode \sa {Customizing Pane}, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls 2}, {Event Handling} */ void QQuickPanePrivate::init() diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index abd75d31..57b0177e 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -132,6 +132,9 @@ public: void updateContentWidth(); void updateContentHeight(); + qreal getContentWidth() const override; + qreal getContentHeight() const override; + QQuickScrollBar *verticalScrollBar() const; QQuickScrollBar *horizontalScrollBar() const; @@ -249,6 +252,28 @@ void QQuickScrollViewPrivate::updateContentHeight() emit q->implicitContentHeightChanged(); } +qreal QQuickScrollViewPrivate::getContentWidth() const +{ + if (flickable) { + const qreal cw = flickable->contentWidth(); + if (cw > 0) + return cw; + } + + return QQuickPanePrivate::getContentWidth(); +} + +qreal QQuickScrollViewPrivate::getContentHeight() const +{ + if (flickable) { + const qreal ch = flickable->contentHeight(); + if (ch > 0) + return ch; + } + + return QQuickPanePrivate::getContentHeight(); +} + QQuickScrollBar *QQuickScrollViewPrivate::verticalScrollBar() const { Q_Q(const QQuickScrollView); diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml index 80110b5a..a06072e5 100644 --- a/tests/auto/controls/data/tst_scrollview.qml +++ b/tests/auto/controls/data/tst_scrollview.qml @@ -118,6 +118,22 @@ TestCase { } Component { + id: emptyFlickable + ScrollView { + Flickable { + } + } + } + + Component { + id: labelComponent + Label { + text: "ABC" + font.pixelSize: 512 + } + } + + Component { id: scrollableListView ScrollView { ListView { @@ -241,6 +257,39 @@ TestCase { compare(control.contentHeight, listview.contentHeight) } + function test_flickableWithExplicitContentSize() { + var control = createTemporaryObject(emptyFlickable, testCase) + verify(control) + + var flickable = control.contentItem + verify(flickable.hasOwnProperty("contentX")) + verify(flickable.hasOwnProperty("contentY")) + + var flickableContentSize = 1000; + flickable.contentWidth = flickableContentSize; + flickable.contentHeight = flickableContentSize; + + compare(flickable.contentWidth, flickableContentSize) + compare(flickable.contentHeight, flickableContentSize) + compare(control.implicitWidth, flickableContentSize) + compare(control.implicitHeight, flickableContentSize) + compare(control.contentWidth, flickableContentSize) + compare(control.contentHeight, flickableContentSize) + + // Add a single child to the flickable. This should not + // trick ScrollView into taking the implicit size of + // the child as content size, since the flickable + // already has an explicit content size. + labelComponent.createObject(flickable); + + compare(flickable.contentWidth, flickableContentSize) + compare(flickable.contentHeight, flickableContentSize) + compare(control.implicitWidth, flickableContentSize) + compare(control.implicitHeight, flickableContentSize) + compare(control.contentWidth, flickableContentSize) + compare(control.contentHeight, flickableContentSize) + } + function test_mouse() { var control = createTemporaryObject(scrollView, testCase, {width: 200, height: 200, contentHeight: 400}) verify(control) diff --git a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp index 1f00d8e7..0ecc95c5 100644 --- a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp @@ -216,6 +216,11 @@ void tst_qquickiconlabel::display() QCOMPARE(label->implicitHeight(), qMax(icon->implicitHeight(), text->implicitHeight()) + verticalPadding); break; } + + if (text) + QCOMPARE(label->baselineOffset(), text->y() + text->baselineOffset()); + else + QCOMPARE(label->baselineOffset(), 0); } } |