summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-05-13 21:56:23 (UTC)
committer mickeyl <mickeyl>2004-05-13 21:56:23 (UTC)
commitf005863ac3e3106f3da9fd337ab0a20da0cd4b83 (patch) (side-by-side diff)
treeb633e278659c87b7bc964bb5ea80d46131798960
parent6841da6429d864d5554c5a16e87c2755fe96343b (diff)
downloadopie-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() ) );
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ChangeLog1
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp6
-rw-r--r--noncore/graphics/drawpad/drawpad.h3
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp6
-rw-r--r--noncore/graphics/drawpad/main.cpp1
5 files changed, 11 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c26832..de27eb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,46 +1,47 @@
2004-??-?? The Opie Team <opie@handhelds.org>
+ * Fixed Drawpad initialization (Bug #1314) (mickeyl)
* Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle)
* Added Conversion tool for pim-data (eilers)
* Modifcation of the PIM API for providing generic use of OPimRecords. (eilers)
2004-25-04 The Opie Team <opie@handhelds.org>
* Released as Version 1.1.3 (devel)
* Introduced first implementation of SQL-Support using SQLite (eilers)
* Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp)
* Added a real system graffiti character set (brad)
* Added Generic Keyconfig Widget (zecke)
* Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke)
* Added new Bible reader app - opie-dagger (drw)
* Added a new Image Viewer. Work is ongoing (zecke,alwin)
* Added namespace usage in libopie2 and everywhere (zecke,alwin)
* Enabled the possibility to pass command line arguments to applications (mickeyl)
* Added an about applet showing some credits and information about Opie (mickeyl)
* Added benchmarking functionality to sysinfo (mickeyl)
* Added applet and configuration application for switching hardware keyboard layouts (alwin)
* Ported applications from libopie1 to libopie2* (drw,ar,alwin)
* Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe)
* Clean-up of package information in control files (drw)
* Repaired mediummount which was broken since integrating the quicklauncher (alwin)
* Improved big-screen support (zecke,ar)
* Improved multikeyboard support, added keyboard layout switching applet (mouse)
* Added a new mail client based on libetpan (harlekin,alwin,jgf)
* Added new package manager - opie-packagemanager (drw)
* Improved light-n-power for C7x0 (mickeyl)
* Added automatic rotation support for C7x0 (treke)
* Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl)
* Added scanning the wireless network neighbourhood to networksettings (mickeyl)
2003-11-29 The Opie Team <opie@handhelds.org>
* Released as Version 1.0.3
* Improved i18n (various contributors)
* Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin)
* Made the Documents Tab optional (mickeyl)
* Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken)
2003-08-04 The Opie Team <opie@handhelds.org>
* Released as Version 1.0.0
* 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 @@
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "drawpad.h"
#include "drawpadcanvas.h"
#include "ellipsetool.h"
#include "erasetool.h"
#include "exportdialog.h"
#include "filledellipsetool.h"
#include "filledrectangletool.h"
#include "filltool.h"
#include "importdialog.h"
#include "linetool.h"
#include "newpagedialog.h"
#include "page.h"
#include "pageinformationdialog.h"
#include "pointtool.h"
#include "rectangletool.h"
#include "texttool.h"
#include "thumbnailview.h"
#include <opie2/qcolordialog.h>
#include <opie2/ocolorpopupmenu.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qtoolbar.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qmenubar.h>
#include <qaction.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
using namespace Opie::Ui;
-using namespace Opie::Ui;
DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
: QMainWindow(parent, name, WStyle_ContextHelp)
{
// init members
connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) );
m_pDrawPadCanvas = new DrawPadCanvas(this, this);
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
setCentralWidget(m_pDrawPadCanvas);
// init menu
setToolBarsMovable(false);
QToolBar* menuToolBar = new QToolBar(this);
QMenuBar* menuBar = new QMenuBar(menuToolBar);
QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
deleteAllAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
importPageAction->addTo(toolsPopupMenu);
QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
exportPageAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
thumbnailViewAction->addTo(toolsPopupMenu);
QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
pageInformationAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
@@ -236,97 +235,100 @@ DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
m_pTool = 0;
setRectangleTool();
setEllipseTool();
setPointTool();
emptyToolBar = new QToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
emptyToolBar->addSeparator();
// init draw parameters toolbar
QToolBar* drawParametersToolBar = new QToolBar(this);
m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
m_pPenWidthSpinBox->setValue(1);
m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, m_pPenColorToolButton);
connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
m_pPenColorToolButton->setPopup(penColorPopupMenu);
m_pPenColorToolButton->setPopupDelay(0);
changePenColor(Qt::black);
m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
Opie::OColorPopupMenu* brushColorPopupMenu = new Opie::OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
m_pBrushColorToolButton->setPopupDelay(0);
changeBrushColor(Qt::white);
- finishStartup();
+ // delay the rest of the initialization and do it from within the mainloop
+ // if we don't do this, the widget layout may not be constructed upon
+ // and we will end up with a wrong QScrollview page size (Mickeyl)
+ QTimer::singleShot( 100, this, SLOT( finishStartup() ) );
}
void DrawPad::finishStartup()
{
// init pages
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_ReadOnly)) {
m_pDrawPadCanvas->load(&file);
file.close();
} else {
m_pDrawPadCanvas->initialPage();
}
loadConfig();
}
DrawPad::~DrawPad()
{
saveConfig();
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_WriteOnly)) {
m_pDrawPadCanvas->save(&file);
file.close();
}
}
bool DrawPad::antiAliasing()
{
return (m_pAntiAliasingAction->isOn());
}
void DrawPad::newPage()
{
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
newPageDialog.selectedHeight(), newPageDialog.selectedColor());
}
}
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 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DRAWPAD_H
#define DRAWPAD_H
#include <qmainwindow.h>
#include <qpen.h>
class DrawPadCanvas;
class Tool;
class QAction;
class QColor;
class QSpinBox;
class QToolButton;
class QWidgetStack;
class DrawPad : public QMainWindow
{
Q_OBJECT
public:
DrawPad(QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
~DrawPad();
static QString appName() { return QString::fromLatin1("drawpad"); }
Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
bool antiAliasing();
- void finishStartup();
private slots:
+ void finishStartup();
+
void newPage();
void clearPage();
void deletePage();
void slotAppMessage( const QCString&, const QByteArray& );
void setPointTool();
void setLineTool();
void setRectangleTool();
void setFilledRectangleTool();
void setEllipseTool();
void setFilledEllipseTool();
void setTextTool();
void setFillTool();
void setEraseTool();
void changePenWidth(int value);
void changePenColor(const QColor& color);
void changeBrushColor(const QColor& color);
void updateView();
void deleteAll();
void importPage();
void exportPage();
void thumbnailView();
void pageInformation();
private:
void loadConfig();
void saveConfig();
DrawPadCanvas* m_pDrawPadCanvas;
Tool* m_pTool;
QPen m_pen;
QBrush m_brush;
QAction* m_pAntiAliasingAction;
QAction* m_pUndoAction;
QAction* m_pRedoAction;
QAction* m_pFirstPageAction;
QAction* m_pPreviousPageAction;
QAction* m_pNextPageAction;
QAction* m_pLastPageAction;
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()
}
void DrawPadCanvas::goPreviousPage()
{
m_pages.prev();
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::goNextPage()
{
m_pages.next();
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::goLastPage()
{
m_pages.last();
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mousePressEvent(e);
}
void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mouseReleaseEvent(e);
}
void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mouseMoveEvent(e);
}
void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
{
+ Page* currentPage = m_pages.current();
+ if ( !currentPage ) return; // no page yet --> initialization not finished (Mickeyl)
QRect clipRect(cx, cy, cw, ch);
- QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
+ QRect pixmapRect(0, 0, currentPage->pixmap()->width(), m_pages.current()->pixmap()->height());
QRect drawRect = pixmapRect.intersect(clipRect);
- p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect);
+ p->drawPixmap(drawRect.topLeft(), *(currentPage->pixmap()), drawRect);
if (drawRect.right() < clipRect.right()) {
p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark());
}
if (drawRect.bottom() < clipRect.bottom()) {
p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark());
}
}
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 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "drawpad.h"
#include <opie2/oapplicationfactory.h>
using namespace Opie::Core;
-using namespace Opie::Core;
OPIE_EXPORT_APP( OApplicationFactory<DrawPad> )