aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/material/ItemDelegate.qml2
-rw-r--r--src/imports/controls/material/qquickmaterialstyle.cpp5
-rw-r--r--src/imports/controls/material/qquickmaterialstyle_p.h2
-rw-r--r--src/templates/qquickabstractbutton.cpp7
-rw-r--r--src/templates/qquickspinbox.cpp2
-rw-r--r--src/templates/qquickstackview.cpp6
-rw-r--r--src/templates/qquickstackview_p.cpp8
-rw-r--r--src/templates/qquickswipeview.cpp17
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml21
-rw-r--r--tests/auto/pressandhold/tst_pressandhold.cpp11
10 files changed, 72 insertions, 9 deletions
diff --git a/src/imports/controls/material/ItemDelegate.qml b/src/imports/controls/material/ItemDelegate.qml
index ce0b7b19..132cce3d 100644
--- a/src/imports/controls/material/ItemDelegate.qml
+++ b/src/imports/controls/material/ItemDelegate.qml
@@ -145,7 +145,7 @@ T.ItemDelegate {
//! [background]
background: Rectangle {
visible: control.pressed || control.highlighted
- color: control.pressed ? control.Material.flatButtonPressColor : control.Material.backgroundColor
+ color: control.pressed ? control.Material.flatButtonPressColor : control.Material.listHighlightColor
}
//! [background]
}
diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp
index 5501e50c..29ff2c48 100644
--- a/src/imports/controls/material/qquickmaterialstyle.cpp
+++ b/src/imports/controls/material/qquickmaterialstyle.cpp
@@ -796,6 +796,11 @@ QColor QQuickMaterialStyle::backgroundDimColor() const
return QColor::fromRgba(m_theme == Light ? 0x99303030 : 0x99fafafa);
}
+QColor QQuickMaterialStyle::listHighlightColor() const
+{
+ return QColor::fromRgba(m_theme == Light ? 0x1e000000 : 0x1effffff);
+}
+
QColor QQuickMaterialStyle::color(QQuickMaterialStyle::Color color, QQuickMaterialStyle::Shade shade) const
{
int count = sizeof(colors) / sizeof(colors[0]);
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h
index 00103361..9f3dbbbd 100644
--- a/src/imports/controls/material/qquickmaterialstyle_p.h
+++ b/src/imports/controls/material/qquickmaterialstyle_p.h
@@ -95,6 +95,7 @@ class QQuickMaterialStyle : public QQuickStyle
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)
public:
enum Theme {
@@ -201,6 +202,7 @@ public:
QColor drawerBackgroundColor() const;
QColor dialogColor() const;
QColor backgroundDimColor() const;
+ QColor listHighlightColor() const;
Q_INVOKABLE QColor color(Color color, Shade shade = Shade500) const;
Q_INVOKABLE QColor shade(const QColor &color, Shade shade) const;
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp
index 016c6d5a..8e5b59d2 100644
--- a/src/templates/qquickabstractbutton.cpp
+++ b/src/templates/qquickabstractbutton.cpp
@@ -121,6 +121,7 @@ void QQuickAbstractButtonPrivate::startPressAndHold()
{
Q_Q(QQuickAbstractButton);
wasHeld = false;
+ stopPressAndHold();
if (isPressAndHoldConnected())
holdTimer = q->startTimer(QGuiApplication::styleHints()->mousePressAndHoldInterval());
}
@@ -498,8 +499,10 @@ void QQuickAbstractButton::mousePressEvent(QMouseEvent *event)
if (d->autoRepeat) {
d->startRepeatDelay();
d->repeatButton = event->button();
- } else {
+ } else if (Qt::LeftButton == (event->buttons() & Qt::LeftButton)) {
d->startPressAndHold();
+ } else {
+ d->stopPressAndHold();
}
}
@@ -511,7 +514,7 @@ void QQuickAbstractButton::mouseMoveEvent(QMouseEvent *event)
if (d->autoRepeat)
d->stopPressRepeat();
- else if (!d->pressed)
+ else if (d->holdTimer > 0 && QLineF(d->pressPoint, event->localPos()).length() > QGuiApplication::styleHints()->startDragDistance())
d->stopPressAndHold();
}
diff --git a/src/templates/qquickspinbox.cpp b/src/templates/qquickspinbox.cpp
index 240b5a9b..a0c94101 100644
--- a/src/templates/qquickspinbox.cpp
+++ b/src/templates/qquickspinbox.cpp
@@ -133,7 +133,7 @@ void QQuickSpinBoxPrivate::updateValue()
if (text.isValid()) {
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(qmlEngine(q));
QJSValue loc(v4, QQmlLocale::wrap(v4, locale));
- QJSValue val = valueFromText.call(QJSValueList() << text.toString() << loc);
+ QJSValue val = q->valueFromText().call(QJSValueList() << text.toString() << loc);
q->setValue(val.toInt());
}
}
diff --git a/src/templates/qquickstackview.cpp b/src/templates/qquickstackview.cpp
index 8b48e687..70194257 100644
--- a/src/templates/qquickstackview.cpp
+++ b/src/templates/qquickstackview.cpp
@@ -257,6 +257,12 @@ QT_BEGIN_NAMESPACE
}
\endqml
+ \note Using anchors on the items added to a StackView is not supported.
+ Typically push, pop, and replace transitions animate the position,
+ which is not possible when anchors are applied. Notice that this
+ only applies to the root of the item. Using anchors for its children
+ works as expected.
+
\labs
\sa {Customizing StackView}, {Navigation Controls}, {Container Controls}
diff --git a/src/templates/qquickstackview_p.cpp b/src/templates/qquickstackview_p.cpp
index 63cc1800..f03ff7fc 100644
--- a/src/templates/qquickstackview_p.cpp
+++ b/src/templates/qquickstackview_p.cpp
@@ -36,6 +36,7 @@
#include "qquickstackview_p_p.h"
+#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmllist.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
@@ -227,6 +228,13 @@ void QQuickStackElement::transitionNextReposition(QQuickItemViewTransitioner *tr
bool QQuickStackElement::prepareTransition(QQuickItemViewTransitioner *transitioner, const QRectF &viewBounds)
{
if (transitioner) {
+ if (item) {
+ QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors;
+ // TODO: expose QQuickAnchorLine so we can test for other conflicting anchors
+ if (anchors && (anchors->fill() || anchors->centerIn()))
+ qmlInfo(item) << "StackView has detected conflicting anchors. Transitions may not execute properly.";
+ }
+
// TODO: add force argument to QQuickItemViewTransitionableItem::prepareTransition()?
nextTransitionToSet = true;
nextTransitionFromSet = true;
diff --git a/src/templates/qquickswipeview.cpp b/src/templates/qquickswipeview.cpp
index 3fb27b31..ec51da49 100644
--- a/src/templates/qquickswipeview.cpp
+++ b/src/templates/qquickswipeview.cpp
@@ -36,6 +36,7 @@
#include "qquickswipeview_p.h"
+#include <QtQml/qqmlinfo.h>
#include <QtLabsTemplates/private/qquickcontainer_p_p.h>
QT_BEGIN_NAMESPACE
@@ -67,6 +68,12 @@ QT_BEGIN_NAMESPACE
\l {Container::moveItem()}{move}, and \l {Container::removeItem()}{remove}
pages dynamically at run time.
+ \note SwipeView takes over the geometry management of items added to the
+ view. Using anchors on the items is not supported, and any \c width
+ or \c height assignment will be overridden by the view. Notice that
+ this only applies to the root of the item. Specifying width and height,
+ or using anchors for its children works as expected.
+
\labs
\sa TabBar, PageIndicator, {Customizing SwipeView}, {Navigation Controls}, {Container Controls}
@@ -89,8 +96,16 @@ void QQuickSwipeViewPrivate::resizeItems()
const int count = q->count();
for (int i = 0; i < count; ++i) {
QQuickItem *item = itemAt(i);
- if (item)
+ if (item) {
+ QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors;
+ // TODO: expose QQuickAnchorLine so we can test for other conflicting anchors
+ if (anchors && (anchors->fill() || anchors->centerIn()) && !item->property("_q_QQuickSwipeView_warned").toBool()) {
+ qmlInfo(item) << "SwipeView has detected conflicting anchors. Unable to layout the item.";
+ item->setProperty("_q_QQuickSwipeView_warned", true);
+ }
+
item->setSize(QSizeF(contentItem->width(), contentItem->height()));
+ }
}
}
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index a2ab5a4a..cdea8b66 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -305,4 +305,25 @@ TestCase {
compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
control.destroy()
}
+
+ function test_focus() {
+ var control = spinBox.createObject(testCase, {from: 10, to: 1000, value: 100, focus: true})
+ verify(control)
+
+ control.forceActiveFocus()
+ compare(control.activeFocus, true)
+
+ compare(control.from, 10)
+ compare(control.to, 1000)
+ compare(control.value, 100)
+
+ control.focus = false
+ compare(control.activeFocus, false)
+
+ compare(control.from, 10)
+ compare(control.to, 1000)
+ compare(control.value, 100)
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/pressandhold/tst_pressandhold.cpp b/tests/auto/pressandhold/tst_pressandhold.cpp
index 33d93cc0..8c4cf673 100644
--- a/tests/auto/pressandhold/tst_pressandhold.cpp
+++ b/tests/auto/pressandhold/tst_pressandhold.cpp
@@ -54,14 +54,17 @@ private slots:
void tst_PressAndHold::pressAndHold_data()
{
QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QByteArray>("signal");
- QTest::newRow("TextField") << QByteArray("import Qt.labs.controls 1.0; TextField { text: 'TextField' }");
- QTest::newRow("TextArea") << QByteArray("import Qt.labs.controls 1.0; TextArea { text: 'TextArea' }");
+ QTest::newRow("Button") << QByteArray("import Qt.labs.controls 1.0; Button { text: 'Button' }") << QByteArray(SIGNAL(pressAndHold()));
+ QTest::newRow("TextField") << QByteArray("import Qt.labs.controls 1.0; TextField { text: 'TextField' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
+ QTest::newRow("TextArea") << QByteArray("import Qt.labs.controls 1.0; TextArea { text: 'TextArea' }") << QByteArray(SIGNAL(pressAndHold(QQuickMouseEvent*)));
}
void tst_PressAndHold::pressAndHold()
{
QFETCH(QByteArray, data);
+ QFETCH(QByteArray, signal);
QQmlEngine engine;
QQmlComponent component(&engine);
@@ -71,8 +74,8 @@ void tst_PressAndHold::pressAndHold()
QScopedPointer<QObject> waitControl(component.create());
QVERIFY(!control.isNull() && !waitControl.isNull());
- QSignalSpy spy(control.data(), SIGNAL(pressAndHold(QQuickMouseEvent*)));
- QSignalSpy waitSpy(waitControl.data(), SIGNAL(pressAndHold(QQuickMouseEvent*)));
+ QSignalSpy spy(control.data(), signal);
+ QSignalSpy waitSpy(waitControl.data(), signal);
QVERIFY(spy.isValid() && waitSpy.isValid());
int startDragDistance = QGuiApplication::styleHints()->startDragDistance();