aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-05-12 19:14:19 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-05-16 03:09:44 +0000
commit21f5f9e07655f0ac34c65cc2a14489213097c622 (patch)
treee155fdfb5bd8bf6cbe34c6c16ba685b7704214b9 /src
parentebcefb5586b387445d4152ba2ed833074d9a6ad6 (diff)
QQuickDefaultBusyIndicator: allow specifying pen and fill separately
One color is enough for the current Default style, but if we allow configuring the colors, it must be possible to have them separately to be able to get decent looks. Change-Id: Ibbe6b73142edc9829ca75603cd2e86654ae824b0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/BusyIndicator.qml3
-rw-r--r--src/imports/controls/plugins.qmltypes3
-rw-r--r--src/imports/controls/qquickdefaultbusyindicator.cpp36
-rw-r--r--src/imports/controls/qquickdefaultbusyindicator_p.h13
4 files changed, 40 insertions, 15 deletions
diff --git a/src/imports/controls/BusyIndicator.qml b/src/imports/controls/BusyIndicator.qml
index 5690c71f..e3757703 100644
--- a/src/imports/controls/BusyIndicator.qml
+++ b/src/imports/controls/BusyIndicator.qml
@@ -51,7 +51,8 @@ T.BusyIndicator {
implicitWidth: 48
implicitHeight: 48
- color: Default.textColor
+ pen: Default.textColor
+ fill: Default.textColor
opacity: control.running ? 1 : 0
visible: control.running || animator.running
Behavior on opacity { OpacityAnimator { id: animator; duration: 250 } }
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index fee7c934..e10c187a 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -40,7 +40,8 @@ Module {
prototype: "QQuickItem"
exports: ["QtQuick.Controls.impl/BusyIndicatorImpl 2.0"]
exportMetaObjectRevisions: [0]
- Property { name: "color"; type: "QColor" }
+ Property { name: "pen"; type: "QColor" }
+ Property { name: "fill"; type: "QColor" }
}
Component {
name: "QQuickDefaultDial"
diff --git a/src/imports/controls/qquickdefaultbusyindicator.cpp b/src/imports/controls/qquickdefaultbusyindicator.cpp
index 36f3a538..138e94e8 100644
--- a/src/imports/controls/qquickdefaultbusyindicator.cpp
+++ b/src/imports/controls/qquickdefaultbusyindicator.cpp
@@ -60,7 +60,8 @@ public:
void sync(QQuickItem *item) override;
private:
- QColor m_color;
+ QColor m_pen;
+ QColor m_fill;
};
QQuickDefaultBusyIndicatorNode::QQuickDefaultBusyIndicatorNode(QQuickDefaultBusyIndicator *item)
@@ -94,8 +95,9 @@ void QQuickDefaultBusyIndicatorNode::updateCurrentTime(int time)
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
const bool fill = (firstPhaseProgress > qreal(i) / CircleCount) || (secondPhaseProgress > 0 && secondPhaseProgress < qreal(i) / CircleCount);
- rectNode->setColor(fill ? m_color : QColor::fromRgba(TransparentColor));
- rectNode->setPenWidth(fill ? 0 : 1);
+ rectNode->setColor(fill ? m_fill : QColor::fromRgba(TransparentColor));
+ rectNode->setPenColor(m_pen);
+ rectNode->setPenWidth(1);
rectNode->update();
transformNode = static_cast<QSGTransformNode*>(transformNode->nextSibling());
@@ -110,7 +112,9 @@ void QQuickDefaultBusyIndicatorNode::sync(QQuickItem *item)
const qreal dx = (w - sz) / 2;
const qreal dy = (h - sz) / 2;
const int circleRadius = sz / 12;
- m_color = static_cast<QQuickDefaultBusyIndicator *>(item)->color();
+
+ m_pen = static_cast<QQuickDefaultBusyIndicator *>(item)->pen();
+ m_fill = static_cast<QQuickDefaultBusyIndicator *>(item)->fill();
QSGTransformNode *transformNode = static_cast<QSGTransformNode *>(firstChild());
for (int i = 0; i < CircleCount; ++i) {
@@ -139,17 +143,31 @@ QQuickDefaultBusyIndicator::QQuickDefaultBusyIndicator(QQuickItem *parent) :
setFlag(ItemHasContents);
}
-QColor QQuickDefaultBusyIndicator::color() const
+QColor QQuickDefaultBusyIndicator::pen() const
+{
+ return m_pen;
+}
+
+void QQuickDefaultBusyIndicator::setPen(const QColor &pen)
+{
+ if (pen == m_pen)
+ return;
+
+ m_pen = pen;
+ update();
+}
+
+QColor QQuickDefaultBusyIndicator::fill() const
{
- return m_color;
+ return m_fill;
}
-void QQuickDefaultBusyIndicator::setColor(const QColor &color)
+void QQuickDefaultBusyIndicator::setFill(const QColor &fill)
{
- if (color == m_color)
+ if (fill == m_fill)
return;
- m_color = color;
+ m_fill = fill;
update();
}
diff --git a/src/imports/controls/qquickdefaultbusyindicator_p.h b/src/imports/controls/qquickdefaultbusyindicator_p.h
index 3bbd6c31..e214020c 100644
--- a/src/imports/controls/qquickdefaultbusyindicator_p.h
+++ b/src/imports/controls/qquickdefaultbusyindicator_p.h
@@ -55,13 +55,17 @@ QT_BEGIN_NAMESPACE
class QQuickDefaultBusyIndicator : public QQuickItem
{
Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
+ Q_PROPERTY(QColor pen READ pen WRITE setPen FINAL)
+ Q_PROPERTY(QColor fill READ fill WRITE setFill FINAL)
public:
explicit QQuickDefaultBusyIndicator(QQuickItem *parent = nullptr);
- QColor color() const;
- void setColor(const QColor &color);
+ QColor pen() const;
+ void setPen(const QColor &pen);
+
+ QColor fill() const;
+ void setFill(const QColor &fill);
int elapsed() const;
@@ -71,7 +75,8 @@ protected:
private:
int m_elapsed;
- QColor m_color;
+ QColor m_pen;
+ QColor m_fill;
};
QT_END_NAMESPACE