aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/controls/doc/src/includes/qquickstackview.qdocinc5
-rw-r--r--src/imports/controls/fusion/qquickfusionbusyindicator.cpp4
-rw-r--r--src/imports/controls/material/qquickmaterialbusyindicator.cpp3
-rw-r--r--src/imports/controls/material/qquickmaterialripple.cpp4
-rw-r--r--src/imports/platform/qquickplatformmenuitem.cpp17
-rw-r--r--src/imports/platform/qquickplatformmenuitem_p.h1
-rw-r--r--src/quicktemplates2/qquickstackview.cpp58
-rw-r--r--tests/auto/font/tst_font.cpp37
8 files changed, 114 insertions, 15 deletions
diff --git a/src/imports/controls/doc/src/includes/qquickstackview.qdocinc b/src/imports/controls/doc/src/includes/qquickstackview.qdocinc
new file mode 100644
index 00000000..20c9bdc3
--- /dev/null
+++ b/src/imports/controls/doc/src/includes/qquickstackview.qdocinc
@@ -0,0 +1,5 @@
+//! [pop-ownership]
+Only items that StackView created itself (from a \l Component or \l [QML]
+url) will be destroyed when popped. See \l {Item Ownership} for more
+information.
+//! [pop-ownership]
diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp
index f5c92010..81618191 100644
--- a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp
+++ b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp
@@ -66,8 +66,10 @@ bool QQuickFusionBusyIndicator::isRunning() const
void QQuickFusionBusyIndicator::setRunning(bool running)
{
- if (running)
+ if (running) {
setVisible(true);
+ update();
+ }
}
void QQuickFusionBusyIndicator::paint(QPainter *painter)
diff --git a/src/imports/controls/material/qquickmaterialbusyindicator.cpp b/src/imports/controls/material/qquickmaterialbusyindicator.cpp
index bd15390b..0a4191be 100644
--- a/src/imports/controls/material/qquickmaterialbusyindicator.cpp
+++ b/src/imports/controls/material/qquickmaterialbusyindicator.cpp
@@ -36,6 +36,7 @@
#include "qquickmaterialbusyindicator_p.h"
+#include <QtCore/qmath.h>
#include <QtCore/qeasingcurve.h>
#include <QtGui/qpainter.h>
#include <QtQuick/qsgimagenode.h>
@@ -124,7 +125,7 @@ void QQuickMaterialBusyIndicatorNode::updateCurrentTime(int time)
QPen pen;
QSGImageNode *textureNode = static_cast<QSGImageNode *>(firstChild());
pen.setColor(m_color);
- pen.setWidth(4 * m_devicePixelRatio);
+ pen.setWidth(qCeil(size / 12) * m_devicePixelRatio);
painter.setPen(pen);
const qreal percentageComplete = time / qreal(RotationAnimationDuration);
diff --git a/src/imports/controls/material/qquickmaterialripple.cpp b/src/imports/controls/material/qquickmaterialripple.cpp
index 615d131b..1c3b3f12 100644
--- a/src/imports/controls/material/qquickmaterialripple.cpp
+++ b/src/imports/controls/material/qquickmaterialripple.cpp
@@ -112,8 +112,8 @@ void QQuickMaterialRippleWaveNode::updateCurrentTime(int time)
const qreal dy = (1.0 - p) * (m_anchor.y() - m_bounds.height() / 2);
QMatrix4x4 m;
- m.translate((m_bounds.width() - m_value) / 2 + dx,
- (m_bounds.height() - m_value) / 2 + dy);
+ m.translate(qRound((m_bounds.width() - m_value) / 2 + dx),
+ qRound((m_bounds.height() - m_value) / 2 + dy));
setMatrix(m);
QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode *>(firstChild());
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
index 61a4daab..bc6d97e1 100644
--- a/src/imports/platform/qquickplatformmenuitem.cpp
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -144,10 +144,8 @@ QPlatformMenuItem *QQuickPlatformMenuItem::create()
m_handle = QWidgetPlatform::createMenuItem();
if (m_handle) {
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::triggered);
+ connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::activate);
connect(m_handle, &QPlatformMenuItem::hovered, this, &QQuickPlatformMenuItem::hovered);
- if (m_checkable)
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
}
}
return m_handle;
@@ -354,13 +352,6 @@ void QQuickPlatformMenuItem::setCheckable(bool checkable)
if (m_checkable == checkable)
return;
- if (m_handle) {
- if (checkable)
- connect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
- else
- disconnect(m_handle, &QPlatformMenuItem::activated, this, &QQuickPlatformMenuItem::toggle);
- }
-
m_checkable = checkable;
sync();
emit checkableChanged();
@@ -602,6 +593,12 @@ QQuickPlatformIconLoader *QQuickPlatformMenuItem::iconLoader() const
return m_iconLoader;
}
+void QQuickPlatformMenuItem::activate()
+{
+ toggle();
+ emit triggered();
+}
+
void QQuickPlatformMenuItem::updateIcon()
{
if (!m_handle || !m_iconLoader)
diff --git a/src/imports/platform/qquickplatformmenuitem_p.h b/src/imports/platform/qquickplatformmenuitem_p.h
index 0c1a7c6d..6ff3ad81 100644
--- a/src/imports/platform/qquickplatformmenuitem_p.h
+++ b/src/imports/platform/qquickplatformmenuitem_p.h
@@ -161,6 +161,7 @@ protected:
QQuickPlatformIconLoader *iconLoader() const;
private Q_SLOTS:
+ void activate();
void updateIcon();
private:
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index 2aa41c0d..090a6d74 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -295,6 +295,53 @@ QT_BEGIN_NAMESPACE
only applies to the root of the item. Using anchors for its children
works as expected.
+ \section1 Item Ownership
+
+ StackView only takes ownership of items that it creates itself. This means
+ that any item pushed onto a StackView will never be destroyed by the
+ StackView; only items that StackView creates from \l {Component}{Components}
+ or \l [QML] {url}{URLs} are destroyed by the StackView. To illustrate this,
+ the messages in the example below will only be printed when the StackView
+ is destroyed, not when the items are popped off the stack:
+
+ \qml
+ Component {
+ id: itemComponent
+
+ Item {
+ Component.onDestruction: print("Destroying second item")
+ }
+ }
+
+ StackView {
+ initialItem: Item {
+ Component.onDestruction: print("Destroying initial item")
+ }
+
+ Component.onCompleted: push(itemComponent.createObject(window))
+ }
+ \endqml
+
+ However, both of the items created from the URL and Component in the
+ following example will be destroyed by the StackView when they are popped
+ off of it:
+
+ \qml
+ Component {
+ id: itemComponent
+
+ Item {
+ Component.onDestruction: print("Destroying second item")
+ }
+ }
+
+ StackView {
+ initialItem: "Item1.qml"
+
+ Component.onCompleted: push(itemComponent)
+ }
+ \endqml
+
\sa {Customizing StackView}, {Navigation Controls}, {Container Controls}
*/
@@ -424,7 +471,10 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
current.
StackView creates an instance automatically if the pushed item is a \l Component,
- or a \l [QML] url. The optional \a properties argument specifies a map of initial
+ or a \l [QML] url, and the instance will be destroyed when it is popped
+ off the stack. See \l {Item Ownership} for more information.
+
+ The optional \a properties argument specifies a map of initial
property values for the pushed item. For dynamically created items, these values
are applied before the creation is finalized. This is more efficient than setting
property values after creation, particularly where large sets of property values
@@ -544,6 +594,8 @@ void QQuickStackView::push(QQmlV4Function *args)
items down to (but not including) the first item is popped.
If not specified, only the current item is popped.
+ \include qquickstackview.qdocinc pop-ownership
+
An \a operation can be optionally specified as the last argument. Supported
operations:
@@ -637,6 +689,8 @@ void QQuickStackView::pop(QQmlV4Function *args)
item. The item can be an \l Item, \l Component, or a \l [QML] url.
Returns the item that became current.
+ \include qquickstackview.qdocinc pop-ownership
+
If the \a target argument is specified, all items down to the \target
item will be replaced. If \a target is \c null, all items in the stack
will be replaced. If not specified, only the top item will be replaced.
@@ -800,6 +854,8 @@ bool QQuickStackView::isEmpty() const
Removes all items from the stack.
+ \include qquickstackview.qdocinc pop-ownership
+
Since QtQuick.Controls 2.3, a \a transition can be optionally specified. Supported transitions:
\value StackView.Immediate Clear the stack immediately without any transition (default).
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp
index f3f9dbf5..65dd4971 100644
--- a/tests/auto/font/tst_font.cpp
+++ b/tests/auto/font/tst_font.cpp
@@ -38,6 +38,7 @@
#include "../shared/visualtestutil.h"
#include <QtGui/qfont.h>
+#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
@@ -53,6 +54,8 @@ class tst_font : public QQmlDataTest
Q_OBJECT
private slots:
+ void systemFont();
+
void font_data();
void font();
@@ -66,6 +69,40 @@ private slots:
void listView();
};
+static QFont testFont()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; import QtQuick.Controls 2.0; Text { }", QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ Q_ASSERT_X(!object.isNull(), "testFont", qPrintable(component.errorString()));
+
+ QVariant var = object->property("font");
+ Q_ASSERT_X(var.isValid(), "testFont", var.typeName());
+ return var.value<QFont>();
+}
+
+void tst_font::systemFont()
+{
+ const QFont *originalSystemFont = QGuiApplicationPrivate::platformTheme()->font(QPlatformTheme::SystemFont);
+ if (!originalSystemFont)
+ QSKIP("Cannot test the system font on a minimal platform");
+
+ const QFont fontBefore = testFont();
+ QCOMPARE(fontBefore, *originalSystemFont);
+
+ qmlClearTypeRegistrations();
+ delete QGuiApplicationPrivate::app_font;
+ QGuiApplicationPrivate::app_font = nullptr;
+
+ const QFont appFont = QGuiApplication::font();
+ QCOMPARE(appFont, *originalSystemFont);
+
+ const QFont fontAfter = testFont();
+ QCOMPARE(fontAfter, *originalSystemFont);
+}
+
void tst_font::font_data()
{
QTest::addColumn<QString>("testFile");