-
Notifications
You must be signed in to change notification settings - Fork 0
/
doodlearea.h
56 lines (46 loc) · 1.18 KB
/
doodlearea.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef DOODLEAREA_H
#define DOODLEAREA_H
#define DOODLETOOL_PEN 0
#define DOODLETOOL_RECT 1
#define DOODLETOOL_OVAL 2
#include <QWidget>
#include <QMouseEvent>
#include <QPainter>
#include <QPen>
#include <QColor>
#include <QFileDialog>
class DoodleArea : public QWidget
{
Q_OBJECT
public:
explicit DoodleArea(QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent *event);
signals:
void disableNonPen(bool disable);
void disableNonRect(bool disable);
void disableNonOval(bool disable);
public slots:
void setToolPen(bool enabled);
void setToolRect(bool enabled);
void setToolOval(bool enabled);
void setColor(int colorIndex);
void setPenWidth(int size);
void save();
void clear();
private:
void drawLineTo(const QPoint &endPoint);
void resizeImage(const QSize &newSize);
int currentTool;
int currentPenSize;
bool modified;
bool doodling;
QColor currentColor;
QImage* image;
QPoint lastPoint;
};
#endif // DOODLEAREA_H