author | mickeyl <mickeyl> | 2004-05-13 21:56:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-13 21:56:23 (UTC) |
commit | f005863ac3e3106f3da9fd337ab0a20da0cd4b83 (patch) (unidiff) | |
tree | b633e278659c87b7bc964bb5ea80d46131798960 | |
parent | 6841da6429d864d5554c5a16e87c2755fe96343b (diff) | |
download | opie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.zip opie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.tar.gz opie-f005863ac3e3106f3da9fd337ab0a20da0cd4b83.tar.bz2 |
BUGFIX for 1314: Fix page initialization on first start of drawpad.
Problem was caused by a race condition. Developers: If you have todo
initializations which depend on the widget layout being finished,
_don't_ do this in the widget constructor but in a callback from the mainloop,
i.e. via QTimer::singleShot( 10, this, SLOT( myInitialization() ) );
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 3 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/main.cpp | 1 |
5 files changed, 11 insertions, 6 deletions
@@ -1,46 +1,47 @@ | |||
1 | 2004-??-??The Opie Team <opie@handhelds.org> | 1 | 2004-??-??The Opie Team <opie@handhelds.org> |
2 | 2 | ||
3 | * Fixed Drawpad initialization (Bug #1314) (mickeyl) | ||
3 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) | 4 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) |
4 | * Added Conversion tool for pim-data (eilers) | 5 | * Added Conversion tool for pim-data (eilers) |
5 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) | 6 | * Modifcation of the PIM API for providing generic use of OPimRecords. (eilers) |
6 | 7 | ||
7 | 2004-25-04The Opie Team <opie@handhelds.org> | 8 | 2004-25-04The Opie Team <opie@handhelds.org> |
8 | 9 | ||
9 | * Released as Version 1.1.3 (devel) | 10 | * Released as Version 1.1.3 (devel) |
10 | * Introduced first implementation of SQL-Support using SQLite (eilers) | 11 | * Introduced first implementation of SQL-Support using SQLite (eilers) |
11 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) | 12 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) |
12 | * Added a real system graffiti character set (brad) | 13 | * Added a real system graffiti character set (brad) |
13 | * Added Generic Keyconfig Widget (zecke) | 14 | * Added Generic Keyconfig Widget (zecke) |
14 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) | 15 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) |
15 | * Added new Bible reader app - opie-dagger (drw) | 16 | * Added new Bible reader app - opie-dagger (drw) |
16 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) | 17 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) |
17 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) | 18 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) |
18 | * Enabled the possibility to pass command line arguments to applications (mickeyl) | 19 | * Enabled the possibility to pass command line arguments to applications (mickeyl) |
19 | * Added an about applet showing some credits and information about Opie (mickeyl) | 20 | * Added an about applet showing some credits and information about Opie (mickeyl) |
20 | * Added benchmarking functionality to sysinfo (mickeyl) | 21 | * Added benchmarking functionality to sysinfo (mickeyl) |
21 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) | 22 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) |
22 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) | 23 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) |
23 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) | 24 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) |
24 | * Clean-up of package information in control files (drw) | 25 | * Clean-up of package information in control files (drw) |
25 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) | 26 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) |
26 | * Improved big-screen support (zecke,ar) | 27 | * Improved big-screen support (zecke,ar) |
27 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) | 28 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) |
28 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) | 29 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) |
29 | * Added new package manager - opie-packagemanager (drw) | 30 | * Added new package manager - opie-packagemanager (drw) |
30 | * Improved light-n-power for C7x0 (mickeyl) | 31 | * Improved light-n-power for C7x0 (mickeyl) |
31 | * Added automatic rotation support for C7x0 (treke) | 32 | * Added automatic rotation support for C7x0 (treke) |
32 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) | 33 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) |
33 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) | 34 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) |
34 | 35 | ||
35 | 2003-11-29The Opie Team <opie@handhelds.org> | 36 | 2003-11-29The Opie Team <opie@handhelds.org> |
36 | 37 | ||
37 | * Released as Version 1.0.3 | 38 | * Released as Version 1.0.3 |
38 | * Improved i18n (various contributors) | 39 | * Improved i18n (various contributors) |
39 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) | 40 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) |
40 | * Made the Documents Tab optional (mickeyl) | 41 | * Made the Documents Tab optional (mickeyl) |
41 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) | 42 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) |
42 | 43 | ||
43 | 2003-08-04The Opie Team <opie@handhelds.org> | 44 | 2003-08-04The Opie Team <opie@handhelds.org> |
44 | 45 | ||
45 | * Released as Version 1.0.0 | 46 | * Released as Version 1.0.0 |
46 | * Including a PPP module for easy dial up (tille,harlekin,zecke) | 47 | * Including a PPP module for easy dial up (tille,harlekin,zecke) |
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index d9d0ce0..c0f42d9 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -4,97 +4,96 @@ | |||
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 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qtoolbar.h> | 38 | #include <qtoolbar.h> |
39 | #include <qpe/resource.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 | using namespace Opie::Ui; | ||
53 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | 52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) |
54 | : QMainWindow(parent, name, WStyle_ContextHelp) | 53 | : QMainWindow(parent, name, WStyle_ContextHelp) |
55 | { | 54 | { |
56 | // init members | 55 | // init members |
57 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 56 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
58 | this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) ); | 57 | this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) ); |
59 | 58 | ||
60 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 59 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
61 | 60 | ||
62 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); | 61 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); |
63 | 62 | ||
64 | setCentralWidget(m_pDrawPadCanvas); | 63 | setCentralWidget(m_pDrawPadCanvas); |
65 | 64 | ||
66 | // init menu | 65 | // init menu |
67 | 66 | ||
68 | setToolBarsMovable(false); | 67 | setToolBarsMovable(false); |
69 | 68 | ||
70 | QToolBar* menuToolBar = new QToolBar(this); | 69 | QToolBar* menuToolBar = new QToolBar(this); |
71 | QMenuBar* menuBar = new QMenuBar(menuToolBar); | 70 | QMenuBar* menuBar = new QMenuBar(menuToolBar); |
72 | 71 | ||
73 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); | 72 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
74 | 73 | ||
75 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 74 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
76 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 75 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
77 | deleteAllAction->addTo(toolsPopupMenu); | 76 | deleteAllAction->addTo(toolsPopupMenu); |
78 | 77 | ||
79 | toolsPopupMenu->insertSeparator(); | 78 | toolsPopupMenu->insertSeparator(); |
80 | 79 | ||
81 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 80 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
82 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 81 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
83 | importPageAction->addTo(toolsPopupMenu); | 82 | importPageAction->addTo(toolsPopupMenu); |
84 | 83 | ||
85 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 84 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
86 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 85 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
87 | exportPageAction->addTo(toolsPopupMenu); | 86 | exportPageAction->addTo(toolsPopupMenu); |
88 | 87 | ||
89 | toolsPopupMenu->insertSeparator(); | 88 | toolsPopupMenu->insertSeparator(); |
90 | 89 | ||
91 | 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); |
92 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 91 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
93 | thumbnailViewAction->addTo(toolsPopupMenu); | 92 | thumbnailViewAction->addTo(toolsPopupMenu); |
94 | 93 | ||
95 | 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); |
96 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 95 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
97 | pageInformationAction->addTo(toolsPopupMenu); | 96 | pageInformationAction->addTo(toolsPopupMenu); |
98 | 97 | ||
99 | toolsPopupMenu->insertSeparator(); | 98 | toolsPopupMenu->insertSeparator(); |
100 | 99 | ||
@@ -236,97 +235,100 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | |||
236 | 235 | ||
237 | m_pTool = 0; | 236 | m_pTool = 0; |
238 | setRectangleTool(); | 237 | setRectangleTool(); |
239 | setEllipseTool(); | 238 | setEllipseTool(); |
240 | setPointTool(); | 239 | setPointTool(); |
241 | 240 | ||
242 | emptyToolBar = new QToolBar(this); | 241 | emptyToolBar = new QToolBar(this); |
243 | emptyToolBar->setHorizontalStretchable(true); | 242 | emptyToolBar->setHorizontalStretchable(true); |
244 | emptyToolBar->addSeparator(); | 243 | emptyToolBar->addSeparator(); |
245 | 244 | ||
246 | // init draw parameters toolbar | 245 | // init draw parameters toolbar |
247 | 246 | ||
248 | QToolBar* drawParametersToolBar = new QToolBar(this); | 247 | QToolBar* drawParametersToolBar = new QToolBar(this); |
249 | 248 | ||
250 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 249 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
251 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 250 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
252 | 251 | ||
253 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); | 252 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
254 | m_pPenWidthSpinBox->setValue(1); | 253 | m_pPenWidthSpinBox->setValue(1); |
255 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 254 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
256 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); | 255 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); |
257 | 256 | ||
258 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 257 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
259 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); | 258 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); |
260 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); | 259 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); |
261 | 260 | ||
262 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton); | 261 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton); |
263 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 262 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
264 | 263 | ||
265 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 264 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
266 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 265 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
267 | m_pPenColorToolButton->setPopupDelay(0); | 266 | m_pPenColorToolButton->setPopupDelay(0); |
268 | 267 | ||
269 | changePenColor(Qt::black); | 268 | changePenColor(Qt::black); |
270 | 269 | ||
271 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 270 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
272 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); | 271 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); |
273 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); | 272 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); |
274 | 273 | ||
275 | Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 274 | Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
276 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 275 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
277 | 276 | ||
278 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 277 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
279 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 278 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
280 | m_pBrushColorToolButton->setPopupDelay(0); | 279 | m_pBrushColorToolButton->setPopupDelay(0); |
281 | 280 | ||
282 | changeBrushColor(Qt::white); | 281 | changeBrushColor(Qt::white); |
283 | 282 | ||
284 | finishStartup(); | 283 | // 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 | ||
285 | // and we will end up with a wrong QScrollview page size (Mickeyl) | ||
286 | QTimer::singleShot( 100, this, SLOT( finishStartup() ) ); | ||
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | void DrawPad::finishStartup() | 290 | void DrawPad::finishStartup() |
289 | { | 291 | { |
290 | // init pages | 292 | // init pages |
291 | 293 | ||
292 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 294 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
293 | 295 | ||
294 | if (file.open(IO_ReadOnly)) { | 296 | if (file.open(IO_ReadOnly)) { |
295 | m_pDrawPadCanvas->load(&file); | 297 | m_pDrawPadCanvas->load(&file); |
296 | file.close(); | 298 | file.close(); |
297 | } else { | 299 | } else { |
298 | m_pDrawPadCanvas->initialPage(); | 300 | m_pDrawPadCanvas->initialPage(); |
299 | } | 301 | } |
300 | 302 | ||
301 | loadConfig(); | 303 | loadConfig(); |
302 | 304 | ||
303 | } | 305 | } |
304 | 306 | ||
305 | DrawPad::~DrawPad() | 307 | DrawPad::~DrawPad() |
306 | { | 308 | { |
307 | saveConfig(); | 309 | saveConfig(); |
308 | 310 | ||
309 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 311 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
310 | 312 | ||
311 | if (file.open(IO_WriteOnly)) { | 313 | if (file.open(IO_WriteOnly)) { |
312 | m_pDrawPadCanvas->save(&file); | 314 | m_pDrawPadCanvas->save(&file); |
313 | file.close(); | 315 | file.close(); |
314 | } | 316 | } |
315 | } | 317 | } |
316 | 318 | ||
317 | bool DrawPad::antiAliasing() | 319 | bool DrawPad::antiAliasing() |
318 | { | 320 | { |
319 | return (m_pAntiAliasingAction->isOn()); | 321 | return (m_pAntiAliasingAction->isOn()); |
320 | } | 322 | } |
321 | 323 | ||
322 | void DrawPad::newPage() | 324 | void DrawPad::newPage() |
323 | { | 325 | { |
324 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 326 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
325 | 327 | ||
326 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 328 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
327 | 329 | ||
328 | if (newPageDialog.exec() == QDialog::Accepted) { | 330 | if (newPageDialog.exec() == QDialog::Accepted) { |
329 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 331 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
330 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 332 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
331 | } | 333 | } |
332 | } | 334 | } |
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index ba9e47d..63d3057 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -1,94 +1,95 @@ | |||
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 | #ifndef DRAWPAD_H | 14 | #ifndef DRAWPAD_H |
15 | #define DRAWPAD_H | 15 | #define DRAWPAD_H |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qpen.h> | 18 | #include <qpen.h> |
19 | 19 | ||
20 | class DrawPadCanvas; | 20 | class DrawPadCanvas; |
21 | class Tool; | 21 | class Tool; |
22 | 22 | ||
23 | class QAction; | 23 | class QAction; |
24 | class QColor; | 24 | class QColor; |
25 | class QSpinBox; | 25 | class QSpinBox; |
26 | class QToolButton; | 26 | class QToolButton; |
27 | class QWidgetStack; | 27 | class QWidgetStack; |
28 | 28 | ||
29 | class DrawPad : public QMainWindow | 29 | class DrawPad : public QMainWindow |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 34 | DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
35 | ~DrawPad(); | 35 | ~DrawPad(); |
36 | 36 | ||
37 | static QString appName() { return QString::fromLatin1("drawpad"); } | 37 | static QString appName() { return QString::fromLatin1("drawpad"); } |
38 | 38 | ||
39 | Tool* tool() { return m_pTool; } | 39 | Tool* tool() { return m_pTool; } |
40 | QPen pen() { return m_pen; } | 40 | QPen pen() { return m_pen; } |
41 | QBrush brush() { return m_brush; } | 41 | QBrush brush() { return m_brush; } |
42 | 42 | ||
43 | bool antiAliasing(); | 43 | bool antiAliasing(); |
44 | void finishStartup(); | ||
45 | 44 | ||
46 | private slots: | 45 | private slots: |
46 | void finishStartup(); | ||
47 | |||
47 | void newPage(); | 48 | void newPage(); |
48 | void clearPage(); | 49 | void clearPage(); |
49 | void deletePage(); | 50 | void deletePage(); |
50 | 51 | ||
51 | void slotAppMessage( const QCString&, const QByteArray& ); | 52 | void slotAppMessage( const QCString&, const QByteArray& ); |
52 | 53 | ||
53 | void setPointTool(); | 54 | void setPointTool(); |
54 | void setLineTool(); | 55 | void setLineTool(); |
55 | void setRectangleTool(); | 56 | void setRectangleTool(); |
56 | void setFilledRectangleTool(); | 57 | void setFilledRectangleTool(); |
57 | void setEllipseTool(); | 58 | void setEllipseTool(); |
58 | void setFilledEllipseTool(); | 59 | void setFilledEllipseTool(); |
59 | void setTextTool(); | 60 | void setTextTool(); |
60 | void setFillTool(); | 61 | void setFillTool(); |
61 | void setEraseTool(); | 62 | void setEraseTool(); |
62 | 63 | ||
63 | void changePenWidth(int value); | 64 | void changePenWidth(int value); |
64 | void changePenColor(const QColor& color); | 65 | void changePenColor(const QColor& color); |
65 | void changeBrushColor(const QColor& color); | 66 | void changeBrushColor(const QColor& color); |
66 | 67 | ||
67 | void updateView(); | 68 | void updateView(); |
68 | 69 | ||
69 | void deleteAll(); | 70 | void deleteAll(); |
70 | void importPage(); | 71 | void importPage(); |
71 | void exportPage(); | 72 | void exportPage(); |
72 | void thumbnailView(); | 73 | void thumbnailView(); |
73 | void pageInformation(); | 74 | void pageInformation(); |
74 | 75 | ||
75 | private: | 76 | private: |
76 | void loadConfig(); | 77 | void loadConfig(); |
77 | void saveConfig(); | 78 | void saveConfig(); |
78 | 79 | ||
79 | DrawPadCanvas* m_pDrawPadCanvas; | 80 | DrawPadCanvas* m_pDrawPadCanvas; |
80 | 81 | ||
81 | Tool* m_pTool; | 82 | Tool* m_pTool; |
82 | QPen m_pen; | 83 | QPen m_pen; |
83 | QBrush m_brush; | 84 | QBrush m_brush; |
84 | 85 | ||
85 | QAction* m_pAntiAliasingAction; | 86 | QAction* m_pAntiAliasingAction; |
86 | 87 | ||
87 | QAction* m_pUndoAction; | 88 | QAction* m_pUndoAction; |
88 | QAction* m_pRedoAction; | 89 | QAction* m_pRedoAction; |
89 | 90 | ||
90 | QAction* m_pFirstPageAction; | 91 | QAction* m_pFirstPageAction; |
91 | QAction* m_pPreviousPageAction; | 92 | QAction* m_pPreviousPageAction; |
92 | QAction* m_pNextPageAction; | 93 | QAction* m_pNextPageAction; |
93 | QAction* m_pLastPageAction; | 94 | QAction* m_pLastPageAction; |
94 | 95 | ||
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 423ef26..5d0c6e4 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -471,62 +471,64 @@ void DrawPadCanvas::goFirstPage() | |||
471 | } | 471 | } |
472 | 472 | ||
473 | void DrawPadCanvas::goPreviousPage() | 473 | void DrawPadCanvas::goPreviousPage() |
474 | { | 474 | { |
475 | m_pages.prev(); | 475 | m_pages.prev(); |
476 | 476 | ||
477 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 477 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
478 | viewport()->update(); | 478 | viewport()->update(); |
479 | 479 | ||
480 | emit pagesChanged(); | 480 | emit pagesChanged(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void DrawPadCanvas::goNextPage() | 483 | void DrawPadCanvas::goNextPage() |
484 | { | 484 | { |
485 | m_pages.next(); | 485 | m_pages.next(); |
486 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 486 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
487 | viewport()->update(); | 487 | viewport()->update(); |
488 | 488 | ||
489 | emit pagesChanged(); | 489 | emit pagesChanged(); |
490 | } | 490 | } |
491 | 491 | ||
492 | void DrawPadCanvas::goLastPage() | 492 | void DrawPadCanvas::goLastPage() |
493 | { | 493 | { |
494 | m_pages.last(); | 494 | m_pages.last(); |
495 | 495 | ||
496 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 496 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
497 | viewport()->update(); | 497 | viewport()->update(); |
498 | 498 | ||
499 | emit pagesChanged(); | 499 | emit pagesChanged(); |
500 | } | 500 | } |
501 | 501 | ||
502 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 502 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
503 | { | 503 | { |
504 | m_pDrawPad->tool()->mousePressEvent(e); | 504 | m_pDrawPad->tool()->mousePressEvent(e); |
505 | } | 505 | } |
506 | 506 | ||
507 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 507 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
508 | { | 508 | { |
509 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 509 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
510 | } | 510 | } |
511 | 511 | ||
512 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 512 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
513 | { | 513 | { |
514 | m_pDrawPad->tool()->mouseMoveEvent(e); | 514 | m_pDrawPad->tool()->mouseMoveEvent(e); |
515 | } | 515 | } |
516 | 516 | ||
517 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 517 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
518 | { | 518 | { |
519 | Page* currentPage = m_pages.current(); | ||
520 | if ( !currentPage ) return; // no page yet --> initialization not finished (Mickeyl) | ||
519 | QRect clipRect(cx, cy, cw, ch); | 521 | QRect clipRect(cx, cy, cw, ch); |
520 | QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 522 | QRect pixmapRect(0, 0, currentPage->pixmap()->width(), m_pages.current()->pixmap()->height()); |
521 | QRect drawRect = pixmapRect.intersect(clipRect); | 523 | QRect drawRect = pixmapRect.intersect(clipRect); |
522 | 524 | ||
523 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); | 525 | p->drawPixmap(drawRect.topLeft(), *(currentPage->pixmap()), drawRect); |
524 | 526 | ||
525 | if (drawRect.right() < clipRect.right()) { | 527 | if (drawRect.right() < clipRect.right()) { |
526 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); | 528 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); |
527 | } | 529 | } |
528 | 530 | ||
529 | if (drawRect.bottom() < clipRect.bottom()) { | 531 | if (drawRect.bottom() < clipRect.bottom()) { |
530 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); | 532 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); |
531 | } | 533 | } |
532 | } | 534 | } |
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp index e48bb2e..f468022 100644 --- a/noncore/graphics/drawpad/main.cpp +++ b/noncore/graphics/drawpad/main.cpp | |||
@@ -1,20 +1,19 @@ | |||
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 <opie2/oapplicationfactory.h> | 16 | #include <opie2/oapplicationfactory.h> |
17 | 17 | ||
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | using namespace Opie::Core; | ||
20 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) | 19 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) |