Diffstat (limited to 'noncore/graphics/drawpad/thumbnailview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
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 | |||
@@ -4,25 +4,27 @@ | |||
4 | * * | 4 | * * |
5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * | 5 | * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * |
6 | * * | 6 | * * |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | * * | 11 | * * |
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
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> |
20 | 22 | ||
21 | #include <qapplication.h> | 23 | #include <qapplication.h> |
22 | #include <qheader.h> | 24 | #include <qheader.h> |
23 | #include <qimage.h> | 25 | #include <qimage.h> |
24 | #include <qlayout.h> | 26 | #include <qlayout.h> |
25 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
26 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
27 | 29 | ||
28 | PageListViewItem::PageListViewItem(Page* page, QListView* parent) | 30 | PageListViewItem::PageListViewItem(Page* page, QListView* parent) |
@@ -134,39 +136,43 @@ Page* PageListView::selected() const | |||
134 | 136 | ||
135 | PageListViewItem* item = (PageListViewItem*)selectedItem(); | 137 | PageListViewItem* item = (PageListViewItem*)selectedItem(); |
136 | 138 | ||
137 | if (item) { | 139 | if (item) { |
138 | page = item->page(); | 140 | page = item->page(); |
139 | } else { | 141 | } else { |
140 | page = NULL; | 142 | page = NULL; |
141 | } | 143 | } |
142 | 144 | ||
143 | return page; | 145 | return page; |
144 | } | 146 | } |
145 | 147 | ||
146 | ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 148 | ThumbnailView::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")); |
153 | 157 | ||
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")); |
164 | deletePageButton->setAutoRaise(true); | 170 | deletePageButton->setAutoRaise(true); |
165 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | 171 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); |
166 | 172 | ||
167 | QToolButton* movePageUpButton = new QToolButton(this); | 173 | QToolButton* movePageUpButton = new QToolButton(this); |
168 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | 174 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); |
169 | movePageUpButton->setAutoRaise(true); | 175 | movePageUpButton->setAutoRaise(true); |
170 | 176 | ||
171 | QToolButton* movePageDownButton = new QToolButton(this); | 177 | QToolButton* movePageDownButton = new QToolButton(this); |
172 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | 178 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); |
@@ -205,24 +211,54 @@ void ThumbnailView::hide() | |||
205 | } | 211 | } |
206 | 212 | ||
207 | void ThumbnailView::exec() | 213 | void ThumbnailView::exec() |
208 | { | 214 | { |
209 | show(); | 215 | show(); |
210 | 216 | ||
211 | if (!inLoop) { | 217 | if (!inLoop) { |
212 | inLoop = true; | 218 | inLoop = true; |
213 | qApp->enter_loop(); | 219 | qApp->enter_loop(); |
214 | } | 220 | } |
215 | } | 221 | } |
216 | 222 | ||
223 | void 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 | |||
237 | void 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 | |||
217 | void ThumbnailView::deletePage() | 253 | void 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?"), |
220 | QMessageBox::Information, QMessageBox::Yes, | 256 | QMessageBox::Information, QMessageBox::Yes, |
221 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 257 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
222 | QMessageBox::NoButton, this); | 258 | QMessageBox::NoButton, this); |
223 | 259 | ||
224 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 260 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
225 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 261 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
226 | 262 | ||
227 | if (messageBox.exec() == QMessageBox::Yes) { | 263 | if (messageBox.exec() == QMessageBox::Yes) { |
228 | m_pDrawPadCanvas->deletePage(); | 264 | m_pDrawPadCanvas->deletePage(); |