diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-30 00:06:16 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-30 00:39:52 +0100 |
commit | 94238a02c8a947593d69a6271b3fd1cf5e264be2 (patch) | |
tree | 63a1fcf33d03106b696e9e060c8a39dbd6dc63dc /qmlplugin | |
parent | 0d5a7b23b192194833d80540cac8c361f3de24ec (diff) |
Add some more parameters to the heartrate graph
Diffstat (limited to 'qmlplugin')
-rw-r--r-- | qmlplugin/hrGraph.cpp | 25 | ||||
-rw-r--r-- | qmlplugin/hrGraph.h | 16 |
2 files changed, 35 insertions, 6 deletions
diff --git a/qmlplugin/hrGraph.cpp b/qmlplugin/hrGraph.cpp index 7540083..625300e 100644 --- a/qmlplugin/hrGraph.cpp +++ b/qmlplugin/hrGraph.cpp @@ -59,8 +59,13 @@ void HrGraph::paint(QPainter *painter) for(int i = 0; i < j; i++) { calculatedTimeSeconds = (m_filedata.at(i).time - minTime)/timeDelta; calculatedValue = 1 - (m_filedata.at(i).value - minHrValue)/valueDelta; - points[i] = QPointF(1 + calculatedTimeSeconds*(height()-2), 1 + calculatedValue*(width()-2)); //these +2 -1 are here to make sure that the graph fits within the drawn area, as it will be clipped by qt if it doesn't. + points[i] = QPointF(m_lineWidth + calculatedTimeSeconds*(height()-2*m_lineWidth), m_lineWidth + calculatedValue*(width()-2*m_lineWidth)); //these +2 -1 are here to make sure that the graph fits within the drawn area, as it will be clipped by qt if it doesn't. } + QPen pen; + pen.setWidthF(m_lineWidth); + pen.setColor(m_color); + painter->setRenderHints(QPainter::Antialiasing); + painter->setPen(pen); painter->drawPolyline(points,j); } @@ -100,3 +105,21 @@ void HrGraph::loadGraphData(QDate date) { qDebug() << "heartrate graph file loading done"; file.close(); } + +void HrGraph::setLineColor(QColor color) { + m_color = color; + update(); +} + +QColor HrGraph::lineColor() { + return m_color; +} + +void HrGraph::setLineWidth(float width) { + m_lineWidth = width; + update(); +} + +float HrGraph::lineWidth() { + return m_lineWidth; +} diff --git a/qmlplugin/hrGraph.h b/qmlplugin/hrGraph.h index 3e25311..55f4219 100644 --- a/qmlplugin/hrGraph.h +++ b/qmlplugin/hrGraph.h @@ -39,8 +39,8 @@ class HrGraph : public QQuickPaintedItem { Q_OBJECT - // Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - // Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth) + Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged) struct HrDatapoint { qint64 time; @@ -53,14 +53,20 @@ public: signals: void loadingDone(); + void lineColorChanged(); + +public slots: + float lineWidth(); + void setLineWidth(float width); + QColor lineColor(); + void setLineColor(QColor color); private: void updateBasePixmap(); void loadGraphData(QDate date = QDate::currentDate()); - float m_size; - QString m_name; - QColor m_color; + float m_lineWidth = 0; + QColor m_color = QColor(255,255,255); QPixmap m_pixmap; QList<HrDatapoint> m_filedata; bool m_fileLoadStatus; |