aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-07-17 03:00:30 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-07-17 09:45:48 +0000
commitd96bd6069c6d24c12f0a3d96466e50b4d1a09ac4 (patch)
treeb1250acd86c482fc92cd90d1733f0a436d1c2a78
parent1567e4581e1f82dae011d6d3b2e4196efc93b0f4 (diff)
parent449c9c2474da0461c14e7d6ea12ff4e35c3c7aae (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/quickcontrols2/qquickstyle.cpp src/quicktemplates2/qquickscrollview.cpp tests/auto/qquickstyle/tst_qquickstyle.cpp Change-Id: I9afddf07a956f43cf0445e91b8d1a02f167b6bd5
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-button-textundericon.pngbin0 -> 5980 bytes
-rw-r--r--src/imports/controls/doc/qtquickcontrols2.qdocconf2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modal.qml55
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modeless.qml55
-rw-r--r--src/quickcontrols2/qquickstyle.cpp63
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp1
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp10
-rw-r--r--src/quicktemplates2/qquickscrollview.cpp14
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp19
-rw-r--r--src/quicktemplates2/qquicktumbler_p_p.h1
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml8
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp111
12 files changed, 324 insertions, 15 deletions
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-button-textundericon.png b/src/imports/controls/doc/images/qtquickcontrols2-button-textundericon.png
new file mode 100644
index 00000000..fc031ce1
--- /dev/null
+++ b/src/imports/controls/doc/images/qtquickcontrols2-button-textundericon.png
Binary files differ
diff --git a/src/imports/controls/doc/qtquickcontrols2.qdocconf b/src/imports/controls/doc/qtquickcontrols2.qdocconf
index dfb7fc12..eae5a387 100644
--- a/src/imports/controls/doc/qtquickcontrols2.qdocconf
+++ b/src/imports/controls/doc/qtquickcontrols2.qdocconf
@@ -53,7 +53,7 @@ sourcedirs += ../../../quicktemplates2 \
# Exclude .qml files from the doc build to prevent conflicts with .qml files
# in style-specific directories; all types are documented in .cpp/.qdoc files
-excludefiles = *.qml
+sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qdoc"
imagedirs += images \
..
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modal.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modal.qml
new file mode 100644
index 00000000..211697e0
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modal.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Window 2.2
+
+Item {
+ id: root
+ width: 200
+ height: 200
+
+ Binding {
+ target: popup
+ property: "visible"
+ value: root.Window.active
+ }
+//! [1]
+Popup {
+ id: popup
+ width: 400
+ height: 400
+ modal: true
+ visible: true
+
+ Overlay.modal: Rectangle {
+ color: "#aacfdbe7"
+ }
+}
+//! [1]
+}
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modeless.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modeless.qml
new file mode 100644
index 00000000..783f611e
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-overlay-modeless.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+import QtQuick.Window 2.2
+
+Item {
+ id: root
+ width: 200
+ height: 200
+
+ Binding {
+ target: popup
+ property: "visible"
+ value: root.Window.active
+ }
+//! [1]
+Popup {
+ id: popup
+ width: 400
+ height: 400
+ dim: true
+ visible: true
+
+ Overlay.modeless: Rectangle {
+ color: "#aacfdbe7"
+ }
+}
+//! [1]
+}
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp
index 9f101273..b4901db3 100644
--- a/src/quickcontrols2/qquickstyle.cpp
+++ b/src/quickcontrols2/qquickstyle.cpp
@@ -271,6 +271,54 @@ struct QQuickStyleSpec
Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec)
+static QStringList parseStylePathsWithColon(const QString &var)
+{
+ QStringList paths;
+ const QChar colon = QLatin1Char(':');
+ int currentIndex = 0;
+
+ do {
+ int nextColonIndex = -1;
+ QString path;
+
+ if (var.at(currentIndex) == colon) {
+ // This is either a list separator, or a qrc path.
+ if (var.at(currentIndex + 1) == colon) {
+ // It's a double colon (list separator followed by qrc path);
+ // find the end of the path.
+ nextColonIndex = var.indexOf(colon, currentIndex + 2);
+ path = var.mid(currentIndex + 1,
+ nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex - 1);
+ } else {
+ // It's a single colon.
+ nextColonIndex = var.indexOf(colon, currentIndex + 1);
+ if (currentIndex == 0) {
+ // If we're at the start of the string, then it's a qrc path.
+ path = var.mid(currentIndex,
+ nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex);
+ } else {
+ // Otherwise, it's a separator.
+ path = var.mid(currentIndex + 1,
+ nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex - 1);
+ }
+ }
+ } else {
+ // It's a file path.
+ nextColonIndex = var.indexOf(colon, currentIndex);
+ path = var.mid(currentIndex,
+ nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex);
+ }
+
+ paths += path;
+ currentIndex = nextColonIndex;
+
+ // Keep going until we can't find any more colons,
+ // or we're at the last character.
+ } while (currentIndex != -1 && currentIndex < var.size() - 1);
+
+ return paths;
+}
+
QStringList QQuickStylePrivate::stylePaths(bool resolve)
{
// user-requested style path
@@ -283,6 +331,21 @@ QStringList QQuickStylePrivate::stylePaths(bool resolve)
paths += path;
}
+ if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE_PATH"))) {
+ const QString value = QString::fromLocal8Bit(qgetenv("QT_QUICK_CONTROLS_STYLE_PATH"));
+ const QChar listSeparator = QDir::listSeparator();
+ if (listSeparator == QLatin1Char(':')) {
+ // Split manually to avoid breaking paths on systems where : is the list separator,
+ // since it's also used for qrc paths.
+ paths += parseStylePathsWithColon(value);
+ } else {
+ // Fast/simpler path for systems where something other than : is used as
+ // the list separator (such as ';').
+ const QStringList customPaths = value.split(listSeparator, QString::SkipEmptyParts);
+ paths += customPaths;
+ }
+ }
+
// system/custom style paths
paths += styleSpec()->customStylePaths;
paths += envPathList("QT_QUICK_CONTROLS_STYLE_PATH");
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index dd38b80e..c0ce6978 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -754,6 +754,7 @@ void QQuickAbstractButton::setIcon(const QQuickIcon &icon)
\row \li \c AbstractButton.IconOnly \li \image qtquickcontrols2-button-icononly.png
\row \li \c AbstractButton.TextOnly \li \image qtquickcontrols2-button-textonly.png
\row \li \c AbstractButton.TextBesideIcon \li \image qtquickcontrols2-button-textbesideicon.png
+ \row \li \c AbstractButton.TextUnderIcon \li \image qtquickcontrols2-button-textundericon.png
\endtable
\sa {Control::}{spacing}, {Control::}{padding}
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 43dfa682..cf72c8a6 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -643,6 +643,11 @@ QQuickOverlay *QQuickOverlayAttached::overlay() const
The property can be attached to any popup.
+ For example, to change the color of the background dimming for a modal
+ popup, the following code can be used:
+
+ \snippet qtquickcontrols2-overlay-modal.qml 1
+
\sa Popup::modal
*/
QQmlComponent *QQuickOverlayAttached::modal() const
@@ -671,6 +676,11 @@ void QQuickOverlayAttached::setModal(QQmlComponent *modal)
The property can be attached to any popup.
+ For example, to change the color of the background dimming for a modeless
+ popup, the following code can be used:
+
+ \snippet qtquickcontrols2-overlay-modeless.qml 1
+
\sa Popup::dim
*/
QQmlComponent *QQuickOverlayAttached::modeless() const
diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp
index 1d7ecfad..abd75d31 100644
--- a/src/quicktemplates2/qquickscrollview.cpp
+++ b/src/quicktemplates2/qquickscrollview.cpp
@@ -70,6 +70,20 @@ QT_BEGIN_NAMESPACE
\snippet qtquickcontrols2-scrollview-listview.qml file
+ \section2 Sizing
+
+ As with Flickable, there are several things to keep in mind when using
+ ScrollView:
+ \list
+ \li If only a single item is used within a ScrollView, the content size is
+ automatically calculated based on the implicit size of its contained item.
+ However, if more than one item is used (or an implicit size is not
+ provided), the \l contentWidth and \l contentHeight properties must
+ be set to the combined size of its contained items.
+ \li If the content size is less than or equal to the size of the ScrollView,
+ it will not be flickable.
+ \endlist
+
\section2 Scroll Bars
The horizontal and vertical scroll bars can be accessed and customized using
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 75520375..25710231 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -215,7 +215,7 @@ void QQuickTumblerPrivate::_q_onViewCountChanged()
// If we could successfully set the currentIndex, consider it done.
// Otherwise, we'll try again later in updatePolish().
if (currentIndex == pendingCurrentIndex)
- pendingCurrentIndex = -1;
+ setPendingCurrentIndex(-1);
else
q->polish();
} else if (currentIndex == -1) {
@@ -639,7 +639,7 @@ void QQuickTumblerPrivate::syncCurrentIndex()
// Nothing to do.
if (actualViewIndex == indexToSet) {
- pendingCurrentIndex = -1;
+ setPendingCurrentIndex(-1);
return;
}
@@ -652,11 +652,16 @@ void QQuickTumblerPrivate::syncCurrentIndex()
ignoreCurrentIndexChanges = false;
if (view->property("currentIndex").toInt() == indexToSet)
- pendingCurrentIndex = -1;
+ setPendingCurrentIndex(-1);
else if (isPendingCurrentIndex)
q->polish();
}
+void QQuickTumblerPrivate::setPendingCurrentIndex(int index)
+{
+ pendingCurrentIndex = index;
+}
+
void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex,
QQuickTumblerPrivate::PropertyChangeReason changeReason)
{
@@ -666,7 +671,7 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex,
if (!q->isComponentComplete()) {
// Views can't set currentIndex until they're ready.
- pendingCurrentIndex = newCurrentIndex;
+ setPendingCurrentIndex(newCurrentIndex);
return;
}
@@ -675,7 +680,7 @@ void QQuickTumblerPrivate::setCurrentIndex(int newCurrentIndex,
// the model is in the process of being set and the user has set
// the currentIndex in onModelChanged. We have to queue the currentIndex
// change until we're ready.
- pendingCurrentIndex = newCurrentIndex;
+ setPendingCurrentIndex(newCurrentIndex);
return;
}
@@ -814,7 +819,7 @@ void QQuickTumbler::updatePolish()
// If the count is still 0, it's not going to happen.
if (d->count == 0) {
- d->pendingCurrentIndex = -1;
+ d->setPendingCurrentIndex(-1);
return;
}
@@ -829,7 +834,7 @@ void QQuickTumbler::updatePolish()
d->setCurrentIndex(0);
}
- d->pendingCurrentIndex = -1;
+ d->setPendingCurrentIndex(-1);
}
}
diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h
index 2f8b1207..75c6cd1b 100644
--- a/src/quicktemplates2/qquicktumbler_p_p.h
+++ b/src/quicktemplates2/qquicktumbler_p_p.h
@@ -104,6 +104,7 @@ public:
void setupViewData(QQuickItem *newControlContentItem);
void warnAboutIncorrectContentItem();
void syncCurrentIndex();
+ void setPendingCurrentIndex(int index);
enum PropertyChangeReason {
UserChange,
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index f62c62c2..18f63ed4 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -298,13 +298,7 @@ TestCase {
tryCompare(tumbler, "currentIndex", data.currentIndex);
tumblerView = findView(tumbler);
- // TODO: replace once QTBUG-19708 is fixed.
- for (var delay = 1000; delay >= 0; delay -= 50) {
- if (tumblerView.currentItem)
- break;
- wait(50);
- }
- verify(tumblerView.currentItem);
+ tryVerify(function() { return tumblerView.currentItem });
compare(tumblerView.currentIndex, data.currentIndex);
compare(tumblerView.currentItem.text, data.currentIndex.toString());
diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp
index 324d0b08..2210bf69 100644
--- a/tests/auto/qquickstyle/tst_qquickstyle.cpp
+++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp
@@ -57,6 +57,8 @@ private slots:
void availableStyles();
void qrcStylePaths_data();
void qrcStylePaths();
+ void qrcInQtQuickControlsStylePathEnvVar_data();
+ void qrcInQtQuickControlsStylePathEnvVar();
private:
void loadControls();
@@ -69,6 +71,7 @@ void tst_QQuickStyle::cleanup()
QGuiApplicationPrivate::styleOverride.clear();
qunsetenv("QT_QUICK_CONTROLS_STYLE");
+ qunsetenv("QT_QUICK_CONTROLS_STYLE_PATH");
qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE");
qunsetenv("QT_QUICK_CONTROLS_CONF");
}
@@ -206,6 +209,114 @@ void tst_QQuickStyle::qrcStylePaths()
}
}
+void tst_QQuickStyle::qrcInQtQuickControlsStylePathEnvVar_data()
+{
+ QTest::addColumn<QString>("environmentVariable");
+ QTest::addColumn<QStringList>("expectedAvailableStyles");
+
+ const QChar listSeparator = QDir::listSeparator();
+ const QStringList defaultAvailableStyles = QQuickStyle::availableStyles();
+
+ {
+ QString environmentVariable;
+ QDebug stream(&environmentVariable);
+ stream.noquote().nospace() << "/some/bogus/path/" << listSeparator
+ << ":/qrcStyles1";
+
+ QStringList expectedAvailableStyles = defaultAvailableStyles;
+ // We need to move the Default style to the start of the list,
+ // as that's what availableStyles() does.
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle1"));
+
+ QTest::addRow("%s", qPrintable(environmentVariable))
+ << environmentVariable << expectedAvailableStyles;
+ }
+
+ {
+ QString environmentVariable;
+ QDebug stream(&environmentVariable);
+ stream.noquote().nospace() << ":/qrcStyles2" << listSeparator
+ << "/some/bogus/path";
+
+ QStringList expectedAvailableStyles = defaultAvailableStyles;
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle2"));
+
+ QTest::addRow("%s", qPrintable(environmentVariable))
+ << environmentVariable << expectedAvailableStyles;
+ }
+
+ {
+ QString environmentVariable;
+ QDebug stream(&environmentVariable);
+ stream.noquote().nospace() << ":/qrcStyles1" << listSeparator
+ << ":/qrcStyles2" << listSeparator
+ << QFINDTESTDATA("data");
+
+ QStringList expectedAvailableStyles = defaultAvailableStyles;
+ expectedAvailableStyles.insert(1, QLatin1String("DummyStyle"));
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle2"));
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle1"));
+
+ QTest::addRow("%s", qPrintable(environmentVariable))
+ << environmentVariable << expectedAvailableStyles;
+ }
+
+ {
+ QString environmentVariable;
+ QDebug stream(&environmentVariable);
+ stream.noquote().nospace() << QFINDTESTDATA("data") << listSeparator
+ << ":/qrcStyles1" << listSeparator
+ << ":/qrcStyles2";
+
+ QStringList expectedAvailableStyles = defaultAvailableStyles;
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle2"));
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle1"));
+ expectedAvailableStyles.insert(1, QLatin1String("DummyStyle"));
+
+ QTest::addRow("%s", qPrintable(environmentVariable))
+ << environmentVariable << expectedAvailableStyles;
+ }
+
+ {
+ QString environmentVariable;
+ QDebug stream(&environmentVariable);
+ // Same as the last row, except it adds a superfluous separator
+ // to ensure that it handles it gracefully rather than failing an assertion.
+ stream.noquote().nospace() << QFINDTESTDATA("data") << listSeparator
+ << ":/qrcStyles1" << listSeparator
+ << ":/qrcStyles2" << listSeparator;
+
+ QStringList expectedAvailableStyles = defaultAvailableStyles;
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle2"));
+ expectedAvailableStyles.insert(1, QLatin1String("QrcStyle1"));
+ expectedAvailableStyles.insert(1, QLatin1String("DummyStyle"));
+
+ QTest::addRow("%s", qPrintable(environmentVariable))
+ << environmentVariable << expectedAvailableStyles;
+ }
+}
+
+/*
+ Tests that qrc paths work with QT_QUICK_CONTROLS_STYLE_PATH.
+*/
+void tst_QQuickStyle::qrcInQtQuickControlsStylePathEnvVar()
+{
+ QFETCH(QString, environmentVariable);
+ QFETCH(QStringList, expectedAvailableStyles);
+
+ qputenv("QT_QUICK_CONTROLS_STYLE_PATH", environmentVariable.toLocal8Bit());
+
+ const QStringList availableStyles = QQuickStyle::availableStyles();
+ if (availableStyles != expectedAvailableStyles) {
+ QString failureMessage;
+ QDebug stream(&failureMessage);
+ stream << "Mismatch in actual vs expected available styles:"
+ << "\n Expected:" << expectedAvailableStyles
+ << "\n Actual:" << availableStyles;
+ QFAIL(qPrintable(failureMessage));
+ }
+}
+
QTEST_MAIN(tst_QQuickStyle)
#include "tst_qquickstyle.moc"