aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/basic/impl/qquickbasicdial.cpp
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2023-03-17 14:33:40 +0100
committerMatthias Rauter <matthias.rauter@qt.io>2023-04-28 09:54:16 +0200
commitd93ca833f65893653071d7ba33fd129fe3db53dc (patch)
tree7434a2aed7db461c0392d3757cead8e8dd6e709e /src/quickcontrols/basic/impl/qquickbasicdial.cpp
parent0a333bc7e5ae9db1d289a65aa7eef46ae7916936 (diff)
Add startAngle and endAngle properties to Dial
The start and end angle of the Dial element were hard coded before. Now they can be set by the application developer using the new properties startAngle and endAngle. The angle property is set to an angle between those values, even if it is >360 or <0. The setter functions make sure that the relation between angle and value is unique. Further, values for start and endAngle are limited to [-360, 720]. Wrap works as before. Tests have been updated. All styles have been updated to the new functionality except the Imagine style (see task QTBUG-112387). [ChangeLog][Controls] The start and end angle of the dial element are made customizabe. Fixes: QTBUG-57822 Change-Id: I941837008d4f9b4dde1979e91db5adb624bcbe41 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols/basic/impl/qquickbasicdial.cpp')
-rw-r--r--src/quickcontrols/basic/impl/qquickbasicdial.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/quickcontrols/basic/impl/qquickbasicdial.cpp b/src/quickcontrols/basic/impl/qquickbasicdial.cpp
index 7726bfb159..d2550b7c27 100644
--- a/src/quickcontrols/basic/impl/qquickbasicdial.cpp
+++ b/src/quickcontrols/basic/impl/qquickbasicdial.cpp
@@ -29,6 +29,34 @@ void QQuickBasicDial::setProgress(qreal progress)
update();
}
+qreal QQuickBasicDial::startAngle() const
+{
+ return m_startAngle;
+}
+
+void QQuickBasicDial::setStartAngle(qreal startAngle)
+{
+ if (startAngle == m_startAngle)
+ return;
+
+ m_startAngle = startAngle;
+ update();
+}
+
+qreal QQuickBasicDial::endAngle() const
+{
+ return m_endAngle;
+}
+
+void QQuickBasicDial::setEndAngle(qreal endAngle)
+{
+ if (endAngle == m_endAngle)
+ return;
+
+ m_endAngle = endAngle;
+ update();
+}
+
QColor QQuickBasicDial::color() const
{
return m_color;
@@ -70,8 +98,8 @@ void QQuickBasicDial::paint(QPainter *painter)
painter->setRenderHint(QPainter::Antialiasing);
- const qreal startAngle = (140 + 90);
- const qreal spanAngle = (m_progress * 280) * -1;
+ const qreal startAngle = 90. - m_startAngle;
+ const qreal spanAngle = m_progress * (m_startAngle - m_endAngle);
QPainterPath path;
path.arcMoveTo(rect, startAngle);
path.arcTo(rect, startAngle, spanAngle);