aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-08-15 12:23:54 +0200
committerLiang Qi <liang.qi@qt.io>2017-08-15 13:31:44 +0200
commit9530cc3d4faeae92eba5ade6239a622630872560 (patch)
tree8c34541a430977c7a89bfd166029a3753387580e /src/quicktemplates2
parent068379a66f88b34545530a018c0826c2c09a100a (diff)
parent63f2f55462f2f040cfe175ada8aa1e01168597fc (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: tests/auto/popup/tst_popup.cpp Change-Id: I32e6c6b646a00f8805cb82d181417db60a6fe6c8
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp48
-rw-r--r--src/quicktemplates2/qquickoverlay_p_p.h2
-rw-r--r--src/quicktemplates2/qquickpopuppositioner.cpp16
-rw-r--r--src/quicktemplates2/qquickstackelement.cpp3
-rw-r--r--src/quicktemplates2/qquickstackview_p.cpp8
5 files changed, 63 insertions, 14 deletions
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index ed3d3d45..38f7949e 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -109,10 +109,9 @@ QVector<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
return sorted;
}
-void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &)
+void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
- Q_Q(QQuickOverlay);
- q->setSize(QSizeF(item->width(), item->height()));
+ updateGeometry();
}
QQuickOverlayPrivate::QQuickOverlayPrivate()
@@ -282,6 +281,43 @@ void QQuickOverlayPrivate::setMouseGrabberPopup(QQuickPopup *popup)
mouseGrabberPopup = popup;
}
+void QQuickOverlayPrivate::updateGeometry()
+{
+ Q_Q(QQuickOverlay);
+ if (!window)
+ return;
+
+ QPointF pos;
+ QSizeF size = window->size();
+ qreal rotation = 0;
+
+ switch (window->contentOrientation()) {
+ case Qt::PrimaryOrientation:
+ case Qt::PortraitOrientation:
+ size = window->size();
+ break;
+ case Qt::LandscapeOrientation:
+ rotation = 90;
+ pos = QPointF((size.width() - size.height()) / 2, -(size.width() - size.height()) / 2);
+ size.transpose();
+ break;
+ case Qt::InvertedPortraitOrientation:
+ rotation = 180;
+ break;
+ case Qt::InvertedLandscapeOrientation:
+ rotation = 270;
+ pos = QPointF((size.width() - size.height()) / 2, -(size.width() - size.height()) / 2);
+ size.transpose();
+ break;
+ default:
+ break;
+ }
+
+ q->setSize(size);
+ q->setPosition(pos);
+ q->setRotation(rotation);
+}
+
QQuickOverlay::QQuickOverlay(QQuickItem *parent)
: QQuickItem(*(new QQuickOverlayPrivate), parent)
{
@@ -292,10 +328,12 @@ QQuickOverlay::QQuickOverlay(QQuickItem *parent)
setVisible(false);
if (parent) {
- setSize(QSizeF(parent->width(), parent->height()));
+ d->updateGeometry();
QQuickItemPrivate::get(parent)->addItemChangeListener(d, QQuickItemPrivate::Geometry);
- if (QQuickWindow *window = parent->window())
+ if (QQuickWindow *window = parent->window()) {
window->installEventFilter(this);
+ QObjectPrivate::connect(window, &QWindow::contentOrientationChanged, d, &QQuickOverlayPrivate::updateGeometry);
+ }
}
}
diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h
index 772b9b09..a290ecc2 100644
--- a/src/quicktemplates2/qquickoverlay_p_p.h
+++ b/src/quicktemplates2/qquickoverlay_p_p.h
@@ -89,6 +89,8 @@ public:
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
+ void updateGeometry();
+
QQmlComponent *modal;
QQmlComponent *modeless;
QVector<QQuickPopup *> allPopups;
diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp
index a8e217f1..2b67c85e 100644
--- a/src/quicktemplates2/qquickpopuppositioner.cpp
+++ b/src/quicktemplates2/qquickpopuppositioner.cpp
@@ -116,25 +116,27 @@ void QQuickPopupPositioner::reposition()
!p->hasWidth && iw > 0 ? iw : w,
!p->hasHeight && ih > 0 ? ih : h);
if (m_parentItem) {
- rect = m_parentItem->mapRectToScene(rect);
+ rect.moveTopLeft(m_parentItem->mapToItem(popupItem->parentItem(), rect.topLeft()));
if (p->window) {
const QMarginsF margins = p->getMargins();
- const QRectF bounds(qMax<qreal>(0.0, margins.left()),
- qMax<qreal>(0.0, margins.top()),
- p->window->width() - qMax<qreal>(0.0, margins.left()) - qMax<qreal>(0.0, margins.right()),
- p->window->height() - qMax<qreal>(0.0, margins.top()) - qMax<qreal>(0.0, margins.bottom()));
+ QRectF bounds(qMax<qreal>(0.0, margins.left()),
+ qMax<qreal>(0.0, margins.top()),
+ p->window->width() - qMax<qreal>(0.0, margins.left()) - qMax<qreal>(0.0, margins.right()),
+ p->window->height() - qMax<qreal>(0.0, margins.top()) - qMax<qreal>(0.0, margins.bottom()));
+ if (p->window->contentOrientation() == Qt::LandscapeOrientation || p->window->contentOrientation() == Qt::InvertedLandscapeOrientation)
+ bounds = bounds.transposed();
// if the popup doesn't fit horizontally inside the window, try flipping it around (left <-> right)
if (p->allowHorizontalFlip && (rect.left() < bounds.left() || rect.right() > bounds.right())) {
- const QRectF flipped = m_parentItem->mapRectToScene(QRectF(m_parentItem->width() - p->x - rect.width(), p->y, rect.width(), rect.height()));
+ const QRectF flipped(m_parentItem->mapToScene(QPointF(m_parentItem->width() - p->x - rect.width(), p->y)), rect.size());
if (flipped.intersected(bounds).width() > rect.intersected(bounds).width())
rect.moveLeft(flipped.left());
}
// if the popup doesn't fit vertically inside the window, try flipping it around (above <-> below)
if (p->allowVerticalFlip && (rect.top() < bounds.top() || rect.bottom() > bounds.bottom())) {
- const QRectF flipped = m_parentItem->mapRectToScene(QRectF(p->x, m_parentItem->height() - p->y - rect.height(), rect.width(), rect.height()));
+ const QRectF flipped(m_parentItem->mapToScene(QPointF(p->x, m_parentItem->height() - p->y - rect.height())), rect.size());
if (flipped.intersected(bounds).height() > rect.intersected(bounds).height())
rect.moveTop(flipped.top());
}
diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp
index a3bb840e..887d43af 100644
--- a/src/quicktemplates2/qquickstackelement.cpp
+++ b/src/quicktemplates2/qquickstackelement.cpp
@@ -130,6 +130,9 @@ QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickSta
return nullptr;
}
+ if (url.isRelative())
+ url = qmlContext(view)->resolvedUrl(url);
+
QQuickStackElement *element = new QQuickStackElement;
element->component = new QQmlComponent(qmlEngine(view), url, view);
element->ownComponent = true;
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp
index f4405246..0167ad97 100644
--- a/src/quicktemplates2/qquickstackview_p.cpp
+++ b/src/quicktemplates2/qquickstackview_p.cpp
@@ -278,9 +278,13 @@ void QQuickStackViewPrivate::viewItemTransitionFinished(QQuickItemViewTransition
}
if (transitioner->runningJobs.isEmpty()) {
- qDeleteAll(removed);
- removed.clear();
+ // ~QQuickStackElement() emits QQuickStackViewAttached::removed(), which may be used
+ // to modify the stack. Set the status first and make a copy of the destroyable stack
+ // elements to exclude any modifications that may happen during the loop. (QTBUG-62153)
setBusy(false);
+ QList<QQuickStackElement*> elements = removed;
+ removed.clear();
+ qDeleteAll(elements);
}
removing.remove(element);