aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktextarea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquicktextarea.cpp')
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index ef452fd0..64fc631d 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype TextArea
\inherits TextEdit
- \instantiates QQuickTextArea
+//! \instantiates QQuickTextArea
\inqmlmodule QtQuick.Controls
\since 5.7
\ingroup qtquickcontrols2-input
@@ -121,8 +121,8 @@ QT_BEGIN_NAMESPACE
\qmlsignal QtQuick.Controls::TextArea::pressAndHold(MouseEvent event)
This signal is emitted when there is a long press (the delay depends on the platform plugin).
- The \l {MouseEvent}{event} parameter provides information about the press, including the x and y
- position of the press, and which button is pressed.
+ The \a event parameter provides information about the press, including the x and y
+ coordinates of the press, and which button is pressed.
\sa pressed, released
*/
@@ -132,8 +132,8 @@ QT_BEGIN_NAMESPACE
\since QtQuick.Controls 2.1 (Qt 5.8)
This signal is emitted when the text area is pressed by the user.
- The \l {MouseEvent}{event} parameter provides information about the press,
- including the x and y position of the press, and which button is pressed.
+ The \a event parameter provides information about the press,
+ including the x and y coordinates of the press, and which button is pressed.
\sa released, pressAndHold
*/
@@ -143,8 +143,9 @@ QT_BEGIN_NAMESPACE
\since QtQuick.Controls 2.1 (Qt 5.8)
This signal is emitted when the text area is released by the user.
- The \l {MouseEvent}{event} parameter provides information about the release,
- including the x and y position of the press, and which button is pressed.
+ The \a event parameter provides information about the release,
+ including the x and y coordinates of the press, and which button
+ is pressed.
\sa pressed, pressAndHold
*/
@@ -218,16 +219,25 @@ void QQuickTextAreaPrivate::resizeBackground()
resizingBackground = true;
+ // When using the attached property TextArea.flickable, we reparent the background out
+ // of TextArea and into the Flickable since we don't want the background to move while
+ // flicking. This means that the size of the background should also follow the size of
+ // the Flickable rather than the size of the TextArea.
+ const auto flickable = qobject_cast<QQuickFlickable *>(background->parentItem());
+
QQuickItemPrivate *p = QQuickItemPrivate::get(background);
if (((!p->widthValid || !extra.isAllocated() || !extra->hasBackgroundWidth) && qFuzzyIsNull(background->x()))
|| (extra.isAllocated() && (extra->hasLeftInset || extra->hasRightInset))) {
+ const qreal bgWidth = flickable ? flickable->width() : width;
background->setX(getLeftInset());
- background->setWidth(width - getLeftInset() - getRightInset());
+ background->setWidth(bgWidth - getLeftInset() - getRightInset());
}
+
if (((!p->heightValid || !extra.isAllocated() || !extra->hasBackgroundHeight) && qFuzzyIsNull(background->y()))
|| (extra.isAllocated() && (extra->hasTopInset || extra->hasBottomInset))) {
+ const qreal bgHeight = flickable ? flickable->height() : height;
background->setY(getTopInset());
- background->setHeight(height - getTopInset() - getBottomInset());
+ background->setHeight(bgHeight - getTopInset() - getBottomInset());
}
resizingBackground = false;
@@ -348,6 +358,7 @@ void QQuickTextAreaPrivate::attachFlickable(QQuickFlickable *item)
QObject::connect(flickable, &QQuickFlickable::contentYChanged, q, &QQuickItem::update);
QQuickItemPrivate::get(flickable)->updateOrAddGeometryChangeListener(this, QQuickGeometryChange::Size);
+ QQuickItemPrivate::get(flickable)->addItemChangeListener(this, QQuickItemPrivate::Destroyed);
QObjectPrivate::connect(flickable, &QQuickFlickable::contentWidthChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
QObjectPrivate::connect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
@@ -368,6 +379,7 @@ void QQuickTextAreaPrivate::detachFlickable()
QObject::disconnect(flickable, &QQuickFlickable::contentYChanged, q, &QQuickItem::update);
QQuickItemPrivate::get(flickable)->updateOrRemoveGeometryChangeListener(this, QQuickGeometryChange::Nothing);
+ QQuickItemPrivate::get(flickable)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentWidthChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl);
@@ -552,6 +564,8 @@ void QQuickTextAreaPrivate::itemDestroyed(QQuickItem *item)
background = nullptr;
emit q->implicitBackgroundWidthChanged();
emit q->implicitBackgroundHeightChanged();
+ } else if (item == flickable) {
+ detachFlickable();
}
}
@@ -1072,7 +1086,11 @@ QSGNode *QQuickTextArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if (d->flickable)
clipper = d->flickable;
- const QRectF cr = clipper->clipRect().adjusted(leftPadding(), topPadding(), -rightPadding(), -bottomPadding());
+ const QRectF cr = clipper->clipRect().adjusted(
+ leftPadding(), topPadding(),
+ (!d->cursorItem && effectiveHAlign() == HAlignment::AlignRight ? 1 : 0) - rightPadding(),
+ -bottomPadding());
+
clipNode->setRect(!d->flickable ? cr : cr.translated(d->flickable->contentX(), d->flickable->contentY()));
clipNode->update();