author | drw <drw> | 2005-05-23 22:51:56 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-23 22:51:56 (UTC) |
commit | 71ecaf241641c2c58b997df56074cf4849e6d6c5 (patch) (unidiff) | |
tree | aec19a63d44027eec822775216d9b63e50ff4563 | |
parent | b153f9739d300b3bc608ea76968b818818fce1d0 (diff) | |
download | opie-71ecaf241641c2c58b997df56074cf4849e6d6c5.zip opie-71ecaf241641c2c58b997df56074cf4849e6d6c5.tar.gz opie-71ecaf241641c2c58b997df56074cf4849e6d6c5.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 85 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 22 |
2 files changed, 77 insertions, 30 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index c0f42d9..158a5ed 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,686 +1,725 @@ | |||
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 <opie2/qcolordialog.h> | 33 | #include <opie2/qcolordialog.h> |
34 | #include <opie2/ocolorpopupmenu.h> | 34 | #include <opie2/ocolorpopupmenu.h> |
35 | #include <opie2/oresource.h> | ||
35 | 36 | ||
36 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
38 | #include <qtoolbar.h> | 39 | #include <qtoolbar.h> |
39 | #include <qpe/resource.h> | ||
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | 41 | ||
42 | #include <qmenubar.h> | 42 | #include <qmenubar.h> |
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 <qspinbox.h> | 46 | #include <qspinbox.h> |
47 | #include <qtoolbutton.h> | 47 | #include <qtoolbutton.h> |
48 | #include <qtooltip.h> | 48 | #include <qtooltip.h> |
49 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
50 | 50 | ||
51 | using namespace Opie::Ui; | 51 | using namespace Opie::Ui; |
52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | 52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) |
53 | : QMainWindow(parent, name, WStyle_ContextHelp) | 53 | : QMainWindow(parent, name, WStyle_ContextHelp) |
54 | { | 54 | { |
55 | // init members | 55 | // init members |
56 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 56 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
57 | this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) ); | 57 | this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) ); |
58 | 58 | ||
59 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 59 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
60 | 60 | ||
61 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); | 61 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); |
62 | 62 | ||
63 | setCentralWidget(m_pDrawPadCanvas); | 63 | setCentralWidget(m_pDrawPadCanvas); |
64 | 64 | ||
65 | // init menu | 65 | // init menu |
66 | 66 | ||
67 | setToolBarsMovable(false); | 67 | setToolBarsMovable(false); |
68 | 68 | ||
69 | QToolBar* menuToolBar = new QToolBar(this); | 69 | QToolBar* menuToolBar = new QToolBar(this); |
70 | QMenuBar* menuBar = new QMenuBar(menuToolBar); | 70 | QMenuBar* menuBar = new QMenuBar(menuToolBar); |
71 | 71 | ||
72 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); | 72 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
73 | 73 | ||
74 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 74 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
75 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 75 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
76 | deleteAllAction->addTo(toolsPopupMenu); | 76 | deleteAllAction->addTo(toolsPopupMenu); |
77 | 77 | ||
78 | toolsPopupMenu->insertSeparator(); | 78 | toolsPopupMenu->insertSeparator(); |
79 | 79 | ||
80 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 80 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
81 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 81 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
82 | importPageAction->addTo(toolsPopupMenu); | 82 | importPageAction->addTo(toolsPopupMenu); |
83 | 83 | ||
84 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 84 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
85 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 85 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
86 | exportPageAction->addTo(toolsPopupMenu); | 86 | exportPageAction->addTo(toolsPopupMenu); |
87 | 87 | ||
88 | toolsPopupMenu->insertSeparator(); | 88 | toolsPopupMenu->insertSeparator(); |
89 | 89 | ||
90 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | 90 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); |
91 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 91 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
92 | thumbnailViewAction->addTo(toolsPopupMenu); | 92 | thumbnailViewAction->addTo(toolsPopupMenu); |
93 | 93 | ||
94 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | 94 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); |
95 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 95 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
96 | pageInformationAction->addTo(toolsPopupMenu); | 96 | pageInformationAction->addTo(toolsPopupMenu); |
97 | 97 | ||
98 | toolsPopupMenu->insertSeparator(); | 98 | toolsPopupMenu->insertSeparator(); |
99 | 99 | ||
100 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | 100 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); |
101 | m_pAntiAliasingAction->setToggleAction(true); | 101 | m_pAntiAliasingAction->setToggleAction(true); |
102 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | 102 | m_pAntiAliasingAction->addTo(toolsPopupMenu); |
103 | 103 | ||
104 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 104 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
105 | 105 | ||
106 | // init page toolbar | 106 | // init page toolbar |
107 | 107 | ||
108 | QToolBar* pageToolBar = new QToolBar(this); | 108 | QToolBar* pageToolBar = new QToolBar(this); |
109 | 109 | ||
110 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); | 110 | QAction* newPageAction = new QAction(tr("New Page"), Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon), |
111 | QString::null, 0, this); | ||
111 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 112 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
112 | newPageAction->addTo(pageToolBar); | 113 | newPageAction->addTo(pageToolBar); |
113 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); | 114 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); |
114 | 115 | ||
115 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); | 116 | QAction* clearPageAction = new QAction(tr("Clear Page"), |
117 | Opie::Core::OResource::loadPixmap("drawpad/clear", Opie::Core::OResource::SmallIcon), | ||
118 | QString::null, 0, this); | ||
116 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 119 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
117 | clearPageAction->addTo(pageToolBar); | 120 | clearPageAction->addTo(pageToolBar); |
118 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); | 121 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); |
119 | 122 | ||
120 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); | 123 | QAction* deletePageAction = new QAction(tr("Delete Page"), |
124 | Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), | ||
125 | QString::null, 0, this); | ||
121 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 126 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
122 | deletePageAction->addTo(pageToolBar); | 127 | deletePageAction->addTo(pageToolBar); |
123 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); | 128 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); |
124 | 129 | ||
125 | QToolBar* emptyToolBar = new QToolBar(this); | 130 | QToolBar* emptyToolBar = new QToolBar(this); |
126 | emptyToolBar->setHorizontalStretchable(true); | 131 | emptyToolBar->setHorizontalStretchable(true); |
127 | 132 | ||
128 | // init navigation toolbar | 133 | // init navigation toolbar |
129 | 134 | ||
130 | QToolBar* navigationToolBar = new QToolBar(this); | 135 | QToolBar* navigationToolBar = new QToolBar(this); |
131 | 136 | ||
132 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); | 137 | m_pUndoAction = new QAction(tr("Undo"), Opie::Core::OResource::loadPixmap("undo", Opie::Core::OResource::SmallIcon), |
138 | QString::null, 0, this); | ||
133 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 139 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
134 | m_pUndoAction->addTo(navigationToolBar); | 140 | m_pUndoAction->addTo(navigationToolBar); |
135 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); | 141 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); |
136 | 142 | ||
137 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); | 143 | m_pRedoAction = new QAction(tr("Redo"), Opie::Core::OResource::loadPixmap("redo", Opie::Core::OResource::SmallIcon), |
144 | QString::null, 0, this); | ||
138 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 145 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
139 | m_pRedoAction->addTo(navigationToolBar); | 146 | m_pRedoAction->addTo(navigationToolBar); |
140 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); | 147 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); |
141 | 148 | ||
142 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 149 | m_pFirstPageAction = new QAction(tr("First Page"), |
150 | Opie::Core::OResource::loadPixmap("fastback", Opie::Core::OResource::SmallIcon), | ||
151 | QString::null, 0, this); | ||
143 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 152 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
144 | m_pFirstPageAction->addTo(navigationToolBar); | 153 | m_pFirstPageAction->addTo(navigationToolBar); |
145 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); | 154 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); |
146 | 155 | ||
147 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 156 | m_pPreviousPageAction = new QAction(tr("Previous Page"), |
157 | Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), | ||
158 | QString::null, 0, this); | ||
148 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 159 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
149 | m_pPreviousPageAction->addTo(navigationToolBar); | 160 | m_pPreviousPageAction->addTo(navigationToolBar); |
150 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); | 161 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); |
151 | 162 | ||
152 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 163 | m_pNextPageAction = new QAction(tr("Next Page"), |
164 | Opie::Core::OResource::loadPixmap("forward", Opie::Core::OResource::SmallIcon), | ||
165 | QString::null, 0, this); | ||
153 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 166 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
154 | m_pNextPageAction->addTo(navigationToolBar); | 167 | m_pNextPageAction->addTo(navigationToolBar); |
155 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); | 168 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); |
156 | 169 | ||
157 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 170 | m_pLastPageAction = new QAction(tr("Last Page"), |
171 | Opie::Core::OResource::loadPixmap("fastforward", Opie::Core::OResource::SmallIcon), | ||
172 | QString::null, 0, this); | ||
158 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 173 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
159 | m_pLastPageAction->addTo(navigationToolBar); | 174 | m_pLastPageAction->addTo(navigationToolBar); |
160 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); | 175 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); |
161 | 176 | ||
162 | // init draw mode toolbar | 177 | // init draw mode toolbar |
163 | 178 | ||
164 | QToolBar* drawModeToolBar = new QToolBar(this); | 179 | QToolBar* drawModeToolBar = new QToolBar(this); |
165 | 180 | ||
166 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 181 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
167 | m_pLineToolButton->setToggleButton(true); | 182 | m_pLineToolButton->setToggleButton(true); |
168 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); | 183 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); |
169 | 184 | ||
170 | 185 | ||
171 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 186 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
172 | 187 | ||
173 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); | 188 | m_pPointToolAction = new QAction(tr("Draw Point"), |
189 | Opie::Core::OResource::loadPixmap("drawpad/point", Opie::Core::OResource::SmallIcon), | ||
190 | "", 0, this); | ||
174 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 191 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
175 | m_pPointToolAction->addTo(linePopupMenu); | 192 | m_pPointToolAction->addTo(linePopupMenu); |
176 | 193 | ||
177 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); | 194 | m_pLineToolAction = new QAction(tr("Draw Line"), |
195 | Opie::Core::OResource::loadPixmap("drawpad/line", Opie::Core::OResource::SmallIcon), | ||
196 | "", 0, this); | ||
178 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 197 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
179 | m_pLineToolAction->addTo(linePopupMenu); | 198 | m_pLineToolAction->addTo(linePopupMenu); |
180 | 199 | ||
181 | m_pLineToolButton->setPopup(linePopupMenu); | 200 | m_pLineToolButton->setPopup(linePopupMenu); |
182 | m_pLineToolButton->setPopupDelay(0); | 201 | m_pLineToolButton->setPopupDelay(0); |
183 | 202 | ||
184 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 203 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
185 | m_pRectangleToolButton->setToggleButton(true); | 204 | m_pRectangleToolButton->setToggleButton(true); |
186 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); | 205 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); |
187 | 206 | ||
188 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 207 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
189 | 208 | ||
190 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); | 209 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), |
210 | Opie::Core::OResource::loadPixmap("drawpad/rectangle", Opie::Core::OResource::SmallIcon), | ||
211 | "", 0, this); | ||
191 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 212 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
192 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 213 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
193 | 214 | ||
194 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); | 215 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), |
216 | Opie::Core::OResource::loadPixmap("drawpad/filledrectangle", | ||
217 | Opie::Core::OResource::SmallIcon), "", 0, this); | ||
195 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 218 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
196 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 219 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
197 | 220 | ||
198 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 221 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
199 | m_pRectangleToolButton->setPopupDelay(0); | 222 | m_pRectangleToolButton->setPopupDelay(0); |
200 | 223 | ||
201 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 224 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
202 | m_pEllipseToolButton->setToggleButton(true); | 225 | m_pEllipseToolButton->setToggleButton(true); |
203 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); | 226 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); |
204 | 227 | ||
205 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 228 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
206 | 229 | ||
207 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); | 230 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), |
231 | Opie::Core::OResource::loadPixmap("drawpad/ellipse", Opie::Core::OResource::SmallIcon), | ||
232 | "", 0, this); | ||
208 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 233 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
209 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 234 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
210 | 235 | ||
211 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); | 236 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), |
237 | Opie::Core::OResource::loadPixmap("drawpad/filledellipse", | ||
238 | Opie::Core::OResource::SmallIcon), "", 0, this); | ||
212 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 239 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
213 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 240 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
214 | 241 | ||
215 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 242 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
216 | m_pEllipseToolButton->setPopupDelay(0); | 243 | m_pEllipseToolButton->setPopupDelay(0); |
217 | 244 | ||
218 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); | 245 | m_pTextToolAction = new QAction(tr("Insert Text"), |
246 | Opie::Core::OResource::loadPixmap("drawpad/text", Opie::Core::OResource::SmallIcon), | ||
247 | QString::null, 0, this); | ||
219 | m_pTextToolAction->setToggleAction(true); | 248 | m_pTextToolAction->setToggleAction(true); |
220 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 249 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
221 | m_pTextToolAction->addTo(drawModeToolBar); | 250 | m_pTextToolAction->addTo(drawModeToolBar); |
222 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); | 251 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); |
223 | 252 | ||
224 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); | 253 | m_pFillToolAction = new QAction(tr("Fill Region"), |
254 | Opie::Core::OResource::loadPixmap("drawpad/fill", Opie::Core::OResource::SmallIcon), | ||
255 | QString::null, 0, this); | ||
225 | m_pFillToolAction->setToggleAction(true); | 256 | m_pFillToolAction->setToggleAction(true); |
226 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 257 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
227 | m_pFillToolAction->addTo(drawModeToolBar); | 258 | m_pFillToolAction->addTo(drawModeToolBar); |
228 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); | 259 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); |
229 | 260 | ||
230 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); | 261 | m_pEraseToolAction = new QAction(tr("Erase Point"), |
262 | Opie::Core::OResource::loadPixmap("drawpad/erase", Opie::Core::OResource::SmallIcon), | ||
263 | QString::null, 0, this); | ||
231 | m_pEraseToolAction->setToggleAction(true); | 264 | m_pEraseToolAction->setToggleAction(true); |
232 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 265 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
233 | m_pEraseToolAction->addTo(drawModeToolBar); | 266 | m_pEraseToolAction->addTo(drawModeToolBar); |
234 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); | 267 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); |
235 | 268 | ||
236 | m_pTool = 0; | 269 | m_pTool = 0; |
237 | setRectangleTool(); | 270 | setRectangleTool(); |
238 | setEllipseTool(); | 271 | setEllipseTool(); |
239 | setPointTool(); | 272 | setPointTool(); |
240 | 273 | ||
241 | emptyToolBar = new QToolBar(this); | 274 | emptyToolBar = new QToolBar(this); |
242 | emptyToolBar->setHorizontalStretchable(true); | 275 | emptyToolBar->setHorizontalStretchable(true); |
243 | emptyToolBar->addSeparator(); | 276 | emptyToolBar->addSeparator(); |
244 | 277 | ||
245 | // init draw parameters toolbar | 278 | // init draw parameters toolbar |
246 | 279 | ||
247 | QToolBar* drawParametersToolBar = new QToolBar(this); | 280 | QToolBar* drawParametersToolBar = new QToolBar(this); |
248 | 281 | ||
249 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 282 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
250 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 283 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
251 | 284 | ||
252 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); | 285 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
253 | m_pPenWidthSpinBox->setValue(1); | 286 | m_pPenWidthSpinBox->setValue(1); |
254 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 287 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
255 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); | 288 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); |
256 | 289 | ||
290 | bool useBigIcon = qApp->desktop()->size().width() > 330; | ||
291 | |||
257 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 292 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
258 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); | 293 | m_pPenColorToolButton->setUsesBigPixmap( useBigIcon ); |
294 | m_pPenColorToolButton->setPixmap(Opie::Core::OResource::loadPixmap("drawpad/pencolor", Opie::Core::OResource::SmallIcon)); | ||
259 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); | 295 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); |
260 | 296 | ||
261 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton); | 297 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton); |
262 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 298 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
263 | 299 | ||
264 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 300 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
265 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 301 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
266 | m_pPenColorToolButton->setPopupDelay(0); | 302 | m_pPenColorToolButton->setPopupDelay(0); |
267 | 303 | ||
268 | changePenColor(Qt::black); | 304 | changePenColor(Qt::black); |
269 | 305 | ||
270 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 306 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
271 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); | 307 | m_pBrushColorToolButton->setUsesBigPixmap( useBigIcon ); |
308 | m_pBrushColorToolButton->setPixmap(Opie::Core::OResource::loadPixmap("drawpad/brushcolor", Opie::Core::OResource::SmallIcon)); | ||
272 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); | 309 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); |
273 | 310 | ||
274 | Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 311 | Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
275 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 312 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
276 | 313 | ||
277 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 314 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
278 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 315 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
279 | m_pBrushColorToolButton->setPopupDelay(0); | 316 | m_pBrushColorToolButton->setPopupDelay(0); |
280 | 317 | ||
281 | changeBrushColor(Qt::white); | 318 | changeBrushColor(Qt::white); |
282 | 319 | ||
283 | // delay the rest of the initialization and do it from within the mainloop | 320 | // delay the rest of the initialization and do it from within the mainloop |
284 | // if we don't do this, the widget layout may not be constructed upon | 321 | // if we don't do this, the widget layout may not be constructed upon |
285 | // and we will end up with a wrong QScrollview page size (Mickeyl) | 322 | // and we will end up with a wrong QScrollview page size (Mickeyl) |
286 | QTimer::singleShot( 100, this, SLOT( finishStartup() ) ); | 323 | QTimer::singleShot( 100, this, SLOT( finishStartup() ) ); |
287 | } | 324 | } |
288 | 325 | ||
289 | 326 | ||
290 | void DrawPad::finishStartup() | 327 | void DrawPad::finishStartup() |
291 | { | 328 | { |
292 | // init pages | 329 | // init pages |
293 | 330 | ||
294 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 331 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
295 | 332 | ||
296 | if (file.open(IO_ReadOnly)) { | 333 | if (file.open(IO_ReadOnly)) { |
297 | m_pDrawPadCanvas->load(&file); | 334 | m_pDrawPadCanvas->load(&file); |
298 | file.close(); | 335 | file.close(); |
299 | } else { | 336 | } else { |
300 | m_pDrawPadCanvas->initialPage(); | 337 | m_pDrawPadCanvas->initialPage(); |
301 | } | 338 | } |
302 | 339 | ||
303 | loadConfig(); | 340 | loadConfig(); |
304 | 341 | ||
305 | } | 342 | } |
306 | 343 | ||
307 | DrawPad::~DrawPad() | 344 | DrawPad::~DrawPad() |
308 | { | 345 | { |
309 | saveConfig(); | 346 | saveConfig(); |
310 | 347 | ||
311 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 348 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
312 | 349 | ||
313 | if (file.open(IO_WriteOnly)) { | 350 | if (file.open(IO_WriteOnly)) { |
314 | m_pDrawPadCanvas->save(&file); | 351 | m_pDrawPadCanvas->save(&file); |
315 | file.close(); | 352 | file.close(); |
316 | } | 353 | } |
317 | } | 354 | } |
318 | 355 | ||
319 | bool DrawPad::antiAliasing() | 356 | bool DrawPad::antiAliasing() |
320 | { | 357 | { |
321 | return (m_pAntiAliasingAction->isOn()); | 358 | return (m_pAntiAliasingAction->isOn()); |
322 | } | 359 | } |
323 | 360 | ||
324 | void DrawPad::newPage() | 361 | void DrawPad::newPage() |
325 | { | 362 | { |
326 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 363 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
327 | 364 | ||
328 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 365 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
329 | 366 | ||
330 | if (newPageDialog.exec() == QDialog::Accepted) { | 367 | if (newPageDialog.exec() == QDialog::Accepted) { |
331 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 368 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
332 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 369 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
333 | } | 370 | } |
334 | } | 371 | } |
335 | 372 | ||
336 | void DrawPad::clearPage() | 373 | void DrawPad::clearPage() |
337 | { | 374 | { |
338 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 375 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
339 | QMessageBox::Information, QMessageBox::Yes, | 376 | QMessageBox::Information, QMessageBox::Yes, |
340 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 377 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
341 | QMessageBox::NoButton, this); | 378 | QMessageBox::NoButton, this); |
342 | 379 | ||
343 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 380 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
344 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 381 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
345 | 382 | ||
346 | if (messageBox.exec() == QMessageBox::Yes) { | 383 | if (messageBox.exec() == QMessageBox::Yes) { |
347 | m_pDrawPadCanvas->clearPage(); | 384 | m_pDrawPadCanvas->clearPage(); |
348 | } | 385 | } |
349 | } | 386 | } |
350 | 387 | ||
351 | void DrawPad::deletePage() | 388 | void DrawPad::deletePage() |
352 | { | 389 | { |
353 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 390 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
354 | QMessageBox::Information, QMessageBox::Yes, | 391 | QMessageBox::Information, QMessageBox::Yes, |
355 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 392 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
356 | QMessageBox::NoButton, this); | 393 | QMessageBox::NoButton, this); |
357 | 394 | ||
358 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 395 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
359 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 396 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
360 | 397 | ||
361 | if (messageBox.exec() == QMessageBox::Yes) { | 398 | if (messageBox.exec() == QMessageBox::Yes) { |
362 | m_pDrawPadCanvas->deletePage(); | 399 | m_pDrawPadCanvas->deletePage(); |
363 | } | 400 | } |
364 | } | 401 | } |
365 | 402 | ||
366 | void DrawPad::setPointTool() | 403 | void DrawPad::setPointTool() |
367 | { | 404 | { |
368 | if (m_pTool) { | 405 | if (m_pTool) { |
369 | delete m_pTool; | 406 | delete m_pTool; |
370 | } | 407 | } |
371 | 408 | ||
372 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 409 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
373 | 410 | ||
374 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 411 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
375 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); | 412 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
376 | 413 | ||
377 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 414 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
378 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | 415 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); |
379 | 416 | ||
380 | m_pLineToolButton->setOn(true); | 417 | m_pLineToolButton->setOn(true); |
381 | m_pRectangleToolButton->setOn(false); | 418 | m_pRectangleToolButton->setOn(false); |
382 | m_pEllipseToolButton->setOn(false); | 419 | m_pEllipseToolButton->setOn(false); |
383 | m_pTextToolAction->setOn(false); | 420 | m_pTextToolAction->setOn(false); |
384 | m_pFillToolAction->setOn(false); | 421 | m_pFillToolAction->setOn(false); |
385 | m_pEraseToolAction->setOn(false); | 422 | m_pEraseToolAction->setOn(false); |
386 | } | 423 | } |
387 | 424 | ||
388 | void DrawPad::setLineTool() | 425 | void DrawPad::setLineTool() |
389 | { | 426 | { |
390 | if (m_pTool) { | 427 | if (m_pTool) { |
391 | delete m_pTool; | 428 | delete m_pTool; |
392 | } | 429 | } |
393 | 430 | ||
394 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 431 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
395 | 432 | ||
396 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); | 433 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
397 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); | 434 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
398 | 435 | ||
399 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 436 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
400 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | 437 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); |
401 | 438 | ||
402 | m_pLineToolButton->setOn(true); | 439 | m_pLineToolButton->setOn(true); |
403 | m_pRectangleToolButton->setOn(false); | 440 | m_pRectangleToolButton->setOn(false); |
404 | m_pEllipseToolButton->setOn(false); | 441 | m_pEllipseToolButton->setOn(false); |
405 | m_pTextToolAction->setOn(false); | 442 | m_pTextToolAction->setOn(false); |
406 | m_pFillToolAction->setOn(false); | 443 | m_pFillToolAction->setOn(false); |
407 | m_pEraseToolAction->setOn(false); | 444 | m_pEraseToolAction->setOn(false); |
408 | } | 445 | } |
409 | 446 | ||
410 | void DrawPad::setRectangleTool() | 447 | void DrawPad::setRectangleTool() |
411 | { | 448 | { |
412 | if (m_pTool) { | 449 | if (m_pTool) { |
413 | delete m_pTool; | 450 | delete m_pTool; |
414 | } | 451 | } |
415 | 452 | ||
416 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 453 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
417 | 454 | ||
418 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 455 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
419 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 456 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
420 | 457 | ||
421 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 458 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
422 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 459 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
423 | 460 | ||
424 | m_pLineToolButton->setOn(false); | 461 | m_pLineToolButton->setOn(false); |
425 | m_pRectangleToolButton->setOn(true); | 462 | m_pRectangleToolButton->setOn(true); |
426 | m_pEllipseToolButton->setOn(false); | 463 | m_pEllipseToolButton->setOn(false); |
427 | m_pTextToolAction->setOn(false); | 464 | m_pTextToolAction->setOn(false); |
428 | m_pFillToolAction->setOn(false); | 465 | m_pFillToolAction->setOn(false); |
429 | m_pEraseToolAction->setOn(false); | 466 | m_pEraseToolAction->setOn(false); |
430 | } | 467 | } |
431 | 468 | ||
432 | void DrawPad::setFilledRectangleTool() | 469 | void DrawPad::setFilledRectangleTool() |
433 | { | 470 | { |
434 | if (m_pTool) { | 471 | if (m_pTool) { |
435 | delete m_pTool; | 472 | delete m_pTool; |
436 | } | 473 | } |
437 | 474 | ||
438 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 475 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
439 | 476 | ||
440 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 477 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
441 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 478 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
442 | 479 | ||
443 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 480 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
444 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 481 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
445 | 482 | ||
446 | m_pLineToolButton->setOn(false); | 483 | m_pLineToolButton->setOn(false); |
447 | m_pRectangleToolButton->setOn(true); | 484 | m_pRectangleToolButton->setOn(true); |
448 | m_pEllipseToolButton->setOn(false); | 485 | m_pEllipseToolButton->setOn(false); |
449 | m_pTextToolAction->setOn(false); | 486 | m_pTextToolAction->setOn(false); |
450 | m_pFillToolAction->setOn(false); | 487 | m_pFillToolAction->setOn(false); |
451 | m_pEraseToolAction->setOn(false); | 488 | m_pEraseToolAction->setOn(false); |
452 | } | 489 | } |
453 | 490 | ||
454 | void DrawPad::setEllipseTool() | 491 | void DrawPad::setEllipseTool() |
455 | { | 492 | { |
456 | if (m_pTool) { | 493 | if (m_pTool) { |
457 | delete m_pTool; | 494 | delete m_pTool; |
458 | } | 495 | } |
459 | 496 | ||
460 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 497 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
461 | 498 | ||
462 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 499 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
463 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 500 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
464 | 501 | ||
465 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 502 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
466 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 503 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
467 | 504 | ||
468 | m_pLineToolButton->setOn(false); | 505 | m_pLineToolButton->setOn(false); |
469 | m_pRectangleToolButton->setOn(false); | 506 | m_pRectangleToolButton->setOn(false); |
470 | m_pEllipseToolButton->setOn(true); | 507 | m_pEllipseToolButton->setOn(true); |
471 | m_pTextToolAction->setOn(false); | 508 | m_pTextToolAction->setOn(false); |
472 | m_pFillToolAction->setOn(false); | 509 | m_pFillToolAction->setOn(false); |
473 | m_pEraseToolAction->setOn(false); | 510 | m_pEraseToolAction->setOn(false); |
474 | } | 511 | } |
475 | 512 | ||
476 | void DrawPad::setFilledEllipseTool() | 513 | void DrawPad::setFilledEllipseTool() |
477 | { | 514 | { |
478 | if (m_pTool) { | 515 | if (m_pTool) { |
479 | delete m_pTool; | 516 | delete m_pTool; |
480 | } | 517 | } |
481 | 518 | ||
482 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 519 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
483 | 520 | ||
484 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 521 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
485 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 522 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
486 | 523 | ||
487 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 524 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
488 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 525 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
489 | 526 | ||
490 | m_pLineToolButton->setOn(false); | 527 | m_pLineToolButton->setOn(false); |
491 | m_pRectangleToolButton->setOn(false); | 528 | m_pRectangleToolButton->setOn(false); |
492 | m_pEllipseToolButton->setOn(true); | 529 | m_pEllipseToolButton->setOn(true); |
493 | m_pTextToolAction->setOn(false); | 530 | m_pTextToolAction->setOn(false); |
494 | m_pFillToolAction->setOn(false); | 531 | m_pFillToolAction->setOn(false); |
495 | m_pEraseToolAction->setOn(false); | 532 | m_pEraseToolAction->setOn(false); |
496 | } | 533 | } |
497 | 534 | ||
498 | void DrawPad::setTextTool() | 535 | void DrawPad::setTextTool() |
499 | { | 536 | { |
500 | if (m_pTool) { | 537 | if (m_pTool) { |
501 | delete m_pTool; | 538 | delete m_pTool; |
502 | } | 539 | } |
503 | 540 | ||
504 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 541 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
505 | 542 | ||
506 | m_pLineToolButton->setOn(false); | 543 | m_pLineToolButton->setOn(false); |
507 | m_pRectangleToolButton->setOn(false); | 544 | m_pRectangleToolButton->setOn(false); |
508 | m_pEllipseToolButton->setOn(false); | 545 | m_pEllipseToolButton->setOn(false); |
509 | m_pTextToolAction->setOn(true); | 546 | m_pTextToolAction->setOn(true); |
510 | m_pFillToolAction->setOn(false); | 547 | m_pFillToolAction->setOn(false); |
511 | m_pEraseToolAction->setOn(false); | 548 | m_pEraseToolAction->setOn(false); |
512 | } | 549 | } |
513 | 550 | ||
514 | void DrawPad::setFillTool() | 551 | void DrawPad::setFillTool() |
515 | { | 552 | { |
516 | if (m_pTool) { | 553 | if (m_pTool) { |
517 | delete m_pTool; | 554 | delete m_pTool; |
518 | } | 555 | } |
519 | 556 | ||
520 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 557 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
521 | 558 | ||
522 | m_pLineToolButton->setOn(false); | 559 | m_pLineToolButton->setOn(false); |
523 | m_pRectangleToolButton->setOn(false); | 560 | m_pRectangleToolButton->setOn(false); |
524 | m_pEllipseToolButton->setOn(false); | 561 | m_pEllipseToolButton->setOn(false); |
525 | m_pTextToolAction->setOn(false); | 562 | m_pTextToolAction->setOn(false); |
526 | m_pFillToolAction->setOn(true); | 563 | m_pFillToolAction->setOn(true); |
527 | m_pEraseToolAction->setOn(false); | 564 | m_pEraseToolAction->setOn(false); |
528 | } | 565 | } |
529 | 566 | ||
530 | void DrawPad::setEraseTool() | 567 | void DrawPad::setEraseTool() |
531 | { | 568 | { |
532 | if (m_pTool) { | 569 | if (m_pTool) { |
533 | delete m_pTool; | 570 | delete m_pTool; |
534 | } | 571 | } |
535 | 572 | ||
536 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 573 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
537 | 574 | ||
538 | m_pLineToolButton->setOn(false); | 575 | m_pLineToolButton->setOn(false); |
539 | m_pRectangleToolButton->setOn(false); | 576 | m_pRectangleToolButton->setOn(false); |
540 | m_pEllipseToolButton->setOn(false); | 577 | m_pEllipseToolButton->setOn(false); |
541 | m_pTextToolAction->setOn(false); | 578 | m_pTextToolAction->setOn(false); |
542 | m_pFillToolAction->setOn(false); | 579 | m_pFillToolAction->setOn(false); |
543 | m_pEraseToolAction->setOn(true); | 580 | m_pEraseToolAction->setOn(true); |
544 | } | 581 | } |
545 | 582 | ||
546 | void DrawPad::changePenWidth(int value) | 583 | void DrawPad::changePenWidth(int value) |
547 | { | 584 | { |
548 | m_pen.setWidth(value); | 585 | m_pen.setWidth(value); |
549 | } | 586 | } |
550 | 587 | ||
551 | void DrawPad::changePenColor(const QColor& color) | 588 | void DrawPad::changePenColor(const QColor& color) |
552 | { | 589 | { |
553 | m_pen.setColor(color); | 590 | m_pen.setColor(color); |
554 | 591 | ||
555 | QPainter painter; | 592 | QPainter painter; |
556 | painter.begin(m_pPenColorToolButton->pixmap()); | 593 | painter.begin(m_pPenColorToolButton->pixmap()); |
557 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 594 | int size = AppLnk::smallIconSize(); |
595 | painter.fillRect(QRect(0, 6*size/7+1, size, size/7), m_pen.color()); | ||
558 | painter.end(); | 596 | painter.end(); |
559 | 597 | ||
560 | m_pPenColorToolButton->popup()->hide(); | 598 | m_pPenColorToolButton->popup()->hide(); |
561 | } | 599 | } |
562 | 600 | ||
563 | void DrawPad::changeBrushColor(const QColor& color) | 601 | void DrawPad::changeBrushColor(const QColor& color) |
564 | { | 602 | { |
565 | m_brush = QBrush(color); | 603 | m_brush = QBrush(color); |
566 | 604 | ||
567 | QPainter painter; | 605 | QPainter painter; |
568 | painter.begin(m_pBrushColorToolButton->pixmap()); | 606 | painter.begin(m_pBrushColorToolButton->pixmap()); |
569 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 607 | int size = AppLnk::smallIconSize(); |
608 | painter.fillRect(QRect(0, 6*size/7+1, size, size/7), m_brush.color()); | ||
570 | painter.end(); | 609 | painter.end(); |
571 | 610 | ||
572 | m_pBrushColorToolButton->popup()->hide(); | 611 | m_pBrushColorToolButton->popup()->hide(); |
573 | } | 612 | } |
574 | 613 | ||
575 | void DrawPad::updateView() | 614 | void DrawPad::updateView() |
576 | { | 615 | { |
577 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 616 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
578 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 617 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
579 | 618 | ||
580 | setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); | 619 | setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); |
581 | 620 | ||
582 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); | 621 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); |
583 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); | 622 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); |
584 | 623 | ||
585 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 624 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
586 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 625 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
587 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 626 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
588 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 627 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
589 | } | 628 | } |
590 | 629 | ||
591 | void DrawPad::deleteAll() | 630 | void DrawPad::deleteAll() |
592 | { | 631 | { |
593 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 632 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
594 | QMessageBox::Information, QMessageBox::Yes, | 633 | QMessageBox::Information, QMessageBox::Yes, |
595 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 634 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
596 | QMessageBox::NoButton, this); | 635 | QMessageBox::NoButton, this); |
597 | 636 | ||
598 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 637 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
599 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 638 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
600 | 639 | ||
601 | if (messageBox.exec() == QMessageBox::Yes) { | 640 | if (messageBox.exec() == QMessageBox::Yes) { |
602 | m_pDrawPadCanvas->deleteAll(); | 641 | m_pDrawPadCanvas->deleteAll(); |
603 | } | 642 | } |
604 | } | 643 | } |
605 | 644 | ||
606 | void DrawPad::importPage() | 645 | void DrawPad::importPage() |
607 | { | 646 | { |
608 | ImportDialog importDialog(this); | 647 | ImportDialog importDialog(this); |
609 | 648 | ||
610 | if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) { | 649 | if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) { |
611 | const DocLnk* docLnk = importDialog.selected(); | 650 | const DocLnk* docLnk = importDialog.selected(); |
612 | 651 | ||
613 | if (docLnk) { | 652 | if (docLnk) { |
614 | m_pDrawPadCanvas->importPage(docLnk->file()); | 653 | m_pDrawPadCanvas->importPage(docLnk->file()); |
615 | delete docLnk; | 654 | delete docLnk; |
616 | } | 655 | } |
617 | } | 656 | } |
618 | } | 657 | } |
619 | 658 | ||
620 | void DrawPad::exportPage() | 659 | void DrawPad::exportPage() |
621 | { | 660 | { |
622 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 661 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
623 | 662 | ||
624 | if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) { | 663 | if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) { |
625 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 664 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
626 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 665 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
627 | } | 666 | } |
628 | } | 667 | } |
629 | 668 | ||
630 | void DrawPad::thumbnailView() | 669 | void DrawPad::thumbnailView() |
631 | { | 670 | { |
632 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 671 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
633 | 672 | ||
634 | QPEApplication::showWidget( &thumbnailView ); | 673 | QPEApplication::showWidget( &thumbnailView ); |
635 | thumbnailView.exec(); | 674 | thumbnailView.exec(); |
636 | } | 675 | } |
637 | 676 | ||
638 | void DrawPad::pageInformation() | 677 | void DrawPad::pageInformation() |
639 | { | 678 | { |
640 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 679 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
641 | 680 | ||
642 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 681 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
643 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 682 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
644 | } | 683 | } |
645 | } | 684 | } |
646 | 685 | ||
647 | void DrawPad::loadConfig() | 686 | void DrawPad::loadConfig() |
648 | { | 687 | { |
649 | Config config("drawpad"); | 688 | Config config("drawpad"); |
650 | config.setGroup("General"); | 689 | config.setGroup("General"); |
651 | 690 | ||
652 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); | 691 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); |
653 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); | 692 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); |
654 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); | 693 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); |
655 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); | 694 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); |
656 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); | 695 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); |
657 | } | 696 | } |
658 | 697 | ||
659 | void DrawPad::saveConfig() | 698 | void DrawPad::saveConfig() |
660 | { | 699 | { |
661 | Config config("drawpad"); | 700 | Config config("drawpad"); |
662 | config.setGroup("General"); | 701 | config.setGroup("General"); |
663 | 702 | ||
664 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); | 703 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); |
665 | config.writeEntry("AntiAliasing", antiAliasing()); | 704 | config.writeEntry("AntiAliasing", antiAliasing()); |
666 | config.writeEntry("PenWidth", (int)m_pen.width()); | 705 | config.writeEntry("PenWidth", (int)m_pen.width()); |
667 | config.writeEntry("PenColor", m_pen.color().name()); | 706 | config.writeEntry("PenColor", m_pen.color().name()); |
668 | config.writeEntry("BrushColor", m_brush.color().name()); | 707 | config.writeEntry("BrushColor", m_brush.color().name()); |
669 | } | 708 | } |
670 | 709 | ||
671 | 710 | ||
672 | /* | 711 | /* |
673 | * Import a Thumbnail from SCAP or similiar | 712 | * Import a Thumbnail from SCAP or similiar |
674 | */ | 713 | */ |
675 | void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) { | 714 | void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) { |
676 | QDataStream stream(ar, IO_ReadOnly ); | 715 | QDataStream stream(ar, IO_ReadOnly ); |
677 | /* | 716 | /* |
678 | * import the pixmap | 717 | * import the pixmap |
679 | */ | 718 | */ |
680 | if ( str == "importPixmap(QPixmap)" ) { | 719 | if ( str == "importPixmap(QPixmap)" ) { |
681 | QPixmap pix; | 720 | QPixmap pix; |
682 | stream >> pix;; | 721 | stream >> pix;; |
683 | m_pDrawPadCanvas->importPixmap( pix ); | 722 | m_pDrawPadCanvas->importPixmap( pix ); |
684 | QPEApplication::setKeepRunning(); | 723 | QPEApplication::setKeepRunning(); |
685 | } | 724 | } |
686 | } | 725 | } |
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 1ccf484..d190ffe 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -1,388 +1,396 @@ | |||
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 <opie2/oresource.h> | ||
22 | |||
21 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
22 | #include <qpe/resource.h> | ||
23 | #include <qpe/timestring.h> | 24 | #include <qpe/timestring.h> |
24 | 25 | ||
25 | #include <qapplication.h> | 26 | #include <qapplication.h> |
26 | #include <qlayout.h> | 27 | #include <qlayout.h> |
27 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
28 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
29 | #include <qwhatsthis.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: %1" ).arg( m_pPage->title() ); | 60 | m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); |
60 | m_dimensionText = QObject::tr( "Dimension: %1x%2" ). | 61 | m_dimensionText = QObject::tr( "Dimension: %1x%2" ). |
61 | arg( m_pPage->pixmap()->width() ). | 62 | arg( m_pPage->pixmap()->width() ). |
62 | arg( m_pPage->pixmap()->height() ); | 63 | arg( m_pPage->pixmap()->height() ); |
63 | m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); | 64 | m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); |
64 | 65 | ||
65 | QColor baseColor = parent->colorGroup().base(); | 66 | QColor baseColor = parent->colorGroup().base(); |
66 | int h, s, v; | 67 | int h, s, v; |
67 | baseColor.hsv(&h, &s, &v); | 68 | baseColor.hsv(&h, &s, &v); |
68 | 69 | ||
69 | if (v > 128) { | 70 | if (v > 128) { |
70 | m_alternateColor = baseColor.dark(115); | 71 | m_alternateColor = baseColor.dark(115); |
71 | } else if (baseColor != Qt::black) { | 72 | } else if (baseColor != Qt::black) { |
72 | m_alternateColor = baseColor.light(115); | 73 | m_alternateColor = baseColor.light(115); |
73 | } else { | 74 | } else { |
74 | m_alternateColor = QColor(32, 32, 32); | 75 | m_alternateColor = QColor(32, 32, 32); |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | PageListBoxItem::~PageListBoxItem() | 79 | PageListBoxItem::~PageListBoxItem() |
79 | { | 80 | { |
80 | } | 81 | } |
81 | 82 | ||
82 | int PageListBoxItem::height(const QListBox*) const | 83 | int PageListBoxItem::height(const QListBox*) const |
83 | { | 84 | { |
84 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); | 85 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); |
85 | } | 86 | } |
86 | 87 | ||
87 | int PageListBoxItem::width(const QListBox* lb) const | 88 | int PageListBoxItem::width(const QListBox* lb) const |
88 | { | 89 | { |
89 | QFontMetrics fontMetrics = lb->fontMetrics(); | 90 | QFontMetrics fontMetrics = lb->fontMetrics(); |
90 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), | 91 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), |
91 | QMAX(fontMetrics.width(m_dimensionText), | 92 | QMAX(fontMetrics.width(m_dimensionText), |
92 | fontMetrics.width(m_dateText))); | 93 | fontMetrics.width(m_dateText))); |
93 | 94 | ||
94 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); | 95 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); |
95 | } | 96 | } |
96 | 97 | ||
97 | void PageListBoxItem::paint(QPainter *painter) | 98 | void PageListBoxItem::paint(QPainter *painter) |
98 | { | 99 | { |
99 | QRect itemRect = listBox()->itemRect(this); | 100 | QRect itemRect = listBox()->itemRect(this); |
100 | 101 | ||
101 | if (!selected() && (listBox()->index(this) % 2)) { | 102 | if (!selected() && (listBox()->index(this) % 2)) { |
102 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); | 103 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); |
103 | } | 104 | } |
104 | 105 | ||
105 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, | 106 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, |
106 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, | 107 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, |
107 | m_thumbnail); | 108 | m_thumbnail); |
108 | 109 | ||
109 | QFont standardFont = painter->font(); | 110 | QFont standardFont = painter->font(); |
110 | QFont boldFont = painter->font(); | 111 | QFont boldFont = painter->font(); |
111 | boldFont.setBold(TRUE); | 112 | boldFont.setBold(TRUE); |
112 | 113 | ||
113 | QFontMetrics fontMetrics = painter->fontMetrics(); | 114 | QFontMetrics fontMetrics = painter->fontMetrics(); |
114 | QRect textRect(THUMBNAIL_SIZE + 6, 2, | 115 | QRect textRect(THUMBNAIL_SIZE + 6, 2, |
115 | itemRect.width() - THUMBNAIL_SIZE - 8, | 116 | itemRect.width() - THUMBNAIL_SIZE - 8, |
116 | itemRect.height() - 4); | 117 | itemRect.height() - 4); |
117 | 118 | ||
118 | painter->setFont(boldFont); | 119 | painter->setFont(boldFont); |
119 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); | 120 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); |
120 | 121 | ||
121 | painter->setFont(standardFont); | 122 | painter->setFont(standardFont); |
122 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); | 123 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); |
123 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); | 124 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); |
124 | 125 | ||
125 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { | 126 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { |
126 | 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); |
127 | } | 128 | } |
128 | } | 129 | } |
129 | 130 | ||
130 | Page* PageListBoxItem::page() const | 131 | Page* PageListBoxItem::page() const |
131 | { | 132 | { |
132 | return m_pPage; | 133 | return m_pPage; |
133 | } | 134 | } |
134 | 135 | ||
135 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) | 136 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) |
136 | { | 137 | { |
137 | QString result; | 138 | QString result; |
138 | 139 | ||
139 | Config config("qpe"); | 140 | Config config("qpe"); |
140 | config.setGroup("Date"); | 141 | config.setGroup("Date"); |
141 | 142 | ||
142 | QChar separator = config.readEntry("Separator", "/")[0]; | 143 | QChar separator = config.readEntry("Separator", "/")[0]; |
143 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); | 144 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); |
144 | 145 | ||
145 | for (int i = 0; i < 3; i++) { | 146 | for (int i = 0; i < 3; i++) { |
146 | switch((shortOrder >> (i * 3)) & 0x0007) { | 147 | switch((shortOrder >> (i * 3)) & 0x0007) { |
147 | case 0x0001: | 148 | case 0x0001: |
148 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); | 149 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); |
149 | break; | 150 | break; |
150 | case 0x0002: | 151 | case 0x0002: |
151 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); | 152 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); |
152 | break; | 153 | break; |
153 | case 0x0004: | 154 | case 0x0004: |
154 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); | 155 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); |
155 | break; | 156 | break; |
156 | default: | 157 | default: |
157 | break; | 158 | break; |
158 | } | 159 | } |
159 | 160 | ||
160 | if (i < 2) { | 161 | if (i < 2) { |
161 | result.append( separator ); | 162 | result.append( separator ); |
162 | } | 163 | } |
163 | } | 164 | } |
164 | 165 | ||
165 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); | 166 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); |
166 | 167 | ||
167 | return result; | 168 | return result; |
168 | } | 169 | } |
169 | 170 | ||
170 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 171 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
171 | : QListBox(parent, name) | 172 | : QListBox(parent, name) |
172 | { | 173 | { |
173 | m_pDrawPadCanvas = drawPadCanvas; | 174 | m_pDrawPadCanvas = drawPadCanvas; |
174 | 175 | ||
175 | setVScrollBarMode(QScrollView::AlwaysOn); | 176 | setVScrollBarMode(QScrollView::AlwaysOn); |
176 | 177 | ||
177 | updateView(); | 178 | updateView(); |
178 | } | 179 | } |
179 | 180 | ||
180 | PageListBox::~PageListBox() | 181 | PageListBox::~PageListBox() |
181 | { | 182 | { |
182 | } | 183 | } |
183 | 184 | ||
184 | void PageListBox::updateView() | 185 | void PageListBox::updateView() |
185 | { | 186 | { |
186 | clear(); | 187 | clear(); |
187 | 188 | ||
188 | if (m_pDrawPadCanvas) { | 189 | if (m_pDrawPadCanvas) { |
189 | QList<Page> pageList = m_pDrawPadCanvas->pages(); | 190 | QList<Page> pageList = m_pDrawPadCanvas->pages(); |
190 | QListIterator<Page> it(pageList); | 191 | QListIterator<Page> it(pageList); |
191 | 192 | ||
192 | for (; it.current(); ++it) { | 193 | for (; it.current(); ++it) { |
193 | new PageListBoxItem(it.current(), this); | 194 | new PageListBoxItem(it.current(), this); |
194 | } | 195 | } |
195 | 196 | ||
196 | select(m_pDrawPadCanvas->currentPage()); | 197 | select(m_pDrawPadCanvas->currentPage()); |
197 | } | 198 | } |
198 | } | 199 | } |
199 | 200 | ||
200 | void PageListBox::select(Page* page) | 201 | void PageListBox::select(Page* page) |
201 | { | 202 | { |
202 | uint i = 0; | 203 | uint i = 0; |
203 | uint itemCount = count(); | 204 | uint itemCount = count(); |
204 | 205 | ||
205 | while (i < itemCount) { | 206 | while (i < itemCount) { |
206 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); | 207 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); |
207 | 208 | ||
208 | if (currentItem->page() == page) { | 209 | if (currentItem->page() == page) { |
209 | setCurrentItem(currentItem); | 210 | setCurrentItem(currentItem); |
210 | break; | 211 | break; |
211 | } | 212 | } |
212 | 213 | ||
213 | i++; | 214 | i++; |
214 | } | 215 | } |
215 | } | 216 | } |
216 | 217 | ||
217 | Page* PageListBox::selected() const | 218 | Page* PageListBox::selected() const |
218 | { | 219 | { |
219 | Page* page; | 220 | Page* page; |
220 | 221 | ||
221 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); | 222 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); |
222 | 223 | ||
223 | if (selectedItem) { | 224 | if (selectedItem) { |
224 | page = selectedItem->page(); | 225 | page = selectedItem->page(); |
225 | } else { | 226 | } else { |
226 | page = NULL; | 227 | page = NULL; |
227 | } | 228 | } |
228 | 229 | ||
229 | return page; | 230 | return page; |
230 | } | 231 | } |
231 | 232 | ||
232 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 233 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
233 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) | 234 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) |
234 | { | 235 | { |
235 | inLoop = false; | 236 | inLoop = false; |
236 | 237 | ||
237 | m_pDrawPad = drawPad; | 238 | m_pDrawPad = drawPad; |
238 | m_pDrawPadCanvas = drawPadCanvas; | 239 | m_pDrawPadCanvas = drawPadCanvas; |
239 | 240 | ||
240 | setCaption(tr("DrawPad - Thumbnail View")); | 241 | setCaption(tr("DrawPad - Thumbnail View")); |
241 | 242 | ||
243 | bool useBigIcon = qApp->desktop()->size().width() > 330; | ||
244 | |||
242 | QToolButton* newPageButton = new QToolButton(this); | 245 | QToolButton* newPageButton = new QToolButton(this); |
243 | newPageButton->setIconSet(Resource::loadIconSet("new")); | 246 | newPageButton->setUsesBigPixmap( useBigIcon ); |
247 | newPageButton->setPixmap(Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon)); | ||
244 | newPageButton->setAutoRaise(true); | 248 | newPageButton->setAutoRaise(true); |
245 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); | 249 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); |
246 | QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); | 250 | QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); |
247 | 251 | ||
248 | QToolButton* clearPageButton = new QToolButton(this); | 252 | QToolButton* clearPageButton = new QToolButton(this); |
249 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | 253 | clearPageButton->setUsesBigPixmap( useBigIcon ); |
254 | clearPageButton->setPixmap(Opie::Core::OResource::loadPixmap("drawpad/clear", Opie::Core::OResource::SmallIcon)); | ||
250 | clearPageButton->setAutoRaise(true); | 255 | clearPageButton->setAutoRaise(true); |
251 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); | 256 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); |
252 | QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); | 257 | QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); |
253 | 258 | ||
254 | QToolButton* deletePageButton = new QToolButton(this); | 259 | QToolButton* deletePageButton = new QToolButton(this); |
255 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 260 | deletePageButton->setUsesBigPixmap( useBigIcon ); |
261 | deletePageButton->setPixmap(Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon)); | ||
256 | deletePageButton->setAutoRaise(true); | 262 | deletePageButton->setAutoRaise(true); |
257 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | 263 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); |
258 | QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); | 264 | QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); |
259 | 265 | ||
260 | m_pMovePageUpButton = new QToolButton(this); | 266 | m_pMovePageUpButton = new QToolButton(this); |
261 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); | 267 | m_pMovePageUpButton->setUsesBigPixmap( useBigIcon ); |
268 | m_pMovePageUpButton->setPixmap(Opie::Core::OResource::loadPixmap("up", Opie::Core::OResource::SmallIcon)); | ||
262 | m_pMovePageUpButton->setAutoRaise(true); | 269 | m_pMovePageUpButton->setAutoRaise(true); |
263 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); | 270 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); |
264 | QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); | 271 | QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); |
265 | 272 | ||
266 | m_pMovePageDownButton = new QToolButton(this); | 273 | m_pMovePageDownButton = new QToolButton(this); |
267 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); | 274 | m_pMovePageDownButton->setUsesBigPixmap( useBigIcon ); |
275 | m_pMovePageDownButton->setPixmap(Opie::Core::OResource::loadPixmap("down", Opie::Core::OResource::SmallIcon)); | ||
268 | m_pMovePageDownButton->setAutoRaise(true); | 276 | m_pMovePageDownButton->setAutoRaise(true); |
269 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); | 277 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); |
270 | QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); | 278 | QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); |
271 | 279 | ||
272 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); | 280 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); |
273 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); | 281 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); |
274 | 282 | ||
275 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 283 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
276 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | 284 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); |
277 | 285 | ||
278 | buttonLayout->addWidget(newPageButton); | 286 | buttonLayout->addWidget(newPageButton); |
279 | buttonLayout->addWidget(clearPageButton); | 287 | buttonLayout->addWidget(clearPageButton); |
280 | buttonLayout->addWidget(deletePageButton); | 288 | buttonLayout->addWidget(deletePageButton); |
281 | buttonLayout->addStretch(); | 289 | buttonLayout->addStretch(); |
282 | buttonLayout->addWidget(m_pMovePageUpButton); | 290 | buttonLayout->addWidget(m_pMovePageUpButton); |
283 | buttonLayout->addWidget(m_pMovePageDownButton); | 291 | buttonLayout->addWidget(m_pMovePageDownButton); |
284 | 292 | ||
285 | mainLayout->addLayout(buttonLayout); | 293 | mainLayout->addLayout(buttonLayout); |
286 | mainLayout->addWidget(m_pPageListBox); | 294 | mainLayout->addWidget(m_pPageListBox); |
287 | 295 | ||
288 | updateView(); | 296 | updateView(); |
289 | } | 297 | } |
290 | 298 | ||
291 | ThumbnailView::~ThumbnailView() | 299 | ThumbnailView::~ThumbnailView() |
292 | { | 300 | { |
293 | hide(); | 301 | hide(); |
294 | } | 302 | } |
295 | 303 | ||
296 | void ThumbnailView::updateView() | 304 | void ThumbnailView::updateView() |
297 | { | 305 | { |
298 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 306 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
299 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 307 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
300 | } | 308 | } |
301 | 309 | ||
302 | void ThumbnailView::hide() | 310 | void ThumbnailView::hide() |
303 | { | 311 | { |
304 | QWidget::hide(); | 312 | QWidget::hide(); |
305 | 313 | ||
306 | if (inLoop) { | 314 | if (inLoop) { |
307 | inLoop = false; | 315 | inLoop = false; |
308 | qApp->exit_loop(); | 316 | qApp->exit_loop(); |
309 | } | 317 | } |
310 | } | 318 | } |
311 | 319 | ||
312 | void ThumbnailView::exec() | 320 | void ThumbnailView::exec() |
313 | { | 321 | { |
314 | show(); | 322 | show(); |
315 | 323 | ||
316 | if (!inLoop) { | 324 | if (!inLoop) { |
317 | inLoop = true; | 325 | inLoop = true; |
318 | qApp->enter_loop(); | 326 | qApp->enter_loop(); |
319 | } | 327 | } |
320 | } | 328 | } |
321 | 329 | ||
322 | void ThumbnailView::newPage() | 330 | void ThumbnailView::newPage() |
323 | { | 331 | { |
324 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 332 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
325 | 333 | ||
326 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 334 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
327 | m_pDrawPad->brush().color(), this); | 335 | m_pDrawPad->brush().color(), this); |
328 | 336 | ||
329 | if (newPageDialog.exec() == QDialog::Accepted) { | 337 | if (newPageDialog.exec() == QDialog::Accepted) { |
330 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 338 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
331 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 339 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
332 | m_pPageListBox->updateView(); | 340 | m_pPageListBox->updateView(); |
333 | updateView(); | 341 | updateView(); |
334 | } | 342 | } |
335 | } | 343 | } |
336 | 344 | ||
337 | void ThumbnailView::clearPage() | 345 | void ThumbnailView::clearPage() |
338 | { | 346 | { |
339 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), | 347 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), |
340 | QMessageBox::Information, QMessageBox::Yes, | 348 | QMessageBox::Information, QMessageBox::Yes, |
341 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 349 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
342 | QMessageBox::NoButton, this); | 350 | QMessageBox::NoButton, this); |
343 | 351 | ||
344 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 352 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
345 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 353 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
346 | 354 | ||
347 | if (messageBox.exec() == QMessageBox::Yes) { | 355 | if (messageBox.exec() == QMessageBox::Yes) { |
348 | m_pDrawPadCanvas->clearPage(); | 356 | m_pDrawPadCanvas->clearPage(); |
349 | m_pPageListBox->updateView(); | 357 | m_pPageListBox->updateView(); |
350 | } | 358 | } |
351 | } | 359 | } |
352 | 360 | ||
353 | void ThumbnailView::deletePage() | 361 | void ThumbnailView::deletePage() |
354 | { | 362 | { |
355 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), | 363 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), |
356 | QMessageBox::Information, QMessageBox::Yes, | 364 | QMessageBox::Information, QMessageBox::Yes, |
357 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 365 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
358 | QMessageBox::NoButton, this); | 366 | QMessageBox::NoButton, this); |
359 | 367 | ||
360 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 368 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
361 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 369 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
362 | 370 | ||
363 | if (messageBox.exec() == QMessageBox::Yes) { | 371 | if (messageBox.exec() == QMessageBox::Yes) { |
364 | m_pDrawPadCanvas->deletePage(); | 372 | m_pDrawPadCanvas->deletePage(); |
365 | m_pPageListBox->updateView(); | 373 | m_pPageListBox->updateView(); |
366 | updateView(); | 374 | updateView(); |
367 | } | 375 | } |
368 | } | 376 | } |
369 | 377 | ||
370 | void ThumbnailView::movePageUp() | 378 | void ThumbnailView::movePageUp() |
371 | { | 379 | { |
372 | m_pDrawPadCanvas->movePageUp(); | 380 | m_pDrawPadCanvas->movePageUp(); |
373 | m_pPageListBox->updateView(); | 381 | m_pPageListBox->updateView(); |
374 | updateView(); | 382 | updateView(); |
375 | } | 383 | } |
376 | 384 | ||
377 | void ThumbnailView::movePageDown() | 385 | void ThumbnailView::movePageDown() |
378 | { | 386 | { |
379 | m_pDrawPadCanvas->movePageDown(); | 387 | m_pDrawPadCanvas->movePageDown(); |
380 | m_pPageListBox->updateView(); | 388 | m_pPageListBox->updateView(); |
381 | updateView(); | 389 | updateView(); |
382 | } | 390 | } |
383 | 391 | ||
384 | void ThumbnailView::changePage() | 392 | void ThumbnailView::changePage() |
385 | { | 393 | { |
386 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); | 394 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); |
387 | updateView(); | 395 | updateView(); |
388 | } | 396 | } |