summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-08 16:46:59 (UTC)
committer leseb <leseb>2002-06-08 16:46:59 (UTC)
commit0fef046e0668d727df1884422144b26851d7de41 (patch) (unidiff)
treee25a8838720d1ce0a3e419ddf079f84f1e148588
parent571908b989a85d256767dc5b27bccdb717554bb5 (diff)
downloadopie-0fef046e0668d727df1884422144b26851d7de41.zip
opie-0fef046e0668d727df1884422144b26851d7de41.tar.gz
opie-0fef046e0668d727df1884422144b26851d7de41.tar.bz2
Working version of new page and clear page in thumbnail view
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp17
-rw-r--r--noncore/graphics/drawpad/drawpad.h1
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp33
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp38
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h7
6 files changed, 75 insertions, 23 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 58c0d09..ef55268 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -22,6 +22,7 @@
22#include "filltool.h" 22#include "filltool.h"
23#include "importdialog.h" 23#include "importdialog.h"
24#include "linetool.h" 24#include "linetool.h"
25#include "newpagedialog.h"
25#include "pointtool.h" 26#include "pointtool.h"
26#include "rectangletool.h" 27#include "rectangletool.h"
27#include "texttool.h" 28#include "texttool.h"
@@ -93,7 +94,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
93 QPEToolBar* pageToolBar = new QPEToolBar(this); 94 QPEToolBar* pageToolBar = new QPEToolBar(this);
94 95
95 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); 96 QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this);
96 connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); 97 connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage()));
97 newPageAction->addTo(pageToolBar); 98 newPageAction->addTo(pageToolBar);
98 99
99 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); 100 QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this);
@@ -268,6 +269,18 @@ DrawPad::~DrawPad()
268 } 269 }
269} 270}
270 271
272void DrawPad::newPage()
273{
274 QRect rect = m_pDrawPadCanvas->contentsRect();
275
276 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
277
278 if (newPageDialog.exec() == QDialog::Accepted) {
279 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
280 newPageDialog.selectedColor());
281 }
282}
283
271void DrawPad::clearPage() 284void DrawPad::clearPage()
272{ 285{
273 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), 286 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
@@ -575,7 +588,7 @@ void DrawPad::exportPage()
575 588
576void DrawPad::thumbnailView() 589void DrawPad::thumbnailView()
577{ 590{
578 ThumbnailView thumbnailView(m_pDrawPadCanvas, this); 591 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this);
579 592
580 thumbnailView.showMaximized(); 593 thumbnailView.showMaximized();
581 thumbnailView.exec(); 594 thumbnailView.exec();
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 01061b4..9a821f6 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -39,6 +39,7 @@ public:
39 QBrush brush() { return m_brush; } 39 QBrush brush() { return m_brush; }
40 40
41private slots: 41private slots:
42 void newPage();
42 void clearPage(); 43 void clearPage();
43 void deletePage(); 44 void deletePage();
44 45
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 0a1e9a5..c23ee34 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -14,7 +14,6 @@
14#include "drawpadcanvas.h" 14#include "drawpadcanvas.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "newpagedialog.h"
18#include "page.h" 17#include "page.h"
19#include "tool.h" 18#include "tool.h"
20 19
@@ -373,34 +372,32 @@ void DrawPadCanvas::deleteAll()
373 emit pageBackupsChanged(); 372 emit pageBackupsChanged();
374} 373}
375 374
376void DrawPadCanvas::newPage() 375void DrawPadCanvas::newPage(uint width, uint height, const QColor& color)
377{ 376{
378 QRect rect = contentsRect(); 377 m_pages.insert(m_pages.at() + 1, new Page(width, height));
378 m_pages.current()->fill(color);
379 379
380 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), 380 m_pageBackups.clear();
381 m_pDrawPad->brush().color(), this); 381 m_pageBackups.append(new Page(*(m_pages.current())));
382
383 if (newPageDialog.exec() == QDialog::Accepted) {
384 m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(),
385 newPageDialog.selectedHeight()));
386 m_pages.current()->fill(newPageDialog.selectedColor());
387
388 m_pageBackups.clear();
389 m_pageBackups.append(new Page(*(m_pages.current())));
390 382
391 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 383 resizeContents(m_pages.current()->width(), m_pages.current()->height());
392 viewport()->update(); 384 viewport()->update();
393 385
394 emit pagesChanged(); 386 emit pagesChanged();
395 emit pageBackupsChanged(); 387 emit pageBackupsChanged();
396 }
397} 388}
398 389
399void DrawPadCanvas::clearPage() 390void DrawPadCanvas::clearPage()
400{ 391{
401 m_pages.current()->fill(Qt::white); 392 m_pages.current()->fill(Qt::white);
402 393
394 m_pageBackups.clear();
395 m_pageBackups.append(new Page(*(m_pages.current())));
396
397 resizeContents(m_pages.current()->width(), m_pages.current()->height());
403 viewport()->update(); 398 viewport()->update();
399
400 emit pageBackupsChanged();
404} 401}
405 402
406void DrawPadCanvas::deletePage() 403void DrawPadCanvas::deletePage()
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index cf2d904..d74d425 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -52,7 +52,7 @@ public:
52 52
53public slots: 53public slots:
54 void deleteAll(); 54 void deleteAll();
55 void newPage(); 55 void newPage(uint width, uint height, const QColor& color);
56 void clearPage(); 56 void clearPage();
57 void deletePage(); 57 void deletePage();
58 58
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 476b7b9..08e106d 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -13,7 +13,9 @@
13 13
14#include "thumbnailview.h" 14#include "thumbnailview.h"
15 15
16#include "drawpad.h"
16#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "newpagedialog.h"
17#include "page.h" 19#include "page.h"
18 20
19#include <qpe/resource.h> 21#include <qpe/resource.h>
@@ -143,10 +145,12 @@ Page* PageListView::selected() const
143 return page; 145 return page;
144} 146}
145 147
146ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 148ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
147 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) 149 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel)
148{ 150{
149 inLoop = false; 151 inLoop = false;
152
153 m_pDrawPad = drawPad;
150 m_pDrawPadCanvas = drawPadCanvas; 154 m_pDrawPadCanvas = drawPadCanvas;
151 155
152 setCaption(tr("Thumbnail")); 156 setCaption(tr("Thumbnail"));
@@ -154,10 +158,12 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons
154 QToolButton* newPageButton = new QToolButton(this); 158 QToolButton* newPageButton = new QToolButton(this);
155 newPageButton->setIconSet(Resource::loadIconSet("new")); 159 newPageButton->setIconSet(Resource::loadIconSet("new"));
156 newPageButton->setAutoRaise(true); 160 newPageButton->setAutoRaise(true);
161 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage()));
157 162
158 QToolButton* clearPageButton = new QToolButton(this); 163 QToolButton* clearPageButton = new QToolButton(this);
159 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); 164 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
160 clearPageButton->setAutoRaise(true); 165 clearPageButton->setAutoRaise(true);
166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
161 167
162 QToolButton* deletePageButton = new QToolButton(this); 168 QToolButton* deletePageButton = new QToolButton(this);
163 deletePageButton->setIconSet(Resource::loadIconSet("trash")); 169 deletePageButton->setIconSet(Resource::loadIconSet("trash"));
@@ -214,6 +220,36 @@ void ThumbnailView::exec()
214 } 220 }
215} 221}
216 222
223void ThumbnailView::newPage()
224{
225 QRect rect = m_pDrawPadCanvas->contentsRect();
226
227 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
228 m_pDrawPad->brush().color(), this);
229
230 if (newPageDialog.exec() == QDialog::Accepted) {
231 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
232 newPageDialog.selectedColor());
233 m_pPageListView->updateView();
234 }
235}
236
237void ThumbnailView::clearPage()
238{
239 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"),
240 QMessageBox::Information, QMessageBox::Yes,
241 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
242 QMessageBox::NoButton, this);
243
244 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
245 messageBox.setButtonText(QMessageBox::No, tr("No"));
246
247 if (messageBox.exec() == QMessageBox::Yes) {
248 m_pDrawPadCanvas->clearPage();
249 m_pPageListView->updateView();
250 }
251}
252
217void ThumbnailView::deletePage() 253void ThumbnailView::deletePage()
218{ 254{
219 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), 255 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"),
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
index 9417655..1fdb168 100644
--- a/noncore/graphics/drawpad/thumbnailview.h
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -17,6 +17,7 @@
17#include <qwidget.h> 17#include <qwidget.h>
18#include <qlistview.h> 18#include <qlistview.h>
19 19
20class DrawPad;
20class DrawPadCanvas; 21class DrawPadCanvas;
21class Page; 22class Page;
22 23
@@ -55,18 +56,22 @@ class ThumbnailView : public QWidget
55 Q_OBJECT 56 Q_OBJECT
56 57
57public: 58public:
58 ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); 59 ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
59 ~ThumbnailView(); 60 ~ThumbnailView();
60 61
61 void hide(); 62 void hide();
62 void exec(); 63 void exec();
63 64
64public slots: 65public slots:
66 void newPage();
67 void clearPage();
65 void deletePage(); 68 void deletePage();
66 void changePage(); 69 void changePage();
67 70
68private: 71private:
69 bool inLoop; 72 bool inLoop;
73
74 DrawPad* m_pDrawPad;
70 DrawPadCanvas* m_pDrawPadCanvas; 75 DrawPadCanvas* m_pDrawPadCanvas;
71 76
72 PageListView* m_pPageListView; 77 PageListView* m_pPageListView;