-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 |
4 files changed, 10 insertions, 6 deletions
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 | |||
@@ -40,25 +40,24 @@ | |||
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); |
@@ -272,25 +271,28 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) | |||
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(); |
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 | |||
@@ -32,27 +32,28 @@ class DrawPad : public QMainWindow | |||
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(); |
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 | |||
@@ -507,26 +507,28 @@ void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | |||
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 | |||
@@ -7,14 +7,13 @@ | |||
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> ) |