aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp6
-rw-r--r--src/quick/items/qquickflickable_p.h2
-rw-r--r--src/quick/items/qquickgridview.cpp13
-rw-r--r--src/quick/items/qquickimage.cpp50
-rw-r--r--src/quick/items/qquickimage_p_p.h18
-rw-r--r--src/quick/items/qquickitem.cpp2
-rw-r--r--src/quick/items/qquickitemsmodule.cpp4
-rw-r--r--src/quick/items/qquickitemview.cpp7
-rw-r--r--src/quick/items/qquickitemview_p.h1
-rw-r--r--src/quick/items/qquickitemviewfxitem.cpp2
-rw-r--r--src/quick/items/qquickitemviewfxitem_p_p.h8
-rw-r--r--src/quick/items/qquicklistview.cpp14
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp17
-rw-r--r--src/quick/items/qquickpathview.cpp27
-rw-r--r--src/quick/items/qquickpathview_p.h1
-rw-r--r--src/quick/items/qquicktableview.cpp204
-rw-r--r--src/quick/items/qquicktableview_p.h9
-rw-r--r--src/quick/items/qquicktableview_p_p.h14
-rw-r--r--src/quick/items/qquicktextcontrol.cpp2
-rw-r--r--src/quick/items/qquicktextedit.cpp3
-rw-r--r--src/quick/items/qquicktextinput.cpp4
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp2
-rw-r--r--src/quick/items/qquickwindow.cpp56
-rw-r--r--src/quick/items/qquickwindowmodule.cpp6
25 files changed, 334 insertions, 140 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 06dddabb65..14443a2f2f 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -735,7 +735,7 @@ void QQuickCanvasItem::updatePolish()
for (auto it = animationCallbacks.cbegin(), end = animationCallbacks.cend(); it != end; ++it) {
function = it.value().value();
- jsCall->args[0] = QV4::Value::fromUInt32(QDateTime::currentMSecsSinceEpoch() / 1000);
+ jsCall->args[0] = QV4::Value::fromUInt32(QDateTime::currentMSecsSinceEpoch());
function->call(jsCall);
}
}
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 66727e7845..de19a927a0 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -2999,7 +2999,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(const QV4::Fun
if (argc >= 1) {
QFontMetrics fm(r->d()->context()->state.font);
- uint width = fm.width(argv[0].toQStringNoThrow());
+ uint width = fm.horizontalAdvance(argv[0].toQStringNoThrow());
QV4::ScopedObject tm(scope, scope.engine->newObject());
tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(),
QV4::ScopedValue(scope, QV4::Value::fromDouble(width)));
@@ -4079,10 +4079,10 @@ static int textAlignOffset(QQuickContext2D::TextAlignType value, const QFontMetr
value = QGuiApplication::layoutDirection() == Qt::LeftToRight ? QQuickContext2D::Right: QQuickContext2D::Left;
switch (value) {
case QQuickContext2D::Center:
- offset = metrics.width(text)/2;
+ offset = metrics.horizontalAdvance(text) / 2;
break;
case QQuickContext2D::Right:
- offset = metrics.width(text);
+ offset = metrics.horizontalAdvance(text);
case QQuickContext2D::Left:
default:
break;
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index f21fe94177..c54ed5ce71 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -117,7 +117,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
public:
QQuickFlickable(QQuickItem *parent=nullptr);
- ~QQuickFlickable();
+ ~QQuickFlickable() override;
QQmlListProperty<QObject> flickableData();
QQmlListProperty<QQuickItem> flickableChildren();
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 272d4a4df5..6638fbd3e8 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -2636,6 +2636,19 @@ bool QQuickGridViewPrivate::needsRefillForAddedOrRemovedIndex(int modelIndex) co
\b Note: methods should only be called after the Component has completed.
*/
+/*!
+ \qmlmethod Item QtQuick::GridView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
/*!
\qmlmethod QtQuick::GridView::forceLayout()
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index 49e5b7b1fa..2b71ad5f52 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -52,42 +52,28 @@
QT_BEGIN_NAMESPACE
-class QQuickImageTextureProvider : public QSGTextureProvider
+QQuickImageTextureProvider::QQuickImageTextureProvider()
+ : m_texture(nullptr)
+ , m_smooth(false)
{
- Q_OBJECT
-public:
- QQuickImageTextureProvider()
- : m_texture(nullptr)
- , m_smooth(false)
- {
- }
+}
- void updateTexture(QSGTexture *texture) {
- if (m_texture == texture)
- return;
- m_texture = texture;
- emit textureChanged();
- }
+void QQuickImageTextureProvider::updateTexture(QSGTexture *texture) {
+ if (m_texture == texture)
+ return;
+ m_texture = texture;
+ emit textureChanged();
+}
- QSGTexture *texture() const override {
- if (m_texture) {
- m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
- m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
- m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
- m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge);
- }
- return m_texture;
+QSGTexture *QQuickImageTextureProvider::texture() const {
+ if (m_texture) {
+ m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
+ m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
+ m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge);
+ m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge);
}
-
- friend class QQuickImage;
-
- QSGTexture *m_texture;
- bool m_smooth;
- bool m_mipmap;
-};
-
-#include "qquickimage.moc"
-#include "moc_qquickimage_p.cpp"
+ return m_texture;
+}
QQuickImagePrivate::QQuickImagePrivate()
: fillMode(QQuickImage::Stretch)
diff --git a/src/quick/items/qquickimage_p_p.h b/src/quick/items/qquickimage_p_p.h
index afc33def0f..e2c467c311 100644
--- a/src/quick/items/qquickimage_p_p.h
+++ b/src/quick/items/qquickimage_p_p.h
@@ -53,10 +53,26 @@
#include "qquickimagebase_p_p.h"
#include "qquickimage_p.h"
+#include <QtQuick/qsgtextureprovider.h>
QT_BEGIN_NAMESPACE
-class QQuickImageTextureProvider;
+class Q_QUICK_PRIVATE_EXPORT QQuickImageTextureProvider : public QSGTextureProvider
+{
+ Q_OBJECT
+public:
+ QQuickImageTextureProvider();
+
+ void updateTexture(QSGTexture *texture);
+
+ QSGTexture *texture() const override ;
+
+ friend class QQuickImage;
+
+ QSGTexture *m_texture;
+ bool m_smooth;
+ bool m_mipmap;
+};
class Q_QUICK_PRIVATE_EXPORT QQuickImagePrivate : public QQuickImageBasePrivate
{
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 9e32ccfee9..ec6bf5a1b8 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -4444,6 +4444,8 @@ void QQuickItem::update()
When the scene graph processes the request, it will call updatePolish()
on this item.
+
+ \sa updatePolish(), QQuickTest::qIsPolishScheduled()
*/
void QQuickItem::polish()
{
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index b2fcfb4307..ddd438e56d 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -472,6 +472,10 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
#if QT_CONFIG(quick_tableview)
qmlRegisterType<QQuickTableView>(uri, 2, 12, "TableView");
#endif
+
+ qmlRegisterUncreatableType<QQuickItemView, 13>(uri, 2, 13, itemViewName, itemViewMessage);
+ qmlRegisterType<QQuickPathView, 13>(uri, 2, 13, "PathView");
+ qmlRegisterType<QQuickGridView, 13>(uri, 2, 13, "GridView");
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 8dafc16cf4..1f8a0de72b 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -951,6 +951,13 @@ QQuickItem *QQuickItemView::itemAt(qreal x, qreal y) const
return item ? item->item : nullptr;
}
+QQuickItem *QQuickItemView::itemAtIndex(int index) const
+{
+ Q_D(const QQuickItemView);
+ const FxViewItem *item = d->visibleItem(index);
+ return item ? item->item : nullptr;
+}
+
void QQuickItemView::forceLayout()
{
Q_D(QQuickItemView);
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index 483fc1a09f..0a0da587b4 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -228,6 +228,7 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
+ Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
Q_INVOKABLE void positionViewAtBeginning();
Q_INVOKABLE void positionViewAtEnd();
Q_REVISION(1) Q_INVOKABLE void forceLayout();
diff --git a/src/quick/items/qquickitemviewfxitem.cpp b/src/quick/items/qquickitemviewfxitem.cpp
index f9c65967ea..60e9d7b115 100644
--- a/src/quick/items/qquickitemviewfxitem.cpp
+++ b/src/quick/items/qquickitemviewfxitem.cpp
@@ -45,9 +45,9 @@ QT_BEGIN_NAMESPACE
QQuickItemViewFxItem::QQuickItemViewFxItem(QQuickItem *item, bool ownItem, QQuickItemChangeListener* changeListener)
: item(item)
- , ownItem(ownItem)
, changeListener(changeListener)
, transitionableItem(nullptr)
+ , ownItem(ownItem)
, releaseAfterTransition(false)
, trackGeom(false)
{
diff --git a/src/quick/items/qquickitemviewfxitem_p_p.h b/src/quick/items/qquickitemviewfxitem_p_p.h
index 48ffe248bc..3bc5ba440c 100644
--- a/src/quick/items/qquickitemviewfxitem_p_p.h
+++ b/src/quick/items/qquickitemviewfxitem_p_p.h
@@ -94,13 +94,13 @@ public:
virtual bool contains(qreal x, qreal y) const = 0;
- int index = -1;
QPointer<QQuickItem> item;
- bool ownItem;
QQuickItemChangeListener *changeListener;
QQuickItemViewTransitionableItem *transitionableItem;
- bool releaseAfterTransition;
- bool trackGeom;
+ int index = -1;
+ bool ownItem : 1;
+ bool releaseAfterTransition : 1;
+ bool trackGeom : 1;
};
QT_END_NAMESPACE
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 62cbfcef2b..2a59e50304 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -3513,6 +3513,20 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
*/
/*!
+ \qmlmethod Item QtQuick::ListView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
+
+/*!
\qmlmethod QtQuick::ListView::forceLayout()
Responding to changes in the model is usually batched to happen only once
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index cad598d2c0..3aa00340b2 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -245,7 +245,11 @@ void QQuickOpenGLShaderEffectCommon::connectPropertySignals(QQuickItem *item,
const QMetaObject *itemMetaObject,
Key::ShaderType shaderType)
{
- QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item);
+ auto engine = qmlEngine(item);
+ if (!engine)
+ return;
+
+ QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(engine, item);
for (int i = 0; i < uniformData[shaderType].size(); ++i) {
if (signalMappers[shaderType].at(i) == 0)
continue;
@@ -317,7 +321,8 @@ void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item,
Key::ShaderType shaderType,
const QByteArray &code)
{
- QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item);
+ auto engine = qmlEngine(item);
+ QQmlPropertyCache *propCache = (engine) ? QQmlData::ensurePropertyCache(engine, item) : nullptr;
int index = 0;
int typeIndex = -1;
int typeLength = 0;
@@ -350,9 +355,11 @@ void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item,
} else if (nameLength > srLen && qstrncmp("qt_SubRect_", s + nameIndex, srLen) == 0) {
d.specialType = UniformData::SubRect;
} else {
- if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)) {
- if (!pd->isFunction())
- d.propertyIndex = pd->coreIndex();
+ if (propCache) {
+ if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)) {
+ if (!pd->isFunction())
+ d.propertyIndex = pd->coreIndex();
+ }
}
const int mappedId = uniformData[shaderType].size() | (shaderType << 16);
mapper = new QtPrivate::MappedSlotObject([this, mappedId](){
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 77ed8a659c..be8532bf64 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1550,6 +1550,33 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
return nullptr;
}
+/*!
+ \qmlmethod Item QtQuick::QQuickPathView::itemAtIndex(int index)
+
+ Returns the item for \a index. If there is no item for that index, for example
+ because it has not been created yet, or because it has been panned out of
+ the visible area and removed from the cache, null is returned.
+
+ \b Note: this method should only be called after the Component has completed.
+ The returned value should also not be stored since it can turn to null
+ as soon as control goes out of the calling scope, if the view releases that item.
+
+ \since 5.13
+*/
+QQuickItem *QQuickPathView::itemAtIndex(int index) const
+{
+ Q_D(const QQuickPathView);
+ if (!d->isValid())
+ return nullptr;
+
+ for (QQuickItem *item : d->items) {
+ if (index == d->model->indexOf(item, nullptr))
+ return item;
+ }
+
+ return nullptr;
+}
+
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
{
const auto pathLength = path->path().length();
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index 0e237b7b74..66be7fa6ff 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -180,6 +180,7 @@ public:
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE QQuickItem *itemAt(qreal x, qreal y) const;
+ Q_REVISION(13) Q_INVOKABLE QQuickItem *itemAtIndex(int index) const;
static QQuickPathViewAttached *qmlAttachedProperties(QObject *);
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index eaf0e4cf89..0b5bebb7ba 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -377,36 +377,6 @@ Q_LOGGING_CATEGORY(lcTableViewDelegateLifecycle, "qt.quick.tableview.lifecycle")
static const Qt::Edge allTableEdges[] = { Qt::LeftEdge, Qt::RightEdge, Qt::TopEdge, Qt::BottomEdge };
-static QLine rectangleEdge(const QRect &rect, Qt::Edge tableEdge)
-{
- switch (tableEdge) {
- case Qt::LeftEdge:
- return QLine(rect.topLeft(), rect.bottomLeft());
- case Qt::RightEdge:
- return QLine(rect.topRight(), rect.bottomRight());
- case Qt::TopEdge:
- return QLine(rect.topLeft(), rect.topRight());
- case Qt::BottomEdge:
- return QLine(rect.bottomLeft(), rect.bottomRight());
- }
- return QLine();
-}
-
-static QRect expandedRect(const QRect &rect, Qt::Edge edge, int increment)
-{
- switch (edge) {
- case Qt::LeftEdge:
- return rect.adjusted(-increment, 0, 0, 0);
- case Qt::RightEdge:
- return rect.adjusted(0, 0, increment, 0);
- case Qt::TopEdge:
- return rect.adjusted(0, -increment, 0, 0);
- case Qt::BottomEdge:
- return rect.adjusted(0, 0, 0, increment);
- }
- return QRect();
-}
-
const QPoint QQuickTableViewPrivate::kLeft = QPoint(-1, 0);
const QPoint QQuickTableViewPrivate::kRight = QPoint(1, 0);
const QPoint QQuickTableViewPrivate::kUp = QPoint(0, -1);
@@ -427,8 +397,8 @@ QQuickTableViewPrivate::~QQuickTableViewPrivate()
QString QQuickTableViewPrivate::tableLayoutToString() const
{
return QString(QLatin1String("table cells: (%1,%2) -> (%3,%4), item count: %5, table rect: %6,%7 x %8,%9"))
- .arg(loadedTable.topLeft().x()).arg(loadedTable.topLeft().y())
- .arg(loadedTable.bottomRight().x()).arg(loadedTable.bottomRight().y())
+ .arg(leftColumn()).arg(topRow())
+ .arg(rightColumn()).arg(bottomRow())
.arg(loadedItems.count())
.arg(loadedTableOuterRect.x())
.arg(loadedTableOuterRect.y())
@@ -489,7 +459,7 @@ void QQuickTableViewPrivate::updateContentWidth()
}
const qreal thresholdBeforeAdjust = 0.1;
- int currentRightColumn = loadedTable.right();
+ int currentRightColumn = rightColumn();
if (currentRightColumn > contentSizeBenchMarkPoint.x()) {
contentSizeBenchMarkPoint.setX(currentRightColumn);
@@ -526,7 +496,7 @@ void QQuickTableViewPrivate::updateContentHeight()
}
const qreal thresholdBeforeAdjust = 0.1;
- int currentBottomRow = loadedTable.bottom();
+ int currentBottomRow = bottomRow();
if (currentBottomRow > contentSizeBenchMarkPoint.y()) {
contentSizeBenchMarkPoint.setY(currentBottomRow);
@@ -561,7 +531,7 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
bool layoutNeeded = false;
const qreal flickMargin = 50;
- if (loadedTable.x() == 0 && loadedTableOuterRect.x() > 0) {
+ if (leftColumn() == 0 && loadedTableOuterRect.x() > 0) {
// The table is at the beginning, but not at the edge of the
// content view. So move the table to origin.
loadedTableOuterRect.moveLeft(0);
@@ -569,15 +539,15 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
} else if (loadedTableOuterRect.x() < 0) {
// The table is outside the beginning of the content view. Move
// the whole table inside, and make some room for flicking.
- loadedTableOuterRect.moveLeft(loadedTable.x() == 0 ? 0 : flickMargin);
+ loadedTableOuterRect.moveLeft(leftColumn() == 0 ? 0 : flickMargin);
layoutNeeded = true;
}
- if (loadedTable.y() == 0 && loadedTableOuterRect.y() > 0) {
+ if (topRow() == 0 && loadedTableOuterRect.y() > 0) {
loadedTableOuterRect.moveTop(0);
layoutNeeded = true;
} else if (loadedTableOuterRect.y() < 0) {
- loadedTableOuterRect.moveTop(loadedTable.y() == 0 ? 0 : flickMargin);
+ loadedTableOuterRect.moveTop(topRow() == 0 ? 0 : flickMargin);
layoutNeeded = true;
}
@@ -589,8 +559,8 @@ void QQuickTableViewPrivate::enforceTableAtOrigin()
void QQuickTableViewPrivate::updateAverageEdgeSize()
{
- int bottomCell = loadedTable.bottom();
- int rightCell = loadedTable.right();
+ int bottomCell = bottomRow();
+ int rightCell = rightColumn();
qreal accRowSpacing = bottomCell * cellSpacing.height();
qreal accColumnSpacing = rightCell * cellSpacing.width();
averageEdgeSize.setHeight((loadedTableOuterRect.bottom() - accRowSpacing) / (bottomCell + 1));
@@ -599,9 +569,11 @@ void QQuickTableViewPrivate::updateAverageEdgeSize()
void QQuickTableViewPrivate::syncLoadedTableRectFromLoadedTable()
{
- QRectF topLeftRect = loadedTableItem(loadedTable.topLeft())->geometry();
- QRectF bottomRightRect = loadedTableItem(loadedTable.bottomRight())->geometry();
- loadedTableOuterRect = topLeftRect.united(bottomRightRect);
+ const QPoint topLeft = QPoint(leftColumn(), topRow());
+ const QPoint bottomRight = QPoint(rightColumn(), bottomRow());
+ QRectF topLeftRect = loadedTableItem(topLeft)->geometry();
+ QRectF bottomRightRect = loadedTableItem(bottomRight)->geometry();
+ loadedTableOuterRect = QRectF(topLeftRect.topLeft(), bottomRightRect.bottomRight());
loadedTableInnerRect = QRectF(topLeftRect.bottomRight(), bottomRightRect.topLeft());
}
@@ -609,18 +581,19 @@ void QQuickTableViewPrivate::syncLoadedTableFromLoadRequest()
{
if (loadRequest.edge() == Qt::Edge(0)) {
// No edge means we're loading the top-left item
- loadedTable = QRect(loadRequest.firstCell(), loadRequest.lastCell());
+ loadedColumns.insert(loadRequest.firstCell().x(), 0);
+ loadedRows.insert(loadRequest.firstCell().y(), 0);
return;
}
switch (loadRequest.edge()) {
case Qt::LeftEdge:
- case Qt::TopEdge:
- loadedTable.setTopLeft(loadRequest.firstCell());
- break;
case Qt::RightEdge:
+ loadedColumns.insert(loadRequest.firstCell().x(), 0);
+ break;
+ case Qt::TopEdge:
case Qt::BottomEdge:
- loadedTable.setBottomRight(loadRequest.lastCell());
+ loadedRows.insert(loadRequest.firstCell().y(), 0);
break;
}
}
@@ -776,23 +749,38 @@ void QQuickTableViewPrivate::unloadItems(const QLine &items)
}
}
+int QQuickTableViewPrivate::nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge)
+{
+ switch (edge) {
+ case Qt::LeftEdge:
+ return leftColumn() - 1;
+ case Qt::RightEdge:
+ return rightColumn() + 1;
+ case Qt::TopEdge:
+ return topRow() - 1;
+ case Qt::BottomEdge:
+ return bottomRow() + 1;
+ }
+ return -1;
+}
+
bool QQuickTableViewPrivate::canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const
{
switch (tableEdge) {
case Qt::LeftEdge:
- if (loadedTable.topLeft().x() == 0)
+ if (leftColumn() == 0)
return false;
return loadedTableOuterRect.left() > fillRect.left() + cellSpacing.width();
case Qt::RightEdge:
- if (loadedTable.bottomRight().x() >= tableSize.width() - 1)
+ if (rightColumn() == tableSize.width() - 1)
return false;
return loadedTableOuterRect.right() < fillRect.right() - cellSpacing.width();
case Qt::TopEdge:
- if (loadedTable.topLeft().y() == 0)
+ if (topRow() == 0)
return false;
return loadedTableOuterRect.top() > fillRect.top() + cellSpacing.height();
case Qt::BottomEdge:
- if (loadedTable.bottomRight().y() >= tableSize.height() - 1)
+ if (bottomRow() == tableSize.height() - 1)
return false;
return loadedTableOuterRect.bottom() < fillRect.bottom() - cellSpacing.height();
}
@@ -806,19 +794,19 @@ bool QQuickTableViewPrivate::canUnloadTableEdge(Qt::Edge tableEdge, const QRectF
// they are needed as anchor point for further layouting.
switch (tableEdge) {
case Qt::LeftEdge:
- if (loadedTable.width() <= 1)
+ if (loadedColumns.count() <= 1)
return false;
return loadedTableInnerRect.left() <= fillRect.left();
case Qt::RightEdge:
- if (loadedTable.width() <= 1)
+ if (loadedColumns.count() <= 1)
return false;
return loadedTableInnerRect.right() >= fillRect.right();
case Qt::TopEdge:
- if (loadedTable.height() <= 1)
+ if (loadedRows.count() <= 1)
return false;
return loadedTableInnerRect.top() <= fillRect.top();
case Qt::BottomEdge:
- if (loadedTable.height() <= 1)
+ if (loadedRows.count() <= 1)
return false;
return loadedTableInnerRect.bottom() >= fillRect.bottom();
}
@@ -864,8 +852,10 @@ qreal QQuickTableViewPrivate::sizeHintForColumn(int column)
{
// Find the widest cell in the column, and return its width
qreal columnWidth = 0;
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row)
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
columnWidth = qMax(columnWidth, cellWidth(QPoint(column, row)));
+ }
return columnWidth;
}
@@ -874,8 +864,10 @@ qreal QQuickTableViewPrivate::sizeHintForRow(int row)
{
// Find the highest cell in the row, and return its height
qreal rowHeight = 0;
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column)
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
rowHeight = qMax(rowHeight, cellHeight(QPoint(column, row)));
+ }
return rowHeight;
}
@@ -902,7 +894,6 @@ void QQuickTableViewPrivate::calculateTableSize()
qreal QQuickTableViewPrivate::resolveColumnWidth(int column)
{
- Q_TABLEVIEW_ASSERT(column >= loadedTable.left() && column <= loadedTable.right(), column);
qreal columnWidth = -1;
if (!columnWidthProvider.isUndefined()) {
@@ -948,7 +939,6 @@ qreal QQuickTableViewPrivate::resolveColumnWidth(int column)
qreal QQuickTableViewPrivate::resolveRowHeight(int row)
{
- Q_TABLEVIEW_ASSERT(row >= loadedTable.top() && row <= loadedTable.bottom(), row);
qreal rowHeight = -1;
if (!rowHeightProvider.isUndefined()) {
@@ -1011,11 +1001,13 @@ void QQuickTableViewPrivate::relayoutTableItems()
qreal nextColumnX = loadedTableOuterRect.x();
qreal nextRowY = loadedTableOuterRect.y();
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
// Adjust the geometry of all cells in the current column
const qreal width = resolveColumnWidth(column);
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
auto item = loadedTableItem(QPoint(column, row));
QRectF geometry = item->geometry();
geometry.moveLeft(nextColumnX);
@@ -1026,11 +1018,13 @@ void QQuickTableViewPrivate::relayoutTableItems()
nextColumnX += width + cellSpacing.width();
}
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
// Adjust the geometry of all cells in the current row
const qreal height = resolveRowHeight(row);
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
auto item = loadedTableItem(QPoint(column, row));
QRectF geometry = item->geometry();
geometry.moveTop(nextRowY);
@@ -1042,8 +1036,10 @@ void QQuickTableViewPrivate::relayoutTableItems()
}
if (Q_UNLIKELY(lcTableViewDelegateLifecycle().isDebugEnabled())) {
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
QPoint cell = QPoint(column, row);
qCDebug(lcTableViewDelegateLifecycle()) << "relayout item:" << cell << loadedTableItem(cell)->geometry();
}
@@ -1053,11 +1049,12 @@ void QQuickTableViewPrivate::relayoutTableItems()
void QQuickTableViewPrivate::layoutVerticalEdge(Qt::Edge tableEdge)
{
- int column = (tableEdge == Qt::LeftEdge) ? loadedTable.left() : loadedTable.right();
+ int column = (tableEdge == Qt::LeftEdge) ? leftColumn() : rightColumn();
QPoint neighbourDirection = (tableEdge == Qt::LeftEdge) ? kRight : kLeft;
qreal width = resolveColumnWidth(column);
- for (int row = loadedTable.top(); row <= loadedTable.bottom(); ++row) {
+ for (auto r = loadedRows.cbegin(); r != loadedRows.cend(); ++r) {
+ const int row = r.key();
auto fxTableItem = loadedTableItem(QPoint(column, row));
auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
@@ -1080,11 +1077,12 @@ void QQuickTableViewPrivate::layoutVerticalEdge(Qt::Edge tableEdge)
void QQuickTableViewPrivate::layoutHorizontalEdge(Qt::Edge tableEdge)
{
- int row = (tableEdge == Qt::TopEdge) ? loadedTable.top() : loadedTable.bottom();
+ int row = (tableEdge == Qt::TopEdge) ? topRow() : bottomRow();
QPoint neighbourDirection = (tableEdge == Qt::TopEdge) ? kDown : kUp;
qreal height = resolveRowHeight(row);
- for (int column = loadedTable.left(); column <= loadedTable.right(); ++column) {
+ for (auto c = loadedColumns.cbegin(); c != loadedColumns.cend(); ++c) {
+ const int column = c.key();
auto fxTableItem = loadedTableItem(QPoint(column, row));
auto const neighbourItem = itemNextTo(fxTableItem, neighbourDirection);
@@ -1232,14 +1230,14 @@ void QQuickTableViewPrivate::processRebuildTable()
&& reusableFlag == QQmlTableInstanceModel::Reusable);
if (rebuildState == RebuildState::PreloadColumns) {
- if (preload && loadedTable.right() < tableSize.width() - 1)
+ if (preload && rightColumn() < tableSize.width() - 1)
loadEdge(Qt::RightEdge, QQmlIncubator::AsynchronousIfNested);
if (!moveToNextRebuildState())
return;
}
if (rebuildState == RebuildState::PreloadRows) {
- if (preload && loadedTable.bottom() < tableSize.height() - 1)
+ if (preload && bottomRow() < tableSize.height() - 1)
loadEdge(Qt::BottomEdge, QQmlIncubator::AsynchronousIfNested);
if (!moveToNextRebuildState())
return;
@@ -1289,7 +1287,7 @@ void QQuickTableViewPrivate::beginRebuildTable()
topLeft.ry() = qBound(0, newRow, tableSize.height() - 1);
topLeftPos.ry() = topLeft.y() * (averageEdgeSize.height() + cellSpacing.height());
} else {
- topLeft.ry() = qBound(0, loadedTable.topLeft().y(), tableSize.height() - 1);
+ topLeft.ry() = qBound(0, topRow(), tableSize.height() - 1);
topLeftPos.ry() = loadedTableOuterRect.topLeft().y();
}
if (rebuildOptions & RebuildOption::CalculateNewTopLeftColumn) {
@@ -1297,14 +1295,15 @@ void QQuickTableViewPrivate::beginRebuildTable()
topLeft.rx() = qBound(0, newColumn, tableSize.width() - 1);
topLeftPos.rx() = topLeft.x() * (averageEdgeSize.width() + cellSpacing.width());
} else {
- topLeft.rx() = qBound(0, loadedTable.topLeft().x(), tableSize.width() - 1);
+ topLeft.rx() = qBound(0, leftColumn(), tableSize.width() - 1);
topLeftPos.rx() = loadedTableOuterRect.topLeft().x();
}
} else {
Q_TABLEVIEW_UNREACHABLE(rebuildOptions);
}
- loadedTable = QRect();
+ loadedColumns.clear();
+ loadedRows.clear();
loadedTableOuterRect = QRect();
loadedTableInnerRect = QRect();
contentSizeBenchMarkPoint = QPoint(-1, -1);
@@ -1351,15 +1350,44 @@ void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QP
void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge)
{
- unloadItems(rectangleEdge(loadedTable, edge));
- loadedTable = expandedRect(loadedTable, edge, -1);
+ qCDebug(lcTableViewDelegateLifecycle) << edge;
+
+ switch (edge) {
+ case Qt::LeftEdge:
+ case Qt::RightEdge: {
+ const int column = edge == Qt::LeftEdge ? leftColumn() : rightColumn();
+ unloadItems(QLine(column, topRow(), column, bottomRow()));
+ loadedColumns.remove(column);
+ break; }
+ case Qt::TopEdge:
+ case Qt::BottomEdge: {
+ const int row = edge == Qt::TopEdge ? topRow() : bottomRow();
+ unloadItems(QLine(leftColumn(), row, rightColumn(), row));
+ loadedRows.remove(row);
+ break; }
+ }
+
syncLoadedTableRectFromLoadedTable();
qCDebug(lcTableViewDelegateLifecycle) << tableLayoutToString();
}
void QQuickTableViewPrivate::loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode)
{
- QLine cellsToLoad = rectangleEdge(expandedRect(loadedTable, edge, 1), edge);
+ const int edgeIndex = nextVisibleEdgeIndexAroundLoadedTable(edge);
+ qCDebug(lcTableViewDelegateLifecycle) << edge << edgeIndex;
+ QLine cellsToLoad;
+
+ switch (edge) {
+ case Qt::LeftEdge:
+ case Qt::RightEdge:
+ cellsToLoad = QLine(edgeIndex, topRow(), edgeIndex, bottomRow());
+ break;
+ case Qt::TopEdge:
+ case Qt::BottomEdge:
+ cellsToLoad = QLine(leftColumn(), edgeIndex, rightColumn(), edgeIndex);
+ break;
+ }
+
loadRequest.begin(cellsToLoad, edge, incubationMode);
processLoadRequest();
}
@@ -1446,8 +1474,8 @@ void QQuickTableViewPrivate::drainReusePoolAfterLoadRequest()
// in with varying sizes, causing some items not to be resued immediately), we multiply the
// value by 2. Note that we also add an extra +1 to the column count, because the number of
// visible columns will fluctuate between +1/-1 while flicking.
- const int w = loadedTable.width();
- const int h = loadedTable.height();
+ const int w = loadedColumns.count();
+ const int h = loadedRows.count();
const int minTime = int(std::ceil(w > h ? qreal(w + 1) / h : qreal(h + 1) / w));
const int maxTime = minTime * 2;
tableModel->drainReusableItemsPool(maxTime);
@@ -1596,6 +1624,12 @@ void QQuickTableViewPrivate::syncRebuildOptions()
rebuildOptions = scheduledRebuildOptions;
scheduledRebuildOptions = RebuildOption::None;
rebuildScheduled = false;
+
+ if (loadedItems.isEmpty()) {
+ // If we have no items from before, we cannot just rebuild the viewport, but need
+ // to rebuild everything, since we have no top-left loaded item to start from.
+ rebuildOptions.setFlag(RebuildOption::All);
+ }
}
void QQuickTableViewPrivate::syncDelegate()
@@ -1774,6 +1808,16 @@ QQuickTableView::QQuickTableView(QQuickItem *parent)
setFlag(QQuickItem::ItemIsFocusScope);
}
+QQuickTableView::~QQuickTableView()
+{
+}
+
+QQuickTableView::QQuickTableView(QQuickTableViewPrivate &dd, QQuickItem *parent)
+ : QQuickFlickable(dd, parent)
+{
+ setFlag(QQuickItem::ItemIsFocusScope);
+}
+
int QQuickTableView::rows() const
{
return d_func()->tableSize.height();
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h
index 9fcd4c6c17..c5197b4230 100644
--- a/src/quick/items/qquicktableview_p.h
+++ b/src/quick/items/qquicktableview_p.h
@@ -82,7 +82,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable
public:
QQuickTableView(QQuickItem *parent = nullptr);
-
+ ~QQuickTableView() override;
int rows() const;
int columns() const;
@@ -98,8 +98,8 @@ public:
QJSValue columnWidthProvider() const;
void setColumnWidthProvider(QJSValue provider);
- QVariant model() const;
- void setModel(const QVariant &newModel);
+ virtual QVariant model() const;
+ virtual void setModel(const QVariant &newModel);
QQmlComponent *delegate() const;
void setDelegate(QQmlComponent *);
@@ -130,6 +130,9 @@ protected:
void viewportMoved(Qt::Orientations orientation) override;
void componentComplete() override;
+protected:
+ QQuickTableView(QQuickTableViewPrivate &dd, QQuickItem *parent);
+
private:
Q_DISABLE_COPY(QQuickTableView)
Q_DECLARE_PRIVATE(QQuickTableView)
diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h
index 2ed04f8d29..ed6f8026a2 100644
--- a/src/quick/items/qquicktableview_p_p.h
+++ b/src/quick/items/qquicktableview_p_p.h
@@ -213,13 +213,14 @@ public:
QVariant assignedModel = QVariant(int(0));
QQmlComponent *assignedDelegate = nullptr;
- // loadedTable describes the table cells that are currently loaded (from top left
+ // loadedRows/Columns describes the rows and columns that are currently loaded (from top left
// row/column to bottom right row/column). loadedTableOuterRect describes the actual
- // pixels that those cells cover, and is matched agains the viewport to determine when
+ // pixels that all the loaded delegate items cover, and is matched agains the viewport to determine when
// we need to fill up with more rows/columns. loadedTableInnerRect describes the pixels
// that the loaded table covers if you remove one row/column on each side of the table, and
// is used to determine rows/columns that are no longer visible and can be unloaded.
- QRect loadedTable;
+ QMap<int, int> loadedColumns;
+ QMap<int, int> loadedRows;
QRectF loadedTableOuterRect;
QRectF loadedTableInnerRect;
@@ -283,6 +284,11 @@ public:
qreal resolveColumnWidth(int column);
qreal resolveRowHeight(int row);
+ inline int topRow() const { return loadedRows.firstKey(); }
+ inline int bottomRow() const { return loadedRows.lastKey(); }
+ inline int leftColumn() const { return loadedColumns.firstKey(); }
+ inline int rightColumn() const { return loadedColumns.lastKey(); }
+
void relayoutTable();
void relayoutTableItems();
@@ -299,6 +305,8 @@ public:
void syncLoadedTableRectFromLoadedTable();
void syncLoadedTableFromLoadRequest();
+ int nextVisibleEdgeIndexAroundLoadedTable(Qt::Edge edge);
+
bool canLoadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
bool canUnloadTableEdge(Qt::Edge tableEdge, const QRectF fillRect) const;
Qt::Edge nextEdgeToLoad(const QRectF rect);
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 38ca7283b4..a7a90c9134 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -998,7 +998,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
if (relativePos < line.textLength() - line.textStart())
w = line.cursorToX(relativePos + 1) - x;
else
- w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(block.layout()->font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), textCursorWidth + w, line.height());
} else {
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 06a0fc396b..3a12ad6ba5 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1641,7 +1641,8 @@ bool QQuickTextEdit::event(QEvent *event)
Q_D(QQuickTextEdit);
if (event->type() == QEvent::ShortcutOverride) {
d->control->processEvent(event, QPointF(-d->xoff, -d->yoff));
- return event->isAccepted();
+ if (event->isAccepted())
+ return true;
}
return QQuickImplicitSizeItem::event(event);
}
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index aac7137ff3..5f6fd8f50f 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -877,7 +877,7 @@ QRectF QQuickTextInput::cursorRectangle() const
if (c < text().length())
w = l.cursorToX(c + 1) - x;
else
- w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
return QRectF(x, y, w, l.height());
}
@@ -1383,7 +1383,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const
if (pos < text().length())
w = l.cursorToX(pos + 1) - x;
else
- w = QFontMetrics(font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
return QRectF(x, y, w, l.height());
}
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index 504d629b3e..792aa31a88 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -1051,7 +1051,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText
if (text.contains(QChar::ObjectReplacementCharacter)) {
QTextFrame *frame = qobject_cast<QTextFrame *>(textDocument->objectForFormat(charFormat));
- if (frame && frame->frameFormat().position() == QTextFrameFormat::InFlow) {
+ if (!frame || frame->frameFormat().position() == QTextFrameFormat::InFlow) {
int blockRelativePosition = textPos - block.position();
QTextLine line = block.layout()->lineForTextPosition(blockRelativePosition);
if (!currentLine().isValid()
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 61c8bcc1e7..f517b5b3e9 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -4608,6 +4608,62 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
+ \qmlproperty QWindow Window::transientParent
+ \since 5.13
+
+ The window for which this window is a transient pop-up.
+
+ This is a hint to the window manager that this window is a dialog or pop-up
+ on behalf of the transient parent. It usually means that the transient
+ window will be centered over its transient parent when it is initially
+ shown, that minimizing the parent window will also minimize the transient
+ window, and so on; however results vary somewhat from platform to platform.
+
+ Normally if you declare a Window inside an Item or inside another Window,
+ this relationship is deduced automatically. In that case, if you declare
+ this window's \l visible property \c true, it will not actually be shown
+ until the \c transientParent window is shown.
+
+ However if you set this property, then Qt Quick will no longer wait until
+ the \c transientParent window is shown before showing this window. If you
+ want to to be able to show a transient window independently of the "parent"
+ Item or Window within which it was declared, you can remove that
+ relationship by setting \c transientParent to \c null:
+
+ \l qml
+ import QtQuick.Window 2.13
+
+ Window {
+ // visible is false by default
+ Window {
+ transientParent: null
+ visible: true
+ }
+ }
+ \qml
+
+ In order to cause the window to be centered above its transient parent by
+ default, depending on the window manager, it may also be necessary to set
+ the \l Window::flags property with a suitable \l Qt::WindowType (such as
+ \c Qt::Dialog).
+*/
+
+/*!
+ \property QQuickWindow::transientParent
+ \brief The window for which this window is a transient pop-up.
+ \since 5.13
+
+ This is a hint to the window manager that this window is a dialog or pop-up
+ on behalf of the transient parent, which may be any kind of \l QWindow.
+
+ In order to cause the window to be centered above its transient parent by
+ default, depending on the window manager, it may also be necessary to set
+ the \l flags property with a suitable \l Qt::WindowType (such as \c Qt::Dialog).
+
+ \sa parent()
+ */
+
+/*!
\qmlproperty Item Window::activeFocusItem
\since 5.1
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index ab3f49d5b6..2b109c0897 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -124,7 +124,8 @@ void QQuickWindowQmlImpl::componentComplete()
Q_D(QQuickWindowQmlImpl);
d->complete = true;
QQuickItem *itemParent = qmlobject_cast<QQuickItem *>(QObject::parent());
- if (itemParent && !itemParent->window()) {
+ const bool transientParentAlreadySet = QQuickWindowPrivate::get(this)->transientParentPropertySet;
+ if (!transientParentAlreadySet && itemParent && !itemParent->window()) {
qCDebug(lcTransient) << "window" << title() << "has invisible Item parent" << itemParent << "transientParent"
<< transientParent() << "declared visibility" << d->visibility << "; delaying show";
connect(itemParent, &QQuickItem::windowChanged, this,
@@ -210,6 +211,9 @@ void QQuickWindowModule::defineModule()
qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
qmlRegisterUncreatableType<QQuickScreenInfo,10>(uri, 2, 10, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
+ qmlRegisterRevision<QWindow,13>(uri, 2, 13);
+ qmlRegisterRevision<QQuickWindow,13>(uri, 2, 13);
+ qmlRegisterType<QQuickWindowQmlImpl,13>(uri, 2, 13, "Window");
}
QT_END_NAMESPACE