author | leseb <leseb> | 2002-06-08 16:46:59 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-08 16:46:59 (UTC) |
commit | 0fef046e0668d727df1884422144b26851d7de41 (patch) (side-by-side diff) | |
tree | e25a8838720d1ce0a3e419ddf079f84f1e148588 /noncore/graphics | |
parent | 571908b989a85d256767dc5b27bccdb717554bb5 (diff) | |
download | opie-0fef046e0668d727df1884422144b26851d7de41.zip opie-0fef046e0668d727df1884422144b26851d7de41.tar.gz opie-0fef046e0668d727df1884422144b26851d7de41.tar.bz2 |
Working version of new page and clear page in thumbnail view
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 17 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 33 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 38 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 7 |
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 @@ -21,8 +21,9 @@ #include "filledrectangletool.h" #include "filltool.h" #include "importdialog.h" #include "linetool.h" +#include "newpagedialog.h" #include "pointtool.h" #include "rectangletool.h" #include "texttool.h" #include "thumbnailview.h" @@ -92,9 +93,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name) QPEToolBar* pageToolBar = new QPEToolBar(this); QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); - connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); + connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); newPageAction->addTo(pageToolBar); QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); @@ -267,8 +268,20 @@ DrawPad::~DrawPad() file.close(); } } +void DrawPad::newPage() +{ + QRect rect = m_pDrawPadCanvas->contentsRect(); + + NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); + + if (newPageDialog.exec() == QDialog::Accepted) { + m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), + newPageDialog.selectedColor()); + } +} + void DrawPad::clearPage() { QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), QMessageBox::Information, QMessageBox::Yes, @@ -574,9 +587,9 @@ void DrawPad::exportPage() } void DrawPad::thumbnailView() { - ThumbnailView thumbnailView(m_pDrawPadCanvas, this); + ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); thumbnailView.showMaximized(); 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 @@ -38,8 +38,9 @@ public: QPen pen() { return m_pen; } QBrush brush() { return m_brush; } private slots: + void newPage(); void clearPage(); void deletePage(); void setPointTool(); 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 @@ -13,9 +13,8 @@ #include "drawpadcanvas.h" #include "drawpad.h" -#include "newpagedialog.h" #include "page.h" #include "tool.h" #include <qpe/applnk.h> @@ -372,36 +371,34 @@ void DrawPadCanvas::deleteAll() emit pagesChanged(); emit pageBackupsChanged(); } -void DrawPadCanvas::newPage() +void DrawPadCanvas::newPage(uint width, uint height, const QColor& color) { - QRect rect = contentsRect(); + m_pages.insert(m_pages.at() + 1, new Page(width, height)); + m_pages.current()->fill(color); - NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), - m_pDrawPad->brush().color(), this); - - if (newPageDialog.exec() == QDialog::Accepted) { - m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(), - newPageDialog.selectedHeight())); - m_pages.current()->fill(newPageDialog.selectedColor()); - - m_pageBackups.clear(); - m_pageBackups.append(new Page(*(m_pages.current()))); + m_pageBackups.clear(); + m_pageBackups.append(new Page(*(m_pages.current()))); - resizeContents(m_pages.current()->width(), m_pages.current()->height()); - viewport()->update(); + resizeContents(m_pages.current()->width(), m_pages.current()->height()); + viewport()->update(); - emit pagesChanged(); - emit pageBackupsChanged(); - } + emit pagesChanged(); + emit pageBackupsChanged(); } void DrawPadCanvas::clearPage() { m_pages.current()->fill(Qt::white); + m_pageBackups.clear(); + m_pageBackups.append(new Page(*(m_pages.current()))); + + resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); + + emit pageBackupsChanged(); } void 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 @@ -51,9 +51,9 @@ public: void backupPage(); public slots: void deleteAll(); - void newPage(); + void newPage(uint width, uint height, const QColor& color); void clearPage(); void deletePage(); void undo(); 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 @@ -12,9 +12,11 @@ ***************************************************************************/ #include "thumbnailview.h" +#include "drawpad.h" #include "drawpadcanvas.h" +#include "newpagedialog.h" #include "page.h" #include <qpe/resource.h> @@ -142,23 +144,27 @@ Page* PageListView::selected() const return page; } -ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) +ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) { inLoop = false; + + m_pDrawPad = drawPad; m_pDrawPadCanvas = drawPadCanvas; setCaption(tr("Thumbnail")); QToolButton* newPageButton = new QToolButton(this); newPageButton->setIconSet(Resource::loadIconSet("new")); newPageButton->setAutoRaise(true); + connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); QToolButton* clearPageButton = new QToolButton(this); clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); clearPageButton->setAutoRaise(true); + connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); QToolButton* deletePageButton = new QToolButton(this); deletePageButton->setIconSet(Resource::loadIconSet("trash")); deletePageButton->setAutoRaise(true); @@ -213,8 +219,38 @@ void ThumbnailView::exec() qApp->enter_loop(); } } +void ThumbnailView::newPage() +{ + QRect rect = m_pDrawPadCanvas->contentsRect(); + + NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), + m_pDrawPad->brush().color(), this); + + if (newPageDialog.exec() == QDialog::Accepted) { + m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), + newPageDialog.selectedColor()); + m_pPageListView->updateView(); + } +} + +void ThumbnailView::clearPage() +{ + QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), + QMessageBox::Information, QMessageBox::Yes, + QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, + QMessageBox::NoButton, this); + + messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); + messageBox.setButtonText(QMessageBox::No, tr("No")); + + if (messageBox.exec() == QMessageBox::Yes) { + m_pDrawPadCanvas->clearPage(); + m_pPageListView->updateView(); + } +} + void ThumbnailView::deletePage() { QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), QMessageBox::Information, QMessageBox::Yes, 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 @@ -16,8 +16,9 @@ #include <qwidget.h> #include <qlistview.h> +class DrawPad; class DrawPadCanvas; class Page; class PageListViewItem : public QListViewItem @@ -54,20 +55,24 @@ class ThumbnailView : public QWidget { Q_OBJECT public: - ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); + ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); ~ThumbnailView(); void hide(); void exec(); public slots: + void newPage(); + void clearPage(); void deletePage(); void changePage(); private: bool inLoop; + + DrawPad* m_pDrawPad; DrawPadCanvas* m_pDrawPadCanvas; PageListView* m_pPageListView; }; |