author | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
commit | 531bb3c03f5576523a3c7ccecc714362507f69e1 (patch) (unidiff) | |
tree | 8bdda021e3ddd110ca75df06a1f6a5fbf0429a6c | |
parent | 527c3a7240bee3fe1d7c000aecc8ff0a01219fdd (diff) | |
download | opie-531bb3c03f5576523a3c7ccecc714362507f69e1.zip opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.gz opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.bz2 |
Add application config
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 39 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 1 |
4 files changed, 54 insertions, 5 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index b29f5ba..4eb47a5 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,100 +1,101 @@ | |||
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 "drawpadcanvas.h" | 16 | #include "drawpadcanvas.h" |
17 | #include "ellipsetool.h" | 17 | #include "ellipsetool.h" |
18 | #include "erasetool.h" | 18 | #include "erasetool.h" |
19 | #include "exportdialog.h" | 19 | #include "exportdialog.h" |
20 | #include "filledellipsetool.h" | 20 | #include "filledellipsetool.h" |
21 | #include "filledrectangletool.h" | 21 | #include "filledrectangletool.h" |
22 | #include "filltool.h" | 22 | #include "filltool.h" |
23 | #include "importdialog.h" | 23 | #include "importdialog.h" |
24 | #include "linetool.h" | 24 | #include "linetool.h" |
25 | #include "newpagedialog.h" | 25 | #include "newpagedialog.h" |
26 | #include "page.h" | 26 | #include "page.h" |
27 | #include "pageinformationdialog.h" | 27 | #include "pageinformationdialog.h" |
28 | #include "pointtool.h" | 28 | #include "pointtool.h" |
29 | #include "rectangletool.h" | 29 | #include "rectangletool.h" |
30 | #include "texttool.h" | 30 | #include "texttool.h" |
31 | #include "thumbnailview.h" | 31 | #include "thumbnailview.h" |
32 | 32 | ||
33 | #include <opie/colordialog.h> | 33 | #include <opie/colordialog.h> |
34 | #include <opie/colorpopupmenu.h> | 34 | #include <opie/colorpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | ||
37 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
38 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | 42 | ||
42 | #include <qaction.h> | 43 | #include <qaction.h> |
43 | #include <qfile.h> | 44 | #include <qfile.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qpainter.h> | 46 | #include <qpainter.h> |
46 | #include <qspinbox.h> | 47 | #include <qspinbox.h> |
47 | #include <qtoolbutton.h> | 48 | #include <qtoolbutton.h> |
48 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
49 | 50 | ||
50 | DrawPad::DrawPad(QWidget* parent, const char* name) | 51 | DrawPad::DrawPad(QWidget* parent, const char* name) |
51 | : QMainWindow(parent, name) | 52 | : QMainWindow(parent, name) |
52 | { | 53 | { |
53 | // init members | 54 | // init members |
54 | 55 | ||
55 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 56 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
56 | 57 | ||
57 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 59 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
59 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 60 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
60 | 61 | ||
61 | setCentralWidget(m_pDrawPadCanvas); | 62 | setCentralWidget(m_pDrawPadCanvas); |
62 | 63 | ||
63 | // init menu | 64 | // init menu |
64 | 65 | ||
65 | setToolBarsMovable(false); | 66 | setToolBarsMovable(false); |
66 | 67 | ||
67 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 68 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
68 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 69 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
69 | 70 | ||
70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); | 71 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
71 | 72 | ||
72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 73 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 74 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
74 | deleteAllAction->addTo(toolsPopupMenu); | 75 | deleteAllAction->addTo(toolsPopupMenu); |
75 | 76 | ||
76 | toolsPopupMenu->insertSeparator(); | 77 | toolsPopupMenu->insertSeparator(); |
77 | 78 | ||
78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 79 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 80 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
80 | importPageAction->addTo(toolsPopupMenu); | 81 | importPageAction->addTo(toolsPopupMenu); |
81 | 82 | ||
82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 83 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 84 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
84 | exportPageAction->addTo(toolsPopupMenu); | 85 | exportPageAction->addTo(toolsPopupMenu); |
85 | 86 | ||
86 | toolsPopupMenu->insertSeparator(); | 87 | toolsPopupMenu->insertSeparator(); |
87 | 88 | ||
88 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | 89 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); |
89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 90 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
90 | thumbnailViewAction->addTo(toolsPopupMenu); | 91 | thumbnailViewAction->addTo(toolsPopupMenu); |
91 | 92 | ||
92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | 93 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); |
93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 94 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
94 | pageInformationAction->addTo(toolsPopupMenu); | 95 | pageInformationAction->addTo(toolsPopupMenu); |
95 | 96 | ||
96 | toolsPopupMenu->insertSeparator(); | 97 | toolsPopupMenu->insertSeparator(); |
97 | 98 | ||
98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | 99 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); |
99 | m_pAntiAliasingAction->setToggleAction(true); | 100 | m_pAntiAliasingAction->setToggleAction(true); |
100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | 101 | m_pAntiAliasingAction->addTo(toolsPopupMenu); |
@@ -167,173 +168,177 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
167 | 168 | ||
168 | m_pLineToolButton->setPopup(linePopupMenu); | 169 | m_pLineToolButton->setPopup(linePopupMenu); |
169 | m_pLineToolButton->setPopupDelay(0); | 170 | m_pLineToolButton->setPopupDelay(0); |
170 | 171 | ||
171 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 172 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
172 | m_pRectangleToolButton->setToggleButton(true); | 173 | m_pRectangleToolButton->setToggleButton(true); |
173 | 174 | ||
174 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 175 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
175 | 176 | ||
176 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 177 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); |
177 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 178 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
178 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 179 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
179 | 180 | ||
180 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 181 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
181 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 182 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
182 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 183 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
183 | 184 | ||
184 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 185 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
185 | m_pRectangleToolButton->setPopupDelay(0); | 186 | m_pRectangleToolButton->setPopupDelay(0); |
186 | 187 | ||
187 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 188 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
188 | m_pEllipseToolButton->setToggleButton(true); | 189 | m_pEllipseToolButton->setToggleButton(true); |
189 | 190 | ||
190 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 191 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
191 | 192 | ||
192 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 193 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
193 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 194 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
194 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 195 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
195 | 196 | ||
196 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 197 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
197 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 198 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
198 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 199 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
199 | 200 | ||
200 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 201 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
201 | m_pEllipseToolButton->setPopupDelay(0); | 202 | m_pEllipseToolButton->setPopupDelay(0); |
202 | 203 | ||
203 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | 204 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); |
204 | m_pTextToolAction->setToggleAction(true); | 205 | m_pTextToolAction->setToggleAction(true); |
205 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 206 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
206 | m_pTextToolAction->addTo(drawModeToolBar); | 207 | m_pTextToolAction->addTo(drawModeToolBar); |
207 | 208 | ||
208 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 209 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
209 | m_pFillToolAction->setToggleAction(true); | 210 | m_pFillToolAction->setToggleAction(true); |
210 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 211 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
211 | m_pFillToolAction->addTo(drawModeToolBar); | 212 | m_pFillToolAction->addTo(drawModeToolBar); |
212 | 213 | ||
213 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 214 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
214 | m_pEraseToolAction->setToggleAction(true); | 215 | m_pEraseToolAction->setToggleAction(true); |
215 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 216 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
216 | m_pEraseToolAction->addTo(drawModeToolBar); | 217 | m_pEraseToolAction->addTo(drawModeToolBar); |
217 | 218 | ||
218 | m_pTool = 0; | 219 | m_pTool = 0; |
219 | setRectangleTool(); | 220 | setRectangleTool(); |
220 | setEllipseTool(); | 221 | setEllipseTool(); |
221 | setPointTool(); | 222 | setPointTool(); |
222 | 223 | ||
223 | emptyToolBar = new QPEToolBar(this); | 224 | emptyToolBar = new QPEToolBar(this); |
224 | emptyToolBar->setHorizontalStretchable(true); | 225 | emptyToolBar->setHorizontalStretchable(true); |
225 | emptyToolBar->addSeparator(); | 226 | emptyToolBar->addSeparator(); |
226 | 227 | ||
227 | // init draw parameters toolbar | 228 | // init draw parameters toolbar |
228 | 229 | ||
229 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 230 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
230 | 231 | ||
231 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 232 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
232 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 233 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
233 | 234 | ||
234 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 235 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
235 | penWidthSpinBox->setValue(1); | 236 | m_pPenWidthSpinBox->setValue(1); |
236 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 237 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
237 | 238 | ||
238 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 239 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
239 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 240 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
240 | 241 | ||
241 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); | 242 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); |
242 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 243 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
243 | 244 | ||
244 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 245 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
245 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 246 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
246 | m_pPenColorToolButton->setPopupDelay(0); | 247 | m_pPenColorToolButton->setPopupDelay(0); |
247 | 248 | ||
248 | changePenColor(Qt::black); | 249 | changePenColor(Qt::black); |
249 | 250 | ||
250 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 251 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
251 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); | 252 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); |
252 | 253 | ||
253 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 254 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
254 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 255 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
255 | 256 | ||
256 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 257 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
257 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 258 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
258 | m_pBrushColorToolButton->setPopupDelay(0); | 259 | m_pBrushColorToolButton->setPopupDelay(0); |
259 | 260 | ||
260 | changeBrushColor(Qt::white); | 261 | changeBrushColor(Qt::white); |
261 | 262 | ||
262 | // init pages | 263 | // init pages |
263 | 264 | ||
264 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 265 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
265 | 266 | ||
266 | if (file.open(IO_ReadOnly)) { | 267 | if (file.open(IO_ReadOnly)) { |
267 | m_pDrawPadCanvas->load(&file); | 268 | m_pDrawPadCanvas->load(&file); |
268 | file.close(); | 269 | file.close(); |
269 | } else { | 270 | } else { |
270 | m_pDrawPadCanvas->initialPage(); | 271 | m_pDrawPadCanvas->initialPage(); |
271 | } | 272 | } |
273 | |||
274 | loadConfig(); | ||
272 | } | 275 | } |
273 | 276 | ||
274 | DrawPad::~DrawPad() | 277 | DrawPad::~DrawPad() |
275 | { | 278 | { |
279 | saveConfig(); | ||
280 | |||
276 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 281 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
277 | 282 | ||
278 | if (file.open(IO_WriteOnly)) { | 283 | if (file.open(IO_WriteOnly)) { |
279 | m_pDrawPadCanvas->save(&file); | 284 | m_pDrawPadCanvas->save(&file); |
280 | file.close(); | 285 | file.close(); |
281 | } | 286 | } |
282 | } | 287 | } |
283 | 288 | ||
284 | bool DrawPad::antiAliasing() | 289 | bool DrawPad::antiAliasing() |
285 | { | 290 | { |
286 | return (m_pAntiAliasingAction->isOn()); | 291 | return (m_pAntiAliasingAction->isOn()); |
287 | } | 292 | } |
288 | 293 | ||
289 | void DrawPad::newPage() | 294 | void DrawPad::newPage() |
290 | { | 295 | { |
291 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 296 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
292 | 297 | ||
293 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 298 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
294 | 299 | ||
295 | if (newPageDialog.exec() == QDialog::Accepted) { | 300 | if (newPageDialog.exec() == QDialog::Accepted) { |
296 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 301 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
297 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 302 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ||
301 | void DrawPad::clearPage() | 306 | void DrawPad::clearPage() |
302 | { | 307 | { |
303 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 308 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
304 | QMessageBox::Information, QMessageBox::Yes, | 309 | QMessageBox::Information, QMessageBox::Yes, |
305 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 310 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
306 | QMessageBox::NoButton, this); | 311 | QMessageBox::NoButton, this); |
307 | 312 | ||
308 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 313 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
309 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 314 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
310 | 315 | ||
311 | if (messageBox.exec() == QMessageBox::Yes) { | 316 | if (messageBox.exec() == QMessageBox::Yes) { |
312 | m_pDrawPadCanvas->clearPage(); | 317 | m_pDrawPadCanvas->clearPage(); |
313 | } | 318 | } |
314 | } | 319 | } |
315 | 320 | ||
316 | void DrawPad::deletePage() | 321 | void DrawPad::deletePage() |
317 | { | 322 | { |
318 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 323 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
319 | QMessageBox::Information, QMessageBox::Yes, | 324 | QMessageBox::Information, QMessageBox::Yes, |
320 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 325 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
321 | QMessageBox::NoButton, this); | 326 | QMessageBox::NoButton, this); |
322 | 327 | ||
323 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 328 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
324 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 329 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
325 | 330 | ||
326 | if (messageBox.exec() == QMessageBox::Yes) { | 331 | if (messageBox.exec() == QMessageBox::Yes) { |
327 | m_pDrawPadCanvas->deletePage(); | 332 | m_pDrawPadCanvas->deletePage(); |
328 | } | 333 | } |
329 | } | 334 | } |
330 | 335 | ||
331 | void DrawPad::setPointTool() | 336 | void DrawPad::setPointTool() |
332 | { | 337 | { |
333 | if (m_pTool) { | 338 | if (m_pTool) { |
334 | delete m_pTool; | 339 | delete m_pTool; |
335 | } | 340 | } |
336 | 341 | ||
337 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 342 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
338 | 343 | ||
339 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 344 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
@@ -558,64 +563,88 @@ void DrawPad::updateCaption() | |||
558 | 563 | ||
559 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 564 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
560 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 565 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
561 | } | 566 | } |
562 | 567 | ||
563 | void DrawPad::deleteAll() | 568 | void DrawPad::deleteAll() |
564 | { | 569 | { |
565 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 570 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
566 | QMessageBox::Information, QMessageBox::Yes, | 571 | QMessageBox::Information, QMessageBox::Yes, |
567 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 572 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
568 | QMessageBox::NoButton, this); | 573 | QMessageBox::NoButton, this); |
569 | 574 | ||
570 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 575 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
571 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 576 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
572 | 577 | ||
573 | if (messageBox.exec() == QMessageBox::Yes) { | 578 | if (messageBox.exec() == QMessageBox::Yes) { |
574 | m_pDrawPadCanvas->deleteAll(); | 579 | m_pDrawPadCanvas->deleteAll(); |
575 | } | 580 | } |
576 | } | 581 | } |
577 | 582 | ||
578 | void DrawPad::importPage() | 583 | void DrawPad::importPage() |
579 | { | 584 | { |
580 | ImportDialog importDialog(this); | 585 | ImportDialog importDialog(this); |
581 | 586 | ||
582 | importDialog.showMaximized(); | 587 | importDialog.showMaximized(); |
583 | 588 | ||
584 | if (importDialog.exec() == QDialog::Accepted) { | 589 | if (importDialog.exec() == QDialog::Accepted) { |
585 | const DocLnk* docLnk = importDialog.selected(); | 590 | const DocLnk* docLnk = importDialog.selected(); |
586 | 591 | ||
587 | if (docLnk) { | 592 | if (docLnk) { |
588 | m_pDrawPadCanvas->importPage(docLnk->file()); | 593 | m_pDrawPadCanvas->importPage(docLnk->file()); |
589 | delete docLnk; | 594 | delete docLnk; |
590 | } | 595 | } |
591 | } | 596 | } |
592 | } | 597 | } |
593 | 598 | ||
594 | void DrawPad::exportPage() | 599 | void DrawPad::exportPage() |
595 | { | 600 | { |
596 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 601 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
597 | 602 | ||
598 | exportDialog.showMaximized(); | 603 | exportDialog.showMaximized(); |
599 | 604 | ||
600 | if (exportDialog.exec() == QDialog::Accepted) { | 605 | if (exportDialog.exec() == QDialog::Accepted) { |
601 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 606 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
602 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 607 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
603 | } | 608 | } |
604 | } | 609 | } |
605 | 610 | ||
606 | void DrawPad::thumbnailView() | 611 | void DrawPad::thumbnailView() |
607 | { | 612 | { |
608 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 613 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
609 | 614 | ||
610 | thumbnailView.showMaximized(); | 615 | thumbnailView.showMaximized(); |
611 | thumbnailView.exec(); | 616 | thumbnailView.exec(); |
612 | } | 617 | } |
613 | 618 | ||
614 | void DrawPad::pageInformation() | 619 | void DrawPad::pageInformation() |
615 | { | 620 | { |
616 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 621 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
617 | 622 | ||
618 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 623 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
619 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 624 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
620 | } | 625 | } |
621 | } | 626 | } |
627 | |||
628 | void DrawPad::loadConfig() | ||
629 | { | ||
630 | Config config("drawpad"); | ||
631 | config.setGroup("General"); | ||
632 | |||
633 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); | ||
634 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); | ||
635 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); | ||
636 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); | ||
637 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); | ||
638 | } | ||
639 | |||
640 | void DrawPad::saveConfig() | ||
641 | { | ||
642 | Config config("drawpad"); | ||
643 | config.setGroup("General"); | ||
644 | |||
645 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); | ||
646 | config.writeEntry("AntiAliasing", antiAliasing()); | ||
647 | config.writeEntry("PenWidth", (int)m_pen.width()); | ||
648 | config.writeEntry("PenColor", m_pen.color().name()); | ||
649 | config.writeEntry("BrushColor", m_brush.color().name()); | ||
650 | } | ||
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index 8e29c61..c57606c 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -1,106 +1,112 @@ | |||
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 QSpinBox; | ||
26 | class QToolButton; | 27 | class QToolButton; |
27 | class QWidgetStack; | 28 | class QWidgetStack; |
28 | 29 | ||
29 | class DrawPad : public QMainWindow | 30 | class DrawPad : public QMainWindow |
30 | { | 31 | { |
31 | Q_OBJECT | 32 | Q_OBJECT |
32 | 33 | ||
33 | public: | 34 | public: |
34 | DrawPad(QWidget* parent = 0, const char* name = 0); | 35 | DrawPad(QWidget* parent = 0, const char* name = 0); |
35 | ~DrawPad(); | 36 | ~DrawPad(); |
36 | 37 | ||
37 | Tool* tool() { return m_pTool; } | 38 | Tool* tool() { return m_pTool; } |
38 | QPen pen() { return m_pen; } | 39 | QPen pen() { return m_pen; } |
39 | QBrush brush() { return m_brush; } | 40 | QBrush brush() { return m_brush; } |
40 | 41 | ||
41 | bool antiAliasing(); | 42 | bool antiAliasing(); |
42 | 43 | ||
43 | private slots: | 44 | private slots: |
44 | void newPage(); | 45 | void newPage(); |
45 | void clearPage(); | 46 | void clearPage(); |
46 | void deletePage(); | 47 | void deletePage(); |
47 | 48 | ||
48 | void setPointTool(); | 49 | void setPointTool(); |
49 | void setLineTool(); | 50 | void setLineTool(); |
50 | void setRectangleTool(); | 51 | void setRectangleTool(); |
51 | void setFilledRectangleTool(); | 52 | void setFilledRectangleTool(); |
52 | void setEllipseTool(); | 53 | void setEllipseTool(); |
53 | void setFilledEllipseTool(); | 54 | void setFilledEllipseTool(); |
54 | void setTextTool(); | 55 | void setTextTool(); |
55 | void setFillTool(); | 56 | void setFillTool(); |
56 | void setEraseTool(); | 57 | void setEraseTool(); |
57 | 58 | ||
58 | void changePenWidth(int value); | 59 | void changePenWidth(int value); |
59 | void changePenColor(const QColor& color); | 60 | void changePenColor(const QColor& color); |
60 | void changeBrushColor(const QColor& color); | 61 | void changeBrushColor(const QColor& color); |
61 | 62 | ||
62 | void updateUndoRedoToolButtons(); | 63 | void updateUndoRedoToolButtons(); |
63 | void updateNavigationToolButtons(); | 64 | void updateNavigationToolButtons(); |
64 | void updateCaption(); | 65 | void updateCaption(); |
65 | 66 | ||
66 | void deleteAll(); | 67 | void deleteAll(); |
67 | void importPage(); | 68 | void importPage(); |
68 | void exportPage(); | 69 | void exportPage(); |
69 | void thumbnailView(); | 70 | void thumbnailView(); |
70 | void pageInformation(); | 71 | void pageInformation(); |
71 | 72 | ||
72 | private: | 73 | private: |
74 | void loadConfig(); | ||
75 | void saveConfig(); | ||
76 | |||
73 | DrawPadCanvas* m_pDrawPadCanvas; | 77 | DrawPadCanvas* m_pDrawPadCanvas; |
74 | 78 | ||
75 | Tool* m_pTool; | 79 | Tool* m_pTool; |
76 | QPen m_pen; | 80 | QPen m_pen; |
77 | QBrush m_brush; | 81 | QBrush m_brush; |
78 | 82 | ||
79 | QAction* m_pAntiAliasingAction; | 83 | QAction* m_pAntiAliasingAction; |
80 | 84 | ||
81 | QAction* m_pUndoAction; | 85 | QAction* m_pUndoAction; |
82 | QAction* m_pRedoAction; | 86 | QAction* m_pRedoAction; |
83 | 87 | ||
84 | QAction* m_pFirstPageAction; | 88 | QAction* m_pFirstPageAction; |
85 | QAction* m_pPreviousPageAction; | 89 | QAction* m_pPreviousPageAction; |
86 | QAction* m_pNextPageAction; | 90 | QAction* m_pNextPageAction; |
87 | QAction* m_pLastPageAction; | 91 | QAction* m_pLastPageAction; |
88 | 92 | ||
89 | QAction* m_pPointToolAction; | 93 | QAction* m_pPointToolAction; |
90 | QAction* m_pLineToolAction; | 94 | QAction* m_pLineToolAction; |
91 | QAction* m_pRectangleToolAction; | 95 | QAction* m_pRectangleToolAction; |
92 | QAction* m_pFilledRectangleToolAction; | 96 | QAction* m_pFilledRectangleToolAction; |
93 | QAction* m_pEllipseToolAction; | 97 | QAction* m_pEllipseToolAction; |
94 | QAction* m_pFilledEllipseToolAction; | 98 | QAction* m_pFilledEllipseToolAction; |
95 | QAction* m_pTextToolAction; | 99 | QAction* m_pTextToolAction; |
96 | QAction* m_pFillToolAction; | 100 | QAction* m_pFillToolAction; |
97 | QAction* m_pEraseToolAction; | 101 | QAction* m_pEraseToolAction; |
98 | 102 | ||
99 | QToolButton* m_pLineToolButton; | 103 | QToolButton* m_pLineToolButton; |
100 | QToolButton* m_pRectangleToolButton; | 104 | QToolButton* m_pRectangleToolButton; |
101 | QToolButton* m_pEllipseToolButton; | 105 | QToolButton* m_pEllipseToolButton; |
102 | QToolButton* m_pPenColorToolButton; | 106 | QToolButton* m_pPenColorToolButton; |
103 | QToolButton* m_pBrushColorToolButton; | 107 | QToolButton* m_pBrushColorToolButton; |
108 | |||
109 | QSpinBox* m_pPenWidthSpinBox; | ||
104 | }; | 110 | }; |
105 | 111 | ||
106 | #endif // DRAWPAD_H | 112 | #endif // DRAWPAD_H |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 5437068..05dd408 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -285,128 +285,141 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c | |||
285 | docLnk.setName(name); | 285 | docLnk.setName(name); |
286 | docLnk.setType(mimeType.id()); | 286 | docLnk.setType(mimeType.id()); |
287 | 287 | ||
288 | FileManager fileManager; | 288 | FileManager fileManager; |
289 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 289 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
290 | QImageIO imageIO(ioDevice, format); | 290 | QImageIO imageIO(ioDevice, format); |
291 | 291 | ||
292 | QImage image = m_pages.current()->convertToImage(); | 292 | QImage image = m_pages.current()->convertToImage(); |
293 | imageIO.setImage(image); | 293 | imageIO.setImage(image); |
294 | imageIO.write(); | 294 | imageIO.write(); |
295 | delete ioDevice; | 295 | delete ioDevice; |
296 | } else { | 296 | } else { |
297 | for (uint i = fromPage; i <= toPage; i++) { | 297 | for (uint i = fromPage; i <= toPage; i++) { |
298 | DocLnk docLnk; | 298 | DocLnk docLnk; |
299 | MimeType mimeType(format); | 299 | MimeType mimeType(format); |
300 | 300 | ||
301 | docLnk.setName(name + QString::number(i)); | 301 | docLnk.setName(name + QString::number(i)); |
302 | docLnk.setType(mimeType.id()); | 302 | docLnk.setType(mimeType.id()); |
303 | 303 | ||
304 | FileManager fileManager; | 304 | FileManager fileManager; |
305 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 305 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
306 | QImageIO imageIO(ioDevice, format); | 306 | QImageIO imageIO(ioDevice, format); |
307 | 307 | ||
308 | QImage image = m_pages.at(i - 1)->convertToImage(); | 308 | QImage image = m_pages.at(i - 1)->convertToImage(); |
309 | imageIO.setImage(image); | 309 | imageIO.setImage(image); |
310 | imageIO.write(); | 310 | imageIO.write(); |
311 | delete ioDevice; | 311 | delete ioDevice; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | Page* DrawPadCanvas::currentPage() | 316 | Page* DrawPadCanvas::currentPage() |
317 | { | 317 | { |
318 | return m_pages.current(); | 318 | return m_pages.current(); |
319 | } | 319 | } |
320 | 320 | ||
321 | QList<Page> DrawPadCanvas::pages() | 321 | QList<Page> DrawPadCanvas::pages() |
322 | { | 322 | { |
323 | return m_pages; | 323 | return m_pages; |
324 | } | 324 | } |
325 | 325 | ||
326 | uint DrawPadCanvas::pagePosition() | 326 | uint DrawPadCanvas::pagePosition() |
327 | { | 327 | { |
328 | return (m_pages.at() + 1); | 328 | return (m_pages.at() + 1); |
329 | } | 329 | } |
330 | 330 | ||
331 | uint DrawPadCanvas::pageCount() | 331 | uint DrawPadCanvas::pageCount() |
332 | { | 332 | { |
333 | return m_pages.count(); | 333 | return m_pages.count(); |
334 | } | 334 | } |
335 | 335 | ||
336 | void DrawPadCanvas::selectPage(Page* page) | 336 | void DrawPadCanvas::selectPage(Page* page) |
337 | { | 337 | { |
338 | m_pages.findRef(page); | 338 | m_pages.findRef(page); |
339 | m_pageBackups.clear(); | 339 | m_pageBackups.clear(); |
340 | m_pageBackups.append(new Page(*(m_pages.current()))); | 340 | m_pageBackups.append(new Page(*(m_pages.current()))); |
341 | 341 | ||
342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
343 | viewport()->update(); | 343 | viewport()->update(); |
344 | 344 | ||
345 | emit pagesChanged(); | 345 | emit pagesChanged(); |
346 | emit pageBackupsChanged(); | 346 | emit pageBackupsChanged(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void DrawPadCanvas::selectPage(uint pagePosition) | ||
350 | { | ||
351 | m_pages.at(pagePosition - 1); | ||
352 | m_pageBackups.clear(); | ||
353 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
354 | |||
355 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
356 | viewport()->update(); | ||
357 | |||
358 | emit pagesChanged(); | ||
359 | emit pageBackupsChanged(); | ||
360 | } | ||
361 | |||
349 | void DrawPadCanvas::backupPage() | 362 | void DrawPadCanvas::backupPage() |
350 | { | 363 | { |
351 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); | 364 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); |
352 | 365 | ||
353 | Page* currentBackup = m_pageBackups.current(); | 366 | Page* currentBackup = m_pageBackups.current(); |
354 | while (m_pageBackups.last() != currentBackup) { | 367 | while (m_pageBackups.last() != currentBackup) { |
355 | m_pageBackups.removeLast(); | 368 | m_pageBackups.removeLast(); |
356 | } | 369 | } |
357 | 370 | ||
358 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { | 371 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { |
359 | m_pageBackups.removeFirst(); | 372 | m_pageBackups.removeFirst(); |
360 | } | 373 | } |
361 | 374 | ||
362 | m_pageBackups.append(new Page(*(m_pages.current()))); | 375 | m_pageBackups.append(new Page(*(m_pages.current()))); |
363 | 376 | ||
364 | emit pageBackupsChanged(); | 377 | emit pageBackupsChanged(); |
365 | } | 378 | } |
366 | 379 | ||
367 | void DrawPadCanvas::deleteAll() | 380 | void DrawPadCanvas::deleteAll() |
368 | { | 381 | { |
369 | m_pages.clear(); | 382 | m_pages.clear(); |
370 | 383 | ||
371 | m_pages.append(new Page("", contentsRect().size())); | 384 | m_pages.append(new Page("", contentsRect().size())); |
372 | m_pages.current()->fill(Qt::white); | 385 | m_pages.current()->fill(Qt::white); |
373 | 386 | ||
374 | m_pageBackups.clear(); | 387 | m_pageBackups.clear(); |
375 | m_pageBackups.append(new Page(*(m_pages.current()))); | 388 | m_pageBackups.append(new Page(*(m_pages.current()))); |
376 | 389 | ||
377 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 390 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
378 | viewport()->update(); | 391 | viewport()->update(); |
379 | 392 | ||
380 | emit pagesChanged(); | 393 | emit pagesChanged(); |
381 | emit pageBackupsChanged(); | 394 | emit pageBackupsChanged(); |
382 | } | 395 | } |
383 | 396 | ||
384 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) | 397 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
385 | { | 398 | { |
386 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); | 399 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
387 | m_pages.current()->fill(color); | 400 | m_pages.current()->fill(color); |
388 | 401 | ||
389 | m_pageBackups.clear(); | 402 | m_pageBackups.clear(); |
390 | m_pageBackups.append(new Page(*(m_pages.current()))); | 403 | m_pageBackups.append(new Page(*(m_pages.current()))); |
391 | 404 | ||
392 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 405 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
393 | viewport()->update(); | 406 | viewport()->update(); |
394 | 407 | ||
395 | emit pagesChanged(); | 408 | emit pagesChanged(); |
396 | emit pageBackupsChanged(); | 409 | emit pageBackupsChanged(); |
397 | } | 410 | } |
398 | 411 | ||
399 | void DrawPadCanvas::clearPage() | 412 | void DrawPadCanvas::clearPage() |
400 | { | 413 | { |
401 | m_pages.current()->fill(Qt::white); | 414 | m_pages.current()->fill(Qt::white); |
402 | 415 | ||
403 | m_pageBackups.clear(); | 416 | m_pageBackups.clear(); |
404 | m_pageBackups.append(new Page(*(m_pages.current()))); | 417 | m_pageBackups.append(new Page(*(m_pages.current()))); |
405 | 418 | ||
406 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 419 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
407 | viewport()->update(); | 420 | viewport()->update(); |
408 | 421 | ||
409 | emit pageBackupsChanged(); | 422 | emit pageBackupsChanged(); |
410 | } | 423 | } |
411 | 424 | ||
412 | void DrawPadCanvas::deletePage() | 425 | void DrawPadCanvas::deletePage() |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index dcaff5c..2283e5e 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -1,85 +1,86 @@ | |||
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 DRAWPADCANVAS_H | 14 | #ifndef DRAWPADCANVAS_H |
15 | #define DRAWPADCANVAS_H | 15 | #define DRAWPADCANVAS_H |
16 | 16 | ||
17 | #include <qscrollview.h> | 17 | #include <qscrollview.h> |
18 | 18 | ||
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <qpointarray.h> | 20 | #include <qpointarray.h> |
21 | 21 | ||
22 | class DrawPad; | 22 | class DrawPad; |
23 | class Page; | 23 | class Page; |
24 | 24 | ||
25 | class DrawPadCanvas : public QScrollView | 25 | class DrawPadCanvas : public QScrollView |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); | 30 | DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); |
31 | ~DrawPadCanvas(); | 31 | ~DrawPadCanvas(); |
32 | 32 | ||
33 | void load(QIODevice* ioDevice); | 33 | void load(QIODevice* ioDevice); |
34 | void initialPage(); | 34 | void initialPage(); |
35 | void save(QIODevice* ioDevice); | 35 | void save(QIODevice* ioDevice); |
36 | 36 | ||
37 | void importPage(const QString& fileName); | 37 | void importPage(const QString& fileName); |
38 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); | 38 | void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); |
39 | 39 | ||
40 | bool undoEnabled(); | 40 | bool undoEnabled(); |
41 | bool redoEnabled(); | 41 | bool redoEnabled(); |
42 | bool goPreviousPageEnabled(); | 42 | bool goPreviousPageEnabled(); |
43 | bool goNextPageEnabled(); | 43 | bool goNextPageEnabled(); |
44 | 44 | ||
45 | Page* currentPage(); | 45 | Page* currentPage(); |
46 | QList<Page> pages(); | 46 | QList<Page> pages(); |
47 | uint pagePosition(); | 47 | uint pagePosition(); |
48 | uint pageCount(); | 48 | uint pageCount(); |
49 | 49 | ||
50 | void selectPage(Page* page); | 50 | void selectPage(Page* page); |
51 | void selectPage(uint pagePosition); | ||
51 | void backupPage(); | 52 | void backupPage(); |
52 | 53 | ||
53 | public slots: | 54 | public slots: |
54 | void deleteAll(); | 55 | void deleteAll(); |
55 | void newPage(QString title, uint width, uint height, const QColor& color); | 56 | void newPage(QString title, uint width, uint height, const QColor& color); |
56 | void clearPage(); | 57 | void clearPage(); |
57 | void deletePage(); | 58 | void deletePage(); |
58 | void movePageUp(); | 59 | void movePageUp(); |
59 | void movePageDown(); | 60 | void movePageDown(); |
60 | 61 | ||
61 | void undo(); | 62 | void undo(); |
62 | void redo(); | 63 | void redo(); |
63 | 64 | ||
64 | void goFirstPage(); | 65 | void goFirstPage(); |
65 | void goPreviousPage(); | 66 | void goPreviousPage(); |
66 | void goNextPage(); | 67 | void goNextPage(); |
67 | void goLastPage(); | 68 | void goLastPage(); |
68 | 69 | ||
69 | signals: | 70 | signals: |
70 | void pagesChanged(); | 71 | void pagesChanged(); |
71 | void pageBackupsChanged(); | 72 | void pageBackupsChanged(); |
72 | 73 | ||
73 | protected: | 74 | protected: |
74 | void contentsMousePressEvent(QMouseEvent* e); | 75 | void contentsMousePressEvent(QMouseEvent* e); |
75 | void contentsMouseReleaseEvent(QMouseEvent* e); | 76 | void contentsMouseReleaseEvent(QMouseEvent* e); |
76 | void contentsMouseMoveEvent(QMouseEvent* e); | 77 | void contentsMouseMoveEvent(QMouseEvent* e); |
77 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); | 78 | void drawContents(QPainter* p, int cx, int cy, int cw, int ch); |
78 | 79 | ||
79 | private: | 80 | private: |
80 | DrawPad* m_pDrawPad; | 81 | DrawPad* m_pDrawPad; |
81 | QList<Page> m_pages; | 82 | QList<Page> m_pages; |
82 | QList<Page> m_pageBackups; | 83 | QList<Page> m_pageBackups; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | #endif // DRAWPADCANVAS_H | 86 | #endif // DRAWPADCANVAS_H |