summaryrefslogtreecommitdiff
authorzecke <zecke>2004-04-08 00:42:01 (UTC)
committer zecke <zecke>2004-04-08 00:42:01 (UTC)
commit5afca2540a2d6bf733c89ea97748496a679bc576 (patch) (unidiff)
tree3e4e419ccc0e1b1cb71cc2cf7e75d36f9301de81
parent8c54ad421c7bee65b2a1442ce85c09f2eff3efc6 (diff)
downloadopie-5afca2540a2d6bf733c89ea97748496a679bc576.zip
opie-5afca2540a2d6bf733c89ea97748496a679bc576.tar.gz
opie-5afca2540a2d6bf733c89ea97748496a679bc576.tar.bz2
Import a QPixmap via QCOP
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
@@ -53,8 +53,10 @@ using namespace Opie::Ui;
53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ ) 53DrawPad::DrawPad(QWidget* parent, const char* name, WFlags /*fl*/ )
54 : QMainWindow(parent, name, WStyle_ContextHelp) 54 : QMainWindow(parent, name, WStyle_ContextHelp)
55{ 55{
56 // init members 56 // init members
57 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
58 this, SLOT(slotAppMessage(const QCString&, const QByteArray&)) );
57 59
58 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 60 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
59 61
60 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 62 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
@@ -662,4 +664,21 @@ void DrawPad::saveConfig()
662 config.writeEntry("PenWidth", (int)m_pen.width()); 664 config.writeEntry("PenWidth", (int)m_pen.width());
663 config.writeEntry("PenColor", m_pen.color().name()); 665 config.writeEntry("PenColor", m_pen.color().name());
664 config.writeEntry("BrushColor", m_brush.color().name()); 666 config.writeEntry("BrushColor", m_brush.color().name());
665} 667}
668
669
670/*
671 * Import a Thumbnail from SCAP or similiar
672 */
673void DrawPad::slotAppMessage( const QCString& str, const QByteArray& ar ) {
674 QDataStream stream(ar, IO_ReadOnly );
675 /*
676 * import the pixmap
677 */
678 if ( str == "importPixmap(QPixmap)" ) {
679 QPixmap pix;
680 stream >> pix;;
681 m_pDrawPadCanvas->importPixmap( pix );
682 QPEApplication::setKeepRunning();
683 }
684}
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
@@ -47,8 +47,10 @@ private slots:
47 void newPage(); 47 void newPage();
48 void clearPage(); 48 void clearPage();
49 void deletePage(); 49 void deletePage();
50 50
51 void slotAppMessage( const QCString&, const QByteArray& );
52
51 void setPointTool(); 53 void setPointTool();
52 void setLineTool(); 54 void setLineTool();
53 void setRectangleTool(); 55 void setRectangleTool();
54 void setFilledRectangleTool(); 56 void setFilledRectangleTool();
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
@@ -179,9 +179,9 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
179 179
180 m_pages = drawPadCanvasXmlHandler.pages(); 180 m_pages = drawPadCanvasXmlHandler.pages();
181 181
182 if (m_pages.isEmpty()) { 182 if (m_pages.isEmpty()) {
183 m_pages.append(new Page("", 183 m_pages.append(new Page("",
184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 184 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 185 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
186 m_pages.current()->pixmap()->fill(Qt::white); 186 m_pages.current()->pixmap()->fill(Qt::white);
187 } 187 }
@@ -193,9 +193,9 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
193} 193}
194 194
195void DrawPadCanvas::initialPage() 195void DrawPadCanvas::initialPage()
196{ 196{
197 m_pages.append(new Page("", 197 m_pages.append(new Page("",
198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 198 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 199 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
200 //236, 232)); no more fixed sizes 200 //236, 232)); no more fixed sizes
201 201
@@ -264,8 +264,20 @@ void DrawPadCanvas::importPage(const QString& fileName)
264 264
265 emit pagesChanged(); 265 emit pagesChanged();
266} 266}
267 267
268void DrawPadCanvas::importPixmap( const QPixmap& pix ) {
269 Page* importedPage = new Page();
270
271 (*importedPage->pixmap()) = pix;
272 m_pages.insert(m_pages.at()+1, importedPage );
273 resizeContents(m_pages.current()->pixmap()->width(),
274 m_pages.current()->pixmap()->height() );
275 viewport()->update();
276
277 emit pagesChanged();
278}
279
268void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) 280void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
269{ 281{
270 if (fromPage == toPage) { 282 if (fromPage == toPage) {
271 DocLnk docLnk; 283 DocLnk docLnk;
@@ -352,9 +364,9 @@ void DrawPadCanvas::selectPage(uint pagePosition)
352void DrawPadCanvas::deleteAll() 364void DrawPadCanvas::deleteAll()
353{ 365{
354 m_pages.clear(); 366 m_pages.clear();
355 367
356 m_pages.append(new Page("", 368 m_pages.append(new Page("",
357 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 369 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
358 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 370 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
359 371
360 m_pages.current()->pixmap()->fill(Qt::white); 372 m_pages.current()->pixmap()->fill(Qt::white);
@@ -388,9 +400,9 @@ void DrawPadCanvas::deletePage()
388{ 400{
389 m_pages.remove(m_pages.current()); 401 m_pages.remove(m_pages.current());
390 402
391 if (m_pages.isEmpty()) { 403 if (m_pages.isEmpty()) {
392 m_pages.append(new Page("", 404 m_pages.append(new Page("",
393 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), 405 clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
394 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); 406 clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
395 407
396 m_pages.current()->pixmap()->fill(Qt::white); 408 m_pages.current()->pixmap()->fill(Qt::white);
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
@@ -22,9 +22,9 @@
22class DrawPad; 22class DrawPad;
23class Page; 23class Page;
24 24
25class DrawPadCanvas : public QScrollView 25class DrawPadCanvas : public QScrollView
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28 28
29public: 29public:
30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0); 30 DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
@@ -35,8 +35,9 @@ public:
35 void save(QIODevice* ioDevice); 35 void save(QIODevice* ioDevice);
36 36
37 void importPage(const QString& fileName); 37 void importPage(const QString& fileName);
38 void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format); 38 void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
39 void importPixmap( const QPixmap& );
39 40
40 bool goPreviousPageEnabled(); 41 bool goPreviousPageEnabled();
41 bool goNextPageEnabled(); 42 bool goNextPageEnabled();
42 43
@@ -55,9 +56,9 @@ public slots:
55 void clearPage(); 56 void clearPage();
56 void deletePage(); 57 void deletePage();
57 void movePageUp(); 58 void movePageUp();
58 void movePageDown(); 59 void movePageDown();
59 60
60 void undo(); 61 void undo();
61 void redo(); 62 void redo();
62 63
63 void goFirstPage(); 64 void goFirstPage();