10
10
#include < QConicalGradient>
11
11
#include < QPen>
12
12
#include < QtMath>
13
+ #include < QtGlobal>
13
14
14
15
BlockClockDial::BlockClockDial (QQuickItem *parent)
15
16
: QQuickPaintedItem(parent)
16
17
, m_time_ratio_list{0.0 }
18
+ , m_pen_width{4 }
17
19
, m_background_color{QColor (" #2D2D2D" )}
18
20
, m_confirmation_colors{QList<QColor>{}}
19
21
, m_time_tick_color{QColor (" #000000" )}
@@ -132,6 +134,12 @@ void BlockClockDial::setPaused(bool paused)
132
134
}
133
135
}
134
136
137
+ void BlockClockDial::setPenWidth (qreal width)
138
+ {
139
+ m_pen_width = width;
140
+ update ();
141
+ }
142
+
135
143
void BlockClockDial::setBackgroundColor (QColor color)
136
144
{
137
145
m_background_color = color;
@@ -183,7 +191,7 @@ void BlockClockDial::paintBlocks(QPainter * painter)
183
191
}
184
192
185
193
QPen pen (m_confirmation_colors[5 ]);
186
- pen.setWidth ( 4 );
194
+ pen.setWidthF (m_pen_width );
187
195
pen.setCapStyle (Qt::FlatCap);
188
196
const QRectF bounds = getBoundsForPen (pen);
189
197
painter->setPen (pen);
@@ -196,7 +204,7 @@ void BlockClockDial::paintBlocks(QPainter * painter)
196
204
for (int i = 1 ; i < numberOfBlocks; i++) {
197
205
if (numberOfBlocks - i <= 6 ) {
198
206
QPen pen (m_confirmation_colors[numberOfBlocks - i - 1 ]);
199
- pen.setWidth ( 4 );
207
+ pen.setWidthF (m_pen_width );
200
208
pen.setCapStyle (Qt::FlatCap);
201
209
painter->setPen (pen);
202
210
}
@@ -227,7 +235,7 @@ void BlockClockDial::paintBlocks(QPainter * painter)
227
235
void BlockClockDial::paintProgress (QPainter * painter)
228
236
{
229
237
QPen pen (m_confirmation_colors[5 ]);
230
- pen.setWidthF (4 );
238
+ pen.setWidthF (m_pen_width );
231
239
pen.setCapStyle (Qt::RoundCap);
232
240
const QRectF bounds = getBoundsForPen (pen);
233
241
painter->setPen (pen);
@@ -250,7 +258,7 @@ void BlockClockDial::paintProgress(QPainter * painter)
250
258
void BlockClockDial::paintConnectingAnimation (QPainter * painter)
251
259
{
252
260
QPen pen;
253
- pen.setWidthF (4 );
261
+ pen.setWidthF (m_pen_width );
254
262
setupConnectingGradient (pen);
255
263
pen.setBrush (QBrush (m_connecting_gradient));
256
264
pen.setCapStyle (Qt::RoundCap);
@@ -267,7 +275,7 @@ void BlockClockDial::paintConnectingAnimation(QPainter * painter)
267
275
void BlockClockDial::paintBackground (QPainter * painter)
268
276
{
269
277
QPen pen (m_background_color);
270
- pen.setWidthF (4 );
278
+ pen.setWidthF (m_pen_width );
271
279
const QRectF bounds = getBoundsForPen (pen);
272
280
painter->setPen (pen);
273
281
@@ -283,12 +291,12 @@ double BlockClockDial::degreesPerPixel()
283
291
void BlockClockDial::paintTimeTicks (QPainter * painter)
284
292
{
285
293
QPen pen (m_time_tick_color);
286
- pen.setWidthF (4 );
294
+ pen.setWidthF (m_pen_width );
287
295
// Calculate bound based on width of default pen
288
296
const QRectF bounds = getBoundsForPen (pen);
289
297
290
298
QPen time_tick_pen = QPen (m_time_tick_color);
291
- time_tick_pen.setWidth ( 2 );
299
+ time_tick_pen.setWidthF (m_pen_width / 2 );
292
300
time_tick_pen.setCapStyle (Qt::RoundCap);
293
301
painter->setPen (time_tick_pen);
294
302
for (double angle = 0 ; angle < 360 ; angle += 30 ) {
0 commit comments