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