DoodleWindow.h
3.41 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#ifndef DOODLEWINDOW_H
#define DOODLEWINDOW_H
#include <QMainWindow>
#include <QDockWidget>
#include <QPushButton>
#include "DoodlePage.h"
#include <QListWidget>
namespace Ui {
class WidgetClass;
}
namespace JusDoodle {
enum DoodleColor {
Red,
green,
Blue,
yellow,
darkCyan,
darkRed
};
enum DoodleWidth {
Thin,
Middle,
Thick
};
class DoodleWindow : public QMainWindow
{
Q_OBJECT
public:
explicit DoodleWindow(QWidget *parent = 0);
~DoodleWindow();
// Override resize event.
// Resize current doodle page.
void resizeEvent(QResizeEvent *event);
// Initialization
// Create corresponding pages for doodle.
void init(int pageCount);
// Set background images.
void setBackgroundImages(const QStringList &imagePaths);
// Set background image
void setBackgroundImage(int pageId, const QString &path);
// Process draw action received.
void actionDraw(int pageId, unsigned int argb, double width, const Path &path);
// Process erase action received.
void actionErase(int pageId, double width, const Path &path);
// Process clean action received.
void actionClean(int pageId);
// Process select page action received.
void actionSelectPage(int pageId);
public Q_SLOTS:
// Process black is selected.
void colorBlackSelected(bool checked);
// Process red is selected.
void colorRedSelected(bool checked);
// Process blue is selected.
void colorBlueSelected(bool checked);
// Process thin is selected.
void widthThinSelected(bool checked);
// Process middle is selected.
void widthMiddleSelected(bool checked);
// Process thick is selected.
void widthThickSelected(bool checked);
// Process erase is selected.
void toolsEraseSelected(bool checked);
// Process clear is clicked.
void toolsClear();
// Process previous is clicked.
void pagePrevious();
// Process next is clicked.
void pageNext();
// Process message in status bar..
void onStatusMessageChanged(const QString &message);
Q_SIGNALS:
// Emit when color is changed.
void colorChanged(const QColor &color);
// Emit when width is changed.
void widthChanged(double width);
// Emit when mode is changed.
void modeChanged(bool erase);
// Emit when selected page is changed.
void notifyPageChanged(int pageId);
// Emit when clean is clicked.
void notifyClean(int pageId);
// Emit after drawing a line.
void notifyDrawPath(int pageId, const Path &path,
const QColor &color, double width);
// Emit after erase a line.
void notifyErasePath(int pageId, const Path &path,
double width);
void setDrawFlag(bool);
private slots:
void on_btnColor_clicked(bool checked);
void selectedColor();
void on_btnPen_clicked();
private:
// Calculate rectangle of doodle page.
void calculateRect(const QSize &size, QRect &rect);
// Process of a color is selected.
void colorSelected(enum DoodleColor colorId);
// Process of a width is selected.
void widthSelected(enum DoodleWidth widthId);
// Process of a page is selected.
bool pageSelected(int newIndex);
public:
Ui::WidgetClass *ui;
private:
int _currentPageId;
std::vector<DoodlePage *> _pages;
QColor _color;
double _width;
bool _erase;
bool drawFlag;
QStringList imagePathlist;
};
}
#endif // DOODLEWINDOW_H