aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-18 10:46:59 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-01-19 08:53:38 +0000
commit148722b44972734f10a71fbbb57573388aacb005 (patch)
tree9747f98c9502b023e56224e50cc83486e2977423 /src/imports/controls
parent47b3a29210042c22627a04445055bdacf1f9c722 (diff)
Imports: create QColor from RGB instead of string.
... don't repeatedly re-create QColor in loop. Just cache it. Change-Id: Ic723eb3777f7c92eaf5bc1f257bf85c3a2e660a8 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/qquickbusyindicatorring.cpp9
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp5
2 files changed, 9 insertions, 5 deletions
diff --git a/src/imports/controls/qquickbusyindicatorring.cpp b/src/imports/controls/qquickbusyindicatorring.cpp
index 18413b73..96213fa4 100644
--- a/src/imports/controls/qquickbusyindicatorring.cpp
+++ b/src/imports/controls/qquickbusyindicatorring.cpp
@@ -101,6 +101,7 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
const qreal dx = (w - sz) / 2;
const qreal dy = (h - sz) / 2;
const int circleRadius = sz / 12;
+ const QColor color(0x35, 0x36, 0x37);
QSGTransformNode *transformNode = static_cast<QSGTransformNode *>(rootTransformNode->firstChild());
for (int i = 0; i < circles; ++i) {
@@ -113,8 +114,8 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
rectNode->setAntialiasing(true);
- rectNode->setColor(QColor("#353637"));
- rectNode->setPenColor(QColor("#353637"));
+ rectNode->setColor(color);
+ rectNode->setPenColor(color);
opacityNode->appendChildNode(rectNode);
}
@@ -191,6 +192,8 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
const qreal secondPhaseProgress = percentageComplete > 0.5 ? (percentageComplete - 0.5) * 2 : 0;
QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(rootTransformNode->firstChild());
+ const QColor color(0x35, 0x36, 0x37);
+ const QColor transparent(Qt::transparent);
Q_ASSERT(transformNode->type() == QSGNode::TransformNodeType);
for (int i = 0; i < circles; ++i) {
QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode*>(transformNode->firstChild());
@@ -201,7 +204,7 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
const bool fill = (firstPhaseProgress > qreal(i) / circles) || (secondPhaseProgress > 0 && secondPhaseProgress < qreal(i) / circles);
rectNode->setPenWidth(fill ? 0 : 1);
- rectNode->setColor(fill ? QColor("#353637") : QColor("transparent"));
+ rectNode->setColor(fill ? color : transparent);
rectNode->update();
transformNode = static_cast<QSGTransformNode*>(transformNode->nextSibling());
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
index 046fd77c..e9480ff1 100644
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ b/src/imports/controls/qquickprogressstrip.cpp
@@ -142,6 +142,7 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
}
Q_ASSERT(rootTransformNode->type() == QSGNode::TransformNodeType);
+ const QColor color(0x35, 0x36, 0x37);
if (m_indeterminate) {
if (rootTransformNode->childCount() != blocks) {
// This was previously a regular progress bar; remove the old nodes.
@@ -158,7 +159,7 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(transformNode->firstChild());
if (!rectNode) {
rectNode = d->sceneGraphContext()->createRectangleNode();
- rectNode->setColor(QColor(0x35, 0x36, 0x37));
+ rectNode->setColor(color);
transformNode->appendChildNode(rectNode);
}
@@ -180,7 +181,7 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(rootTransformNode->firstChild());
if (!rectNode) {
rectNode = d->sceneGraphContext()->createRectangleNode();
- rectNode->setColor(QColor(0x35, 0x36, 0x37));
+ rectNode->setColor(color);
rootTransformNode->appendChildNode(rectNode);
}