summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp58
1 files changed, 14 insertions, 44 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 77fee98..74787e5 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,85 +1,84 @@
/***************************************************************************
* *
* 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 "colordialog.h"
-//#include "colorpanel.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 "pointtool.h"
#include "rectangletool.h"
#include "texttool.h"
+#include <opie/colordialog.h>
+#include <opie/colorpopupmenu.h>
+
#include <qpe/applnk.h>
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
-#include <opie/colordialog.h>
-#include <opie/colorpopupmenu.h>
#include <qaction.h>
#include <qfile.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
DrawPad::DrawPad(QWidget* parent, const char* name)
: QMainWindow(parent, name)
{
// init members
m_pDrawPadCanvas = new DrawPadCanvas(this, this);
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons()));
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption()));
connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons()));
setCentralWidget(m_pDrawPadCanvas);
// init menu
setToolBarsMovable(false);
QPEToolBar* menuToolBar = new QPEToolBar(this);
QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, 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);
menuBar->insertItem(tr("Tools"), toolsPopupMenu);
// init page toolbar
@@ -173,145 +172,116 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
m_pEllipseToolAction->addTo(ellipsePopupMenu);
m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this);
connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
m_pEllipseToolButton->setPopup(ellipsePopupMenu);
m_pEllipseToolButton->setPopupDelay(0);
m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this);
m_pTextToolAction->setToggleAction(true);
connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool()));
m_pTextToolAction->addTo(drawModeToolBar);
m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
m_pFillToolAction->setToggleAction(true);
connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
m_pFillToolAction->addTo(drawModeToolBar);
m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this);
m_pEraseToolAction->setToggleAction(true);
connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
m_pEraseToolAction->addTo(drawModeToolBar);
m_pTool = 0;
setRectangleTool();
setEllipseTool();
setPointTool();
emptyToolBar = new QPEToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
emptyToolBar->addSeparator();
// init draw parameters toolbar
QPEToolBar* drawParametersToolBar = new QPEToolBar(this);
QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
QToolTip::add(penWidthSpinBox, tr("Pen Width"));
penWidthSpinBox->setValue(1);
penWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
- ColorPopupMenu* colorPopupMenu = new ColorPopupMenu( Qt::black, m_pPenColorToolButton );
- m_pPenColorToolButton->setPopup( colorPopupMenu );
- m_pPenColorToolButton->setPopupDelay( 0 );
- QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
- connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changePenColor( const QColor& ) ) );
-
-// QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton);
-
-// ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu);
-// connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
+ ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton);
+ connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
-// penColorPopupMenu->insertItem(penColorPanel);
-// penColorPopupMenu->insertSeparator();
-
-// QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this);
-// connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor()));
-// choosePenColorAction->addTo(penColorPopupMenu);
-
-// m_pPenColorToolButton->setPopup(colorPopupMenu);
-// m_pPenColorToolButton->setPopupDelay(0);
+ QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
+ m_pPenColorToolButton->setPopup(penColorPopupMenu);
+ m_pPenColorToolButton->setPopupDelay(0);
-// penColorPanel->buttonSelected(Qt::black);
+ changePenColor(Qt::black);
m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png"));
+ ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(Qt::white, m_pBrushColorToolButton);
+ connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
- colorPopupMenu = new ColorPopupMenu( Qt::white, m_pBrushColorToolButton );
- m_pBrushColorToolButton->setPopup( colorPopupMenu );
- m_pBrushColorToolButton->setPopupDelay( 0 );
QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
- connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeeBrushColor( const QColor& ) ) );
-
-// QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton);
-
-// ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu);
-// connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
-
-// brushColorPopupMenu->insertItem(brushColorPanel);
-// brushColorPopupMenu->insertSeparator();
-
-// QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this);
-// connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor()));
-// chooseBrushColorAction->addTo(brushColorPopupMenu);
-
-// m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
-// m_pBrushColorToolButton->setPopupDelay(0);
+ m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
+ m_pBrushColorToolButton->setPopupDelay(0);
-// brushColorPanel->buttonSelected(Qt::white);
+ changeBrushColor(Qt::white);
// init pages
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_ReadOnly)) {
m_pDrawPadCanvas->load(&file);
file.close();
} else {
m_pDrawPadCanvas->initialPage();
}
}
DrawPad::~DrawPad()
{
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_WriteOnly)) {
m_pDrawPadCanvas->save(&file);
file.close();
}
}
void DrawPad::setPointTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new PointTool(this, m_pDrawPadCanvas);
m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet());
QToolTip::add(m_pLineToolButton, m_pPointToolAction->text());
disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0);
connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated()));
m_pLineToolButton->setOn(true);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
m_pTextToolAction->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setLineTool()
{
if (m_pTool) {