summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 139c752..9f0e27f 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,664 +1,663 @@
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/config.h>
38#include <qpe/global.h>
39#include <qpe/qpetoolbar.h> 38#include <qpe/qpetoolbar.h>
40#include <qpe/resource.h> 39#include <qpe/resource.h>
41#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
42 41
43#include <qmenubar.h> 42#include <qmenubar.h>
44#include <qaction.h> 43#include <qaction.h>
45#include <qfile.h> 44#include <qfile.h>
46#include <qmessagebox.h> 45#include <qmessagebox.h>
47#include <qspinbox.h> 46#include <qspinbox.h>
48#include <qtoolbutton.h> 47#include <qtoolbutton.h>
49#include <qtooltip.h> 48#include <qtooltip.h>
50#include <qwhatsthis.h> 49#include <qwhatsthis.h>
51 50
52DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) 51DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl )
53 : QMainWindow(parent, name, WStyle_ContextHelp) 52 : QMainWindow(parent, name, WStyle_ContextHelp)
54{ 53{
55 // init members 54 // init members
56 55
57 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 56 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
58 57
59 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 58 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
60 59
61 setCentralWidget(m_pDrawPadCanvas); 60 setCentralWidget(m_pDrawPadCanvas);
62 61
63 // init menu 62 // init menu
64 63
65 setToolBarsMovable(false); 64 setToolBarsMovable(false);
66 65
67 QToolBar* menuToolBar = new QToolBar(this); 66 QToolBar* menuToolBar = new QToolBar(this);
68 QMenuBar* menuBar = new QMenuBar(menuToolBar); 67 QMenuBar* menuBar = new QMenuBar(menuToolBar);
69 68
70 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 69 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
71 70
72 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 71 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
73 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 72 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
74 deleteAllAction->addTo(toolsPopupMenu); 73 deleteAllAction->addTo(toolsPopupMenu);
75 74
76 toolsPopupMenu->insertSeparator(); 75 toolsPopupMenu->insertSeparator();
77 76
78 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 77 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
79 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 78 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
80 importPageAction->addTo(toolsPopupMenu); 79 importPageAction->addTo(toolsPopupMenu);
81 80
82 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); 81 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
83 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); 82 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
84 exportPageAction->addTo(toolsPopupMenu); 83 exportPageAction->addTo(toolsPopupMenu);
85 84
86 toolsPopupMenu->insertSeparator(); 85 toolsPopupMenu->insertSeparator();
87 86
88 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); 87 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
89 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); 88 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
90 thumbnailViewAction->addTo(toolsPopupMenu); 89 thumbnailViewAction->addTo(toolsPopupMenu);
91 90
92 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); 91 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
93 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); 92 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
94 pageInformationAction->addTo(toolsPopupMenu); 93 pageInformationAction->addTo(toolsPopupMenu);
95 94
96 toolsPopupMenu->insertSeparator(); 95 toolsPopupMenu->insertSeparator();
97 96
98 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); 97 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
99 m_pAntiAliasingAction->setToggleAction(true); 98 m_pAntiAliasingAction->setToggleAction(true);
100 m_pAntiAliasingAction->addTo(toolsPopupMenu); 99 m_pAntiAliasingAction->addTo(toolsPopupMenu);
101 100
102 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 101 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
103 102
104 // init page toolbar 103 // init page toolbar
105 104
106 QToolBar* pageToolBar = new QToolBar(this); 105 QToolBar* pageToolBar = new QToolBar(this);
107 106
108 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); 107 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this);
109 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); 108 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
110 newPageAction->addTo(pageToolBar); 109 newPageAction->addTo(pageToolBar);
111 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); 110 newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) );
112 111
113 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); 112 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this);
114 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); 113 connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage()));
115 clearPageAction->addTo(pageToolBar); 114 clearPageAction->addTo(pageToolBar);
116 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); 115 clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) );
117 116
118 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); 117 QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this);
119 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); 118 connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
120 deletePageAction->addTo(pageToolBar); 119 deletePageAction->addTo(pageToolBar);
121 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); 120 deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) );
122 121
123 QToolBar* emptyToolBar = new QToolBar(this); 122 QToolBar* emptyToolBar = new QToolBar(this);
124 emptyToolBar->setHorizontalStretchable(true); 123 emptyToolBar->setHorizontalStretchable(true);
125 124
126 // init navigation toolbar 125 // init navigation toolbar
127 126
128 QToolBar* navigationToolBar = new QToolBar(this); 127 QToolBar* navigationToolBar = new QToolBar(this);
129 128
130 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); 129 m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this);
131 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); 130 connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
132 m_pUndoAction->addTo(navigationToolBar); 131 m_pUndoAction->addTo(navigationToolBar);
133 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); 132 m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) );
134 133
135 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); 134 m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this);
136 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); 135 connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
137 m_pRedoAction->addTo(navigationToolBar); 136 m_pRedoAction->addTo(navigationToolBar);
138 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); 137 m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) );
139 138
140 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); 139 m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
141 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); 140 connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
142 m_pFirstPageAction->addTo(navigationToolBar); 141 m_pFirstPageAction->addTo(navigationToolBar);
143 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); 142 m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) );
144 143
145 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); 144 m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
146 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); 145 connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
147 m_pPreviousPageAction->addTo(navigationToolBar); 146 m_pPreviousPageAction->addTo(navigationToolBar);
148 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); 147 m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) );
149 148
150 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); 149 m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
151 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); 150 connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
152 m_pNextPageAction->addTo(navigationToolBar); 151 m_pNextPageAction->addTo(navigationToolBar);
153 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); 152 m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) );
154 153
155 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); 154 m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
156 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); 155 connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
157 m_pLastPageAction->addTo(navigationToolBar); 156 m_pLastPageAction->addTo(navigationToolBar);
158 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); 157 m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) );
159 158
160 // init draw mode toolbar 159 // init draw mode toolbar
161 160
162 QToolBar* drawModeToolBar = new QToolBar(this); 161 QToolBar* drawModeToolBar = new QToolBar(this);
163 162
164 m_pLineToolButton = new QToolButton(drawModeToolBar); 163 m_pLineToolButton = new QToolButton(drawModeToolBar);
165 m_pLineToolButton->setToggleButton(true); 164 m_pLineToolButton->setToggleButton(true);
166 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); 165 QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) );
167 166
168 167
169 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); 168 QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton);
170 169
171 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); 170 m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this);
172 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); 171 connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool()));
173 m_pPointToolAction->addTo(linePopupMenu); 172 m_pPointToolAction->addTo(linePopupMenu);
174 173
175 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); 174 m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this);
176 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); 175 connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool()));
177 m_pLineToolAction->addTo(linePopupMenu); 176 m_pLineToolAction->addTo(linePopupMenu);
178 177
179 m_pLineToolButton->setPopup(linePopupMenu); 178 m_pLineToolButton->setPopup(linePopupMenu);
180 m_pLineToolButton->setPopupDelay(0); 179 m_pLineToolButton->setPopupDelay(0);
181 180
182 m_pRectangleToolButton = new QToolButton(drawModeToolBar); 181 m_pRectangleToolButton = new QToolButton(drawModeToolBar);
183 m_pRectangleToolButton->setToggleButton(true); 182 m_pRectangleToolButton->setToggleButton(true);
184 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); 183 QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) );
185 184
186 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); 185 QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
187 186
188 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); 187 m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this);
189 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); 188 connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
190 m_pRectangleToolAction->addTo(rectanglePopupMenu); 189 m_pRectangleToolAction->addTo(rectanglePopupMenu);
191 190
192 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); 191 m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this);
193 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); 192 connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
194 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); 193 m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
195 194
196 m_pRectangleToolButton->setPopup(rectanglePopupMenu); 195 m_pRectangleToolButton->setPopup(rectanglePopupMenu);
197 m_pRectangleToolButton->setPopupDelay(0); 196 m_pRectangleToolButton->setPopupDelay(0);
198 197
199 m_pEllipseToolButton = new QToolButton(drawModeToolBar); 198 m_pEllipseToolButton = new QToolButton(drawModeToolBar);
200 m_pEllipseToolButton->setToggleButton(true); 199 m_pEllipseToolButton->setToggleButton(true);
201 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); 200 QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) );
202 201
203 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); 202 QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
204 203
205 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); 204 m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this);
206 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); 205 connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
207 m_pEllipseToolAction->addTo(ellipsePopupMenu); 206 m_pEllipseToolAction->addTo(ellipsePopupMenu);
208 207
209 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); 208 m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this);
210 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); 209 connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
211 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); 210 m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
212 211
213 m_pEllipseToolButton->setPopup(ellipsePopupMenu); 212 m_pEllipseToolButton->setPopup(ellipsePopupMenu);
214 m_pEllipseToolButton->setPopupDelay(0); 213 m_pEllipseToolButton->setPopupDelay(0);
215 214
216 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); 215 m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this);
217 m_pTextToolAction->setToggleAction(true); 216 m_pTextToolAction->setToggleAction(true);
218 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); 217 connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
219 m_pTextToolAction->addTo(drawModeToolBar); 218 m_pTextToolAction->addTo(drawModeToolBar);
220 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); 219 m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) );
221 220
222 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); 221 m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this);
223 m_pFillToolAction->setToggleAction(true); 222 m_pFillToolAction->setToggleAction(true);
224 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); 223 connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
225 m_pFillToolAction->addTo(drawModeToolBar); 224 m_pFillToolAction->addTo(drawModeToolBar);
226 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); 225 m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) );
227 226
228 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); 227 m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this);
229 m_pEraseToolAction->setToggleAction(true); 228 m_pEraseToolAction->setToggleAction(true);
230 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); 229 connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
231 m_pEraseToolAction->addTo(drawModeToolBar); 230 m_pEraseToolAction->addTo(drawModeToolBar);
232 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); 231 m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) );
233 232
234 m_pTool = 0; 233 m_pTool = 0;
235 setRectangleTool(); 234 setRectangleTool();
236 setEllipseTool(); 235 setEllipseTool();
237 setPointTool(); 236 setPointTool();
238 237
239 emptyToolBar = new QToolBar(this); 238 emptyToolBar = new QToolBar(this);
240 emptyToolBar->setHorizontalStretchable(true); 239 emptyToolBar->setHorizontalStretchable(true);
241 emptyToolBar->addSeparator(); 240 emptyToolBar->addSeparator();
242 241
243 // init draw parameters toolbar 242 // init draw parameters toolbar
244 243
245 QToolBar* drawParametersToolBar = new QToolBar(this); 244 QToolBar* drawParametersToolBar = new QToolBar(this);
246 245
247 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); 246 m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
248 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); 247 connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
249 248
250 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); 249 QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
251 m_pPenWidthSpinBox->setValue(1); 250 m_pPenWidthSpinBox->setValue(1);
252 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); 251 m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
253 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); 252 QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
254 253
255 m_pPenColorToolButton = new QToolButton(drawParametersToolBar); 254 m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
256 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); 255 m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
257 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); 256 QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
258 257
259 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); 258 OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton);
260 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); 259 connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
261 260
262 QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); 261 QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
263 m_pPenColorToolButton->setPopup(penColorPopupMenu); 262 m_pPenColorToolButton->setPopup(penColorPopupMenu);
264 m_pPenColorToolButton->setPopupDelay(0); 263 m_pPenColorToolButton->setPopupDelay(0);
265 264
266 changePenColor(Qt::black); 265 changePenColor(Qt::black);
267 266
268 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); 267 m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
269 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); 268 m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
270 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); 269 QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
271 270
272 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); 271 OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
273 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); 272 connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
274 273
275 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); 274 QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
276 m_pBrushColorToolButton->setPopup(brushColorPopupMenu); 275 m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
277 m_pBrushColorToolButton->setPopupDelay(0); 276 m_pBrushColorToolButton->setPopupDelay(0);
278 277
279 changeBrushColor(Qt::white); 278 changeBrushColor(Qt::white);
280 279
281 finishStartup(); 280 finishStartup();
282} 281}
283 282
284 283
285void DrawPad::finishStartup() 284void DrawPad::finishStartup()
286{ 285{
287 // init pages 286 // init pages
288 287
289 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 288 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
290 289
291 if (file.open(IO_ReadOnly)) { 290 if (file.open(IO_ReadOnly)) {
292 m_pDrawPadCanvas->load(&file); 291 m_pDrawPadCanvas->load(&file);
293 file.close(); 292 file.close();
294 } else { 293 } else {
295 m_pDrawPadCanvas->initialPage(); 294 m_pDrawPadCanvas->initialPage();
296 } 295 }
297 296
298 loadConfig(); 297 loadConfig();
299 298
300} 299}
301 300
302DrawPad::~DrawPad() 301DrawPad::~DrawPad()
303{ 302{
304 saveConfig(); 303 saveConfig();
305 304
306 QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); 305 QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
307 306
308 if (file.open(IO_WriteOnly)) { 307 if (file.open(IO_WriteOnly)) {
309 m_pDrawPadCanvas->save(&file); 308 m_pDrawPadCanvas->save(&file);
310 file.close(); 309 file.close();
311 } 310 }
312} 311}
313 312
314bool DrawPad::antiAliasing() 313bool DrawPad::antiAliasing()
315{ 314{
316 return (m_pAntiAliasingAction->isOn()); 315 return (m_pAntiAliasingAction->isOn());
317} 316}
318 317
319void DrawPad::newPage() 318void DrawPad::newPage()
320{ 319{
321 QRect rect = m_pDrawPadCanvas->contentsRect(); 320 QRect rect = m_pDrawPadCanvas->contentsRect();
322 321
323 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); 322 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
324 323
325 if (newPageDialog.exec() == QDialog::Accepted) { 324 if (newPageDialog.exec() == QDialog::Accepted) {
326 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), 325 m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
327 newPageDialog.selectedHeight(), newPageDialog.selectedColor()); 326 newPageDialog.selectedHeight(), newPageDialog.selectedColor());
328 } 327 }
329} 328}
330 329
331void DrawPad::clearPage() 330void DrawPad::clearPage()
332{ 331{
333 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), 332 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
334 QMessageBox::Information, QMessageBox::Yes, 333 QMessageBox::Information, QMessageBox::Yes,
335 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 334 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
336 QMessageBox::NoButton, this); 335 QMessageBox::NoButton, this);
337 336
338 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 337 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
339 messageBox.setButtonText(QMessageBox::No, tr("No")); 338 messageBox.setButtonText(QMessageBox::No, tr("No"));
340 339
341 if (messageBox.exec() == QMessageBox::Yes) { 340 if (messageBox.exec() == QMessageBox::Yes) {
342 m_pDrawPadCanvas->clearPage(); 341 m_pDrawPadCanvas->clearPage();
343 } 342 }
344} 343}
345 344
346void DrawPad::deletePage() 345void DrawPad::deletePage()
347{ 346{
348 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), 347 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
349 QMessageBox::Information, QMessageBox::Yes, 348 QMessageBox::Information, QMessageBox::Yes,
350 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 349 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
351 QMessageBox::NoButton, this); 350 QMessageBox::NoButton, this);
352 351
353 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 352 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
354 messageBox.setButtonText(QMessageBox::No, tr("No")); 353 messageBox.setButtonText(QMessageBox::No, tr("No"));
355 354
356 if (messageBox.exec() == QMessageBox::Yes) { 355 if (messageBox.exec() == QMessageBox::Yes) {
357 m_pDrawPadCanvas->deletePage(); 356 m_pDrawPadCanvas->deletePage();
358 } 357 }
359} 358}
360 359
361void DrawPad::setPointTool() 360void DrawPad::setPointTool()
362{ 361{
363 if (m_pTool) { 362 if (m_pTool) {
364 delete m_pTool; 363 delete m_pTool;
365 } 364 }
366 365
367 m_pTool = new PointTool(this, m_pDrawPadCanvas); 366 m_pTool = new PointTool(this, m_pDrawPadCanvas);
368 367
369 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); 368 m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet());
370 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); 369 QToolTip::add(m_pLineToolButton, m_pPointToolAction->text());
371 370
372 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 371 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
373 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); 372 connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated()));
374 373
375 m_pLineToolButton->setOn(true); 374 m_pLineToolButton->setOn(true);
376 m_pRectangleToolButton->setOn(false); 375 m_pRectangleToolButton->setOn(false);
377 m_pEllipseToolButton->setOn(false); 376 m_pEllipseToolButton->setOn(false);
378 m_pTextToolAction->setOn(false); 377 m_pTextToolAction->setOn(false);
379 m_pFillToolAction->setOn(false); 378 m_pFillToolAction->setOn(false);
380 m_pEraseToolAction->setOn(false); 379 m_pEraseToolAction->setOn(false);
381} 380}
382 381
383void DrawPad::setLineTool() 382void DrawPad::setLineTool()
384{ 383{
385 if (m_pTool) { 384 if (m_pTool) {
386 delete m_pTool; 385 delete m_pTool;
387 } 386 }
388 387
389 m_pTool = new LineTool(this, m_pDrawPadCanvas); 388 m_pTool = new LineTool(this, m_pDrawPadCanvas);
390 389
391 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); 390 m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet());
392 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); 391 QToolTip::add(m_pLineToolButton, m_pLineToolAction->text());
393 392
394 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); 393 disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
395 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); 394 connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated()));
396 395
397 m_pLineToolButton->setOn(true); 396 m_pLineToolButton->setOn(true);
398 m_pRectangleToolButton->setOn(false); 397 m_pRectangleToolButton->setOn(false);
399 m_pEllipseToolButton->setOn(false); 398 m_pEllipseToolButton->setOn(false);
400 m_pTextToolAction->setOn(false); 399 m_pTextToolAction->setOn(false);
401 m_pFillToolAction->setOn(false); 400 m_pFillToolAction->setOn(false);
402 m_pEraseToolAction->setOn(false); 401 m_pEraseToolAction->setOn(false);
403} 402}
404 403
405void DrawPad::setRectangleTool() 404void DrawPad::setRectangleTool()
406{ 405{
407 if (m_pTool) { 406 if (m_pTool) {
408 delete m_pTool; 407 delete m_pTool;
409 } 408 }
410 409
411 m_pTool = new RectangleTool(this, m_pDrawPadCanvas); 410 m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
412 411
413 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); 412 m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
414 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); 413 QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
415 414
416 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 415 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
417 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); 416 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
418 417
419 m_pLineToolButton->setOn(false); 418 m_pLineToolButton->setOn(false);
420 m_pRectangleToolButton->setOn(true); 419 m_pRectangleToolButton->setOn(true);
421 m_pEllipseToolButton->setOn(false); 420 m_pEllipseToolButton->setOn(false);
422 m_pTextToolAction->setOn(false); 421 m_pTextToolAction->setOn(false);
423 m_pFillToolAction->setOn(false); 422 m_pFillToolAction->setOn(false);
424 m_pEraseToolAction->setOn(false); 423 m_pEraseToolAction->setOn(false);
425} 424}
426 425
427void DrawPad::setFilledRectangleTool() 426void DrawPad::setFilledRectangleTool()
428{ 427{
429 if (m_pTool) { 428 if (m_pTool) {
430 delete m_pTool; 429 delete m_pTool;
431 } 430 }
432 431
433 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); 432 m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
434 433
435 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); 434 m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
436 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); 435 QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
437 436
438 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); 437 disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
439 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); 438 connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
440 439
441 m_pLineToolButton->setOn(false); 440 m_pLineToolButton->setOn(false);
442 m_pRectangleToolButton->setOn(true); 441 m_pRectangleToolButton->setOn(true);
443 m_pEllipseToolButton->setOn(false); 442 m_pEllipseToolButton->setOn(false);
444 m_pTextToolAction->setOn(false); 443 m_pTextToolAction->setOn(false);
445 m_pFillToolAction->setOn(false); 444 m_pFillToolAction->setOn(false);
446 m_pEraseToolAction->setOn(false); 445 m_pEraseToolAction->setOn(false);
447} 446}
448 447
449void DrawPad::setEllipseTool() 448void DrawPad::setEllipseTool()
450{ 449{
451 if (m_pTool) { 450 if (m_pTool) {
452 delete m_pTool; 451 delete m_pTool;
453 } 452 }
454 453
455 m_pTool = new EllipseTool(this, m_pDrawPadCanvas); 454 m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
456 455
457 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); 456 m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
458 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); 457 QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
459 458
460 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 459 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
461 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); 460 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
462 461
463 m_pLineToolButton->setOn(false); 462 m_pLineToolButton->setOn(false);
464 m_pRectangleToolButton->setOn(false); 463 m_pRectangleToolButton->setOn(false);
465 m_pEllipseToolButton->setOn(true); 464 m_pEllipseToolButton->setOn(true);
466 m_pTextToolAction->setOn(false); 465 m_pTextToolAction->setOn(false);
467 m_pFillToolAction->setOn(false); 466 m_pFillToolAction->setOn(false);
468 m_pEraseToolAction->setOn(false); 467 m_pEraseToolAction->setOn(false);
469} 468}
470 469
471void DrawPad::setFilledEllipseTool() 470void DrawPad::setFilledEllipseTool()
472{ 471{
473 if (m_pTool) { 472 if (m_pTool) {
474 delete m_pTool; 473 delete m_pTool;
475 } 474 }
476 475
477 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); 476 m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
478 477
479 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); 478 m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
480 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); 479 QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
481 480
482 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); 481 disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
483 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); 482 connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
484 483
485 m_pLineToolButton->setOn(false); 484 m_pLineToolButton->setOn(false);
486 m_pRectangleToolButton->setOn(false); 485 m_pRectangleToolButton->setOn(false);
487 m_pEllipseToolButton->setOn(true); 486 m_pEllipseToolButton->setOn(true);
488 m_pTextToolAction->setOn(false); 487 m_pTextToolAction->setOn(false);
489 m_pFillToolAction->setOn(false); 488 m_pFillToolAction->setOn(false);
490 m_pEraseToolAction->setOn(false); 489 m_pEraseToolAction->setOn(false);
491} 490}
492 491
493void DrawPad::setTextTool() 492void DrawPad::setTextTool()
494{ 493{
495 if (m_pTool) { 494 if (m_pTool) {
496 delete m_pTool; 495 delete m_pTool;
497 } 496 }
498 497
499 m_pTool = new TextTool(this, m_pDrawPadCanvas); 498 m_pTool = new TextTool(this, m_pDrawPadCanvas);
500 499
501 m_pLineToolButton->setOn(false); 500 m_pLineToolButton->setOn(false);
502 m_pRectangleToolButton->setOn(false); 501 m_pRectangleToolButton->setOn(false);
503 m_pEllipseToolButton->setOn(false); 502 m_pEllipseToolButton->setOn(false);
504 m_pTextToolAction->setOn(true); 503 m_pTextToolAction->setOn(true);
505 m_pFillToolAction->setOn(false); 504 m_pFillToolAction->setOn(false);
506 m_pEraseToolAction->setOn(false); 505 m_pEraseToolAction->setOn(false);
507} 506}
508 507
509void DrawPad::setFillTool() 508void DrawPad::setFillTool()
510{ 509{
511 if (m_pTool) { 510 if (m_pTool) {
512 delete m_pTool; 511 delete m_pTool;
513 } 512 }
514 513
515 m_pTool = new FillTool(this, m_pDrawPadCanvas); 514 m_pTool = new FillTool(this, m_pDrawPadCanvas);
516 515
517 m_pLineToolButton->setOn(false); 516 m_pLineToolButton->setOn(false);
518 m_pRectangleToolButton->setOn(false); 517 m_pRectangleToolButton->setOn(false);
519 m_pEllipseToolButton->setOn(false); 518 m_pEllipseToolButton->setOn(false);
520 m_pTextToolAction->setOn(false); 519 m_pTextToolAction->setOn(false);
521 m_pFillToolAction->setOn(true); 520 m_pFillToolAction->setOn(true);
522 m_pEraseToolAction->setOn(false); 521 m_pEraseToolAction->setOn(false);
523} 522}
524 523
525void DrawPad::setEraseTool() 524void DrawPad::setEraseTool()
526{ 525{
527 if (m_pTool) { 526 if (m_pTool) {
528 delete m_pTool; 527 delete m_pTool;
529 } 528 }
530 529
531 m_pTool = new EraseTool(this, m_pDrawPadCanvas); 530 m_pTool = new EraseTool(this, m_pDrawPadCanvas);
532 531
533 m_pLineToolButton->setOn(false); 532 m_pLineToolButton->setOn(false);
534 m_pRectangleToolButton->setOn(false); 533 m_pRectangleToolButton->setOn(false);
535 m_pEllipseToolButton->setOn(false); 534 m_pEllipseToolButton->setOn(false);
536 m_pTextToolAction->setOn(false); 535 m_pTextToolAction->setOn(false);
537 m_pFillToolAction->setOn(false); 536 m_pFillToolAction->setOn(false);
538 m_pEraseToolAction->setOn(true); 537 m_pEraseToolAction->setOn(true);
539} 538}
540 539
541void DrawPad::changePenWidth(int value) 540void DrawPad::changePenWidth(int value)
542{ 541{
543 m_pen.setWidth(value); 542 m_pen.setWidth(value);
544} 543}
545 544
546void DrawPad::changePenColor(const QColor& color) 545void DrawPad::changePenColor(const QColor& color)
547{ 546{
548 m_pen.setColor(color); 547 m_pen.setColor(color);
549 548
550 QPainter painter; 549 QPainter painter;
551 painter.begin(m_pPenColorToolButton->pixmap()); 550 painter.begin(m_pPenColorToolButton->pixmap());
552 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 551 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
553 painter.end(); 552 painter.end();
554 553
555 m_pPenColorToolButton->popup()->hide(); 554 m_pPenColorToolButton->popup()->hide();
556} 555}
557 556
558void DrawPad::changeBrushColor(const QColor& color) 557void DrawPad::changeBrushColor(const QColor& color)
559{ 558{
560 m_brush = QBrush(color); 559 m_brush = QBrush(color);
561 560
562 QPainter painter; 561 QPainter painter;
563 painter.begin(m_pBrushColorToolButton->pixmap()); 562 painter.begin(m_pBrushColorToolButton->pixmap());
564 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 563 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
565 painter.end(); 564 painter.end();
566 565
567 m_pBrushColorToolButton->popup()->hide(); 566 m_pBrushColorToolButton->popup()->hide();
568} 567}
569 568
570void DrawPad::updateView() 569void DrawPad::updateView()
571{ 570{
572 uint pagePosition = m_pDrawPadCanvas->pagePosition(); 571 uint pagePosition = m_pDrawPadCanvas->pagePosition();
573 uint pageCount = m_pDrawPadCanvas->pageCount(); 572 uint pageCount = m_pDrawPadCanvas->pageCount();
574 573
575 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); 574 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) );
576 575
577 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); 576 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled());
578 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); 577 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled());
579 578
580 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 579 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
581 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 580 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
582 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 581 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
583 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 582 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
584} 583}
585 584
586void DrawPad::deleteAll() 585void DrawPad::deleteAll()
587{ 586{
588 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 587 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
589 QMessageBox::Information, QMessageBox::Yes, 588 QMessageBox::Information, QMessageBox::Yes,
590 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 589 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
591 QMessageBox::NoButton, this); 590 QMessageBox::NoButton, this);
592 591
593 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 592 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
594 messageBox.setButtonText(QMessageBox::No, tr("No")); 593 messageBox.setButtonText(QMessageBox::No, tr("No"));
595 594
596 if (messageBox.exec() == QMessageBox::Yes) { 595 if (messageBox.exec() == QMessageBox::Yes) {
597 m_pDrawPadCanvas->deleteAll(); 596 m_pDrawPadCanvas->deleteAll();
598 } 597 }
599} 598}
600 599
601void DrawPad::importPage() 600void DrawPad::importPage()
602{ 601{
603 ImportDialog importDialog(this); 602 ImportDialog importDialog(this);
604 603
605 if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) { 604 if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) {
606 const DocLnk* docLnk = importDialog.selected(); 605 const DocLnk* docLnk = importDialog.selected();
607 606
608 if (docLnk) { 607 if (docLnk) {
609 m_pDrawPadCanvas->importPage(docLnk->file()); 608 m_pDrawPadCanvas->importPage(docLnk->file());
610 delete docLnk; 609 delete docLnk;
611 } 610 }
612 } 611 }
613} 612}
614 613
615void DrawPad::exportPage() 614void DrawPad::exportPage()
616{ 615{
617 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); 616 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
618 617
619 if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) { 618 if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) {
620 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), 619 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
621 exportDialog.selectedName(), exportDialog.selectedFormat()); 620 exportDialog.selectedName(), exportDialog.selectedFormat());
622 } 621 }
623} 622}
624 623
625void DrawPad::thumbnailView() 624void DrawPad::thumbnailView()
626{ 625{
627 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); 626 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this);
628 627
629 QPEApplication::showWidget( &thumbnailView ); 628 QPEApplication::showWidget( &thumbnailView );
630 thumbnailView.exec(); 629 thumbnailView.exec();
631} 630}
632 631
633void DrawPad::pageInformation() 632void DrawPad::pageInformation()
634{ 633{
635 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); 634 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage());
636 635
637 if (pageInformationDialog.exec() == QDialog::Accepted) { 636 if (pageInformationDialog.exec() == QDialog::Accepted) {
638 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); 637 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
639 } 638 }
640} 639}
641 640
642void DrawPad::loadConfig() 641void DrawPad::loadConfig()
643{ 642{
644 Config config("drawpad"); 643 Config config("drawpad");
645 config.setGroup("General"); 644 config.setGroup("General");
646 645
647 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); 646 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
648 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); 647 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
649 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); 648 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
650 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); 649 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
651 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); 650 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
652} 651}
653 652
654void DrawPad::saveConfig() 653void DrawPad::saveConfig()
655{ 654{
656 Config config("drawpad"); 655 Config config("drawpad");
657 config.setGroup("General"); 656 config.setGroup("General");
658 657
659 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); 658 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
660 config.writeEntry("AntiAliasing", antiAliasing()); 659 config.writeEntry("AntiAliasing", antiAliasing());
661 config.writeEntry("PenWidth", (int)m_pen.width()); 660 config.writeEntry("PenWidth", (int)m_pen.width());
662 config.writeEntry("PenColor", m_pen.color().name()); 661 config.writeEntry("PenColor", m_pen.color().name());
663 config.writeEntry("BrushColor", m_brush.color().name()); 662 config.writeEntry("BrushColor", m_brush.color().name());
664} 663}