-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 77 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 10 |
3 files changed, 43 insertions, 48 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 7e6fc53..77fee98 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,550 +1,551 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "drawpad.h" | 14 | #include "drawpad.h" |
15 | 15 | ||
16 | #include "colordialog.h" | 16 | //#include "colordialog.h" |
17 | #include "colorpanel.h" | 17 | //#include "colorpanel.h" |
18 | #include "drawpadcanvas.h" | 18 | #include "drawpadcanvas.h" |
19 | #include "ellipsetool.h" | 19 | #include "ellipsetool.h" |
20 | #include "erasetool.h" | 20 | #include "erasetool.h" |
21 | #include "exportdialog.h" | 21 | #include "exportdialog.h" |
22 | #include "filledellipsetool.h" | 22 | #include "filledellipsetool.h" |
23 | #include "filledrectangletool.h" | 23 | #include "filledrectangletool.h" |
24 | #include "filltool.h" | 24 | #include "filltool.h" |
25 | #include "importdialog.h" | 25 | #include "importdialog.h" |
26 | #include "linetool.h" | 26 | #include "linetool.h" |
27 | #include "pointtool.h" | 27 | #include "pointtool.h" |
28 | #include "rectangletool.h" | 28 | #include "rectangletool.h" |
29 | #include "texttool.h" | 29 | #include "texttool.h" |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | #include <qpe/qpemenubar.h> | 33 | #include <qpe/qpemenubar.h> |
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <opie/colordialog.h> | ||
37 | #include <opie/colorpopupmenu.h> | ||
36 | 38 | ||
37 | #include <qaction.h> | 39 | #include <qaction.h> |
38 | #include <qfile.h> | 40 | #include <qfile.h> |
39 | #include <qpainter.h> | 41 | #include <qpainter.h> |
40 | #include <qspinbox.h> | 42 | #include <qspinbox.h> |
41 | #include <qtoolbutton.h> | 43 | #include <qtoolbutton.h> |
42 | #include <qtooltip.h> | 44 | #include <qtooltip.h> |
43 | 45 | ||
44 | DrawPad::DrawPad(QWidget* parent, const char* name) | 46 | DrawPad::DrawPad(QWidget* parent, const char* name) |
45 | : QMainWindow(parent, name) | 47 | : QMainWindow(parent, name) |
46 | { | 48 | { |
47 | // init members | 49 | // init members |
48 | 50 | ||
49 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 51 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
50 | 52 | ||
51 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 53 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
52 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 54 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
53 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 55 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
54 | 56 | ||
55 | setCentralWidget(m_pDrawPadCanvas); | 57 | setCentralWidget(m_pDrawPadCanvas); |
56 | 58 | ||
57 | // init menu | 59 | // init menu |
58 | 60 | ||
59 | setToolBarsMovable(false); | 61 | setToolBarsMovable(false); |
60 | 62 | ||
61 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 63 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
62 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 64 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
63 | 65 | ||
64 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 66 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); |
65 | 67 | ||
66 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 68 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
67 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); | 69 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); |
68 | deleteAllAction->addTo(toolsPopupMenu); | 70 | deleteAllAction->addTo(toolsPopupMenu); |
69 | 71 | ||
70 | toolsPopupMenu->insertSeparator(); | 72 | toolsPopupMenu->insertSeparator(); |
71 | 73 | ||
72 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 74 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
73 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 75 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
74 | importPageAction->addTo(toolsPopupMenu); | 76 | importPageAction->addTo(toolsPopupMenu); |
75 | 77 | ||
76 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 78 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
77 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 79 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
78 | exportPageAction->addTo(toolsPopupMenu); | 80 | exportPageAction->addTo(toolsPopupMenu); |
79 | 81 | ||
80 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 82 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
81 | 83 | ||
82 | // init page toolbar | 84 | // init page toolbar |
83 | 85 | ||
84 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 86 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
85 | 87 | ||
86 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 88 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
87 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); | 89 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); |
88 | newPageAction->addTo(pageToolBar); | 90 | newPageAction->addTo(pageToolBar); |
89 | 91 | ||
90 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 92 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
91 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); | 93 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); |
92 | clearPageAction->addTo(pageToolBar); | 94 | clearPageAction->addTo(pageToolBar); |
93 | 95 | ||
94 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 96 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
95 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); | 97 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); |
96 | deletePageAction->addTo(pageToolBar); | 98 | deletePageAction->addTo(pageToolBar); |
97 | 99 | ||
98 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 100 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
99 | emptyToolBar->setHorizontalStretchable(true); | 101 | emptyToolBar->setHorizontalStretchable(true); |
100 | 102 | ||
101 | // init navigation toolbar | 103 | // init navigation toolbar |
102 | 104 | ||
103 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 105 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
104 | 106 | ||
105 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 107 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
106 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 108 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
107 | m_pUndoAction->addTo(navigationToolBar); | 109 | m_pUndoAction->addTo(navigationToolBar); |
108 | 110 | ||
109 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 111 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
110 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 112 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
111 | m_pRedoAction->addTo(navigationToolBar); | 113 | m_pRedoAction->addTo(navigationToolBar); |
112 | 114 | ||
113 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 115 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
114 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 116 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
115 | m_pFirstPageAction->addTo(navigationToolBar); | 117 | m_pFirstPageAction->addTo(navigationToolBar); |
116 | 118 | ||
117 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 119 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
118 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 120 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
119 | m_pPreviousPageAction->addTo(navigationToolBar); | 121 | m_pPreviousPageAction->addTo(navigationToolBar); |
120 | 122 | ||
121 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 123 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
122 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 124 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
123 | m_pNextPageAction->addTo(navigationToolBar); | 125 | m_pNextPageAction->addTo(navigationToolBar); |
124 | 126 | ||
125 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 127 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
126 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 128 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
127 | m_pLastPageAction->addTo(navigationToolBar); | 129 | m_pLastPageAction->addTo(navigationToolBar); |
128 | 130 | ||
129 | // init draw mode toolbar | 131 | // init draw mode toolbar |
130 | 132 | ||
131 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 133 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
132 | 134 | ||
133 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 135 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
134 | m_pLineToolButton->setToggleButton(true); | 136 | m_pLineToolButton->setToggleButton(true); |
135 | 137 | ||
136 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 138 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
137 | 139 | ||
138 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); | 140 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); |
139 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 141 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
140 | m_pPointToolAction->addTo(linePopupMenu); | 142 | m_pPointToolAction->addTo(linePopupMenu); |
141 | 143 | ||
142 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); | 144 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); |
143 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 145 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
144 | m_pLineToolAction->addTo(linePopupMenu); | 146 | m_pLineToolAction->addTo(linePopupMenu); |
145 | 147 | ||
146 | m_pLineToolButton->setPopup(linePopupMenu); | 148 | m_pLineToolButton->setPopup(linePopupMenu); |
147 | m_pLineToolButton->setPopupDelay(0); | 149 | m_pLineToolButton->setPopupDelay(0); |
148 | 150 | ||
149 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 151 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
150 | m_pRectangleToolButton->setToggleButton(true); | 152 | m_pRectangleToolButton->setToggleButton(true); |
151 | 153 | ||
152 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 154 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
153 | 155 | ||
154 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 156 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); |
155 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 157 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
156 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 158 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
157 | 159 | ||
158 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 160 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
159 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 161 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
160 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 162 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
161 | 163 | ||
162 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 164 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
163 | m_pRectangleToolButton->setPopupDelay(0); | 165 | m_pRectangleToolButton->setPopupDelay(0); |
164 | 166 | ||
165 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 167 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
166 | m_pEllipseToolButton->setToggleButton(true); | 168 | m_pEllipseToolButton->setToggleButton(true); |
167 | 169 | ||
168 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 170 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
169 | 171 | ||
170 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 172 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
171 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 173 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
172 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 174 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
173 | 175 | ||
174 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 176 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
175 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 177 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
176 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 178 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
177 | 179 | ||
178 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 180 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
179 | m_pEllipseToolButton->setPopupDelay(0); | 181 | m_pEllipseToolButton->setPopupDelay(0); |
180 | 182 | ||
181 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | 183 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); |
182 | m_pTextToolAction->setToggleAction(true); | 184 | m_pTextToolAction->setToggleAction(true); |
183 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 185 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
184 | m_pTextToolAction->addTo(drawModeToolBar); | 186 | m_pTextToolAction->addTo(drawModeToolBar); |
185 | 187 | ||
186 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 188 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
187 | m_pFillToolAction->setToggleAction(true); | 189 | m_pFillToolAction->setToggleAction(true); |
188 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 190 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
189 | m_pFillToolAction->addTo(drawModeToolBar); | 191 | m_pFillToolAction->addTo(drawModeToolBar); |
190 | 192 | ||
191 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 193 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
192 | m_pEraseToolAction->setToggleAction(true); | 194 | m_pEraseToolAction->setToggleAction(true); |
193 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 195 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
194 | m_pEraseToolAction->addTo(drawModeToolBar); | 196 | m_pEraseToolAction->addTo(drawModeToolBar); |
195 | 197 | ||
196 | m_pTool = 0; | 198 | m_pTool = 0; |
197 | setRectangleTool(); | 199 | setRectangleTool(); |
198 | setEllipseTool(); | 200 | setEllipseTool(); |
199 | setPointTool(); | 201 | setPointTool(); |
200 | 202 | ||
201 | emptyToolBar = new QPEToolBar(this); | 203 | emptyToolBar = new QPEToolBar(this); |
202 | emptyToolBar->setHorizontalStretchable(true); | 204 | emptyToolBar->setHorizontalStretchable(true); |
203 | emptyToolBar->addSeparator(); | 205 | emptyToolBar->addSeparator(); |
204 | 206 | ||
205 | // init draw parameters toolbar | 207 | // init draw parameters toolbar |
206 | 208 | ||
207 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 209 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
208 | 210 | ||
209 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 211 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
210 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 212 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
211 | 213 | ||
212 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 214 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); |
213 | penWidthSpinBox->setValue(1); | 215 | penWidthSpinBox->setValue(1); |
214 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 216 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
215 | 217 | ||
216 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 218 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
217 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 219 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
218 | 220 | ||
219 | QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); | 221 | ColorPopupMenu* colorPopupMenu = new ColorPopupMenu( Qt::black, m_pPenColorToolButton ); |
222 | m_pPenColorToolButton->setPopup( colorPopupMenu ); | ||
223 | m_pPenColorToolButton->setPopupDelay( 0 ); | ||
224 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | ||
225 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changePenColor( const QColor& ) ) ); | ||
220 | 226 | ||
221 | ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); | 227 | // QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); |
222 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | ||
223 | 228 | ||
224 | penColorPopupMenu->insertItem(penColorPanel); | 229 | // ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); |
225 | penColorPopupMenu->insertSeparator(); | 230 | // connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
226 | 231 | ||
227 | QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 232 | // penColorPopupMenu->insertItem(penColorPanel); |
228 | connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); | 233 | // penColorPopupMenu->insertSeparator(); |
229 | choosePenColorAction->addTo(penColorPopupMenu); | ||
230 | 234 | ||
231 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 235 | // QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); |
232 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 236 | // connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); |
233 | m_pPenColorToolButton->setPopupDelay(0); | 237 | // choosePenColorAction->addTo(penColorPopupMenu); |
234 | 238 | ||
235 | penColorPanel->buttonSelected(Qt::black); | 239 | // m_pPenColorToolButton->setPopup(colorPopupMenu); |
240 | // m_pPenColorToolButton->setPopupDelay(0); | ||
241 | |||
242 | // penColorPanel->buttonSelected(Qt::black); | ||
236 | 243 | ||
237 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 244 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
238 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); | 245 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); |
239 | 246 | ||
240 | QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); | ||
241 | 247 | ||
242 | ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); | 248 | colorPopupMenu = new ColorPopupMenu( Qt::white, m_pBrushColorToolButton ); |
243 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 249 | m_pBrushColorToolButton->setPopup( colorPopupMenu ); |
250 | m_pBrushColorToolButton->setPopupDelay( 0 ); | ||
251 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | ||
252 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeeBrushColor( const QColor& ) ) ); | ||
244 | 253 | ||
245 | brushColorPopupMenu->insertItem(brushColorPanel); | 254 | // QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); |
246 | brushColorPopupMenu->insertSeparator(); | ||
247 | 255 | ||
248 | QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 256 | // ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); |
249 | connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); | 257 | // connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
250 | chooseBrushColorAction->addTo(brushColorPopupMenu); | ||
251 | 258 | ||
252 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 259 | // brushColorPopupMenu->insertItem(brushColorPanel); |
253 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 260 | // brushColorPopupMenu->insertSeparator(); |
254 | m_pBrushColorToolButton->setPopupDelay(0); | 261 | |
262 | // QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); | ||
263 | // connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); | ||
264 | // chooseBrushColorAction->addTo(brushColorPopupMenu); | ||
265 | |||
266 | // m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | ||
267 | // m_pBrushColorToolButton->setPopupDelay(0); | ||
255 | 268 | ||
256 | brushColorPanel->buttonSelected(Qt::white); | 269 | // brushColorPanel->buttonSelected(Qt::white); |
257 | 270 | ||
258 | // init pages | 271 | // init pages |
259 | 272 | ||
260 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 273 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
261 | 274 | ||
262 | if (file.open(IO_ReadOnly)) { | 275 | if (file.open(IO_ReadOnly)) { |
263 | m_pDrawPadCanvas->load(&file); | 276 | m_pDrawPadCanvas->load(&file); |
264 | file.close(); | 277 | file.close(); |
265 | } else { | 278 | } else { |
266 | m_pDrawPadCanvas->initialPage(); | 279 | m_pDrawPadCanvas->initialPage(); |
267 | } | 280 | } |
268 | } | 281 | } |
269 | 282 | ||
270 | DrawPad::~DrawPad() | 283 | DrawPad::~DrawPad() |
271 | { | 284 | { |
272 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 285 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
273 | 286 | ||
274 | if (file.open(IO_WriteOnly)) { | 287 | if (file.open(IO_WriteOnly)) { |
275 | m_pDrawPadCanvas->save(&file); | 288 | m_pDrawPadCanvas->save(&file); |
276 | file.close(); | 289 | file.close(); |
277 | } | 290 | } |
278 | } | 291 | } |
279 | 292 | ||
280 | void DrawPad::setPointTool() | 293 | void DrawPad::setPointTool() |
281 | { | 294 | { |
282 | if (m_pTool) { | 295 | if (m_pTool) { |
283 | delete m_pTool; | 296 | delete m_pTool; |
284 | } | 297 | } |
285 | 298 | ||
286 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 299 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
287 | 300 | ||
288 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 301 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
289 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); | 302 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
290 | 303 | ||
291 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 304 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
292 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | 305 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); |
293 | 306 | ||
294 | m_pLineToolButton->setOn(true); | 307 | m_pLineToolButton->setOn(true); |
295 | m_pRectangleToolButton->setOn(false); | 308 | m_pRectangleToolButton->setOn(false); |
296 | m_pEllipseToolButton->setOn(false); | 309 | m_pEllipseToolButton->setOn(false); |
297 | m_pTextToolAction->setOn(false); | 310 | m_pTextToolAction->setOn(false); |
298 | m_pFillToolAction->setOn(false); | 311 | m_pFillToolAction->setOn(false); |
299 | m_pEraseToolAction->setOn(false); | 312 | m_pEraseToolAction->setOn(false); |
300 | } | 313 | } |
301 | 314 | ||
302 | void DrawPad::setLineTool() | 315 | void DrawPad::setLineTool() |
303 | { | 316 | { |
304 | if (m_pTool) { | 317 | if (m_pTool) { |
305 | delete m_pTool; | 318 | delete m_pTool; |
306 | } | 319 | } |
307 | 320 | ||
308 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 321 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
309 | 322 | ||
310 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); | 323 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
311 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); | 324 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
312 | 325 | ||
313 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 326 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
314 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | 327 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); |
315 | 328 | ||
316 | m_pLineToolButton->setOn(true); | 329 | m_pLineToolButton->setOn(true); |
317 | m_pRectangleToolButton->setOn(false); | 330 | m_pRectangleToolButton->setOn(false); |
318 | m_pEllipseToolButton->setOn(false); | 331 | m_pEllipseToolButton->setOn(false); |
319 | m_pTextToolAction->setOn(false); | 332 | m_pTextToolAction->setOn(false); |
320 | m_pFillToolAction->setOn(false); | 333 | m_pFillToolAction->setOn(false); |
321 | m_pEraseToolAction->setOn(false); | 334 | m_pEraseToolAction->setOn(false); |
322 | } | 335 | } |
323 | 336 | ||
324 | void DrawPad::setRectangleTool() | 337 | void DrawPad::setRectangleTool() |
325 | { | 338 | { |
326 | if (m_pTool) { | 339 | if (m_pTool) { |
327 | delete m_pTool; | 340 | delete m_pTool; |
328 | } | 341 | } |
329 | 342 | ||
330 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 343 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
331 | 344 | ||
332 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 345 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
333 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 346 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
334 | 347 | ||
335 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 348 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
336 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 349 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
337 | 350 | ||
338 | m_pLineToolButton->setOn(false); | 351 | m_pLineToolButton->setOn(false); |
339 | m_pRectangleToolButton->setOn(true); | 352 | m_pRectangleToolButton->setOn(true); |
340 | m_pEllipseToolButton->setOn(false); | 353 | m_pEllipseToolButton->setOn(false); |
341 | m_pTextToolAction->setOn(false); | 354 | m_pTextToolAction->setOn(false); |
342 | m_pFillToolAction->setOn(false); | 355 | m_pFillToolAction->setOn(false); |
343 | m_pEraseToolAction->setOn(false); | 356 | m_pEraseToolAction->setOn(false); |
344 | } | 357 | } |
345 | 358 | ||
346 | void DrawPad::setFilledRectangleTool() | 359 | void DrawPad::setFilledRectangleTool() |
347 | { | 360 | { |
348 | if (m_pTool) { | 361 | if (m_pTool) { |
349 | delete m_pTool; | 362 | delete m_pTool; |
350 | } | 363 | } |
351 | 364 | ||
352 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 365 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
353 | 366 | ||
354 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 367 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
355 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 368 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
356 | 369 | ||
357 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 370 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
358 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 371 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
359 | 372 | ||
360 | m_pLineToolButton->setOn(false); | 373 | m_pLineToolButton->setOn(false); |
361 | m_pRectangleToolButton->setOn(true); | 374 | m_pRectangleToolButton->setOn(true); |
362 | m_pEllipseToolButton->setOn(false); | 375 | m_pEllipseToolButton->setOn(false); |
363 | m_pTextToolAction->setOn(false); | 376 | m_pTextToolAction->setOn(false); |
364 | m_pFillToolAction->setOn(false); | 377 | m_pFillToolAction->setOn(false); |
365 | m_pEraseToolAction->setOn(false); | 378 | m_pEraseToolAction->setOn(false); |
366 | } | 379 | } |
367 | 380 | ||
368 | void DrawPad::setEllipseTool() | 381 | void DrawPad::setEllipseTool() |
369 | { | 382 | { |
370 | if (m_pTool) { | 383 | if (m_pTool) { |
371 | delete m_pTool; | 384 | delete m_pTool; |
372 | } | 385 | } |
373 | 386 | ||
374 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 387 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
375 | 388 | ||
376 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 389 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
377 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 390 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
378 | 391 | ||
379 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 392 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
380 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 393 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
381 | 394 | ||
382 | m_pLineToolButton->setOn(false); | 395 | m_pLineToolButton->setOn(false); |
383 | m_pRectangleToolButton->setOn(false); | 396 | m_pRectangleToolButton->setOn(false); |
384 | m_pEllipseToolButton->setOn(true); | 397 | m_pEllipseToolButton->setOn(true); |
385 | m_pTextToolAction->setOn(false); | 398 | m_pTextToolAction->setOn(false); |
386 | m_pFillToolAction->setOn(false); | 399 | m_pFillToolAction->setOn(false); |
387 | m_pEraseToolAction->setOn(false); | 400 | m_pEraseToolAction->setOn(false); |
388 | } | 401 | } |
389 | 402 | ||
390 | void DrawPad::setFilledEllipseTool() | 403 | void DrawPad::setFilledEllipseTool() |
391 | { | 404 | { |
392 | if (m_pTool) { | 405 | if (m_pTool) { |
393 | delete m_pTool; | 406 | delete m_pTool; |
394 | } | 407 | } |
395 | 408 | ||
396 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 409 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
397 | 410 | ||
398 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 411 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
399 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 412 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
400 | 413 | ||
401 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 414 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
402 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 415 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
403 | 416 | ||
404 | m_pLineToolButton->setOn(false); | 417 | m_pLineToolButton->setOn(false); |
405 | m_pRectangleToolButton->setOn(false); | 418 | m_pRectangleToolButton->setOn(false); |
406 | m_pEllipseToolButton->setOn(true); | 419 | m_pEllipseToolButton->setOn(true); |
407 | m_pTextToolAction->setOn(false); | 420 | m_pTextToolAction->setOn(false); |
408 | m_pFillToolAction->setOn(false); | 421 | m_pFillToolAction->setOn(false); |
409 | m_pEraseToolAction->setOn(false); | 422 | m_pEraseToolAction->setOn(false); |
410 | } | 423 | } |
411 | 424 | ||
412 | void DrawPad::setTextTool() | 425 | void DrawPad::setTextTool() |
413 | { | 426 | { |
414 | if (m_pTool) { | 427 | if (m_pTool) { |
415 | delete m_pTool; | 428 | delete m_pTool; |
416 | } | 429 | } |
417 | 430 | ||
418 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 431 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
419 | 432 | ||
420 | m_pLineToolButton->setOn(false); | 433 | m_pLineToolButton->setOn(false); |
421 | m_pRectangleToolButton->setOn(false); | 434 | m_pRectangleToolButton->setOn(false); |
422 | m_pEllipseToolButton->setOn(false); | 435 | m_pEllipseToolButton->setOn(false); |
423 | m_pTextToolAction->setOn(true); | 436 | m_pTextToolAction->setOn(true); |
424 | m_pFillToolAction->setOn(false); | 437 | m_pFillToolAction->setOn(false); |
425 | m_pEraseToolAction->setOn(false); | 438 | m_pEraseToolAction->setOn(false); |
426 | } | 439 | } |
427 | 440 | ||
428 | void DrawPad::setFillTool() | 441 | void DrawPad::setFillTool() |
429 | { | 442 | { |
430 | if (m_pTool) { | 443 | if (m_pTool) { |
431 | delete m_pTool; | 444 | delete m_pTool; |
432 | } | 445 | } |
433 | 446 | ||
434 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 447 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
435 | 448 | ||
436 | m_pLineToolButton->setOn(false); | 449 | m_pLineToolButton->setOn(false); |
437 | m_pRectangleToolButton->setOn(false); | 450 | m_pRectangleToolButton->setOn(false); |
438 | m_pEllipseToolButton->setOn(false); | 451 | m_pEllipseToolButton->setOn(false); |
439 | m_pTextToolAction->setOn(false); | 452 | m_pTextToolAction->setOn(false); |
440 | m_pFillToolAction->setOn(true); | 453 | m_pFillToolAction->setOn(true); |
441 | m_pEraseToolAction->setOn(false); | 454 | m_pEraseToolAction->setOn(false); |
442 | } | 455 | } |
443 | 456 | ||
444 | void DrawPad::setEraseTool() | 457 | void DrawPad::setEraseTool() |
445 | { | 458 | { |
446 | if (m_pTool) { | 459 | if (m_pTool) { |
447 | delete m_pTool; | 460 | delete m_pTool; |
448 | } | 461 | } |
449 | 462 | ||
450 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 463 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
451 | 464 | ||
452 | m_pLineToolButton->setOn(false); | 465 | m_pLineToolButton->setOn(false); |
453 | m_pRectangleToolButton->setOn(false); | 466 | m_pRectangleToolButton->setOn(false); |
454 | m_pEllipseToolButton->setOn(false); | 467 | m_pEllipseToolButton->setOn(false); |
455 | m_pTextToolAction->setOn(false); | 468 | m_pTextToolAction->setOn(false); |
456 | m_pFillToolAction->setOn(false); | 469 | m_pFillToolAction->setOn(false); |
457 | m_pEraseToolAction->setOn(true); | 470 | m_pEraseToolAction->setOn(true); |
458 | } | 471 | } |
459 | 472 | ||
460 | void DrawPad::changePenWidth(int value) | 473 | void DrawPad::changePenWidth(int value) |
461 | { | 474 | { |
462 | m_pen.setWidth(value); | 475 | m_pen.setWidth(value); |
463 | } | 476 | } |
464 | 477 | ||
465 | void DrawPad::changePenColor(const QColor& color) | 478 | void DrawPad::changePenColor(const QColor& color) |
466 | { | 479 | { |
467 | m_pen.setColor(color); | 480 | m_pen.setColor(color); |
468 | 481 | ||
469 | QPainter painter; | 482 | QPainter painter; |
470 | painter.begin(m_pPenColorToolButton->pixmap()); | 483 | painter.begin(m_pPenColorToolButton->pixmap()); |
471 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 484 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
472 | painter.end(); | 485 | painter.end(); |
473 | 486 | ||
474 | m_pPenColorToolButton->popup()->hide(); | 487 | m_pPenColorToolButton->popup()->hide(); |
475 | } | 488 | } |
476 | 489 | ||
477 | void DrawPad::changeBrushColor(const QColor& color) | 490 | void DrawPad::changeBrushColor(const QColor& color) |
478 | { | 491 | { |
479 | m_brush = QBrush(color); | 492 | m_brush = QBrush(color); |
480 | 493 | ||
481 | QPainter painter; | 494 | QPainter painter; |
482 | painter.begin(m_pBrushColorToolButton->pixmap()); | 495 | painter.begin(m_pBrushColorToolButton->pixmap()); |
483 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 496 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
484 | painter.end(); | 497 | painter.end(); |
485 | 498 | ||
486 | m_pBrushColorToolButton->popup()->hide(); | 499 | m_pBrushColorToolButton->popup()->hide(); |
487 | } | 500 | } |
488 | 501 | ||
489 | void DrawPad::choosePenColor() | ||
490 | { | ||
491 | QColor newPenColor = QColorDialog::getColor(m_pen.color()); | ||
492 | changePenColor(newPenColor); | ||
493 | } | ||
494 | |||
495 | void DrawPad::chooseBrushColor() | ||
496 | { | ||
497 | QColor newBrushColor = QColorDialog::getColor(m_brush.color()); | ||
498 | changeBrushColor(newBrushColor); | ||
499 | } | ||
500 | |||
501 | void DrawPad::updateUndoRedoToolButtons() | 502 | void DrawPad::updateUndoRedoToolButtons() |
502 | { | 503 | { |
503 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); | 504 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); |
504 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); | 505 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); |
505 | } | 506 | } |
506 | 507 | ||
507 | void DrawPad::updateNavigationToolButtons() | 508 | void DrawPad::updateNavigationToolButtons() |
508 | { | 509 | { |
509 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 510 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
510 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 511 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
511 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 512 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
512 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 513 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
513 | } | 514 | } |
514 | 515 | ||
515 | void DrawPad::updateCaption() | 516 | void DrawPad::updateCaption() |
516 | { | 517 | { |
517 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 518 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
518 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 519 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
519 | 520 | ||
520 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 521 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
521 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 522 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
522 | } | 523 | } |
523 | 524 | ||
524 | void DrawPad::importPage() | 525 | void DrawPad::importPage() |
525 | { | 526 | { |
526 | ImportDialog importDialog(this); | 527 | ImportDialog importDialog(this); |
527 | 528 | ||
528 | importDialog.showMaximized(); | 529 | importDialog.showMaximized(); |
529 | 530 | ||
530 | if (importDialog.exec() == QDialog::Accepted) { | 531 | if (importDialog.exec() == QDialog::Accepted) { |
531 | const DocLnk* docLnk = importDialog.selected(); | 532 | const DocLnk* docLnk = importDialog.selected(); |
532 | 533 | ||
533 | if (docLnk) { | 534 | if (docLnk) { |
534 | m_pDrawPadCanvas->importPage(docLnk->file()); | 535 | m_pDrawPadCanvas->importPage(docLnk->file()); |
535 | delete docLnk; | 536 | delete docLnk; |
536 | } | 537 | } |
537 | } | 538 | } |
538 | } | 539 | } |
539 | 540 | ||
540 | void DrawPad::exportPage() | 541 | void DrawPad::exportPage() |
541 | { | 542 | { |
542 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 543 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
543 | 544 | ||
544 | exportDialog.showMaximized(); | 545 | exportDialog.showMaximized(); |
545 | 546 | ||
546 | if (exportDialog.exec() == QDialog::Accepted) { | 547 | if (exportDialog.exec() == QDialog::Accepted) { |
547 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 548 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
548 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 549 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
549 | } | 550 | } |
550 | } | 551 | } |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index e4fd831..0dcd5c9 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -1,97 +1,95 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * DrawPad - a drawing program for Opie Environment * | 3 | * DrawPad - a drawing program for Opie Environment * |
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #ifndef DRAWPAD_H | 14 | #ifndef DRAWPAD_H |
15 | #define DRAWPAD_H | 15 | #define DRAWPAD_H |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | 18 | ||
19 | #include <qpen.h> | 19 | #include <qpen.h> |
20 | 20 | ||
21 | class DrawPadCanvas; | 21 | class DrawPadCanvas; |
22 | class Tool; | 22 | class Tool; |
23 | 23 | ||
24 | class QAction; | 24 | class QAction; |
25 | class QColor; | 25 | class QColor; |
26 | class QToolButton; | 26 | class QToolButton; |
27 | class QWidgetStack; | 27 | class QWidgetStack; |
28 | 28 | ||
29 | class DrawPad : public QMainWindow | 29 | class DrawPad : public QMainWindow |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | DrawPad(QWidget* parent = 0, const char* name = 0); | 34 | DrawPad(QWidget* parent = 0, const char* name = 0); |
35 | ~DrawPad(); | 35 | ~DrawPad(); |
36 | 36 | ||
37 | Tool* tool() { return m_pTool; } | 37 | Tool* tool() { return m_pTool; } |
38 | QPen pen() { return m_pen; } | 38 | QPen pen() { return m_pen; } |
39 | QBrush brush() { return m_brush; } | 39 | QBrush brush() { return m_brush; } |
40 | 40 | ||
41 | private slots: | 41 | private slots: |
42 | void setPointTool(); | 42 | void setPointTool(); |
43 | void setLineTool(); | 43 | void setLineTool(); |
44 | void setRectangleTool(); | 44 | void setRectangleTool(); |
45 | void setFilledRectangleTool(); | 45 | void setFilledRectangleTool(); |
46 | void setEllipseTool(); | 46 | void setEllipseTool(); |
47 | void setFilledEllipseTool(); | 47 | void setFilledEllipseTool(); |
48 | void setTextTool(); | 48 | void setTextTool(); |
49 | void setFillTool(); | 49 | void setFillTool(); |
50 | void setEraseTool(); | 50 | void setEraseTool(); |
51 | 51 | ||
52 | void changePenWidth(int value); | 52 | void changePenWidth(int value); |
53 | void changePenColor(const QColor& color); | 53 | void changePenColor(const QColor& color); |
54 | void changeBrushColor(const QColor& color); | 54 | void changeBrushColor(const QColor& color); |
55 | void choosePenColor(); | ||
56 | void chooseBrushColor(); | ||
57 | 55 | ||
58 | void updateUndoRedoToolButtons(); | 56 | void updateUndoRedoToolButtons(); |
59 | void updateNavigationToolButtons(); | 57 | void updateNavigationToolButtons(); |
60 | void updateCaption(); | 58 | void updateCaption(); |
61 | 59 | ||
62 | void importPage(); | 60 | void importPage(); |
63 | void exportPage(); | 61 | void exportPage(); |
64 | 62 | ||
65 | private: | 63 | private: |
66 | DrawPadCanvas* m_pDrawPadCanvas; | 64 | DrawPadCanvas* m_pDrawPadCanvas; |
67 | 65 | ||
68 | Tool* m_pTool; | 66 | Tool* m_pTool; |
69 | QPen m_pen; | 67 | QPen m_pen; |
70 | QBrush m_brush; | 68 | QBrush m_brush; |
71 | 69 | ||
72 | QAction* m_pUndoAction; | 70 | QAction* m_pUndoAction; |
73 | QAction* m_pRedoAction; | 71 | QAction* m_pRedoAction; |
74 | 72 | ||
75 | QAction* m_pFirstPageAction; | 73 | QAction* m_pFirstPageAction; |
76 | QAction* m_pPreviousPageAction; | 74 | QAction* m_pPreviousPageAction; |
77 | QAction* m_pNextPageAction; | 75 | QAction* m_pNextPageAction; |
78 | QAction* m_pLastPageAction; | 76 | QAction* m_pLastPageAction; |
79 | 77 | ||
80 | QAction* m_pPointToolAction; | 78 | QAction* m_pPointToolAction; |
81 | QAction* m_pLineToolAction; | 79 | QAction* m_pLineToolAction; |
82 | QAction* m_pRectangleToolAction; | 80 | QAction* m_pRectangleToolAction; |
83 | QAction* m_pFilledRectangleToolAction; | 81 | QAction* m_pFilledRectangleToolAction; |
84 | QAction* m_pEllipseToolAction; | 82 | QAction* m_pEllipseToolAction; |
85 | QAction* m_pFilledEllipseToolAction; | 83 | QAction* m_pFilledEllipseToolAction; |
86 | QAction* m_pTextToolAction; | 84 | QAction* m_pTextToolAction; |
87 | QAction* m_pFillToolAction; | 85 | QAction* m_pFillToolAction; |
88 | QAction* m_pEraseToolAction; | 86 | QAction* m_pEraseToolAction; |
89 | 87 | ||
90 | QToolButton* m_pLineToolButton; | 88 | QToolButton* m_pLineToolButton; |
91 | QToolButton* m_pRectangleToolButton; | 89 | QToolButton* m_pRectangleToolButton; |
92 | QToolButton* m_pEllipseToolButton; | 90 | QToolButton* m_pEllipseToolButton; |
93 | QToolButton* m_pPenColorToolButton; | 91 | QToolButton* m_pPenColorToolButton; |
94 | QToolButton* m_pBrushColorToolButton; | 92 | QToolButton* m_pBrushColorToolButton; |
95 | }; | 93 | }; |
96 | 94 | ||
97 | #endif // DRAWPAD_H | 95 | #endif // DRAWPAD_H |
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index 00eb00d..3b120c9 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro | |||
@@ -1,58 +1,54 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = colordialog.h \ | 3 | HEADERS = drawpad.h \ |
4 | colorpanel.h \ | ||
5 | drawpad.h \ | ||
6 | drawpadcanvas.h \ | 4 | drawpadcanvas.h \ |
7 | ellipsetool.h \ | 5 | ellipsetool.h \ |
8 | erasetool.h \ | 6 | erasetool.h \ |
9 | exportdialog.h \ | 7 | exportdialog.h \ |
10 | filltool.h \ | 8 | filltool.h \ |
11 | filledellipsetool.h \ | 9 | filledellipsetool.h \ |
12 | filledrectangletool.h \ | 10 | filledrectangletool.h \ |
13 | importdialog.h \ | 11 | importdialog.h \ |
14 | linetool.h \ | 12 | linetool.h \ |
15 | newpagedialog.h \ | 13 | newpagedialog.h \ |
16 | pointtool.h \ | 14 | pointtool.h \ |
17 | rectangletool.h \ | 15 | rectangletool.h \ |
18 | shapetool.h \ | 16 | shapetool.h \ |
19 | texttool.h \ | 17 | texttool.h \ |
20 | tool.h | 18 | tool.h |
21 | SOURCES = colordialog.cpp \ | 19 | SOURCES = drawpad.cpp \ |
22 | colorpanel.cpp \ | ||
23 | drawpad.cpp \ | ||
24 | drawpadcanvas.cpp \ | 20 | drawpadcanvas.cpp \ |
25 | ellipsetool.cpp \ | 21 | ellipsetool.cpp \ |
26 | erasetool.cpp \ | 22 | erasetool.cpp \ |
27 | exportdialog.cpp \ | 23 | exportdialog.cpp \ |
28 | filltool.cpp \ | 24 | filltool.cpp \ |
29 | filledellipsetool.cpp \ | 25 | filledellipsetool.cpp \ |
30 | filledrectangletool.cpp \ | 26 | filledrectangletool.cpp \ |
31 | importdialog.cpp \ | 27 | importdialog.cpp \ |
32 | linetool.cpp \ | 28 | linetool.cpp \ |
33 | main.cpp \ | 29 | main.cpp \ |
34 | newpagedialog.cpp \ | 30 | newpagedialog.cpp \ |
35 | pointtool.cpp \ | 31 | pointtool.cpp \ |
36 | rectangletool.cpp \ | 32 | rectangletool.cpp \ |
37 | shapetool.cpp \ | 33 | shapetool.cpp \ |
38 | texttool.cpp \ | 34 | texttool.cpp \ |
39 | tool.cpp | 35 | tool.cpp |
40 | INCLUDEPATH+= $(OPIEDIR)/include \ | 36 | INCLUDEPATH+= $(OPIEDIR)/include \ |
41 | $(QTDIR)/src/3rdparty/zlib | 37 | $(QTDIR)/src/3rdparty/zlib |
42 | DEPENDPATH+= $(OPIEDIR)/include | 38 | DEPENDPATH+= $(OPIEDIR)/include |
43 | LIBS += -lqpe | 39 | LIBS += -lqpe -lopie |
44 | DESTDIR = $(OPIEDIR)/bin | 40 | DESTDIR = $(OPIEDIR)/bin |
45 | TARGET = drawpad | 41 | TARGET = drawpad |
46 | 42 | ||
47 | TRANSLATIONS = ../../i18n/pt_BR/drawpad.ts | 43 | TRANSLATIONS = ../../i18n/pt_BR/drawpad.ts |
48 | TRANSLATIONS += ../../i18n/de/drawpad.ts | 44 | TRANSLATIONS += ../../i18n/de/drawpad.ts |
49 | TRANSLATIONS += ../../i18n/en/drawpad.ts | 45 | TRANSLATIONS += ../../i18n/en/drawpad.ts |
50 | TRANSLATIONS += ../../i18n/hu/drawpad.ts | 46 | TRANSLATIONS += ../../i18n/hu/drawpad.ts |
51 | TRANSLATIONS += ../../i18n/pl/drawpad.ts | 47 | TRANSLATIONS += ../../i18n/pl/drawpad.ts |
52 | TRANSLATIONS += ../../i18n/ja/drawpad.ts | 48 | TRANSLATIONS += ../../i18n/ja/drawpad.ts |
53 | TRANSLATIONS += ../../i18n/sl/drawpad.ts | 49 | TRANSLATIONS += ../../i18n/sl/drawpad.ts |
54 | TRANSLATIONS += ../../i18n/fr/drawpad.ts | 50 | TRANSLATIONS += ../../i18n/fr/drawpad.ts |
55 | TRANSLATIONS += ../../i18n/ko/drawpad.ts | 51 | TRANSLATIONS += ../../i18n/ko/drawpad.ts |
56 | TRANSLATIONS += ../../i18n/no/drawpad.ts | 52 | TRANSLATIONS += ../../i18n/no/drawpad.ts |
57 | TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts | 53 | TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts |
58 | TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts | 54 | TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts |