Warning, file /office/calligra/gemini/ScribbleArea.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2014 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 * 0006 */ 0007 0008 #ifndef SCRIBBLEAREA_H 0009 #define SCRIBBLEAREA_H 0010 0011 #include <QQuickPaintedItem> 0012 #include <QImage> 0013 0014 class ScribbleArea : public QQuickPaintedItem 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 0018 Q_PROPERTY(int penWidth READ penWidth WRITE setPenWidth NOTIFY penWidthChanged) 0019 0020 public: 0021 explicit ScribbleArea(QQuickItem* parent = 0); 0022 ~ScribbleArea() override; 0023 0024 Q_INVOKABLE void clear(); 0025 0026 QColor color() const; 0027 void setColor(const QColor& newColor); 0028 0029 int penWidth() const; 0030 void setPenWidth(const int& newWidth); 0031 0032 Q_SIGNALS: 0033 void colorChanged(); 0034 void penWidthChanged(); 0035 void paintingStopped(); 0036 void paintingStarted(); 0037 0038 protected: 0039 bool event(QEvent* event) override; 0040 void mousePressEvent(QMouseEvent *event) override; 0041 void mouseMoveEvent(QMouseEvent *event) override; 0042 void mouseReleaseEvent(QMouseEvent *event) override; 0043 void paint(QPainter* painter) override; 0044 0045 private: 0046 void drawLineTo(const QPointF &endPoint); 0047 void resizeImage(QImage *image, const QSize &newSize); 0048 0049 bool scribbling; 0050 int myPenWidth; 0051 QColor myPenColor; 0052 QImage image; 0053 QPointF lastPoint; 0054 }; 0055 0056 #endif // SCRIBBLEAREA_H