aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickpositioners.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-01-21 23:40:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-25 18:26:27 +0100
commitafb5bf71c942d411d6102ce637bc7499d8ae467c (patch)
tree50abc97628feb209b52e191091d310fc3e164bdc /src/quick/items/qquickpositioners.cpp
parent97a6e62cb5947ea5731814c0d7183028668dfd03 (diff)
Positioners: fix layout mirroring
Listen to positioner geometry changes when the _effective_ layout direction is RTL. Task-number: QTBUG-35095 Change-Id: If06955c6bb04e5bed2126b05489229278c192173 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/quick/items/qquickpositioners.cpp')
-rw-r--r--src/quick/items/qquickpositioners.cpp80
1 files changed, 61 insertions, 19 deletions
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index c72c2276e0..0ef871be43 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -869,8 +869,31 @@ void QQuickColumn::reportConflictingAnchors()
\sa Grid::spacing
*/
+class QQuickRowPrivate : public QQuickBasePositionerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickRow)
+
+public:
+ QQuickRowPrivate()
+ : QQuickBasePositionerPrivate()
+ {}
+
+ void effectiveLayoutDirectionChange()
+ {
+ Q_Q(QQuickRow);
+ // For RTL layout the positioning changes when the width changes.
+ if (getEffectiveLayoutDirection(q) == Qt::RightToLeft)
+ addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ else
+ removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ // Don't postpone, as it might be the only trigger for visible changes.
+ q->prePositioning();
+ emit q->effectiveLayoutDirectionChanged();
+ }
+};
+
QQuickRow::QQuickRow(QQuickItem *parent)
-: QQuickBasePositioner(Horizontal, parent)
+: QQuickBasePositioner(*new QQuickRowPrivate, Horizontal, parent)
{
}
/*!
@@ -900,14 +923,8 @@ void QQuickRow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate* >(QQuickBasePositionerPrivate::get(this));
if (d->layoutDirection != layoutDirection) {
d->layoutDirection = layoutDirection;
- // For RTL layout the positioning changes when the width changes.
- if (d->layoutDirection == Qt::RightToLeft)
- d->addItemChangeListener(d, QQuickItemPrivate::Geometry);
- else
- d->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- prePositioning();
emit layoutDirectionChanged();
- emit effectiveLayoutDirectionChanged();
+ d->effectiveLayoutDirectionChange();
}
}
/*!
@@ -1111,8 +1128,33 @@ void QQuickRow::reportConflictingAnchors()
\sa rows, columns
*/
+
+class QQuickGridPrivate : public QQuickBasePositionerPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickGrid)
+
+public:
+ QQuickGridPrivate()
+ : QQuickBasePositionerPrivate()
+ {}
+
+ void effectiveLayoutDirectionChange()
+ {
+ Q_Q(QQuickGrid);
+ // For RTL layout the positioning changes when the width changes.
+ if (getEffectiveLayoutDirection(q) == Qt::RightToLeft)
+ addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ else
+ removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ // Don't postpone, as it might be the only trigger for visible changes.
+ q->prePositioning();
+ emit q->effectiveLayoutDirectionChanged();
+ emit q->effectiveHorizontalAlignmentChanged(q->effectiveHAlign());
+ }
+};
+
QQuickGrid::QQuickGrid(QQuickItem *parent)
- : QQuickBasePositioner(Both, parent)
+ : QQuickBasePositioner(*new QQuickGridPrivate, Both, parent)
, m_rows(-1)
, m_columns(-1)
, m_rowSpacing(-1)
@@ -1260,15 +1302,8 @@ void QQuickGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection)
QQuickBasePositionerPrivate *d = static_cast<QQuickBasePositionerPrivate*>(QQuickBasePositionerPrivate::get(this));
if (d->layoutDirection != layoutDirection) {
d->layoutDirection = layoutDirection;
- // For RTL layout the positioning changes when the width changes.
- if (d->layoutDirection == Qt::RightToLeft)
- d->addItemChangeListener(d, QQuickItemPrivate::Geometry);
- else
- d->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
- prePositioning();
emit layoutDirectionChanged();
- emit effectiveLayoutDirectionChanged();
- emit effectiveHorizontalAlignmentChanged(effectiveHAlign());
+ d->effectiveLayoutDirectionChange();
}
}
@@ -1652,6 +1687,14 @@ public:
: QQuickBasePositionerPrivate(), flow(QQuickFlow::LeftToRight)
{}
+ void effectiveLayoutDirectionChange()
+ {
+ Q_Q(QQuickFlow);
+ // Don't postpone, as it might be the only trigger for visible changes.
+ q->prePositioning();
+ emit q->effectiveLayoutDirectionChanged();
+ }
+
QQuickFlow::Flow flow;
};
@@ -1724,9 +1767,8 @@ void QQuickFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection)
Q_D(QQuickFlow);
if (d->layoutDirection != layoutDirection) {
d->layoutDirection = layoutDirection;
- prePositioning();
emit layoutDirectionChanged();
- emit effectiveLayoutDirectionChanged();
+ d->effectiveLayoutDirectionChange();
}
}