-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 @@ -24,2 +24,3 @@ #include "linetool.h" +#include "newpagedialog.h" #include "pointtool.h" @@ -95,3 +96,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name) 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); @@ -270,2 +271,14 @@ DrawPad::~DrawPad() +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() @@ -577,3 +590,3 @@ void DrawPad::thumbnailView() { - ThumbnailView thumbnailView(m_pDrawPadCanvas, this); + ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); 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 @@ -41,2 +41,3 @@ public: private slots: + void newPage(); void clearPage(); 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 @@ -16,3 +16,2 @@ #include "drawpad.h" -#include "newpagedialog.h" #include "page.h" @@ -375,23 +374,15 @@ void DrawPadCanvas::deleteAll() -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(); } @@ -402,3 +393,9 @@ void DrawPadCanvas::clearPage() + m_pageBackups.clear(); + m_pageBackups.append(new Page(*(m_pages.current()))); + + resizeContents(m_pages.current()->width(), m_pages.current()->height()); viewport()->update(); + + emit pageBackupsChanged(); } 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 @@ -54,3 +54,3 @@ public slots: void deleteAll(); - void newPage(); + void newPage(uint width, uint height, const QColor& color); void clearPage(); 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 @@ -15,3 +15,5 @@ +#include "drawpad.h" #include "drawpadcanvas.h" +#include "newpagedialog.h" #include "page.h" @@ -145,3 +147,3 @@ Page* PageListView::selected() const -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) @@ -149,2 +151,4 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons inLoop = false; + + m_pDrawPad = drawPad; m_pDrawPadCanvas = drawPadCanvas; @@ -156,2 +160,3 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons newPageButton->setAutoRaise(true); + connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); @@ -160,2 +165,3 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons clearPageButton->setAutoRaise(true); + connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); @@ -216,2 +222,32 @@ void ThumbnailView::exec() +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() 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 @@ -19,2 +19,3 @@ +class DrawPad; class DrawPadCanvas; @@ -57,3 +58,3 @@ class ThumbnailView : public QWidget public: - ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); + ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); ~ThumbnailView(); @@ -64,2 +65,4 @@ public: public slots: + void newPage(); + void clearPage(); void deletePage(); @@ -69,2 +72,4 @@ private: bool inLoop; + + DrawPad* m_pDrawPad; DrawPadCanvas* m_pDrawPadCanvas; |