aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-08-31 15:09:04 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-08-31 14:23:48 +0000
commit6dbc3715b9a496b91743d6ca3727178897d2af7e (patch)
tree751c39c31841bfd24585d328283f9955d1e8e87c
parentf40583bb6400d4ed67f83bc6e22e88049a314e06 (diff)
Make use of QQuickItem::ItemEnabledHasChanged
It was added in qtdeclarative commit 286f14f1. Getting rid of the slow QObject::connect() gives a little boost of 1~2 frames in qmlbench. Change-Id: If027fe2bee9eedad572afe8828b302c2f44cffac Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp7
-rw-r--r--src/quicktemplates2/qquicklabel.cpp18
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp32
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp22
4 files changed, 48 insertions, 31 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 646ba7ea..6a41aebd 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -669,15 +669,11 @@ void QQuickControlPrivate::destroyDelegate(QObject *delegate, QObject *parent)
QQuickControl::QQuickControl(QQuickItem *parent)
: QQuickItem(*(new QQuickControlPrivate), parent)
{
- // ### TODO: ItemEnabledChanged?
- connect(this, &QQuickItem::enabledChanged, this, &QQuickControl::paletteChanged);
}
QQuickControl::QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent)
: QQuickItem(dd, parent)
{
- // ### TODO: ItemEnabledChanged?
- connect(this, &QQuickItem::enabledChanged, this, &QQuickControl::paletteChanged);
}
void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value)
@@ -685,6 +681,9 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::
Q_D(QQuickControl);
QQuickItem::itemChange(change, value);
switch (change) {
+ case ItemEnabledHasChanged:
+ emit paletteChanged();
+ break;
case ItemVisibleHasChanged:
#if QT_CONFIG(quicktemplates2_hover)
if (!value.boolValue)
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index 115a64c6..f1a5d15e 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -207,9 +207,6 @@ QQuickLabel::QQuickLabel(QQuickItem *parent)
{
Q_D(QQuickLabel);
QObjectPrivate::connect(this, &QQuickText::textChanged, d, &QQuickLabelPrivate::textChanged);
-
- // ### TODO: ItemEnabledChanged?
- connect(this, &QQuickItem::enabledChanged, this, &QQuickLabel::paletteChanged);
}
QFont QQuickLabel::font() const
@@ -314,9 +311,18 @@ void QQuickLabel::itemChange(QQuickItem::ItemChange change, const QQuickItem::It
{
Q_D(QQuickLabel);
QQuickText::itemChange(change, value);
- if (change == ItemParentHasChanged && value.item) {
- d->resolveFont();
- d->resolvePalette();
+ switch (change) {
+ case ItemEnabledHasChanged:
+ emit paletteChanged();
+ break;
+ case ItemParentHasChanged:
+ if (value.item) {
+ d->resolveFont();
+ d->resolvePalette();
+ }
+ break;
+ default:
+ break;
}
}
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 5f6037db..3c3ed419 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -450,9 +450,6 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent)
#endif
QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged,
d, &QQuickTextAreaPrivate::readOnlyChanged);
-
- // ### TODO: ItemEnabledChanged?
- connect(this, &QQuickItem::enabledChanged, this, &QQuickTextArea::paletteChanged);
}
QQuickTextAreaAttached *QQuickTextArea::qmlAttachedProperties(QObject *object)
@@ -697,19 +694,28 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem:
{
Q_D(QQuickTextArea);
QQuickTextEdit::itemChange(change, value);
- if (change == ItemParentHasChanged && value.item) {
- d->resolveFont();
- d->resolvePalette();
+ switch (change) {
+ case ItemEnabledHasChanged:
+ emit paletteChanged();
+ break;
+ case ItemParentHasChanged:
+ if (value.item) {
+ d->resolveFont();
+ d->resolvePalette();
#if QT_CONFIG(quicktemplates2_hover)
- if (!d->explicitHoverEnabled)
- d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+ if (!d->explicitHoverEnabled)
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
#endif
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(value.item->parentItem());
- if (flickable) {
- QQuickScrollView *scrollView = qobject_cast<QQuickScrollView *>(flickable->parentItem());
- if (scrollView)
- d->attachFlickable(flickable);
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(value.item->parentItem());
+ if (flickable) {
+ QQuickScrollView *scrollView = qobject_cast<QQuickScrollView *>(flickable->parentItem());
+ if (scrollView)
+ d->attachFlickable(flickable);
+ }
}
+ break;
+ default:
+ break;
}
}
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 9e3eea50..5033a3cc 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -324,9 +324,6 @@ QQuickTextField::QQuickTextField(QQuickItem *parent)
#endif
QObjectPrivate::connect(this, &QQuickTextInput::readOnlyChanged, d, &QQuickTextFieldPrivate::readOnlyChanged);
QObjectPrivate::connect(this, &QQuickTextInput::echoModeChanged, d, &QQuickTextFieldPrivate::echoModeChanged);
-
- // ### TODO: ItemEnabledChanged?
- connect(this, &QQuickItem::enabledChanged, this, &QQuickTextField::paletteChanged);
}
QFont QQuickTextField::font() const
@@ -558,13 +555,22 @@ void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem
{
Q_D(QQuickTextField);
QQuickTextInput::itemChange(change, value);
- if (change == ItemParentHasChanged && value.item) {
- d->resolveFont();
- d->resolvePalette();
+ switch (change) {
+ case ItemEnabledHasChanged:
+ emit paletteChanged();
+ break;
+ case ItemParentHasChanged:
+ if (value.item) {
+ d->resolveFont();
+ d->resolvePalette();
#if QT_CONFIG(quicktemplates2_hover)
- if (!d->explicitHoverEnabled)
- d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+ if (!d->explicitHoverEnabled)
+ d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
#endif
+ }
+ break;
+ default:
+ break;
}
}