summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp19
-rw-r--r--noncore/graphics/drawpad/drawpad.h2
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp20
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h5
4 files changed, 40 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 3331193..d9d0ce0 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -45,24 +45,26 @@
#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);
@@ -654,12 +656,29 @@ void DrawPad::loadConfig()
void DrawPad::saveConfig()
{
Config config("drawpad");
config.setGroup("General");
config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
config.writeEntry("AntiAliasing", antiAliasing());
config.writeEntry("PenWidth", (int)m_pen.width());
config.writeEntry("PenColor", m_pen.color().name());
config.writeEntry("BrushColor", m_brush.color().name());
}
+
+
+/*
+ * Import a Thumbnail from SCAP or similiar
+ */
+void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) {
+ QDataStream stream(ar, IO_ReadOnly );
+ /*
+ * import the pixmap
+ */
+ if ( str == "importPixmap(QPixmap)" ) {
+ QPixmap pix;
+ stream >> pix;;
+ m_pDrawPadCanvas->importPixmap( pix );
+ QPEApplication::setKeepRunning();
+ }
+}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 8ba6e58..ba9e47d 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -39,24 +39,26 @@ public:
Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
bool antiAliasing();
void finishStartup();
private slots:
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);
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 446096c..423ef26 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -171,39 +171,39 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
QXmlInputSource xmlInputSource(textStream);
QXmlSimpleReader xmlSimpleReader;
DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
xmlSimpleReader.parse(xmlInputSource);
m_pages = drawPadCanvasXmlHandler.pages();
if (m_pages.isEmpty()) {
- m_pages.append(new Page("",
+ m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
m_pages.current()->pixmap()->fill(Qt::white);
}
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::initialPage()
{
- m_pages.append(new Page("",
+ m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
//236, 232)); no more fixed sizes
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
@@ -256,24 +256,36 @@ void DrawPadCanvas::importPage(const QString& fileName)
{
Page* importedPage = new Page();
importedPage->pixmap()->load(fileName);
m_pages.insert(m_pages.at() + 1, importedPage);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
+void DrawPadCanvas::importPixmap( const QPixmap& pix ) {
+ Page* importedPage = new Page();
+
+ (*importedPage->pixmap()) = pix;
+ m_pages.insert(m_pages.at()+1, importedPage );
+ resizeContents(m_pages.current()->pixmap()->width(),
+ m_pages.current()->pixmap()->height() );
+ viewport()->update();
+
+ emit pagesChanged();
+}
+
void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
{
if (fromPage == toPage) {
DocLnk docLnk;
MimeType mimeType(format);
docLnk.setName(name);
docLnk.setType(mimeType.id());
FileManager fileManager;
QIODevice* ioDevice = fileManager.saveFile(docLnk);
QImageIO imageIO(ioDevice, format);
@@ -344,25 +356,25 @@ void DrawPadCanvas::selectPage(uint pagePosition)
m_pages.at(pagePosition - 1);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::deleteAll()
{
m_pages.clear();
- m_pages.append(new Page("",
+ m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
@@ -380,25 +392,25 @@ void DrawPadCanvas::clearPage()
{
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
}
void DrawPadCanvas::deletePage()
{
m_pages.remove(m_pages.current());
if (m_pages.isEmpty()) {
- m_pages.append(new Page("",
+ m_pages.append(new Page("",
clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
m_pages.current()->pixmap()->fill(Qt::white);
}
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index 80a2a7e..2b3d4a5 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -14,58 +14,59 @@
#ifndef DRAWPADCANVAS_H
#define DRAWPADCANVAS_H
#include <qscrollview.h>
#include <qlist.h>
#include <qpointarray.h>
class DrawPad;
class Page;
class DrawPadCanvas : public QScrollView
-{
+{
Q_OBJECT
public:
DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
~DrawPadCanvas();
void load(QIODevice* ioDevice);
void initialPage();
void save(QIODevice* ioDevice);
void importPage(const QString& fileName);
void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
+ void importPixmap( const QPixmap& );
bool goPreviousPageEnabled();
bool goNextPageEnabled();
Page* currentPage();
QList<Page> pages();
uint pagePosition();
uint pageCount();
void selectPage(Page* page);
void selectPage(uint pagePosition);
void backupPage();
public slots:
void deleteAll();
void newPage(QString title, uint width, uint height, const QColor& color);
void clearPage();
void deletePage();
void movePageUp();
void movePageDown();
-
+
void undo();
void redo();
void goFirstPage();
void goPreviousPage();
void goNextPage();
void goLastPage();
signals:
void pagesChanged();
protected: