Skip to content

Commit 2326f41

Browse files
committed
qml: allow to set blockclockdial scale
This represents the factor we use to scale off of the parent width & height.
1 parent 2acc8a1 commit 2326f41

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/qml/components/blockclockdial.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ BlockClockDial::BlockClockDial(QQuickItem *parent)
1616
: QQuickPaintedItem(parent)
1717
, m_time_ratio_list{0.0}
1818
, m_pen_width{4}
19+
, m_scale{5/12}
1920
, m_background_color{QColor("#2D2D2D")}
2021
, m_confirmation_colors{QList<QColor>{}}
2122
, m_time_tick_color{QColor("#000000")}
@@ -140,6 +141,14 @@ void BlockClockDial::setPenWidth(qreal width)
140141
update();
141142
}
142143

144+
void BlockClockDial::setScale(qreal scale)
145+
{
146+
m_scale = scale;
147+
update();
148+
149+
Q_EMIT scaleChanged();
150+
}
151+
143152
void BlockClockDial::setBackgroundColor(QColor color)
144153
{
145154
m_background_color = color;

src/qml/components/blockclockdial.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class BlockClockDial : public QQuickPaintedItem
2020
Q_PROPERTY(bool synced READ synced WRITE setSynced)
2121
Q_PROPERTY(bool paused READ paused WRITE setPaused)
2222
Q_PROPERTY(qreal penWidth READ penWidth WRITE setPenWidth)
23+
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
2324
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
2425
Q_PROPERTY(QList<QColor> confirmationColors READ confirmationColors WRITE setConfirmationColors )
2526
Q_PROPERTY(QColor timeTickColor READ timeTickColor WRITE setTimeTickColor)
@@ -34,6 +35,7 @@ class BlockClockDial : public QQuickPaintedItem
3435
bool synced() const { return m_is_synced; };
3536
bool paused() const { return m_is_paused; };
3637
qreal penWidth() const { return m_pen_width; };
38+
qreal scale() const { return m_scale; };
3739
QColor backgroundColor() const { return m_background_color; };
3840
QList<QColor> confirmationColors() const { return m_confirmation_colors; };
3941
QColor timeTickColor() const { return m_time_tick_color; };
@@ -45,10 +47,14 @@ public Q_SLOTS:
4547
void setSynced(bool synced);
4648
void setPaused(bool paused);
4749
void setPenWidth(qreal width);
50+
void setScale(qreal scale);
4851
void setBackgroundColor(QColor color);
4952
void setConfirmationColors(QList<QColor> colorList);
5053
void setTimeTickColor(QColor color);
5154

55+
Q_SIGNALS:
56+
void scaleChanged();
57+
5258
private:
5359
void paintConnectingAnimation(QPainter * painter);
5460
void paintProgress(QPainter * painter);
@@ -68,6 +74,7 @@ public Q_SLOTS:
6874
bool m_is_synced;
6975
bool m_is_paused;
7076
qreal m_pen_width;
77+
qreal m_scale;
7178
QColor m_background_color;
7279
QConicalGradient m_connecting_gradient;
7380
qreal m_connecting_start_angle = 90;

0 commit comments

Comments
 (0)