aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-tabbar-flickable.pngbin0 -> 3349 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tabbar-flickable.qml50
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp22
-rw-r--r--src/imports/controls/universal/TextArea.qml3
-rw-r--r--src/imports/controls/universal/TextField.qml3
-rw-r--r--src/quicktemplates2/qquickdial.cpp10
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp1
-rw-r--r--src/quicktemplates2/qquickpopup.cpp2
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp2
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp13
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp3
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp3
-rw-r--r--tests/auto/controls/data/tst_dial.qml35
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml16
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml1
15 files changed, 141 insertions, 23 deletions
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-tabbar-flickable.png b/src/imports/controls/doc/images/qtquickcontrols2-tabbar-flickable.png
new file mode 100644
index 00000000..ede59233
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-tabbar-flickable.png
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tabbar-flickable.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tabbar-flickable.qml
new file mode 100644
index 00000000..2a4fac0e
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-tabbar-flickable.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.0
+
+Item {
+ width: 360
+ height: bar.height
+
+//! [1]
+TabBar {
+ id: bar
+ width: parent.width
+
+ Repeater {
+ model: ["First", "Second", "Third", "Fourth", "Fifth"]
+
+ TabButton {
+ text: modelData
+ width: Math.max(100, bar.width / 5)
+ }
+ }
+}
+//! [1]
+}
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index aec92631..a3564c17 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.cpp
@@ -74,6 +74,8 @@ public:
void afterNodeSync() override;
private:
+ int m_lastStartAngle;
+ int m_lastEndAngle;
qreal m_devicePixelRatio;
QSGNode *m_containerNode;
QQuickWindow *m_window;
@@ -155,6 +157,8 @@ QQuickAnimatorJob *QQuickMaterialRingAnimator::createJob() const
}
QQuickMaterialRingAnimatorJob::QQuickMaterialRingAnimatorJob() :
+ m_lastStartAngle(0),
+ m_lastEndAngle(0),
m_devicePixelRatio(1.0),
m_containerNode(nullptr),
m_window(nullptr)
@@ -203,27 +207,25 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
const int iteration = time / spanAnimationDuration;
int startAngle = 0;
int endAngle = 0;
- static int lastStartAngle = 0;
- static int lastEndAngle = 0;
if (iteration % 2 == 0) {
- if (lastStartAngle > 360 * oneDegree) {
- lastStartAngle -= 360 * oneDegree;
+ if (m_lastStartAngle > 360 * oneDegree) {
+ m_lastStartAngle -= 360 * oneDegree;
}
// The start angle is only affected by the rotation animation for the "grow" phase.
- startAngle = lastStartAngle;
+ startAngle = m_lastStartAngle;
QEasingCurve angleCurve(QEasingCurve::OutQuad);
const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete);
- endAngle = lastStartAngle + minSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
- lastEndAngle = endAngle;
+ endAngle = m_lastStartAngle + minSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
+ m_lastEndAngle = endAngle;
} else {
// Both the start angle *and* the span are affected by the "shrink" phase.
QEasingCurve angleCurve(QEasingCurve::InQuad);
const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete);
- startAngle = lastEndAngle - maxSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
- endAngle = lastEndAngle;
- lastStartAngle = startAngle;
+ startAngle = m_lastEndAngle - maxSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
+ endAngle = m_lastEndAngle;
+ m_lastStartAngle = startAngle;
}
const int halfPen = pen.width() / 2;
diff --git a/src/imports/controls/universal/TextArea.qml b/src/imports/controls/universal/TextArea.qml
index 96d3cc13..0e2953ed 100644
--- a/src/imports/controls/universal/TextArea.qml
+++ b/src/imports/controls/universal/TextArea.qml
@@ -58,8 +58,7 @@ T.TextArea {
Universal.theme: activeFocus ? Universal.Light : undefined
- color: !enabled ? Universal.chromeDisabledLowColor :
- activeFocus ? Universal.chromeBlackHighColor : Universal.foreground
+ color: !enabled ? Universal.chromeDisabledLowColor : Universal.foreground
selectionColor: Universal.accent
selectedTextColor: Universal.chromeWhiteColor
diff --git a/src/imports/controls/universal/TextField.qml b/src/imports/controls/universal/TextField.qml
index ba24a155..88bc4fc9 100644
--- a/src/imports/controls/universal/TextField.qml
+++ b/src/imports/controls/universal/TextField.qml
@@ -58,8 +58,7 @@ T.TextField {
Universal.theme: activeFocus ? Universal.Light : undefined
- color: !enabled ? Universal.chromeDisabledLowColor :
- activeFocus ? Universal.chromeBlackHighColor : Universal.foreground
+ color: !enabled ? Universal.chromeDisabledLowColor : Universal.foreground
selectionColor: Universal.accent
selectedTextColor: Universal.chromeWhiteColor
verticalAlignment: TextInput.AlignVCenter
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index 3932fd05..de220853 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -126,9 +126,15 @@ qreal QQuickDialPrivate::valueAt(qreal position) const
qreal QQuickDialPrivate::snapPosition(qreal position) const
{
- if (qFuzzyIsNull(stepSize))
+ const qreal range = to - from;
+ if (qFuzzyIsNull(range))
return position;
- return qRound(position / stepSize) * stepSize;
+
+ const qreal effectiveStep = stepSize / range;
+ if (qFuzzyIsNull(effectiveStep))
+ return position;
+
+ return qRound(position / effectiveStep) * effectiveStep;
}
qreal QQuickDialPrivate::positionAt(const QPoint &point) const
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index efbc2ce5..850de875 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -176,6 +176,7 @@ QQuickOverlayPrivate::QQuickOverlayPrivate() :
QQuickOverlay::QQuickOverlay(QQuickItem *parent)
: QQuickItem(*(new QQuickOverlayPrivate), parent)
{
+ setZ(1000001); // DefaultWindowDecoration+1
setAcceptedMouseButtons(Qt::AllButtons);
setFiltersChildMouseEvents(true);
setVisible(false);
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index a5cc09a1..14810c98 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -192,7 +192,7 @@ void QQuickPopupPrivate::prepareEnterTransition(bool notify)
QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(window);
if (!applicationWindow) {
window->installEventFilter(q);
- popupItem->setZ(10001); // DefaultWindowDecoration+1
+ popupItem->setZ(1000001); // DefaultWindowDecoration+1
popupItem->setParentItem(window->contentItem());
} else {
popupItem->setParentItem(applicationWindow->overlay());
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 52b11dae..b4c3838f 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -351,7 +351,7 @@ static qreal valueAt(const QQuickRangeSlider *slider, qreal position)
static qreal snapPosition(const QQuickRangeSlider *slider, qreal position)
{
- const qreal range = slider->from() + (slider->to() - slider->from());
+ const qreal range = slider->to() - slider->from();
if (qFuzzyIsNull(range))
return position;
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index a980a725..6fe734bb 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -60,6 +60,18 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-tabbar.qml 1
+ \section2 Flickable Tabs
+
+ By default, TabBar resizes its buttons to fit the width of the control.
+ The available space is distributed equally to each button. The default
+ resizing behavior can be overridden by setting an explicit width for the
+ buttons. If the total width of the buttons exceeds the available width
+ of the tab bar, it automatically becomes flickable.
+
+ \image qtquickcontrols2-tabbar-flickable.png
+
+ \snippet qtquickcontrols2-tabbar-flickable.qml 1
+
\sa TabButton, {Customizing TabBar}, {Navigation Controls}, {Container Controls}
*/
@@ -187,6 +199,7 @@ void QQuickTabBar::itemAdded(int index, QQuickItem *item)
{
Q_D(QQuickTabBar);
Q_UNUSED(index);
+ QQuickItemPrivate::get(item)->setCulled(true); // QTBUG-55129
if (QQuickTabButton *button = qobject_cast<QQuickTabButton *>(item))
QObjectPrivate::connect(button, &QQuickTabButton::checkedChanged, d, &QQuickTabBarPrivate::updateCurrentIndex);
if (isComponentComplete())
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 0f78413e..7c2e0f11 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -310,6 +310,9 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent) :
setAcceptedMouseButtons(Qt::AllButtons);
d->setImplicitResizeEnabled(false);
d->pressHandler.control = this;
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::IBeamCursor);
+#endif
QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged,
d, &QQuickTextAreaPrivate::_q_readOnlyChanged);
}
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index bc77317b..88450e78 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -179,6 +179,9 @@ QQuickTextField::QQuickTextField(QQuickItem *parent) :
d->setImplicitResizeEnabled(false);
setAcceptedMouseButtons(Qt::AllButtons);
setActiveFocusOnTab(true);
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::IBeamCursor);
+#endif
QObjectPrivate::connect(this, &QQuickTextInput::readOnlyChanged,
d, &QQuickTextFieldPrivate::_q_readOnlyChanged);
QObjectPrivate::connect(this, &QQuickTextInput::echoModeChanged,
diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml
index a94692eb..e6446d3e 100644
--- a/tests/auto/controls/data/tst_dial.qml
+++ b/tests/auto/controls/data/tst_dial.qml
@@ -321,4 +321,39 @@ TestCase {
focusScope.destroy();
}
+
+ function test_snapMode_data() {
+ return [
+ { tag: "NoSnap", snapMode: Slider.NoSnap, from: 0, to: 2, values: [0, 0, 1], positions: [0, 0.5, 0.5] },
+ { tag: "SnapAlways (0..2)", snapMode: Slider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] },
+ { tag: "SnapAlways (1..3)", snapMode: Slider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] },
+ { tag: "SnapAlways (-1..1)", snapMode: Slider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] },
+ { tag: "SnapAlways (1..-1)", snapMode: Slider.SnapAlways, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] },
+ { tag: "SnapOnRelease (0..2)", snapMode: Slider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 1.0], positions: [0.0, 0.5, 0.5] },
+ { tag: "SnapOnRelease (1..3)", snapMode: Slider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 2.0], positions: [0.0, 0.5, 0.5] },
+ { tag: "SnapOnRelease (-1..1)", snapMode: Slider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, 0.0], positions: [0.5, 0.5, 0.5] },
+ { tag: "SnapOnRelease (1..-1)", snapMode: Slider.SnapOnRelease, from: 1, to: -1, values: [1.0, 1.0, 0.0], positions: [0.0, 0.5, 0.5] }
+ ]
+ }
+
+ function test_snapMode(data) {
+ dial.snapMode = data.snapMode;
+ dial.from = data.from;
+ dial.to = data.to;
+ dial.stepSize = 0.2;
+
+ var fuzz = 0.05;
+
+ mousePress(dial, dial.width * 0.25, dial.height * 0.75);
+ compare(dial.value, data.values[0]);
+ compare(dial.position, data.positions[0]);
+
+ mouseMove(dial, dial.width * 0.5, dial.height * 0.25);
+ fuzzyCompare(dial.value, data.values[1], fuzz);
+ fuzzyCompare(dial.position, data.positions[1], fuzz);
+
+ mouseRelease(dial, dial.width * 0.5, dial.height * 0.25);
+ fuzzyCompare(dial.value, data.values[2], fuzz);
+ fuzzyCompare(dial.position, data.positions[2], fuzz);
+ }
}
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml
index 063af450..392be018 100644
--- a/tests/auto/controls/data/tst_rangeslider.qml
+++ b/tests/auto/controls/data/tst_rangeslider.qml
@@ -621,18 +621,24 @@ TestCase {
function test_snapMode_data() {
return [
- { tag: "NoSnap", snapMode: Slider.NoSnap, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] },
- { tag: "SnapAlways", snapMode: Slider.SnapAlways, values: [0, 0, 0.2], positions: [0, 0.1, 0.1] },
- { tag: "SnapOnRelease", snapMode: Slider.SnapOnRelease, values: [0, 0, 0.2], positions: [0, 0.1, 0.1] }
+ { tag: "NoSnap", snapMode: RangeSlider.NoSnap, from: 0, to: 2, values: [0, 0, 0.25], positions: [0, 0.1, 0.1] },
+ { tag: "SnapAlways (0..2)", snapMode: RangeSlider.SnapAlways, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapAlways (1..3)", snapMode: RangeSlider.SnapAlways, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapAlways (-1..1)", snapMode: RangeSlider.SnapAlways, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapAlways (1..-1)", snapMode: RangeSlider.SnapAlways, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapOnRelease (0..2)", snapMode: RangeSlider.SnapOnRelease, from: 0, to: 2, values: [0.0, 0.0, 0.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapOnRelease (1..3)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: 3, values: [1.0, 1.0, 1.2], positions: [0.0, 0.1, 0.1] },
+ { tag: "SnapOnRelease (-1..1)", snapMode: RangeSlider.SnapOnRelease, from: -1, to: 1, values: [0.0, 0.0, -0.8], positions: [0.5, 0.1, 0.1] },
+ { tag: "SnapOnRelease (1..-1)", snapMode: RangeSlider.SnapOnRelease, from: 1, to: -1, values: [0.0, 0.0, 0.8], positions: [0.5, 0.1, 0.1] }
]
}
function test_snapMode(data) {
- var control = sliderComponent.createObject(testCase, {snapMode: data.snapMode, from: 0, to: 2, stepSize: 0.2})
+ var control = sliderComponent.createObject(testCase, {snapMode: data.snapMode, from: data.from, to: data.to, stepSize: 0.2})
verify(control)
control.first.value = 0
- control.second.value = 2
+ control.second.value = data.to
function sliderCompare(left, right) {
return Math.abs(left - right) < 0.05
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 3c6fe8fb..6f1f0200 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -729,6 +729,7 @@ TestCase {
var dragDirection = distanceToReachContentY > 0 ? -1 : 1;
for (var i = 0; i < distance && Math.floor(listView.contentY) !== Math.floor(data.contentY); ++i) {
mouseMove(tumbler, tumblerXCenter(), tumblerYCenter() + i * dragDirection);
+ wait(1); // because Flickable pays attention to velocity, we need some time between movements (qtdeclarative ebf07c3)
}
}