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