File indexing completed on 2024-10-27 04:39:09

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2018 Kevin Ottens <ervin@kde.org>
0003 
0004 #ifndef STROKEITEM_H
0005 #define STROKEITEM_H
0006 
0007 #include "strokepainter.h"
0008 #include <QQuickPaintedItem>
0009 
0010 #include "stroke.h"
0011 
0012 class StrokeItem : public QQuickPaintedItem
0013 {
0014     Q_OBJECT
0015     Q_PROPERTY(Stroke stroke READ stroke WRITE setStroke NOTIFY strokeChanged)
0016 public:
0017     explicit StrokeItem(QQuickItem *parent = nullptr);
0018 
0019     Stroke stroke() const;
0020     void setStroke(const Stroke &stroke);
0021 
0022     Q_INVOKABLE void addSample(const StrokeSample &sample);
0023 
0024     void paint(QPainter *painter) override;
0025 
0026 Q_SIGNALS:
0027     void strokeChanged(const Stroke &stroke);
0028 
0029 private:
0030     Stroke m_stroke;
0031     StrokePainter m_strokepainter;
0032 };
0033 
0034 #endif // STROKEITEM_H