diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-07-08 13:09:55 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-07-08 17:10:02 +0000 |
commit | e828b95142aa6e3adff13b308f656eef20531b00 (patch) | |
tree | dd0947d408dae5db64fc3858856908de77a1d027 | |
parent | d0efa4b5b0ed0869d0d0001610d4d8feb8ff117a (diff) |
Add PageIndicator::color
Change-Id: Iae5ed3198aeefcaeda237dfcc62751e5b7836c68
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/controls/qquickpageindicator.cpp | 25 | ||||
-rw-r--r-- | src/controls/qquickpageindicator_p.h | 5 | ||||
-rw-r--r-- | src/imports/controls/PageIndicator.qml | 5 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/controls/qquickpageindicator.cpp b/src/controls/qquickpageindicator.cpp index ebc2e89a..0f8af4f7 100644 --- a/src/controls/qquickpageindicator.cpp +++ b/src/controls/qquickpageindicator.cpp @@ -73,6 +73,7 @@ public: int count; int currentIndex; QQmlComponent *delegate; + QColor color; }; QQuickPageIndicator::QQuickPageIndicator(QQuickItem *parent) : @@ -124,6 +125,8 @@ void QQuickPageIndicator::setCurrentIndex(int index) \qmlproperty Component QtQuickControls2::PageIndicator::delegate This property holds a delegate that presents a page. + + \sa color */ QQmlComponent *QQuickPageIndicator::delegate() const { @@ -140,4 +143,26 @@ void QQuickPageIndicator::setDelegate(QQmlComponent *delegate) } } +/*! + \qmlproperty color QtQuickControls2::PageIndicator::color + + This property holds the color of the indicator. + + \sa delegate +*/ +QColor QQuickPageIndicator::color() const +{ + Q_D(const QQuickPageIndicator); + return d->color; +} + +void QQuickPageIndicator::setColor(const QColor &color) +{ + Q_D(QQuickPageIndicator); + if (d->color != color) { + d->color = color; + emit colorChanged(); + } +} + QT_END_NAMESPACE diff --git a/src/controls/qquickpageindicator_p.h b/src/controls/qquickpageindicator_p.h index 79fe617b..59b0e70f 100644 --- a/src/controls/qquickpageindicator_p.h +++ b/src/controls/qquickpageindicator_p.h @@ -61,6 +61,7 @@ class Q_QUICKCONTROLS_EXPORT QQuickPageIndicator : public QQuickControl Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged FINAL) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL) Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) public: explicit QQuickPageIndicator(QQuickItem *parent = Q_NULLPTR); @@ -74,10 +75,14 @@ public: QQmlComponent *delegate() const; void setDelegate(QQmlComponent *delegate); + QColor color() const; + void setColor(const QColor &color); + Q_SIGNALS: void countChanged(); void currentIndexChanged(); void delegateChanged(); + void colorChanged(); private: Q_DISABLE_COPY(QQuickPageIndicator) diff --git a/src/imports/controls/PageIndicator.qml b/src/imports/controls/PageIndicator.qml index dd1dee81..485cb40c 100644 --- a/src/imports/controls/PageIndicator.qml +++ b/src/imports/controls/PageIndicator.qml @@ -49,6 +49,7 @@ AbstractPageIndicator { padding: 6 spacing: 6 + color: Theme.shadowColor // TODO //! [delegate] delegate: Rectangle { @@ -56,9 +57,9 @@ AbstractPageIndicator { implicitHeight: 8 radius: width / 2 - color: control.Theme.shadowColor // TODO + color: control.color - opacity: index === currentIndex ? 0.75 : 0.25 + opacity: index === currentIndex ? 0.95 : 0.45 Behavior on opacity { OpacityAnimator { duration: 100 } } } //! [delegate] |