Diffstat (limited to 'noncore/graphics/drawpad/drawpad.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 317 |
1 files changed, 215 insertions, 102 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index e94187f..5c7e541 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -18,9 +18,14 @@ | |||
18 | #include "drawpadcanvas.h" | 18 | #include "drawpadcanvas.h" |
19 | #include "ellipsedrawmode.h" | 19 | #include "ellipsetool.h" |
20 | #include "erasedrawmode.h" | 20 | #include "erasetool.h" |
21 | #include "filldrawmode.h" | 21 | #include "exportdialog.h" |
22 | #include "linedrawmode.h" | 22 | #include "filledellipsetool.h" |
23 | #include "pointdrawmode.h" | 23 | #include "filledrectangletool.h" |
24 | #include "rectangledrawmode.h" | 24 | #include "filltool.h" |
25 | 25 | #include "importdialog.h" | |
26 | #include "linetool.h" | ||
27 | #include "pointtool.h" | ||
28 | #include "rectangletool.h" | ||
29 | |||
30 | #include <qpe/applnk.h> | ||
26 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
@@ -59,5 +64,5 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
59 | 64 | ||
60 | QAction* clearAllAction = new QAction(tr("Clear All"), QString::null, 0, this); | 65 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
61 | connect(clearAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearAll())); | 66 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); |
62 | clearAllAction->addTo(toolsPopupMenu); | 67 | deleteAllAction->addTo(toolsPopupMenu); |
63 | 68 | ||
@@ -65,4 +70,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
65 | 70 | ||
66 | QAction* setOptionsAction = new QAction(tr("Options"), tr("Options..."), 0, this); | 71 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
67 | setOptionsAction->addTo(toolsPopupMenu); | 72 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
73 | importPageAction->addTo(toolsPopupMenu); | ||
74 | |||
75 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | ||
76 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | ||
77 | exportPageAction->addTo(toolsPopupMenu); | ||
68 | 78 | ||
@@ -121,34 +131,56 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
121 | 131 | ||
122 | m_pPointDrawModeAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); | 132 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); |
123 | m_pPointDrawModeAction->setToggleAction(true); | 133 | m_pPointToolAction->setToggleAction(true); |
124 | connect(m_pPointDrawModeAction, SIGNAL(activated()), this, SLOT(setPointDrawMode())); | 134 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
125 | m_pPointDrawModeAction->addTo(drawModeToolBar); | 135 | m_pPointToolAction->addTo(drawModeToolBar); |
136 | |||
137 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); | ||
138 | m_pLineToolAction->setToggleAction(true); | ||
139 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | ||
140 | m_pLineToolAction->addTo(drawModeToolBar); | ||
141 | |||
142 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | ||
143 | m_pRectangleToolButton->setToggleButton(true); | ||
144 | |||
145 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | ||
146 | |||
147 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | ||
148 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | ||
149 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | ||
126 | 150 | ||
127 | m_pLineDrawModeAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); | 151 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
128 | m_pLineDrawModeAction->setToggleAction(true); | 152 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
129 | connect(m_pLineDrawModeAction, SIGNAL(activated()), this, SLOT(setLineDrawMode())); | 153 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
130 | m_pLineDrawModeAction->addTo(drawModeToolBar); | ||
131 | 154 | ||
132 | m_pRectangleDrawModeAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), QString::null, 0, this); | 155 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
133 | m_pRectangleDrawModeAction->setToggleAction(true); | ||
134 | connect(m_pRectangleDrawModeAction, SIGNAL(activated()), this, SLOT(setRectangleDrawMode())); | ||
135 | m_pRectangleDrawModeAction->addTo(drawModeToolBar); | ||
136 | 156 | ||
137 | m_pEllipseDrawModeAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), QString::null, 0, this); | 157 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
138 | m_pEllipseDrawModeAction->setToggleAction(true); | 158 | m_pEllipseToolButton->setToggleButton(true); |
139 | connect(m_pEllipseDrawModeAction, SIGNAL(activated()), this, SLOT(setEllipseDrawMode())); | ||
140 | m_pEllipseDrawModeAction->addTo(drawModeToolBar); | ||
141 | 159 | ||
142 | m_pFillDrawModeAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 160 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
143 | m_pFillDrawModeAction->setToggleAction(true); | ||
144 | connect(m_pFillDrawModeAction, SIGNAL(activated()), this, SLOT(setFillDrawMode())); | ||
145 | m_pFillDrawModeAction->addTo(drawModeToolBar); | ||
146 | 161 | ||
147 | m_pEraseDrawModeAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 162 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
148 | m_pEraseDrawModeAction->setToggleAction(true); | 163 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
149 | connect(m_pEraseDrawModeAction, SIGNAL(activated()), this, SLOT(setEraseDrawMode())); | 164 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
150 | m_pEraseDrawModeAction->addTo(drawModeToolBar); | ||
151 | 165 | ||
152 | m_pDrawMode = 0; | 166 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
153 | setPointDrawMode(); | 167 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
168 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | ||
169 | |||
170 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | ||
171 | |||
172 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | ||
173 | m_pFillToolAction->setToggleAction(true); | ||
174 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | ||
175 | m_pFillToolAction->addTo(drawModeToolBar); | ||
176 | |||
177 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | ||
178 | m_pEraseToolAction->setToggleAction(true); | ||
179 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | ||
180 | m_pEraseToolAction->addTo(drawModeToolBar); | ||
181 | |||
182 | m_pTool = 0; | ||
183 | setRectangleTool(); | ||
184 | setEllipseTool(); | ||
185 | setPointTool(); | ||
154 | 186 | ||
@@ -165,3 +197,5 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
165 | 197 | ||
198 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | ||
166 | penWidthSpinBox->setValue(1); | 199 | penWidthSpinBox->setValue(1); |
200 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | ||
167 | 201 | ||
@@ -174,4 +208,4 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
174 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 208 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
175 | penColorPopupMenu->insertItem(penColorPanel); | ||
176 | 209 | ||
210 | penColorPopupMenu->insertItem(penColorPanel); | ||
177 | penColorPopupMenu->insertSeparator(); | 211 | penColorPopupMenu->insertSeparator(); |
@@ -186,3 +220,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
186 | 220 | ||
187 | penColorPopupMenu->activateItemAt(0); | 221 | penColorPanel->buttonSelected(Qt::black); |
188 | 222 | ||
@@ -195,4 +229,4 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
195 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 229 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
196 | brushColorPopupMenu->insertItem(brushColorPanel); | ||
197 | 230 | ||
231 | brushColorPopupMenu->insertItem(brushColorPanel); | ||
198 | brushColorPopupMenu->insertSeparator(); | 232 | brushColorPopupMenu->insertSeparator(); |
@@ -207,3 +241,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
207 | 241 | ||
208 | brushColorPopupMenu->activateItemAt(1); | 242 | brushColorPanel->buttonSelected(Qt::white); |
209 | 243 | ||
@@ -231,96 +265,152 @@ DrawPad::~DrawPad() | |||
231 | 265 | ||
232 | void DrawPad::setPointDrawMode() | 266 | void DrawPad::setPointTool() |
267 | { | ||
268 | if (m_pTool) { | ||
269 | delete m_pTool; | ||
270 | } | ||
271 | |||
272 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | ||
273 | |||
274 | m_pPointToolAction->setOn(true); | ||
275 | m_pLineToolAction->setOn(false); | ||
276 | m_pRectangleToolButton->setOn(false); | ||
277 | m_pEllipseToolButton->setOn(false); | ||
278 | m_pFillToolAction->setOn(false); | ||
279 | m_pEraseToolAction->setOn(false); | ||
280 | } | ||
281 | |||
282 | void DrawPad::setLineTool() | ||
283 | { | ||
284 | if (m_pTool) { | ||
285 | delete m_pTool; | ||
286 | } | ||
287 | |||
288 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | ||
289 | |||
290 | m_pPointToolAction->setOn(false); | ||
291 | m_pLineToolAction->setOn(true); | ||
292 | m_pRectangleToolButton->setOn(false); | ||
293 | m_pEllipseToolButton->setOn(false); | ||
294 | m_pFillToolAction->setOn(false); | ||
295 | m_pEraseToolAction->setOn(false); | ||
296 | } | ||
297 | |||
298 | void DrawPad::setRectangleTool() | ||
233 | { | 299 | { |
234 | if (m_pDrawMode) { | 300 | if (m_pTool) { |
235 | delete m_pDrawMode; | 301 | delete m_pTool; |
236 | } | 302 | } |
237 | 303 | ||
238 | m_pDrawMode = new PointDrawMode(this, m_pDrawPadCanvas); | 304 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
239 | 305 | ||
240 | m_pPointDrawModeAction->setOn(true); | 306 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
241 | m_pLineDrawModeAction->setOn(false); | 307 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
242 | m_pRectangleDrawModeAction->setOn(false); | 308 | |
243 | m_pEllipseDrawModeAction->setOn(false); | 309 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
244 | m_pFillDrawModeAction->setOn(false); | 310 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
245 | m_pEraseDrawModeAction->setOn(false); | 311 | |
312 | m_pPointToolAction->setOn(false); | ||
313 | m_pLineToolAction->setOn(false); | ||
314 | m_pRectangleToolButton->setOn(true); | ||
315 | m_pEllipseToolButton->setOn(false); | ||
316 | m_pFillToolAction->setOn(false); | ||
317 | m_pEraseToolAction->setOn(false); | ||
246 | } | 318 | } |
247 | 319 | ||
248 | void DrawPad::setLineDrawMode() | 320 | void DrawPad::setFilledRectangleTool() |
249 | { | 321 | { |
250 | if (m_pDrawMode) { | 322 | if (m_pTool) { |
251 | delete m_pDrawMode; | 323 | delete m_pTool; |
252 | } | 324 | } |
253 | 325 | ||
254 | m_pDrawMode = new LineDrawMode(this, m_pDrawPadCanvas); | 326 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
327 | |||
328 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | ||
329 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | ||
255 | 330 | ||
256 | m_pPointDrawModeAction->setOn(false); | 331 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
257 | m_pLineDrawModeAction->setOn(true); | 332 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
258 | m_pRectangleDrawModeAction->setOn(false); | 333 | |
259 | m_pEllipseDrawModeAction->setOn(false); | 334 | m_pPointToolAction->setOn(false); |
260 | m_pFillDrawModeAction->setOn(false); | 335 | m_pLineToolAction->setOn(false); |
261 | m_pEraseDrawModeAction->setOn(false); | 336 | m_pRectangleToolButton->setOn(true); |
337 | m_pEllipseToolButton->setOn(false); | ||
338 | m_pFillToolAction->setOn(false); | ||
339 | m_pEraseToolAction->setOn(false); | ||
262 | } | 340 | } |
263 | 341 | ||
264 | void DrawPad::setRectangleDrawMode() | 342 | void DrawPad::setEllipseTool() |
265 | { | 343 | { |
266 | if (m_pDrawMode) { | 344 | if (m_pTool) { |
267 | delete m_pDrawMode; | 345 | delete m_pTool; |
268 | } | 346 | } |
269 | 347 | ||
270 | m_pDrawMode = new RectangleDrawMode(this, m_pDrawPadCanvas); | 348 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
349 | |||
350 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | ||
351 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | ||
352 | |||
353 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | ||
354 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | ||
271 | 355 | ||
272 | m_pPointDrawModeAction->setOn(false); | 356 | m_pPointToolAction->setOn(false); |
273 | m_pLineDrawModeAction->setOn(false); | 357 | m_pLineToolAction->setOn(false); |
274 | m_pRectangleDrawModeAction->setOn(true); | 358 | m_pRectangleToolButton->setOn(false); |
275 | m_pEllipseDrawModeAction->setOn(false); | 359 | m_pEllipseToolButton->setOn(true); |
276 | m_pFillDrawModeAction->setOn(false); | 360 | m_pFillToolAction->setOn(false); |
277 | m_pEraseDrawModeAction->setOn(false); | 361 | m_pEraseToolAction->setOn(false); |
278 | } | 362 | } |
279 | 363 | ||
280 | void DrawPad::setEllipseDrawMode() | 364 | void DrawPad::setFilledEllipseTool() |
281 | { | 365 | { |
282 | if (m_pDrawMode) { | 366 | if (m_pTool) { |
283 | delete m_pDrawMode; | 367 | delete m_pTool; |
284 | } | 368 | } |
285 | 369 | ||
286 | m_pDrawMode = new EllipseDrawMode(this, m_pDrawPadCanvas); | 370 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
287 | 371 | ||
288 | m_pPointDrawModeAction->setOn(false); | 372 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
289 | m_pLineDrawModeAction->setOn(false); | 373 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
290 | m_pRectangleDrawModeAction->setOn(false); | 374 | |
291 | m_pEllipseDrawModeAction->setOn(true); | 375 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
292 | m_pFillDrawModeAction->setOn(false); | 376 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
293 | m_pEraseDrawModeAction->setOn(false); | 377 | |
378 | m_pPointToolAction->setOn(false); | ||
379 | m_pLineToolAction->setOn(false); | ||
380 | m_pRectangleToolButton->setOn(false); | ||
381 | m_pEllipseToolButton->setOn(true); | ||
382 | m_pFillToolAction->setOn(false); | ||
383 | m_pEraseToolAction->setOn(false); | ||
294 | } | 384 | } |
295 | 385 | ||
296 | void DrawPad::setFillDrawMode() | 386 | void DrawPad::setFillTool() |
297 | { | 387 | { |
298 | if (m_pDrawMode) { | 388 | if (m_pTool) { |
299 | delete m_pDrawMode; | 389 | delete m_pTool; |
300 | } | 390 | } |
301 | 391 | ||
302 | m_pDrawMode = new FillDrawMode(this, m_pDrawPadCanvas); | 392 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
303 | 393 | ||
304 | m_pPointDrawModeAction->setOn(false); | 394 | m_pPointToolAction->setOn(false); |
305 | m_pLineDrawModeAction->setOn(false); | 395 | m_pLineToolAction->setOn(false); |
306 | m_pRectangleDrawModeAction->setOn(false); | 396 | m_pRectangleToolButton->setOn(false); |
307 | m_pEllipseDrawModeAction->setOn(false); | 397 | m_pEllipseToolButton->setOn(false); |
308 | m_pFillDrawModeAction->setOn(true); | 398 | m_pFillToolAction->setOn(true); |
309 | m_pEraseDrawModeAction->setOn(false); | 399 | m_pEraseToolAction->setOn(false); |
310 | } | 400 | } |
311 | 401 | ||
312 | void DrawPad::setEraseDrawMode() | 402 | void DrawPad::setEraseTool() |
313 | { | 403 | { |
314 | if (m_pDrawMode) { | 404 | if (m_pTool) { |
315 | delete m_pDrawMode; | 405 | delete m_pTool; |
316 | } | 406 | } |
317 | 407 | ||
318 | m_pDrawMode = new EraseDrawMode(this, m_pDrawPadCanvas); | 408 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
319 | 409 | ||
320 | m_pPointDrawModeAction->setOn(false); | 410 | m_pPointToolAction->setOn(false); |
321 | m_pLineDrawModeAction->setOn(false); | 411 | m_pLineToolAction->setOn(false); |
322 | m_pRectangleDrawModeAction->setOn(false); | 412 | m_pRectangleToolButton->setOn(false); |
323 | m_pEllipseDrawModeAction->setOn(false); | 413 | m_pEllipseToolButton->setOn(false); |
324 | m_pFillDrawModeAction->setOn(false); | 414 | m_pFillToolAction->setOn(false); |
325 | m_pEraseDrawModeAction->setOn(true); | 415 | m_pEraseToolAction->setOn(true); |
326 | } | 416 | } |
@@ -390 +480,24 @@ void DrawPad::updateCaption() | |||
390 | } | 480 | } |
481 | |||
482 | void DrawPad::importPage() | ||
483 | { | ||
484 | ImportDialog importDialog(this); | ||
485 | |||
486 | importDialog.showMaximized(); | ||
487 | |||
488 | if (importDialog.exec() == QDialog::Accepted) { | ||
489 | m_pDrawPadCanvas->importPage(importDialog.selected()->file()); | ||
490 | } | ||
491 | } | ||
492 | |||
493 | void DrawPad::exportPage() | ||
494 | { | ||
495 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | ||
496 | |||
497 | exportDialog.showMaximized(); | ||
498 | |||
499 | if (exportDialog.exec() == QDialog::Accepted) { | ||
500 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | ||
501 | exportDialog.selectedName(), exportDialog.selectedFormat()); | ||
502 | } | ||
503 | } | ||