diff options
author | Aleix Pol <aleixpol@kde.org> | 2017-11-29 16:40:07 +0100 |
---|---|---|
committer | Aleix Pol Gonzalez <aleixpol@kde.org> | 2018-07-31 16:38:01 +0000 |
commit | e92f76cf9ea91e87ec2e3e68234899fd9c12142f (patch) | |
tree | f90d2d8a3d7a787368a25b8e868835cbf7d3fe9c /src | |
parent | 6952f40a3ef47e5bc62286f75b26b2d79eaa9d74 (diff) |
Increase fine-grained signals for some properties in Text
Text.[content/painted][Width/Height] were being always notified of
changes at bulk. This is can be harmful in performance of QML
applications that will trigger change requests on the program whenever
a property is modified.
This introduces separate signals so it's not a problem anymore.
Change-Id: I5b82cf13158298dbc91157b837d0ed4aadeb86cf
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitemsmodule.cpp | 1 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquicktext_p.h | 10 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index c8550af7cc..fd6788c256 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -463,6 +463,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType<QQuickAnimatedSprite, 12>("QtQuick", 2, 12, "AnimatedSprite"); qmlRegisterType<QQuickGradient, 12>(uri, 2, 12, "Gradient"); qmlRegisterType<QQuickFlickable, 12>(uri, 2, 12, "Flickable"); + qmlRegisterType<QQuickText, 12>(uri, 2, 12, "Text"); } static void initResources() diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 3c260165f7..3cce30aaf6 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -486,6 +486,10 @@ void QQuickTextPrivate::updateSize() if (layedOutTextRect.size() != previousSize) emit q->contentSizeChanged(); + if (layedOutTextRect.width() != previousSize.width()) + emit q->contentWidthChanged(layedOutTextRect.width()); + if (layedOutTextRect.height() != previousSize.height()) + emit q->contentHeightChanged(layedOutTextRect.height()); updateType = UpdatePaintNode; q->update(); } diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h index 15e989c13d..f4e7fa7046 100644 --- a/src/quick/items/qquicktext_p.h +++ b/src/quick/items/qquicktext_p.h @@ -79,10 +79,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? - Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged) - Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged) - Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged) // Compatibility - Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged) + Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentWidthChanged) + Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentHeightChanged) + Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentWidthChanged) // Compatibility + Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentHeightChanged) Q_PROPERTY(qreal lineHeight READ lineHeight WRITE setLineHeight NOTIFY lineHeightChanged) Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged) Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged) @@ -272,6 +272,8 @@ Q_SIGNALS: void textFormatChanged(QQuickText::TextFormat textFormat); void elideModeChanged(QQuickText::TextElideMode mode); void contentSizeChanged(); + Q_REVISION(12) void contentWidthChanged(qreal contentWidth); + Q_REVISION(12) void contentHeightChanged(qreal contentHeight); void lineHeightChanged(qreal lineHeight); void lineHeightModeChanged(LineHeightMode mode); void fontSizeModeChanged(); |