-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 53 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.cpp | 10 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 29 |
3 files changed, 59 insertions, 33 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index b0a414e..53db993 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,378 +1,398 @@ | |||
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 | 51 | ||
51 | DrawPad::DrawPad(QWidget* parent, const char* name) | 52 | DrawPad::DrawPad(QWidget* parent, const char* name) |
52 | : QMainWindow(parent, name) | 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 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 67 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
67 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 68 | QPEMenuBar* menuBar = new QPEMenuBar(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 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 106 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
106 | 107 | ||
107 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("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); |
111 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); | ||
110 | 112 | ||
111 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 113 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); |
112 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 114 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
113 | clearPageAction->addTo(pageToolBar); | 115 | clearPageAction->addTo(pageToolBar); |
116 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); | ||
114 | 117 | ||
115 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 118 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); |
116 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 119 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
117 | deletePageAction->addTo(pageToolBar); | 120 | deletePageAction->addTo(pageToolBar); |
121 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); | ||
118 | 122 | ||
119 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 123 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
120 | emptyToolBar->setHorizontalStretchable(true); | 124 | emptyToolBar->setHorizontalStretchable(true); |
121 | 125 | ||
122 | // init navigation toolbar | 126 | // init navigation toolbar |
123 | 127 | ||
124 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 128 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
125 | 129 | ||
126 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 130 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
127 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 131 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
128 | m_pUndoAction->addTo(navigationToolBar); | 132 | m_pUndoAction->addTo(navigationToolBar); |
133 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); | ||
129 | 134 | ||
130 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 135 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
131 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 136 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
132 | m_pRedoAction->addTo(navigationToolBar); | 137 | m_pRedoAction->addTo(navigationToolBar); |
138 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); | ||
133 | 139 | ||
134 | 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); |
135 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 141 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
136 | m_pFirstPageAction->addTo(navigationToolBar); | 142 | m_pFirstPageAction->addTo(navigationToolBar); |
143 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); | ||
137 | 144 | ||
138 | 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); |
139 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 146 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
140 | m_pPreviousPageAction->addTo(navigationToolBar); | 147 | m_pPreviousPageAction->addTo(navigationToolBar); |
148 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); | ||
141 | 149 | ||
142 | 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); |
143 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 151 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
144 | m_pNextPageAction->addTo(navigationToolBar); | 152 | m_pNextPageAction->addTo(navigationToolBar); |
153 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); | ||
145 | 154 | ||
146 | 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); |
147 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 156 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
148 | m_pLastPageAction->addTo(navigationToolBar); | 157 | m_pLastPageAction->addTo(navigationToolBar); |
158 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); | ||
149 | 159 | ||
150 | // init draw mode toolbar | 160 | // init draw mode toolbar |
151 | 161 | ||
152 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 162 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
153 | 163 | ||
154 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 164 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
155 | 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." ) ); | ||
167 | |||
156 | 168 | ||
157 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 169 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
158 | 170 | ||
159 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); | 171 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); |
160 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 172 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
161 | m_pPointToolAction->addTo(linePopupMenu); | 173 | m_pPointToolAction->addTo(linePopupMenu); |
162 | 174 | ||
163 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); | 175 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); |
164 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 176 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
165 | m_pLineToolAction->addTo(linePopupMenu); | 177 | m_pLineToolAction->addTo(linePopupMenu); |
166 | 178 | ||
167 | m_pLineToolButton->setPopup(linePopupMenu); | 179 | m_pLineToolButton->setPopup(linePopupMenu); |
168 | m_pLineToolButton->setPopupDelay(0); | 180 | m_pLineToolButton->setPopupDelay(0); |
169 | 181 | ||
170 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 182 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
171 | 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." ) ); | ||
172 | 185 | ||
173 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 186 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
174 | 187 | ||
175 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 188 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); |
176 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 189 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
177 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 190 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
178 | 191 | ||
179 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 192 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); |
180 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 193 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
181 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 194 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
182 | 195 | ||
183 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 196 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
184 | m_pRectangleToolButton->setPopupDelay(0); | 197 | m_pRectangleToolButton->setPopupDelay(0); |
185 | 198 | ||
186 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 199 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
187 | 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." ) ); | ||
188 | 202 | ||
189 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 203 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
190 | 204 | ||
191 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 205 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); |
192 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 206 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
193 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 207 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
194 | 208 | ||
195 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 209 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); |
196 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 210 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
197 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 211 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
198 | 212 | ||
199 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 213 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
200 | m_pEllipseToolButton->setPopupDelay(0); | 214 | m_pEllipseToolButton->setPopupDelay(0); |
201 | 215 | ||
202 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); | 216 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); |
203 | m_pTextToolAction->setToggleAction(true); | 217 | m_pTextToolAction->setToggleAction(true); |
204 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 218 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
205 | m_pTextToolAction->addTo(drawModeToolBar); | 219 | m_pTextToolAction->addTo(drawModeToolBar); |
220 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); | ||
206 | 221 | ||
207 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 222 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); |
208 | m_pFillToolAction->setToggleAction(true); | 223 | m_pFillToolAction->setToggleAction(true); |
209 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 224 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
210 | m_pFillToolAction->addTo(drawModeToolBar); | 225 | m_pFillToolAction->addTo(drawModeToolBar); |
226 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); | ||
211 | 227 | ||
212 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 228 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); |
213 | m_pEraseToolAction->setToggleAction(true); | 229 | m_pEraseToolAction->setToggleAction(true); |
214 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 230 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
215 | m_pEraseToolAction->addTo(drawModeToolBar); | 231 | m_pEraseToolAction->addTo(drawModeToolBar); |
232 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); | ||
216 | 233 | ||
217 | m_pTool = 0; | 234 | m_pTool = 0; |
218 | setRectangleTool(); | 235 | setRectangleTool(); |
219 | setEllipseTool(); | 236 | setEllipseTool(); |
220 | setPointTool(); | 237 | setPointTool(); |
221 | 238 | ||
222 | emptyToolBar = new QPEToolBar(this); | 239 | emptyToolBar = new QPEToolBar(this); |
223 | emptyToolBar->setHorizontalStretchable(true); | 240 | emptyToolBar->setHorizontalStretchable(true); |
224 | emptyToolBar->addSeparator(); | 241 | emptyToolBar->addSeparator(); |
225 | 242 | ||
226 | // init draw parameters toolbar | 243 | // init draw parameters toolbar |
227 | 244 | ||
228 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 245 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
229 | 246 | ||
230 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 247 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
231 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 248 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
232 | 249 | ||
233 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); | 250 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
234 | m_pPenWidthSpinBox->setValue(1); | 251 | m_pPenWidthSpinBox->setValue(1); |
235 | 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." ) ); | ||
236 | 254 | ||
237 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 255 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
238 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 256 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); |
257 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); | ||
239 | 258 | ||
240 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); | 259 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); |
241 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 260 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
242 | 261 | ||
243 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 262 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
244 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 263 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
245 | m_pPenColorToolButton->setPopupDelay(0); | 264 | m_pPenColorToolButton->setPopupDelay(0); |
246 | 265 | ||
247 | changePenColor(Qt::black); | 266 | changePenColor(Qt::black); |
248 | 267 | ||
249 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 268 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
250 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); | 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." ) ); | ||
251 | 271 | ||
252 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 272 | ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
253 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 273 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
254 | 274 | ||
255 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 275 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
256 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 276 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
257 | m_pBrushColorToolButton->setPopupDelay(0); | 277 | m_pBrushColorToolButton->setPopupDelay(0); |
258 | 278 | ||
259 | changeBrushColor(Qt::white); | 279 | changeBrushColor(Qt::white); |
260 | 280 | ||
261 | // init pages | 281 | // init pages |
262 | 282 | ||
263 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 283 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
264 | 284 | ||
265 | if (file.open(IO_ReadOnly)) { | 285 | if (file.open(IO_ReadOnly)) { |
266 | m_pDrawPadCanvas->load(&file); | 286 | m_pDrawPadCanvas->load(&file); |
267 | file.close(); | 287 | file.close(); |
268 | } else { | 288 | } else { |
269 | m_pDrawPadCanvas->initialPage(); | 289 | m_pDrawPadCanvas->initialPage(); |
270 | } | 290 | } |
271 | 291 | ||
272 | loadConfig(); | 292 | loadConfig(); |
273 | } | 293 | } |
274 | 294 | ||
275 | DrawPad::~DrawPad() | 295 | DrawPad::~DrawPad() |
276 | { | 296 | { |
277 | saveConfig(); | 297 | saveConfig(); |
278 | 298 | ||
279 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 299 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
280 | 300 | ||
281 | if (file.open(IO_WriteOnly)) { | 301 | if (file.open(IO_WriteOnly)) { |
282 | m_pDrawPadCanvas->save(&file); | 302 | m_pDrawPadCanvas->save(&file); |
283 | file.close(); | 303 | file.close(); |
284 | } | 304 | } |
285 | } | 305 | } |
286 | 306 | ||
287 | bool DrawPad::antiAliasing() | 307 | bool DrawPad::antiAliasing() |
288 | { | 308 | { |
289 | return (m_pAntiAliasingAction->isOn()); | 309 | return (m_pAntiAliasingAction->isOn()); |
290 | } | 310 | } |
291 | 311 | ||
292 | void DrawPad::newPage() | 312 | void DrawPad::newPage() |
293 | { | 313 | { |
294 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 314 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
295 | 315 | ||
296 | 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); |
297 | 317 | ||
298 | if (newPageDialog.exec() == QDialog::Accepted) { | 318 | if (newPageDialog.exec() == QDialog::Accepted) { |
299 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 319 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
300 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 320 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
301 | } | 321 | } |
302 | } | 322 | } |
303 | 323 | ||
304 | void DrawPad::clearPage() | 324 | void DrawPad::clearPage() |
305 | { | 325 | { |
306 | 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?"), |
307 | QMessageBox::Information, QMessageBox::Yes, | 327 | QMessageBox::Information, QMessageBox::Yes, |
308 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 328 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
309 | QMessageBox::NoButton, this); | 329 | QMessageBox::NoButton, this); |
310 | 330 | ||
311 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 331 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
312 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 332 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
313 | 333 | ||
314 | if (messageBox.exec() == QMessageBox::Yes) { | 334 | if (messageBox.exec() == QMessageBox::Yes) { |
315 | m_pDrawPadCanvas->clearPage(); | 335 | m_pDrawPadCanvas->clearPage(); |
316 | } | 336 | } |
317 | } | 337 | } |
318 | 338 | ||
319 | void DrawPad::deletePage() | 339 | void DrawPad::deletePage() |
320 | { | 340 | { |
321 | 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?"), |
322 | QMessageBox::Information, QMessageBox::Yes, | 342 | QMessageBox::Information, QMessageBox::Yes, |
323 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 343 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
324 | QMessageBox::NoButton, this); | 344 | QMessageBox::NoButton, this); |
325 | 345 | ||
326 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 346 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
327 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 347 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
328 | 348 | ||
329 | if (messageBox.exec() == QMessageBox::Yes) { | 349 | if (messageBox.exec() == QMessageBox::Yes) { |
330 | m_pDrawPadCanvas->deletePage(); | 350 | m_pDrawPadCanvas->deletePage(); |
331 | } | 351 | } |
332 | } | 352 | } |
333 | 353 | ||
334 | void DrawPad::setPointTool() | 354 | void DrawPad::setPointTool() |
335 | { | 355 | { |
336 | if (m_pTool) { | 356 | if (m_pTool) { |
337 | delete m_pTool; | 357 | delete m_pTool; |
338 | } | 358 | } |
339 | 359 | ||
340 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 360 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
341 | 361 | ||
342 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 362 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
343 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); | 363 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
344 | 364 | ||
345 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 365 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
346 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | 366 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); |
347 | 367 | ||
348 | m_pLineToolButton->setOn(true); | 368 | m_pLineToolButton->setOn(true); |
349 | m_pRectangleToolButton->setOn(false); | 369 | m_pRectangleToolButton->setOn(false); |
350 | m_pEllipseToolButton->setOn(false); | 370 | m_pEllipseToolButton->setOn(false); |
351 | m_pTextToolAction->setOn(false); | 371 | m_pTextToolAction->setOn(false); |
352 | m_pFillToolAction->setOn(false); | 372 | m_pFillToolAction->setOn(false); |
353 | m_pEraseToolAction->setOn(false); | 373 | m_pEraseToolAction->setOn(false); |
354 | } | 374 | } |
355 | 375 | ||
356 | void DrawPad::setLineTool() | 376 | void DrawPad::setLineTool() |
357 | { | 377 | { |
358 | if (m_pTool) { | 378 | if (m_pTool) { |
359 | delete m_pTool; | 379 | delete m_pTool; |
360 | } | 380 | } |
361 | 381 | ||
362 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 382 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
363 | 383 | ||
364 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); | 384 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
365 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); | 385 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
366 | 386 | ||
367 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 387 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
368 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | 388 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); |
369 | 389 | ||
370 | m_pLineToolButton->setOn(true); | 390 | m_pLineToolButton->setOn(true); |
371 | m_pRectangleToolButton->setOn(false); | 391 | m_pRectangleToolButton->setOn(false); |
372 | m_pEllipseToolButton->setOn(false); | 392 | m_pEllipseToolButton->setOn(false); |
373 | m_pTextToolAction->setOn(false); | 393 | m_pTextToolAction->setOn(false); |
374 | m_pFillToolAction->setOn(false); | 394 | m_pFillToolAction->setOn(false); |
375 | m_pEraseToolAction->setOn(false); | 395 | m_pEraseToolAction->setOn(false); |
376 | } | 396 | } |
377 | 397 | ||
378 | void DrawPad::setRectangleTool() | 398 | void DrawPad::setRectangleTool() |
@@ -420,223 +440,222 @@ void DrawPad::setFilledRectangleTool() | |||
420 | } | 440 | } |
421 | 441 | ||
422 | void DrawPad::setEllipseTool() | 442 | void DrawPad::setEllipseTool() |
423 | { | 443 | { |
424 | if (m_pTool) { | 444 | if (m_pTool) { |
425 | delete m_pTool; | 445 | delete m_pTool; |
426 | } | 446 | } |
427 | 447 | ||
428 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 448 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
429 | 449 | ||
430 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 450 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
431 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 451 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
432 | 452 | ||
433 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 453 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
434 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 454 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
435 | 455 | ||
436 | m_pLineToolButton->setOn(false); | 456 | m_pLineToolButton->setOn(false); |
437 | m_pRectangleToolButton->setOn(false); | 457 | m_pRectangleToolButton->setOn(false); |
438 | m_pEllipseToolButton->setOn(true); | 458 | m_pEllipseToolButton->setOn(true); |
439 | m_pTextToolAction->setOn(false); | 459 | m_pTextToolAction->setOn(false); |
440 | m_pFillToolAction->setOn(false); | 460 | m_pFillToolAction->setOn(false); |
441 | m_pEraseToolAction->setOn(false); | 461 | m_pEraseToolAction->setOn(false); |
442 | } | 462 | } |
443 | 463 | ||
444 | void DrawPad::setFilledEllipseTool() | 464 | void DrawPad::setFilledEllipseTool() |
445 | { | 465 | { |
446 | if (m_pTool) { | 466 | if (m_pTool) { |
447 | delete m_pTool; | 467 | delete m_pTool; |
448 | } | 468 | } |
449 | 469 | ||
450 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 470 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
451 | 471 | ||
452 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 472 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
453 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 473 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
454 | 474 | ||
455 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 475 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
456 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 476 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
457 | 477 | ||
458 | m_pLineToolButton->setOn(false); | 478 | m_pLineToolButton->setOn(false); |
459 | m_pRectangleToolButton->setOn(false); | 479 | m_pRectangleToolButton->setOn(false); |
460 | m_pEllipseToolButton->setOn(true); | 480 | m_pEllipseToolButton->setOn(true); |
461 | m_pTextToolAction->setOn(false); | 481 | m_pTextToolAction->setOn(false); |
462 | m_pFillToolAction->setOn(false); | 482 | m_pFillToolAction->setOn(false); |
463 | m_pEraseToolAction->setOn(false); | 483 | m_pEraseToolAction->setOn(false); |
464 | } | 484 | } |
465 | 485 | ||
466 | void DrawPad::setTextTool() | 486 | void DrawPad::setTextTool() |
467 | { | 487 | { |
468 | if (m_pTool) { | 488 | if (m_pTool) { |
469 | delete m_pTool; | 489 | delete m_pTool; |
470 | } | 490 | } |
471 | 491 | ||
472 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 492 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
473 | 493 | ||
474 | m_pLineToolButton->setOn(false); | 494 | m_pLineToolButton->setOn(false); |
475 | m_pRectangleToolButton->setOn(false); | 495 | m_pRectangleToolButton->setOn(false); |
476 | m_pEllipseToolButton->setOn(false); | 496 | m_pEllipseToolButton->setOn(false); |
477 | m_pTextToolAction->setOn(true); | 497 | m_pTextToolAction->setOn(true); |
478 | m_pFillToolAction->setOn(false); | 498 | m_pFillToolAction->setOn(false); |
479 | m_pEraseToolAction->setOn(false); | 499 | m_pEraseToolAction->setOn(false); |
480 | } | 500 | } |
481 | 501 | ||
482 | void DrawPad::setFillTool() | 502 | void DrawPad::setFillTool() |
483 | { | 503 | { |
484 | if (m_pTool) { | 504 | if (m_pTool) { |
485 | delete m_pTool; | 505 | delete m_pTool; |
486 | } | 506 | } |
487 | 507 | ||
488 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 508 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
489 | 509 | ||
490 | m_pLineToolButton->setOn(false); | 510 | m_pLineToolButton->setOn(false); |
491 | m_pRectangleToolButton->setOn(false); | 511 | m_pRectangleToolButton->setOn(false); |
492 | m_pEllipseToolButton->setOn(false); | 512 | m_pEllipseToolButton->setOn(false); |
493 | m_pTextToolAction->setOn(false); | 513 | m_pTextToolAction->setOn(false); |
494 | m_pFillToolAction->setOn(true); | 514 | m_pFillToolAction->setOn(true); |
495 | m_pEraseToolAction->setOn(false); | 515 | m_pEraseToolAction->setOn(false); |
496 | } | 516 | } |
497 | 517 | ||
498 | void DrawPad::setEraseTool() | 518 | void DrawPad::setEraseTool() |
499 | { | 519 | { |
500 | if (m_pTool) { | 520 | if (m_pTool) { |
501 | delete m_pTool; | 521 | delete m_pTool; |
502 | } | 522 | } |
503 | 523 | ||
504 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 524 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
505 | 525 | ||
506 | m_pLineToolButton->setOn(false); | 526 | m_pLineToolButton->setOn(false); |
507 | m_pRectangleToolButton->setOn(false); | 527 | m_pRectangleToolButton->setOn(false); |
508 | m_pEllipseToolButton->setOn(false); | 528 | m_pEllipseToolButton->setOn(false); |
509 | m_pTextToolAction->setOn(false); | 529 | m_pTextToolAction->setOn(false); |
510 | m_pFillToolAction->setOn(false); | 530 | m_pFillToolAction->setOn(false); |
511 | m_pEraseToolAction->setOn(true); | 531 | m_pEraseToolAction->setOn(true); |
512 | } | 532 | } |
513 | 533 | ||
514 | void DrawPad::changePenWidth(int value) | 534 | void DrawPad::changePenWidth(int value) |
515 | { | 535 | { |
516 | m_pen.setWidth(value); | 536 | m_pen.setWidth(value); |
517 | } | 537 | } |
518 | 538 | ||
519 | void DrawPad::changePenColor(const QColor& color) | 539 | void DrawPad::changePenColor(const QColor& color) |
520 | { | 540 | { |
521 | m_pen.setColor(color); | 541 | m_pen.setColor(color); |
522 | 542 | ||
523 | QPainter painter; | 543 | QPainter painter; |
524 | painter.begin(m_pPenColorToolButton->pixmap()); | 544 | painter.begin(m_pPenColorToolButton->pixmap()); |
525 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 545 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
526 | painter.end(); | 546 | painter.end(); |
527 | 547 | ||
528 | m_pPenColorToolButton->popup()->hide(); | 548 | m_pPenColorToolButton->popup()->hide(); |
529 | } | 549 | } |
530 | 550 | ||
531 | void DrawPad::changeBrushColor(const QColor& color) | 551 | void DrawPad::changeBrushColor(const QColor& color) |
532 | { | 552 | { |
533 | m_brush = QBrush(color); | 553 | m_brush = QBrush(color); |
534 | 554 | ||
535 | QPainter painter; | 555 | QPainter painter; |
536 | painter.begin(m_pBrushColorToolButton->pixmap()); | 556 | painter.begin(m_pBrushColorToolButton->pixmap()); |
537 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 557 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
538 | painter.end(); | 558 | painter.end(); |
539 | 559 | ||
540 | m_pBrushColorToolButton->popup()->hide(); | 560 | m_pBrushColorToolButton->popup()->hide(); |
541 | } | 561 | } |
542 | 562 | ||
543 | void DrawPad::updateView() | 563 | void DrawPad::updateView() |
544 | { | 564 | { |
545 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 565 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
546 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 566 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
547 | 567 | ||
548 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 568 | setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); |
549 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | ||
550 | 569 | ||
551 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); | 570 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); |
552 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); | 571 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); |
553 | 572 | ||
554 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 573 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
555 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 574 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
556 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 575 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
557 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 576 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
558 | } | 577 | } |
559 | 578 | ||
560 | void DrawPad::deleteAll() | 579 | void DrawPad::deleteAll() |
561 | { | 580 | { |
562 | 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?"), |
563 | QMessageBox::Information, QMessageBox::Yes, | 582 | QMessageBox::Information, QMessageBox::Yes, |
564 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 583 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
565 | QMessageBox::NoButton, this); | 584 | QMessageBox::NoButton, this); |
566 | 585 | ||
567 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 586 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
568 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 587 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
569 | 588 | ||
570 | if (messageBox.exec() == QMessageBox::Yes) { | 589 | if (messageBox.exec() == QMessageBox::Yes) { |
571 | m_pDrawPadCanvas->deleteAll(); | 590 | m_pDrawPadCanvas->deleteAll(); |
572 | } | 591 | } |
573 | } | 592 | } |
574 | 593 | ||
575 | void DrawPad::importPage() | 594 | void DrawPad::importPage() |
576 | { | 595 | { |
577 | ImportDialog importDialog(this); | 596 | ImportDialog importDialog(this); |
578 | 597 | ||
579 | importDialog.showMaximized(); | 598 | importDialog.showMaximized(); |
580 | 599 | ||
581 | if (importDialog.exec() == QDialog::Accepted) { | 600 | if (importDialog.exec() == QDialog::Accepted) { |
582 | const DocLnk* docLnk = importDialog.selected(); | 601 | const DocLnk* docLnk = importDialog.selected(); |
583 | 602 | ||
584 | if (docLnk) { | 603 | if (docLnk) { |
585 | m_pDrawPadCanvas->importPage(docLnk->file()); | 604 | m_pDrawPadCanvas->importPage(docLnk->file()); |
586 | delete docLnk; | 605 | delete docLnk; |
587 | } | 606 | } |
588 | } | 607 | } |
589 | } | 608 | } |
590 | 609 | ||
591 | void DrawPad::exportPage() | 610 | void DrawPad::exportPage() |
592 | { | 611 | { |
593 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 612 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
594 | 613 | ||
595 | exportDialog.showMaximized(); | 614 | exportDialog.showMaximized(); |
596 | 615 | ||
597 | if (exportDialog.exec() == QDialog::Accepted) { | 616 | if (exportDialog.exec() == QDialog::Accepted) { |
598 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 617 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
599 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 618 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
600 | } | 619 | } |
601 | } | 620 | } |
602 | 621 | ||
603 | void DrawPad::thumbnailView() | 622 | void DrawPad::thumbnailView() |
604 | { | 623 | { |
605 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 624 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
606 | 625 | ||
607 | thumbnailView.showMaximized(); | 626 | thumbnailView.showMaximized(); |
608 | thumbnailView.exec(); | 627 | thumbnailView.exec(); |
609 | } | 628 | } |
610 | 629 | ||
611 | void DrawPad::pageInformation() | 630 | void DrawPad::pageInformation() |
612 | { | 631 | { |
613 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 632 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
614 | 633 | ||
615 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 634 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
616 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 635 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
617 | } | 636 | } |
618 | } | 637 | } |
619 | 638 | ||
620 | void DrawPad::loadConfig() | 639 | void DrawPad::loadConfig() |
621 | { | 640 | { |
622 | Config config("drawpad"); | 641 | Config config("drawpad"); |
623 | config.setGroup("General"); | 642 | config.setGroup("General"); |
624 | 643 | ||
625 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); | 644 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); |
626 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); | 645 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); |
627 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); | 646 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); |
628 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); | 647 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); |
629 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); | 648 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); |
630 | } | 649 | } |
631 | 650 | ||
632 | void DrawPad::saveConfig() | 651 | void DrawPad::saveConfig() |
633 | { | 652 | { |
634 | Config config("drawpad"); | 653 | Config config("drawpad"); |
635 | config.setGroup("General"); | 654 | config.setGroup("General"); |
636 | 655 | ||
637 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); | 656 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); |
638 | config.writeEntry("AntiAliasing", antiAliasing()); | 657 | config.writeEntry("AntiAliasing", antiAliasing()); |
639 | config.writeEntry("PenWidth", (int)m_pen.width()); | 658 | config.writeEntry("PenWidth", (int)m_pen.width()); |
640 | config.writeEntry("PenColor", m_pen.color().name()); | 659 | config.writeEntry("PenColor", m_pen.color().name()); |
641 | config.writeEntry("BrushColor", m_brush.color().name()); | 660 | config.writeEntry("BrushColor", m_brush.color().name()); |
642 | } | 661 | } |
diff --git a/noncore/graphics/drawpad/pageinformationdialog.cpp b/noncore/graphics/drawpad/pageinformationdialog.cpp index cb14d73..d769668 100644 --- a/noncore/graphics/drawpad/pageinformationdialog.cpp +++ b/noncore/graphics/drawpad/pageinformationdialog.cpp | |||
@@ -1,117 +1,117 @@ | |||
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 "pageinformationdialog.h" | 14 | #include "pageinformationdialog.h" |
15 | 15 | ||
16 | #include "page.h" | 16 | #include "page.h" |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/timestring.h> | 19 | #include <qpe/timestring.h> |
20 | 20 | ||
21 | #include <qgroupbox.h> | 21 | #include <qgroupbox.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qlayout.h> | 23 | #include <qlayout.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | 25 | ||
26 | PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const char* name) | 26 | PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const char* name) |
27 | : QDialog(parent, name, true) | 27 | : QDialog(parent, name, true) |
28 | { | 28 | { |
29 | m_pPage = page; | 29 | m_pPage = page; |
30 | 30 | ||
31 | setCaption(tr("Page Information")); | 31 | setCaption(tr("Page Information")); |
32 | 32 | ||
33 | QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); | 33 | QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); |
34 | 34 | ||
35 | QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); | 35 | QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); |
36 | 36 | ||
37 | m_pTitleLineEdit = new QLineEdit(generalGroupBox); | 37 | m_pTitleLineEdit = new QLineEdit(generalGroupBox); |
38 | m_pTitleLineEdit->setText(page->title()); | 38 | m_pTitleLineEdit->setText(page->title()); |
39 | 39 | ||
40 | QLabel* dateLabel = new QLabel(tr("Date:"), generalGroupBox); | 40 | QLabel* dateLabel = new QLabel(tr("Date:"), generalGroupBox); |
41 | QLabel* dateValueLabel = new QLabel(dateTimeString(m_pPage->lastModified()), generalGroupBox); | 41 | QLabel* dateValueLabel = new QLabel(dateTimeString(m_pPage->lastModified()), generalGroupBox); |
42 | 42 | ||
43 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); | 43 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); |
44 | 44 | ||
45 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); | 45 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); |
46 | QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->pixmap()->width()), sizeGroupBox); | 46 | QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->pixmap()->width()), sizeGroupBox); |
47 | 47 | ||
48 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); | 48 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); |
49 | QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->pixmap()->height()), sizeGroupBox); | 49 | QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->pixmap()->height()), sizeGroupBox); |
50 | 50 | ||
51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
52 | generalGroupBox->layout()->setSpacing(4); | 52 | generalGroupBox->layout()->setSpacing(4); |
53 | sizeGroupBox->layout()->setSpacing(4); | 53 | sizeGroupBox->layout()->setSpacing(4); |
54 | QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 2, 2); | 54 | QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 2, 2); |
55 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); | 55 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); |
56 | 56 | ||
57 | generalLayout->addWidget(titleLabel, 0, 0); | 57 | generalLayout->addWidget(titleLabel, 0, 0); |
58 | generalLayout->addWidget(m_pTitleLineEdit, 0, 1); | 58 | generalLayout->addWidget(m_pTitleLineEdit, 0, 1); |
59 | generalLayout->addWidget(dateLabel, 1, 0); | 59 | generalLayout->addWidget(dateLabel, 1, 0); |
60 | generalLayout->addWidget(dateValueLabel, 1, 1); | 60 | generalLayout->addWidget(dateValueLabel, 1, 1); |
61 | 61 | ||
62 | generalLayout->setColStretch(1, 1); | 62 | generalLayout->setColStretch(1, 1); |
63 | 63 | ||
64 | sizeLayout->addWidget(widthLabel, 0, 0); | 64 | sizeLayout->addWidget(widthLabel, 0, 0); |
65 | sizeLayout->addWidget(widthValueLabel, 0, 1); | 65 | sizeLayout->addWidget(widthValueLabel, 0, 1); |
66 | sizeLayout->addWidget(heightLabel, 1, 0); | 66 | sizeLayout->addWidget(heightLabel, 1, 0); |
67 | sizeLayout->addWidget(heightValueLabel, 1, 1); | 67 | sizeLayout->addWidget(heightValueLabel, 1, 1); |
68 | 68 | ||
69 | sizeLayout->setColStretch(1, 1); | 69 | sizeLayout->setColStretch(1, 1); |
70 | 70 | ||
71 | mainLayout->addWidget(generalGroupBox); | 71 | mainLayout->addWidget(generalGroupBox); |
72 | mainLayout->addWidget(sizeGroupBox); | 72 | mainLayout->addWidget(sizeGroupBox); |
73 | } | 73 | } |
74 | 74 | ||
75 | PageInformationDialog::~PageInformationDialog() | 75 | PageInformationDialog::~PageInformationDialog() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | QString PageInformationDialog::selectedTitle() | 79 | QString PageInformationDialog::selectedTitle() |
80 | { | 80 | { |
81 | return (m_pTitleLineEdit->text()); | 81 | return (m_pTitleLineEdit->text()); |
82 | } | 82 | } |
83 | 83 | ||
84 | QString PageInformationDialog::dateTimeString(QDateTime dateTime) | 84 | QString PageInformationDialog::dateTimeString(QDateTime dateTime) |
85 | { | 85 | { |
86 | QString result; | 86 | QString result; |
87 | 87 | ||
88 | Config config("qpe"); | 88 | Config config("qpe"); |
89 | config.setGroup("Date"); | 89 | config.setGroup("Date"); |
90 | 90 | ||
91 | QChar separator = config.readEntry("Separator", "/")[0]; | 91 | QChar separator = config.readEntry("Separator", "/")[0]; |
92 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); | 92 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); |
93 | 93 | ||
94 | for (int i = 0; i < 3; i++) { | 94 | for (int i = 0; i < 3; i++) { |
95 | switch((shortOrder >> (i * 3)) & 0x0007) { | 95 | switch((shortOrder >> (i * 3)) & 0x0007) { |
96 | case 0x0001: | 96 | case 0x0001: |
97 | result += QString().sprintf("%02d", dateTime.date().day()); | 97 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); |
98 | break; | 98 | break; |
99 | case 0x0002: | 99 | case 0x0002: |
100 | result += QString().sprintf("%02d", dateTime.date().month()); | 100 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); |
101 | break; | 101 | break; |
102 | case 0x0004: | 102 | case 0x0004: |
103 | result += QString().sprintf("%04d", dateTime.date().year()); | 103 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); |
104 | break; | 104 | break; |
105 | default: | 105 | default: |
106 | break; | 106 | break; |
107 | } | 107 | } |
108 | 108 | ||
109 | if (i < 2) { | 109 | if (i < 2) { |
110 | result += separator; | 110 | result.append( separator ); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()); | 114 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); |
115 | 115 | ||
116 | return result; | 116 | return result; |
117 | } | 117 | } |
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 9b08ca2..90ba39c 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -1,382 +1,389 @@ | |||
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 "thumbnailview.h" | 14 | #include "thumbnailview.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "newpagedialog.h" | 18 | #include "newpagedialog.h" |
19 | #include "page.h" | 19 | #include "page.h" |
20 | 20 | ||
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/timestring.h> | 23 | #include <qpe/timestring.h> |
24 | 24 | ||
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qwhatsthis.h> | ||
30 | 31 | ||
31 | #define THUMBNAIL_SIZE 48 | 32 | #define THUMBNAIL_SIZE 48 |
32 | 33 | ||
33 | PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | 34 | PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) |
34 | : QListBoxItem(parent) | 35 | : QListBoxItem(parent) |
35 | { | 36 | { |
36 | m_pPage = page; | 37 | m_pPage = page; |
37 | 38 | ||
38 | QImage image = m_pPage->pixmap()->convertToImage(); | 39 | QImage image = m_pPage->pixmap()->convertToImage(); |
39 | 40 | ||
40 | int previewWidth = THUMBNAIL_SIZE; | 41 | int previewWidth = THUMBNAIL_SIZE; |
41 | int previewHeight = THUMBNAIL_SIZE; | 42 | int previewHeight = THUMBNAIL_SIZE; |
42 | 43 | ||
43 | float widthScale = 1.0; | 44 | float widthScale = 1.0; |
44 | float heightScale = 1.0; | 45 | float heightScale = 1.0; |
45 | 46 | ||
46 | if (previewWidth < image.width()) { | 47 | if (previewWidth < image.width()) { |
47 | widthScale = (float)previewWidth / float(image.width()); | 48 | widthScale = (float)previewWidth / float(image.width()); |
48 | } | 49 | } |
49 | 50 | ||
50 | if (previewHeight < image.height()) { | 51 | if (previewHeight < image.height()) { |
51 | heightScale = (float)previewHeight / float(image.height()); | 52 | heightScale = (float)previewHeight / float(image.height()); |
52 | } | 53 | } |
53 | 54 | ||
54 | float scale = (widthScale < heightScale ? widthScale : heightScale); | 55 | float scale = (widthScale < heightScale ? widthScale : heightScale); |
55 | QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | 56 | QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); |
56 | 57 | ||
57 | m_thumbnail.convertFromImage(thumbnailImage); | 58 | m_thumbnail.convertFromImage(thumbnailImage); |
58 | 59 | ||
59 | m_titleText = QObject::tr("Title:") + " " + m_pPage->title(); | 60 | m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); |
60 | m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->pixmap()->width()) | 61 | m_dimensionText = QObject::tr( "Dimension: %1x%2" ). |
61 | + "x" + QString::number(m_pPage->pixmap()->height()); | 62 | arg( m_pPage->pixmap()->width() ). |
62 | m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); | 63 | arg( m_pPage->pixmap()->height() ); |
64 | m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); | ||
63 | 65 | ||
64 | QColor baseColor = parent->colorGroup().base(); | 66 | QColor baseColor = parent->colorGroup().base(); |
65 | int h, s, v; | 67 | int h, s, v; |
66 | baseColor.hsv(&h, &s, &v); | 68 | baseColor.hsv(&h, &s, &v); |
67 | 69 | ||
68 | if (v > 128) { | 70 | if (v > 128) { |
69 | m_alternateColor = baseColor.dark(115); | 71 | m_alternateColor = baseColor.dark(115); |
70 | } else if (baseColor != Qt::black) { | 72 | } else if (baseColor != Qt::black) { |
71 | m_alternateColor = baseColor.light(115); | 73 | m_alternateColor = baseColor.light(115); |
72 | } else { | 74 | } else { |
73 | m_alternateColor = QColor(32, 32, 32); | 75 | m_alternateColor = QColor(32, 32, 32); |
74 | } | 76 | } |
75 | } | 77 | } |
76 | 78 | ||
77 | PageListBoxItem::~PageListBoxItem() | 79 | PageListBoxItem::~PageListBoxItem() |
78 | { | 80 | { |
79 | } | 81 | } |
80 | 82 | ||
81 | int PageListBoxItem::height(const QListBox*) const | 83 | int PageListBoxItem::height(const QListBox*) const |
82 | { | 84 | { |
83 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); | 85 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); |
84 | } | 86 | } |
85 | 87 | ||
86 | int PageListBoxItem::width(const QListBox* lb) const | 88 | int PageListBoxItem::width(const QListBox* lb) const |
87 | { | 89 | { |
88 | QFontMetrics fontMetrics = lb->fontMetrics(); | 90 | QFontMetrics fontMetrics = lb->fontMetrics(); |
89 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), | 91 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), |
90 | QMAX(fontMetrics.width(m_dimensionText), | 92 | QMAX(fontMetrics.width(m_dimensionText), |
91 | fontMetrics.width(m_dateText))); | 93 | fontMetrics.width(m_dateText))); |
92 | 94 | ||
93 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); | 95 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); |
94 | } | 96 | } |
95 | 97 | ||
96 | void PageListBoxItem::paint(QPainter *painter) | 98 | void PageListBoxItem::paint(QPainter *painter) |
97 | { | 99 | { |
98 | QRect itemRect = listBox()->itemRect(this); | 100 | QRect itemRect = listBox()->itemRect(this); |
99 | 101 | ||
100 | if (!selected() && (listBox()->index(this) % 2)) { | 102 | if (!selected() && (listBox()->index(this) % 2)) { |
101 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); | 103 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); |
102 | } | 104 | } |
103 | 105 | ||
104 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, | 106 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, |
105 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, | 107 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, |
106 | m_thumbnail); | 108 | m_thumbnail); |
107 | 109 | ||
108 | QFont standardFont = painter->font(); | 110 | QFont standardFont = painter->font(); |
109 | QFont boldFont = painter->font(); | 111 | QFont boldFont = painter->font(); |
110 | boldFont.setBold(TRUE); | 112 | boldFont.setBold(TRUE); |
111 | 113 | ||
112 | QFontMetrics fontMetrics = painter->fontMetrics(); | 114 | QFontMetrics fontMetrics = painter->fontMetrics(); |
113 | QRect textRect(THUMBNAIL_SIZE + 6, 2, | 115 | QRect textRect(THUMBNAIL_SIZE + 6, 2, |
114 | itemRect.width() - THUMBNAIL_SIZE - 8, | 116 | itemRect.width() - THUMBNAIL_SIZE - 8, |
115 | itemRect.height() - 4); | 117 | itemRect.height() - 4); |
116 | 118 | ||
117 | painter->setFont(boldFont); | 119 | painter->setFont(boldFont); |
118 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); | 120 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); |
119 | 121 | ||
120 | painter->setFont(standardFont); | 122 | painter->setFont(standardFont); |
121 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); | 123 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); |
122 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); | 124 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); |
123 | 125 | ||
124 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { | 126 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { |
125 | painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); | 127 | painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | 130 | ||
129 | Page* PageListBoxItem::page() const | 131 | Page* PageListBoxItem::page() const |
130 | { | 132 | { |
131 | return m_pPage; | 133 | return m_pPage; |
132 | } | 134 | } |
133 | 135 | ||
134 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) | 136 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) |
135 | { | 137 | { |
136 | QString result; | 138 | QString result; |
137 | 139 | ||
138 | Config config("qpe"); | 140 | Config config("qpe"); |
139 | config.setGroup("Date"); | 141 | config.setGroup("Date"); |
140 | 142 | ||
141 | QChar separator = config.readEntry("Separator", "/")[0]; | 143 | QChar separator = config.readEntry("Separator", "/")[0]; |
142 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); | 144 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); |
143 | 145 | ||
144 | for (int i = 0; i < 3; i++) { | 146 | for (int i = 0; i < 3; i++) { |
145 | switch((shortOrder >> (i * 3)) & 0x0007) { | 147 | switch((shortOrder >> (i * 3)) & 0x0007) { |
146 | case 0x0001: | 148 | case 0x0001: |
147 | result += QString().sprintf("%02d", dateTime.date().day()); | 149 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); |
148 | break; | 150 | break; |
149 | case 0x0002: | 151 | case 0x0002: |
150 | result += QString().sprintf("%02d", dateTime.date().month()); | 152 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); |
151 | break; | 153 | break; |
152 | case 0x0004: | 154 | case 0x0004: |
153 | result += QString().sprintf("%04d", dateTime.date().year()); | 155 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); |
154 | break; | 156 | break; |
155 | default: | 157 | default: |
156 | break; | 158 | break; |
157 | } | 159 | } |
158 | 160 | ||
159 | if (i < 2) { | 161 | if (i < 2) { |
160 | result += separator; | 162 | result.append( separator ); |
161 | } | 163 | } |
162 | } | 164 | } |
163 | 165 | ||
164 | result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()); | 166 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); |
165 | 167 | ||
166 | return result; | 168 | return result; |
167 | } | 169 | } |
168 | 170 | ||
169 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 171 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
170 | : QListBox(parent, name) | 172 | : QListBox(parent, name) |
171 | { | 173 | { |
172 | m_pDrawPadCanvas = drawPadCanvas; | 174 | m_pDrawPadCanvas = drawPadCanvas; |
173 | 175 | ||
174 | setVScrollBarMode(QScrollView::AlwaysOn); | 176 | setVScrollBarMode(QScrollView::AlwaysOn); |
175 | 177 | ||
176 | updateView(); | 178 | updateView(); |
177 | } | 179 | } |
178 | 180 | ||
179 | PageListBox::~PageListBox() | 181 | PageListBox::~PageListBox() |
180 | { | 182 | { |
181 | } | 183 | } |
182 | 184 | ||
183 | void PageListBox::updateView() | 185 | void PageListBox::updateView() |
184 | { | 186 | { |
185 | clear(); | 187 | clear(); |
186 | 188 | ||
187 | if (m_pDrawPadCanvas) { | 189 | if (m_pDrawPadCanvas) { |
188 | QList<Page> pageList = m_pDrawPadCanvas->pages(); | 190 | QList<Page> pageList = m_pDrawPadCanvas->pages(); |
189 | QListIterator<Page> it(pageList); | 191 | QListIterator<Page> it(pageList); |
190 | 192 | ||
191 | for (; it.current(); ++it) { | 193 | for (; it.current(); ++it) { |
192 | new PageListBoxItem(it.current(), this); | 194 | new PageListBoxItem(it.current(), this); |
193 | } | 195 | } |
194 | 196 | ||
195 | select(m_pDrawPadCanvas->currentPage()); | 197 | select(m_pDrawPadCanvas->currentPage()); |
196 | } | 198 | } |
197 | } | 199 | } |
198 | 200 | ||
199 | void PageListBox::select(Page* page) | 201 | void PageListBox::select(Page* page) |
200 | { | 202 | { |
201 | uint i = 0; | 203 | uint i = 0; |
202 | uint itemCount = count(); | 204 | uint itemCount = count(); |
203 | 205 | ||
204 | while (i < itemCount) { | 206 | while (i < itemCount) { |
205 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); | 207 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); |
206 | 208 | ||
207 | if (currentItem->page() == page) { | 209 | if (currentItem->page() == page) { |
208 | setCurrentItem(currentItem); | 210 | setCurrentItem(currentItem); |
209 | break; | 211 | break; |
210 | } | 212 | } |
211 | 213 | ||
212 | i++; | 214 | i++; |
213 | } | 215 | } |
214 | } | 216 | } |
215 | 217 | ||
216 | Page* PageListBox::selected() const | 218 | Page* PageListBox::selected() const |
217 | { | 219 | { |
218 | Page* page; | 220 | Page* page; |
219 | 221 | ||
220 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); | 222 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); |
221 | 223 | ||
222 | if (selectedItem) { | 224 | if (selectedItem) { |
223 | page = selectedItem->page(); | 225 | page = selectedItem->page(); |
224 | } else { | 226 | } else { |
225 | page = NULL; | 227 | page = NULL; |
226 | } | 228 | } |
227 | 229 | ||
228 | return page; | 230 | return page; |
229 | } | 231 | } |
230 | 232 | ||
231 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 233 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
232 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) | 234 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) |
233 | { | 235 | { |
234 | inLoop = false; | 236 | inLoop = false; |
235 | 237 | ||
236 | m_pDrawPad = drawPad; | 238 | m_pDrawPad = drawPad; |
237 | m_pDrawPadCanvas = drawPadCanvas; | 239 | m_pDrawPadCanvas = drawPadCanvas; |
238 | 240 | ||
239 | setCaption(tr("DrawPad - Thumbnail View")); | 241 | setCaption(tr("DrawPad - Thumbnail View")); |
240 | 242 | ||
241 | QToolButton* newPageButton = new QToolButton(this); | 243 | QToolButton* newPageButton = new QToolButton(this); |
242 | newPageButton->setIconSet(Resource::loadIconSet("new")); | 244 | newPageButton->setIconSet(Resource::loadIconSet("new")); |
243 | newPageButton->setAutoRaise(true); | 245 | newPageButton->setAutoRaise(true); |
244 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); | 246 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); |
247 | QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); | ||
245 | 248 | ||
246 | QToolButton* clearPageButton = new QToolButton(this); | 249 | QToolButton* clearPageButton = new QToolButton(this); |
247 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | 250 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); |
248 | clearPageButton->setAutoRaise(true); | 251 | clearPageButton->setAutoRaise(true); |
249 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); | 252 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); |
253 | QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); | ||
250 | 254 | ||
251 | QToolButton* deletePageButton = new QToolButton(this); | 255 | QToolButton* deletePageButton = new QToolButton(this); |
252 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 256 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); |
253 | deletePageButton->setAutoRaise(true); | 257 | deletePageButton->setAutoRaise(true); |
254 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | 258 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); |
259 | QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); | ||
255 | 260 | ||
256 | m_pMovePageUpButton = new QToolButton(this); | 261 | m_pMovePageUpButton = new QToolButton(this); |
257 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); | 262 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); |
258 | m_pMovePageUpButton->setAutoRaise(true); | 263 | m_pMovePageUpButton->setAutoRaise(true); |
259 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); | 264 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); |
260 | 265 | QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); | |
266 | |||
261 | m_pMovePageDownButton = new QToolButton(this); | 267 | m_pMovePageDownButton = new QToolButton(this); |
262 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); | 268 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); |
263 | m_pMovePageDownButton->setAutoRaise(true); | 269 | m_pMovePageDownButton->setAutoRaise(true); |
264 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); | 270 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); |
271 | QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); | ||
265 | 272 | ||
266 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); | 273 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); |
267 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); | 274 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); |
268 | 275 | ||
269 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 276 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
270 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | 277 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); |
271 | 278 | ||
272 | buttonLayout->addWidget(newPageButton); | 279 | buttonLayout->addWidget(newPageButton); |
273 | buttonLayout->addWidget(clearPageButton); | 280 | buttonLayout->addWidget(clearPageButton); |
274 | buttonLayout->addWidget(deletePageButton); | 281 | buttonLayout->addWidget(deletePageButton); |
275 | buttonLayout->addStretch(); | 282 | buttonLayout->addStretch(); |
276 | buttonLayout->addWidget(m_pMovePageUpButton); | 283 | buttonLayout->addWidget(m_pMovePageUpButton); |
277 | buttonLayout->addWidget(m_pMovePageDownButton); | 284 | buttonLayout->addWidget(m_pMovePageDownButton); |
278 | 285 | ||
279 | mainLayout->addLayout(buttonLayout); | 286 | mainLayout->addLayout(buttonLayout); |
280 | mainLayout->addWidget(m_pPageListBox); | 287 | mainLayout->addWidget(m_pPageListBox); |
281 | 288 | ||
282 | updateView(); | 289 | updateView(); |
283 | } | 290 | } |
284 | 291 | ||
285 | ThumbnailView::~ThumbnailView() | 292 | ThumbnailView::~ThumbnailView() |
286 | { | 293 | { |
287 | hide(); | 294 | hide(); |
288 | } | 295 | } |
289 | 296 | ||
290 | void ThumbnailView::updateView() | 297 | void ThumbnailView::updateView() |
291 | { | 298 | { |
292 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 299 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
293 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 300 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
294 | } | 301 | } |
295 | 302 | ||
296 | void ThumbnailView::hide() | 303 | void ThumbnailView::hide() |
297 | { | 304 | { |
298 | QWidget::hide(); | 305 | QWidget::hide(); |
299 | 306 | ||
300 | if (inLoop) { | 307 | if (inLoop) { |
301 | inLoop = false; | 308 | inLoop = false; |
302 | qApp->exit_loop(); | 309 | qApp->exit_loop(); |
303 | } | 310 | } |
304 | } | 311 | } |
305 | 312 | ||
306 | void ThumbnailView::exec() | 313 | void ThumbnailView::exec() |
307 | { | 314 | { |
308 | show(); | 315 | show(); |
309 | 316 | ||
310 | if (!inLoop) { | 317 | if (!inLoop) { |
311 | inLoop = true; | 318 | inLoop = true; |
312 | qApp->enter_loop(); | 319 | qApp->enter_loop(); |
313 | } | 320 | } |
314 | } | 321 | } |
315 | 322 | ||
316 | void ThumbnailView::newPage() | 323 | void ThumbnailView::newPage() |
317 | { | 324 | { |
318 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 325 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
319 | 326 | ||
320 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 327 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
321 | m_pDrawPad->brush().color(), this); | 328 | m_pDrawPad->brush().color(), this); |
322 | 329 | ||
323 | if (newPageDialog.exec() == QDialog::Accepted) { | 330 | if (newPageDialog.exec() == QDialog::Accepted) { |
324 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 331 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
325 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 332 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
326 | m_pPageListBox->updateView(); | 333 | m_pPageListBox->updateView(); |
327 | updateView(); | 334 | updateView(); |
328 | } | 335 | } |
329 | } | 336 | } |
330 | 337 | ||
331 | void ThumbnailView::clearPage() | 338 | void ThumbnailView::clearPage() |
332 | { | 339 | { |
333 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), | 340 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), |
334 | QMessageBox::Information, QMessageBox::Yes, | 341 | QMessageBox::Information, QMessageBox::Yes, |
335 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 342 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
336 | QMessageBox::NoButton, this); | 343 | QMessageBox::NoButton, this); |
337 | 344 | ||
338 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 345 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
339 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 346 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
340 | 347 | ||
341 | if (messageBox.exec() == QMessageBox::Yes) { | 348 | if (messageBox.exec() == QMessageBox::Yes) { |
342 | m_pDrawPadCanvas->clearPage(); | 349 | m_pDrawPadCanvas->clearPage(); |
343 | m_pPageListBox->updateView(); | 350 | m_pPageListBox->updateView(); |
344 | } | 351 | } |
345 | } | 352 | } |
346 | 353 | ||
347 | void ThumbnailView::deletePage() | 354 | void ThumbnailView::deletePage() |
348 | { | 355 | { |
349 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), | 356 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), |
350 | QMessageBox::Information, QMessageBox::Yes, | 357 | QMessageBox::Information, QMessageBox::Yes, |
351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 358 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
352 | QMessageBox::NoButton, this); | 359 | QMessageBox::NoButton, this); |
353 | 360 | ||
354 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 361 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
355 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 362 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
356 | 363 | ||
357 | if (messageBox.exec() == QMessageBox::Yes) { | 364 | if (messageBox.exec() == QMessageBox::Yes) { |
358 | m_pDrawPadCanvas->deletePage(); | 365 | m_pDrawPadCanvas->deletePage(); |
359 | m_pPageListBox->updateView(); | 366 | m_pPageListBox->updateView(); |
360 | updateView(); | 367 | updateView(); |
361 | } | 368 | } |
362 | } | 369 | } |
363 | 370 | ||
364 | void ThumbnailView::movePageUp() | 371 | void ThumbnailView::movePageUp() |
365 | { | 372 | { |
366 | m_pDrawPadCanvas->movePageUp(); | 373 | m_pDrawPadCanvas->movePageUp(); |
367 | m_pPageListBox->updateView(); | 374 | m_pPageListBox->updateView(); |
368 | updateView(); | 375 | updateView(); |
369 | } | 376 | } |
370 | 377 | ||
371 | void ThumbnailView::movePageDown() | 378 | void ThumbnailView::movePageDown() |
372 | { | 379 | { |
373 | m_pDrawPadCanvas->movePageDown(); | 380 | m_pDrawPadCanvas->movePageDown(); |
374 | m_pPageListBox->updateView(); | 381 | m_pPageListBox->updateView(); |
375 | updateView(); | 382 | updateView(); |
376 | } | 383 | } |
377 | 384 | ||
378 | void ThumbnailView::changePage() | 385 | void ThumbnailView::changePage() |
379 | { | 386 | { |
380 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); | 387 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); |
381 | updateView(); | 388 | updateView(); |
382 | } | 389 | } |