aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktextarea.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-05-02 11:34:45 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-05-02 12:22:15 +0000
commitfac7e9e87caf78554bc33b80fe72dc40518fcc76 (patch)
tree2fa02d844a5f8d3ab8fa0c23913614a802c0ac29 /src/quicktemplates2/qquicktextarea.cpp
parent012556df80470e294c1adaf1b442e1eb8729c598 (diff)
Add missing implicitBackground{Width|Height} to non-QQuickControls
Same as 5bd9d44b for QQuickControl. [ChangeLog][Controls][Label] Added implicitBackgroundWidth and implicitBackgroundHeight properties that can be used to simplify complex implicit size bindings. [ChangeLog][Controls][TextArea] Added implicitBackgroundWidth and implicitBackgroundHeight properties that can be used to simplify complex implicit size bindings. [ChangeLog][Controls][TextField] Added implicitBackgroundWidth and implicitBackgroundHeight properties that can be used to simplify complex implicit size bindings. Change-Id: Idcc2d9af8df086b41c15f352506fd8afdbb2e3e7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktextarea.cpp')
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 4193483c..87a7c5e4 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -458,6 +458,30 @@ void QQuickTextAreaPrivate::executeBackground(bool complete)
quickCompleteDeferred(q, backgroundName(), background);
}
+void QQuickTextAreaPrivate::itemImplicitWidthChanged(QQuickItem *item)
+{
+ Q_Q(QQuickTextArea);
+ if (item == background)
+ emit q->implicitBackgroundWidthChanged();
+}
+
+void QQuickTextAreaPrivate::itemImplicitHeightChanged(QQuickItem *item)
+{
+ Q_Q(QQuickTextArea);
+ if (item == background)
+ emit q->implicitBackgroundHeightChanged();
+}
+
+void QQuickTextAreaPrivate::itemDestroyed(QQuickItem *item)
+{
+ Q_Q(QQuickTextArea);
+ if (item == background) {
+ background = nullptr;
+ emit q->implicitBackgroundWidthChanged();
+ emit q->implicitBackgroundHeightChanged();
+ }
+}
+
QQuickTextArea::QQuickTextArea(QQuickItem *parent)
: QQuickTextEdit(*(new QQuickTextAreaPrivate), parent)
{
@@ -478,6 +502,7 @@ QQuickTextArea::~QQuickTextArea()
Q_D(QQuickTextArea);
if (d->flickable)
d->detachFlickable();
+ QQuickControlPrivate::removeImplicitSizeListener(d->background, d);
}
QQuickTextAreaAttached *QQuickTextArea::qmlAttachedProperties(QObject *object)
@@ -526,8 +551,13 @@ void QQuickTextArea::setBackground(QQuickItem *background)
if (!d->background.isExecuting())
d->cancelBackground();
+ const qreal oldImplicitBackgroundWidth = implicitBackgroundWidth();
+ const qreal oldImplicitBackgroundHeight = implicitBackgroundHeight();
+
+ QQuickControlPrivate::removeImplicitSizeListener(d->background, d);
delete d->background;
d->background = background;
+
if (background) {
if (d->flickable)
background->setParentItem(d->flickable);
@@ -537,7 +567,13 @@ void QQuickTextArea::setBackground(QQuickItem *background)
background->setZ(-1);
if (isComponentComplete())
d->resizeBackground();
+ QQuickControlPrivate::addImplicitSizeListener(background, d);
}
+
+ if (!qFuzzyCompare(oldImplicitBackgroundWidth, implicitBackgroundWidth()))
+ emit implicitBackgroundWidthChanged();
+ if (!qFuzzyCompare(oldImplicitBackgroundHeight, implicitBackgroundHeight()))
+ emit implicitBackgroundHeightChanged();
if (!d->background.isExecuting())
emit backgroundChanged();
}
@@ -729,6 +765,44 @@ void QQuickTextArea::resetPalette()
setPalette(QPalette());
}
+/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty real QtQuick.Controls::TextArea::implicitBackgroundWidth
+ \readonly
+
+ This property holds the implicit background width.
+
+ The value is equal to \c {background ? background.implicitWidth : 0}.
+
+ \sa implicitBackgroundHeight
+*/
+qreal QQuickTextArea::implicitBackgroundWidth() const
+{
+ Q_D(const QQuickTextArea);
+ if (!d->background)
+ return 0;
+ return d->background->implicitWidth();
+}
+
+/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty real QtQuick.Controls::TextArea::implicitBackgroundHeight
+ \readonly
+
+ This property holds the implicit background height.
+
+ The value is equal to \c {background ? background.implicitHeight : 0}.
+
+ \sa implicitBackgroundWidth
+*/
+qreal QQuickTextArea::implicitBackgroundHeight() const
+{
+ Q_D(const QQuickTextArea);
+ if (!d->background)
+ return 0;
+ return d->background->implicitHeight();
+}
+
void QQuickTextArea::classBegin()
{
Q_D(QQuickTextArea);