summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 65b3dea..9f1e50b 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -301,162 +301,171 @@ void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,c
301 QImageIO imageIO(ioDevice, format); 301 QImageIO imageIO(ioDevice, format);
302 302
303 QImage image = m_pages.at(i - 1)->convertToImage(); 303 QImage image = m_pages.at(i - 1)->convertToImage();
304 imageIO.setImage(image); 304 imageIO.setImage(image);
305 imageIO.write(); 305 imageIO.write();
306 delete ioDevice; 306 delete ioDevice;
307 } 307 }
308 } 308 }
309} 309}
310 310
311QPixmap* DrawPadCanvas::currentPage() 311QPixmap* DrawPadCanvas::currentPage()
312{ 312{
313 return m_pages.current(); 313 return m_pages.current();
314} 314}
315 315
316QList<QPixmap> DrawPadCanvas::pages() 316QList<QPixmap> DrawPadCanvas::pages()
317{ 317{
318 return m_pages; 318 return m_pages;
319} 319}
320 320
321uint DrawPadCanvas::pagePosition() 321uint DrawPadCanvas::pagePosition()
322{ 322{
323 return (m_pages.at() + 1); 323 return (m_pages.at() + 1);
324} 324}
325 325
326uint DrawPadCanvas::pageCount() 326uint DrawPadCanvas::pageCount()
327{ 327{
328 return m_pages.count(); 328 return m_pages.count();
329} 329}
330 330
331void DrawPadCanvas::backupPage() 331void DrawPadCanvas::backupPage()
332{ 332{
333 QPixmap* currentBackup = m_pageBackups.current(); 333 QPixmap* currentBackup = m_pageBackups.current();
334 while (m_pageBackups.last() != currentBackup) { 334 while (m_pageBackups.last() != currentBackup) {
335 m_pageBackups.removeLast(); 335 m_pageBackups.removeLast();
336 } 336 }
337 337
338 while (m_pageBackups.count() >= (5 + 1)) { 338 while (m_pageBackups.count() >= (5 + 1)) {
339 m_pageBackups.removeFirst(); 339 m_pageBackups.removeFirst();
340 } 340 }
341 341
342 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 342 m_pageBackups.append(new QPixmap(*(m_pages.current())));
343 343
344 emit pageBackupsChanged(); 344 emit pageBackupsChanged();
345} 345}
346 346
347void DrawPadCanvas::deleteAll() 347void DrawPadCanvas::deleteAll()
348{ 348{
349 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 349 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
350 QMessageBox::Information, QMessageBox::Yes, 350 QMessageBox::Information, QMessageBox::Yes,
351 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 351 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
352 QMessageBox::NoButton, this); 352 QMessageBox::NoButton, this);
353 353
354 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
355 messageBox.setButtonText(QMessageBox::No, tr("No"));
356
354 if (messageBox.exec() == QMessageBox::Yes) { 357 if (messageBox.exec() == QMessageBox::Yes) {
355 m_pages.clear(); 358 m_pages.clear();
356 359
357 m_pages.append(new QPixmap(contentsRect().size())); 360 m_pages.append(new QPixmap(contentsRect().size()));
358 m_pages.current()->fill(Qt::white); 361 m_pages.current()->fill(Qt::white);
359 362
360 m_pageBackups.clear(); 363 m_pageBackups.clear();
361 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 364 m_pageBackups.append(new QPixmap(*(m_pages.current())));
362 365
363 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 366 resizeContents(m_pages.current()->width(), m_pages.current()->height());
364 viewport()->update(); 367 viewport()->update();
365 368
366 emit pagesChanged(); 369 emit pagesChanged();
367 emit pageBackupsChanged(); 370 emit pageBackupsChanged();
368 } 371 }
369} 372}
370 373
371void DrawPadCanvas::newPage() 374void DrawPadCanvas::newPage()
372{ 375{
373 QRect rect = contentsRect(); 376 QRect rect = contentsRect();
374 377
375 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), 378 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
376 m_pDrawPad->brush().color(), this); 379 m_pDrawPad->brush().color(), this);
377 380
378 if (newPageDialog.exec() == QDialog::Accepted) { 381 if (newPageDialog.exec() == QDialog::Accepted) {
379 m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), 382 m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(),
380 newPageDialog.selectedHeight())); 383 newPageDialog.selectedHeight()));
381 m_pages.current()->fill(newPageDialog.selectedColor()); 384 m_pages.current()->fill(newPageDialog.selectedColor());
382 385
383 m_pageBackups.clear(); 386 m_pageBackups.clear();
384 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 387 m_pageBackups.append(new QPixmap(*(m_pages.current())));
385 388
386 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 389 resizeContents(m_pages.current()->width(), m_pages.current()->height());
387 viewport()->update(); 390 viewport()->update();
388 391
389 emit pagesChanged(); 392 emit pagesChanged();
390 emit pageBackupsChanged(); 393 emit pageBackupsChanged();
391 } 394 }
392} 395}
393 396
394void DrawPadCanvas::clearPage() 397void DrawPadCanvas::clearPage()
395{ 398{
396 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), 399 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
397 QMessageBox::Information, QMessageBox::Yes, 400 QMessageBox::Information, QMessageBox::Yes,
398 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 401 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
399 QMessageBox::NoButton, this); 402 QMessageBox::NoButton, this);
400 403
404 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
405 messageBox.setButtonText(QMessageBox::No, tr("No"));
406
401 if (messageBox.exec() == QMessageBox::Yes) { 407 if (messageBox.exec() == QMessageBox::Yes) {
402 m_pages.current()->fill(Qt::white); 408 m_pages.current()->fill(Qt::white);
403 409
404 viewport()->update(); 410 viewport()->update();
405 } 411 }
406} 412}
407 413
408void DrawPadCanvas::deletePage() 414void DrawPadCanvas::deletePage()
409{ 415{
410 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), 416 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
411 QMessageBox::Information, QMessageBox::Yes, 417 QMessageBox::Information, QMessageBox::Yes,
412 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 418 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
413 QMessageBox::NoButton, this); 419 QMessageBox::NoButton, this);
414 420
421 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
422 messageBox.setButtonText(QMessageBox::No, tr("No"));
423
415 if (messageBox.exec() == QMessageBox::Yes) { 424 if (messageBox.exec() == QMessageBox::Yes) {
416 m_pages.remove(m_pages.current()); 425 m_pages.remove(m_pages.current());
417 426
418 if (m_pages.isEmpty()) { 427 if (m_pages.isEmpty()) {
419 m_pages.append(new QPixmap(contentsRect().size())); 428 m_pages.append(new QPixmap(contentsRect().size()));
420 m_pages.current()->fill(Qt::white); 429 m_pages.current()->fill(Qt::white);
421 } 430 }
422 431
423 m_pageBackups.clear(); 432 m_pageBackups.clear();
424 m_pageBackups.append(new QPixmap(*(m_pages.current()))); 433 m_pageBackups.append(new QPixmap(*(m_pages.current())));
425 434
426 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 435 resizeContents(m_pages.current()->width(), m_pages.current()->height());
427 viewport()->update(); 436 viewport()->update();
428 437
429 emit pagesChanged(); 438 emit pagesChanged();
430 emit pageBackupsChanged(); 439 emit pageBackupsChanged();
431 } 440 }
432} 441}
433 442
434bool DrawPadCanvas::undoEnabled() 443bool DrawPadCanvas::undoEnabled()
435{ 444{
436 return (m_pageBackups.current() != m_pageBackups.getFirst()); 445 return (m_pageBackups.current() != m_pageBackups.getFirst());
437} 446}
438 447
439bool DrawPadCanvas::redoEnabled() 448bool DrawPadCanvas::redoEnabled()
440{ 449{
441 return (m_pageBackups.current() != m_pageBackups.getLast()); 450 return (m_pageBackups.current() != m_pageBackups.getLast());
442} 451}
443 452
444bool DrawPadCanvas::goPreviousPageEnabled() 453bool DrawPadCanvas::goPreviousPageEnabled()
445{ 454{
446 return (m_pages.current() != m_pages.getFirst()); 455 return (m_pages.current() != m_pages.getFirst());
447} 456}
448 457
449bool DrawPadCanvas::goNextPageEnabled() 458bool DrawPadCanvas::goNextPageEnabled()
450{ 459{
451 return (m_pages.current() != m_pages.getLast()); 460 return (m_pages.current() != m_pages.getLast());
452} 461}
453 462
454void DrawPadCanvas::undo() 463void DrawPadCanvas::undo()
455{ 464{
456 *(m_pages.current()) = *(m_pageBackups.prev()); 465 *(m_pages.current()) = *(m_pageBackups.prev());
457 466
458 viewport()->update(); 467 viewport()->update();
459 468
460 emit pageBackupsChanged(); 469 emit pageBackupsChanged();
461} 470}
462 471