author | drw <drw> | 2002-04-26 00:51:19 (UTC) |
---|---|---|
committer | drw <drw> | 2002-04-26 00:51:19 (UTC) |
commit | 97e07ec8e7345d90913791edba813d4b72aa33a9 (patch) (side-by-side diff) | |
tree | 468906df1cbe3db449c771071482d9a79d3f39f0 | |
parent | a111f57eedcf27623e9bff2816c83d3287272aff (diff) | |
download | opie-97e07ec8e7345d90913791edba813d4b72aa33a9.zip opie-97e07ec8e7345d90913791edba813d4b72aa33a9.tar.gz opie-97e07ec8e7345d90913791edba813d4b72aa33a9.tar.bz2 |
Use new ColorPopupMenu and ColorDialog found in libopie
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 77 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.pro | 10 |
3 files changed, 43 insertions, 48 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 7e6fc53..77fee98 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp @@ -4,44 +4,46 @@ * * * (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 "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 <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 @@ -207,62 +209,73 @@ DrawPad::DrawPad(QWidget* parent, const char* name) 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")); - QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); + 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& ) ) ); - ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); - connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); +// QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); - penColorPopupMenu->insertItem(penColorPanel); - penColorPopupMenu->insertSeparator(); +// ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); +// connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); - QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); - connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); - choosePenColorAction->addTo(penColorPopupMenu); +// penColorPopupMenu->insertItem(penColorPanel); +// penColorPopupMenu->insertSeparator(); - QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); - m_pPenColorToolButton->setPopup(penColorPopupMenu); - m_pPenColorToolButton->setPopupDelay(0); +// QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); +// connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); +// choosePenColorAction->addTo(penColorPopupMenu); - penColorPanel->buttonSelected(Qt::black); +// m_pPenColorToolButton->setPopup(colorPopupMenu); +// m_pPenColorToolButton->setPopupDelay(0); + +// penColorPanel->buttonSelected(Qt::black); m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); - QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); - ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); - connect(brushColorPanel, 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& ) ) ); - brushColorPopupMenu->insertItem(brushColorPanel); - brushColorPopupMenu->insertSeparator(); +// QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); - QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); - connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); - chooseBrushColorAction->addTo(brushColorPopupMenu); +// ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); +// connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); - QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); - m_pBrushColorToolButton->setPopup(brushColorPopupMenu); - m_pBrushColorToolButton->setPopupDelay(0); +// 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); - brushColorPanel->buttonSelected(Qt::white); +// brushColorPanel->buttonSelected(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(); } } @@ -477,36 +490,24 @@ void DrawPad::changePenColor(const QColor& color) void DrawPad::changeBrushColor(const QColor& color) { m_brush = QBrush(color); QPainter painter; painter.begin(m_pBrushColorToolButton->pixmap()); painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); painter.end(); m_pBrushColorToolButton->popup()->hide(); } -void DrawPad::choosePenColor() -{ - QColor newPenColor = QColorDialog::getColor(m_pen.color()); - changePenColor(newPenColor); -} - -void DrawPad::chooseBrushColor() -{ - QColor newBrushColor = QColorDialog::getColor(m_brush.color()); - changeBrushColor(newBrushColor); -} - void DrawPad::updateUndoRedoToolButtons() { m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); } void DrawPad::updateNavigationToolButtons() { m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index e4fd831..0dcd5c9 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h @@ -18,51 +18,49 @@ #include <qpen.h> class DrawPadCanvas; class Tool; class QAction; class QColor; class QToolButton; class QWidgetStack; class DrawPad : public QMainWindow -{ +{ Q_OBJECT public: DrawPad(QWidget* parent = 0, const char* name = 0); ~DrawPad(); Tool* tool() { return m_pTool; } QPen pen() { return m_pen; } QBrush brush() { return m_brush; } private slots: 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 choosePenColor(); - void chooseBrushColor(); void updateUndoRedoToolButtons(); void updateNavigationToolButtons(); void updateCaption(); void importPage(); void exportPage(); private: DrawPadCanvas* m_pDrawPadCanvas; Tool* m_pTool; diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro index 00eb00d..3b120c9 100644 --- a/noncore/graphics/drawpad/drawpad.pro +++ b/noncore/graphics/drawpad/drawpad.pro @@ -1,55 +1,51 @@ TEMPLATE = app CONFIG = qt warn_on release -HEADERS = colordialog.h \ - colorpanel.h \ - drawpad.h \ +HEADERS = drawpad.h \ drawpadcanvas.h \ ellipsetool.h \ erasetool.h \ exportdialog.h \ filltool.h \ filledellipsetool.h \ filledrectangletool.h \ importdialog.h \ linetool.h \ newpagedialog.h \ pointtool.h \ rectangletool.h \ shapetool.h \ texttool.h \ tool.h -SOURCES = colordialog.cpp \ - colorpanel.cpp \ - drawpad.cpp \ +SOURCES = drawpad.cpp \ drawpadcanvas.cpp \ ellipsetool.cpp \ erasetool.cpp \ exportdialog.cpp \ filltool.cpp \ filledellipsetool.cpp \ filledrectangletool.cpp \ importdialog.cpp \ linetool.cpp \ main.cpp \ newpagedialog.cpp \ pointtool.cpp \ rectangletool.cpp \ shapetool.cpp \ texttool.cpp \ tool.cpp INCLUDEPATH += $(OPIEDIR)/include \ $(QTDIR)/src/3rdparty/zlib DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie DESTDIR = $(OPIEDIR)/bin TARGET = drawpad TRANSLATIONS = ../../i18n/pt_BR/drawpad.ts TRANSLATIONS += ../../i18n/de/drawpad.ts TRANSLATIONS += ../../i18n/en/drawpad.ts TRANSLATIONS += ../../i18n/hu/drawpad.ts TRANSLATIONS += ../../i18n/pl/drawpad.ts TRANSLATIONS += ../../i18n/ja/drawpad.ts TRANSLATIONS += ../../i18n/sl/drawpad.ts TRANSLATIONS += ../../i18n/fr/drawpad.ts TRANSLATIONS += ../../i18n/ko/drawpad.ts |