aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/Container.qml47
-rw-r--r--src/imports/controls/Control.qml47
-rw-r--r--src/imports/controls/controls.pri2
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp8
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h2
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp4
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp29
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp19
-rw-r--r--src/quicktemplates2/qquickscrollindicator.cpp13
-rw-r--r--src/quicktemplates2/qquickswitch.cpp8
-rw-r--r--tests/auto/controls/data/tst_container.qml85
-rw-r--r--tests/auto/controls/data/tst_control.qml29
-rw-r--r--tests/auto/controls/data/tst_popup.qml10
-rw-r--r--tests/auto/controls/data/tst_scrollindicator.qml34
-rw-r--r--tests/auto/controls/data/tst_switch.qml11
-rw-r--r--tests/auto/drawer/tst_drawer.cpp3
-rw-r--r--tests/auto/qquickmaterialstyle/data/tst_material.qml29
17 files changed, 356 insertions, 24 deletions
diff --git a/src/imports/controls/Container.qml b/src/imports/controls/Container.qml
new file mode 100644
index 00000000..9e9215f8
--- /dev/null
+++ b/src/imports/controls/Container.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Templates 2.0 as T
+
+T.Container {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding)
+}
diff --git a/src/imports/controls/Control.qml b/src/imports/controls/Control.qml
new file mode 100644
index 00000000..a4bb95fe
--- /dev/null
+++ b/src/imports/controls/Control.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Templates 2.0 as T
+
+T.Control {
+ id: control
+
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding)
+}
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index eecaccd4..f84c59bc 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -16,6 +16,8 @@ QML_CONTROLS = \
CheckDelegate.qml \
CheckIndicator.qml \
ComboBox.qml \
+ Container.qml \
+ Control.qml \
Dial.qml \
Dialog.qml \
DialogButtonBox.qml \
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index 76332c51..e412ea12 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -706,6 +706,7 @@ void QQuickMaterialStyle::setBackground(const QVariant &var)
m_background = background;
propagateBackground();
emit backgroundChanged();
+ emit paletteChanged();
}
void QQuickMaterialStyle::inheritBackground(uint background, bool custom, bool has)
@@ -854,7 +855,7 @@ QColor QQuickMaterialStyle::buttonColor(bool highlighted) const
QColor color = Qt::transparent;
- if (m_hasBackground) {
+ if (m_explicitBackground) {
color = backgroundColor(shade);
} else if (highlighted) {
color = accentColor(shade);
@@ -950,11 +951,6 @@ QColor QQuickMaterialStyle::scrollBarPressedColor() const
return QColor::fromRgba(m_theme == Light ? 0x80000000 : 0x80FFFFFF);
}
-QColor QQuickMaterialStyle::drawerBackgroundColor() const
-{
- return QColor::fromRgba(dividerColorLight);
-}
-
QColor QQuickMaterialStyle::dialogColor() const
{
if (!m_hasBackground)
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index 78ba88da..56b26dfc 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -91,7 +91,6 @@ class QQuickMaterialStyle : public QQuickStyleAttached
Q_PROPERTY(QColor scrollBarColor READ scrollBarColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor scrollBarHoveredColor READ scrollBarHoveredColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor NOTIFY paletteChanged FINAL)
- Q_PROPERTY(QColor drawerBackgroundColor READ drawerBackgroundColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor dialogColor READ dialogColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor backgroundDimColor READ backgroundDimColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor listHighlightColor READ listHighlightColor NOTIFY paletteChanged FINAL)
@@ -213,7 +212,6 @@ public:
QColor scrollBarColor() const;
QColor scrollBarHoveredColor() const;
QColor scrollBarPressedColor() const;
- QColor drawerBackgroundColor() const;
QColor dialogColor() const;
QColor backgroundDimColor() const;
QColor listHighlightColor() const;
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 8804fff2..f7ee00a6 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -87,8 +87,6 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickAbstractButton>(uri, 2, 0, "AbstractButton");
qmlRegisterType<QQuickButtonGroup>(uri, 2, 0, "ButtonGroup");
qmlRegisterType<QQuickButtonGroupAttached>();
- qmlRegisterType<QQuickContainer>(uri, 2, 0, "Container");
- qmlRegisterType<QQuickControl>(uri, 2, 0, "Control");
QQuickStylePrivate::init(typeUrl());
const QString style = QQuickStyle::name();
@@ -104,6 +102,8 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType(selector.select(QStringLiteral("CheckBox.qml")), uri, 2, 0, "CheckBox");
qmlRegisterType(selector.select(QStringLiteral("CheckDelegate.qml")), uri, 2, 0, "CheckDelegate");
qmlRegisterType(selector.select(QStringLiteral("ComboBox.qml")), uri, 2, 0, "ComboBox");
+ qmlRegisterType(selector.select(QStringLiteral("Container.qml")), uri, 2, 0, "Container");
+ qmlRegisterType(selector.select(QStringLiteral("Control.qml")), uri, 2, 0, "Control");
qmlRegisterType(selector.select(QStringLiteral("Dial.qml")), uri, 2, 0, "Dial");
qmlRegisterType(selector.select(QStringLiteral("Drawer.qml")), uri, 2, 0, "Drawer");
qmlRegisterType(selector.select(QStringLiteral("Frame.qml")), uri, 2, 0, "Frame");
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index e2e6c84e..bb68320d 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -283,8 +283,25 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent
bool wasGrabbed = popupItem->keepMouseGrab();
if (wasGrabbed) {
- velocityCalculator.stopMeasuring(event->pos(), event->timestamp());
- const qreal velocity = velocityCalculator.velocity().x();
+ const QPointF releasePoint = event->windowPos();
+ velocityCalculator.stopMeasuring(releasePoint, event->timestamp());
+
+ qreal velocity = 0;
+ if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
+ velocity = velocityCalculator.velocity().x();
+ else
+ velocity = velocityCalculator.velocity().y();
+
+ // the velocity is calculated so that swipes from left to right
+ // and top to bottom have positive velocity, and swipes from right
+ // to left and bottom to top have negative velocity.
+ //
+ // - top/left edge: positive velocity opens, negative velocity closes
+ // - bottom/right edge: negative velocity opens, positive velocity closes
+ //
+ // => invert the velocity for bottom and right edges, for the threshold comparison below
+ if (edge == Qt::RightEdge || edge == Qt::BottomEdge)
+ velocity = -velocity;
if (position > 0.7 || velocity > openCloseVelocityThreshold) {
transitionManager.transitionEnter();
@@ -293,25 +310,25 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent
} else {
switch (edge) {
case Qt::LeftEdge:
- if (event->x() - pressPoint.x() > 0)
+ if (releasePoint.x() - pressPoint.x() > 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::RightEdge:
- if (event->x() - pressPoint.x() < 0)
+ if (releasePoint.x() - pressPoint.x() < 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::TopEdge:
- if (event->y() - pressPoint.y() > 0)
+ if (releasePoint.y() - pressPoint.y() > 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::BottomEdge:
- if (event->y() - pressPoint.y() < 0)
+ if (releasePoint.y() - pressPoint.y() < 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 850de875..5dd92a26 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -57,6 +57,7 @@ public:
void createOverlay(QQuickPopup *popup);
void destroyOverlay(QQuickPopup *popup);
void resizeOverlay(QQuickPopup *popup);
+ void toggleOverlay();
QVector<QQuickPopup *> stackingOrderPopups() const;
@@ -106,7 +107,7 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ
context->setContextObject(popup);
QQuickItem *item = qobject_cast<QQuickItem*>(component->beginCreate(context));
if (item) {
- item->setOpacity(0.0);
+ item->setOpacity(popup->isVisible() ? 1.0 : 0.0);
item->setParentItem(parent);
item->stackBefore(popup->popupItem());
item->setZ(popup->z());
@@ -150,6 +151,18 @@ void QQuickOverlayPrivate::resizeOverlay(QQuickPopup *popup)
}
}
+void QQuickOverlayPrivate::toggleOverlay()
+{
+ Q_Q(QQuickOverlay);
+ QQuickPopup *popup = qobject_cast<QQuickPopup *>(q->sender());
+ if (!popup)
+ return;
+
+ destroyOverlay(popup);
+ if (popup->dim())
+ createOverlay(popup);
+}
+
QVector<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
{
const QList<QQuickItem *> children = paintOrderChildItems();
@@ -233,6 +246,8 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
d->popups.append(popup);
if (popup->dim())
d->createOverlay(popup);
+ QObjectPrivate::connect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay);
+ QObjectPrivate::connect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay);
QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup);
if (drawer) {
@@ -247,6 +262,8 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
} else if (change == ItemChildRemovedChange) {
d->popups.removeOne(popup);
d->destroyOverlay(popup);
+ QObjectPrivate::disconnect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay);
+ QObjectPrivate::disconnect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay);
QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup);
if (drawer) {
diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp
index acb8dd46..351f3113 100644
--- a/src/quicktemplates2/qquickscrollindicator.cpp
+++ b/src/quicktemplates2/qquickscrollindicator.cpp
@@ -109,12 +109,17 @@ void QQuickScrollIndicatorPrivate::resizeContent()
if (!contentItem)
return;
+ // - negative overshoot (pos < 0): clamp the pos to 0, and deduct the overshoot from the size
+ // - positive overshoot (pos + size > 1): clamp the size to 1-pos
+ const qreal clampedSize = qBound<qreal>(0, size + qMin<qreal>(0, position), 1.0 - position);
+ const qreal clampedPos = qBound<qreal>(0, position, 1.0 - clampedSize);
+
if (orientation == Qt::Horizontal) {
- contentItem->setPosition(QPointF(q->leftPadding() + position * q->availableWidth(), q->topPadding()));
- contentItem->setSize(QSizeF(q->availableWidth() * size, q->availableHeight()));
+ contentItem->setPosition(QPointF(q->leftPadding() + clampedPos * q->availableWidth(), q->topPadding()));
+ contentItem->setSize(QSizeF(q->availableWidth() * clampedSize, q->availableHeight()));
} else {
- contentItem->setPosition(QPointF(q->leftPadding(), q->topPadding() + position * q->availableHeight()));
- contentItem->setSize(QSizeF(q->availableWidth(), q->availableHeight() * size));
+ contentItem->setPosition(QPointF(q->leftPadding(), q->topPadding() + clampedPos * q->availableHeight()));
+ contentItem->setSize(QSizeF(q->availableWidth(), q->availableHeight() * clampedSize));
}
}
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index 439950d8..cb966568 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -37,6 +37,8 @@
#include "qquickswitch_p.h"
#include "qquickabstractbutton_p_p.h"
+#include <QtGui/qstylehints.h>
+#include <QtGui/qguiapplication.h>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
@@ -119,6 +121,9 @@ bool QQuickSwitchPrivate::handleMousePressEvent(QQuickItem *child, QMouseEvent *
{
Q_Q(QQuickSwitch);
Q_UNUSED(child);
+ if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease())
+ q->forceActiveFocus(Qt::MouseFocusReason);
+
pressPoint = event->pos();
q->setPressed(true);
event->accept();
@@ -140,6 +145,9 @@ bool QQuickSwitchPrivate::handleMouseMoveEvent(QQuickItem *child, QMouseEvent *e
bool QQuickSwitchPrivate::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent *event)
{
Q_Q(QQuickSwitch);
+ if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && QGuiApplication::styleHints()->setFocusOnTouchRelease())
+ q->forceActiveFocus(Qt::MouseFocusReason);
+
pressPoint = QPoint();
q->setPressed(false);
if (child->keepMouseGrab()) {
diff --git a/tests/auto/controls/data/tst_container.qml b/tests/auto/controls/data/tst_container.qml
new file mode 100644
index 00000000..d1ff54e0
--- /dev/null
+++ b/tests/auto/controls/data/tst_container.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.2
+import QtTest 1.0
+import QtQuick.Controls 2.0
+import QtQuick.Templates 2.0 as T
+
+TestCase {
+ id: testCase
+ width: 400
+ height: 400
+ visible: true
+ when: windowShown
+ name: "Container"
+
+ Component {
+ id: container
+ Container { }
+ }
+
+ Component {
+ id: rectangle
+ Rectangle { }
+ }
+
+ function test_implicitSize() {
+ var control = container.createObject(testCase)
+ verify(control)
+
+ compare(control.implicitWidth, 0)
+ compare(control.implicitHeight, 0)
+
+ control.contentItem = rectangle.createObject(control, {implicitWidth: 10, implicitHeight: 20})
+ compare(control.implicitWidth, 10)
+ compare(control.implicitHeight, 20)
+
+ control.background = rectangle.createObject(control, {implicitWidth: 20, implicitHeight: 30})
+ compare(control.implicitWidth, 20)
+ compare(control.implicitHeight, 30)
+
+ control.padding = 100
+ compare(control.implicitWidth, 210)
+ compare(control.implicitHeight, 220)
+
+ control.destroy()
+ }
+}
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index fc839493..0061440b 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -53,7 +53,12 @@ TestCase {
Component {
id: component
- T.Control { }
+ Control { }
+ }
+
+ Component {
+ id: rectangle
+ Rectangle { }
}
Component {
@@ -877,4 +882,26 @@ TestCase {
control.destroy()
}
+
+ function test_implicitSize() {
+ var control = component.createObject(testCase)
+ verify(control)
+
+ compare(control.implicitWidth, 0)
+ compare(control.implicitHeight, 0)
+
+ control.contentItem = rectangle.createObject(control, {implicitWidth: 10, implicitHeight: 20})
+ compare(control.implicitWidth, 10)
+ compare(control.implicitHeight, 20)
+
+ control.background = rectangle.createObject(control, {implicitWidth: 20, implicitHeight: 30})
+ compare(control.implicitWidth, 20)
+ compare(control.implicitHeight, 30)
+
+ control.padding = 100
+ compare(control.implicitWidth, 210)
+ compare(control.implicitHeight, 220)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml
index 759d6988..52c24c86 100644
--- a/tests/auto/controls/data/tst_popup.qml
+++ b/tests/auto/controls/data/tst_popup.qml
@@ -1159,17 +1159,23 @@ TestCase {
tryCompare(window.plainPopup, "visible", true)
compare(window.overlay.children.length, countBefore + 1) // only popup added, no overlays involved
+ window.plainPopup.modal = true
+ compare(window.overlay.children.length, countBefore + 2) // overlay added
+
window.plainPopup.close()
tryCompare(window.plainPopup, "visible", false)
- compare(window.overlay.children.length, countBefore) // only popup removed, no overlays involved
+ compare(window.overlay.children.length, countBefore) // popup + overlay removed
window.modalPopupWithoutDim.open()
tryCompare(window.modalPopupWithoutDim, "visible", true)
compare(window.overlay.children.length, countBefore + 1) // only popup added, no overlays involved
+ window.modalPopupWithoutDim.dim = true
+ compare(window.overlay.children.length, countBefore + 2) // overlay added
+
window.modalPopupWithoutDim.close()
tryCompare(window.modalPopupWithoutDim, "visible", false)
- compare(window.overlay.children.length, countBefore) // only popup added, no overlays involved
+ compare(window.overlay.children.length, countBefore) // popup + overlay removed
window.destroy()
}
diff --git a/tests/auto/controls/data/tst_scrollindicator.qml b/tests/auto/controls/data/tst_scrollindicator.qml
index 00730bf4..551247f6 100644
--- a/tests/auto/controls/data/tst_scrollindicator.qml
+++ b/tests/auto/controls/data/tst_scrollindicator.qml
@@ -157,4 +157,38 @@ TestCase {
ignoreWarning(Qt.resolvedUrl("tst_scrollindicator.qml") + ":45:1: QML TestCase: ScrollIndicator must be attached to a Flickable")
testCase.ScrollIndicator.vertical = null
}
+
+ function test_overshoot() {
+ var container = flickable.createObject(testCase)
+ verify(container)
+ waitForRendering(container)
+
+ var vertical = scrollIndicator.createObject(container, {size: 0.5})
+ container.ScrollIndicator.vertical = vertical
+
+ var horizontal = scrollIndicator.createObject(container, {size: 0.5})
+ container.ScrollIndicator.horizontal = horizontal
+
+ // negative vertical overshoot (pos < 0)
+ vertical.position = -0.1
+ compare(vertical.contentItem.y, vertical.topPadding)
+ compare(vertical.contentItem.height, 0.4 * vertical.availableHeight)
+
+ // positive vertical overshoot (pos + size > 1)
+ vertical.position = 0.8
+ compare(vertical.contentItem.y, vertical.topPadding + 0.8 * vertical.availableHeight)
+ compare(vertical.contentItem.height, 0.2 * vertical.availableHeight)
+
+ // negative horizontal overshoot (pos < 0)
+ horizontal.position = -0.1
+ compare(horizontal.contentItem.x, horizontal.leftPadding)
+ compare(horizontal.contentItem.width, 0.4 * horizontal.availableWidth)
+
+ // positive horizontal overshoot (pos + size > 1)
+ horizontal.position = 0.8
+ compare(horizontal.contentItem.x, horizontal.leftPadding + 0.8 * horizontal.availableWidth)
+ compare(horizontal.contentItem.width, 0.2 * horizontal.availableWidth)
+
+ container.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index b75e2713..ec609ca6 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -263,4 +263,15 @@ TestCase {
compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
+
+ function test_focus() {
+ var control = swtch.createObject(testCase)
+ verify(control)
+
+ verify(!control.activeFocus)
+ mouseClick(control.indicator)
+ verify(control.activeFocus)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 0507d01e..0b334387 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -98,7 +98,10 @@ void tst_Drawer::position()
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from);
QTest::mouseMove(window, to);
QCOMPARE(drawer->position(), position);
+
+ // moved half-way open at almost infinite speed => snap to open
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to);
+ QTRY_COMPARE(drawer->position(), 1.0);
}
void tst_Drawer::dragMargin_data()
diff --git a/tests/auto/qquickmaterialstyle/data/tst_material.qml b/tests/auto/qquickmaterialstyle/data/tst_material.qml
index 8eb6933c..9411891f 100644
--- a/tests/auto/qquickmaterialstyle/data/tst_material.qml
+++ b/tests/auto/qquickmaterialstyle/data/tst_material.qml
@@ -74,6 +74,11 @@ TestCase {
}
Component {
+ id: applicationWindow
+ ApplicationWindow { }
+ }
+
+ Component {
id: styledWindow
Window {
Material.theme: Material.Dark
@@ -600,4 +605,28 @@ TestCase {
window.destroy()
}
+
+ function test_buttonBackground() {
+ var appWindow = applicationWindow.createObject(testCase)
+ verify(appWindow)
+ appWindow.visible = true
+
+ var childButton = button.createObject(appWindow)
+ verify(childButton)
+
+ var buttonBackgroundColor = childButton.background.color
+ appWindow.Material.background = "red"
+ // We wait the length of the color animation to be sure that it hasn't actually changed.
+ wait(400)
+ // We want childButton.Material.background to be equal to appWindow.Material.background,
+ // because we want the color to propagate to items that might actually use it...
+ // but Button doesn't use the background color unless explicitly set,
+ // so we compare the actual background rect color instead.
+ compare(childButton.background.color, buttonBackgroundColor)
+
+ childButton.Material.background = "#0000ff"
+ tryCompare(childButton.background, "color", "#0000ff")
+
+ appWindow.destroy()
+ }
}