summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 71c9695..139c752 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,106 +1,107 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
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 "drawpad.h" 14#include "drawpad.h"
15 15
16#include "drawpadcanvas.h" 16#include "drawpadcanvas.h"
17#include "ellipsetool.h" 17#include "ellipsetool.h"
18#include "erasetool.h" 18#include "erasetool.h"
19#include "exportdialog.h" 19#include "exportdialog.h"
20#include "filledellipsetool.h" 20#include "filledellipsetool.h"
21#include "filledrectangletool.h" 21#include "filledrectangletool.h"
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 "newpagedialog.h"
26#include "page.h" 26#include "page.h"
27#include "pageinformationdialog.h" 27#include "pageinformationdialog.h"
28#include "pointtool.h" 28#include "pointtool.h"
29#include "rectangletool.h" 29#include "rectangletool.h"
30#include "texttool.h" 30#include "texttool.h"
31#include "thumbnailview.h" 31#include "thumbnailview.h"
32 32
33#include <opie/colordialog.h> 33#include <opie/colordialog.h>
34#include <opie/colorpopupmenu.h> 34#include <opie/colorpopupmenu.h>
35 35
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qmenubar.h>
40#include <qpe/qpetoolbar.h> 39#include <qpe/qpetoolbar.h>
41#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/qpeapplication.h>
42 42
43#include <qmenubar.h>
43#include <qaction.h> 44#include <qaction.h>
44#include <qfile.h> 45#include <qfile.h>
45#include <qmessagebox.h> 46#include <qmessagebox.h>
46#include <qspinbox.h> 47#include <qspinbox.h>
47#include <qtoolbutton.h> 48#include <qtoolbutton.h>
48#include <qtooltip.h> 49#include <qtooltip.h>
49#include <qwhatsthis.h> 50#include <qwhatsthis.h>
50 51
51DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) 52DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl )
52 : QMainWindow(parent, name, WStyle_ContextHelp) 53 : QMainWindow(parent, name, WStyle_ContextHelp)
53{ 54{
54 // init members 55 // init members
55 56
56 m_pDrawPadCanvas = new DrawPadCanvas(this, this); 57 m_pDrawPadCanvas = new DrawPadCanvas(this, this);
57 58
58 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); 59 connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView()));
59 60
60 setCentralWidget(m_pDrawPadCanvas); 61 setCentralWidget(m_pDrawPadCanvas);
61 62
62 // init menu 63 // init menu
63 64
64 setToolBarsMovable(false); 65 setToolBarsMovable(false);
65 66
66 QToolBar* menuToolBar = new QToolBar(this); 67 QToolBar* menuToolBar = new QToolBar(this);
67 QMenuBar* menuBar = new QMenuBar(menuToolBar); 68 QMenuBar* menuBar = new QMenuBar(menuToolBar);
68 69
69 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); 70 QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar);
70 71
71 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); 72 QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
72 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); 73 connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
73 deleteAllAction->addTo(toolsPopupMenu); 74 deleteAllAction->addTo(toolsPopupMenu);
74 75
75 toolsPopupMenu->insertSeparator(); 76 toolsPopupMenu->insertSeparator();
76 77
77 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); 78 QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
78 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); 79 connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
79 importPageAction->addTo(toolsPopupMenu); 80 importPageAction->addTo(toolsPopupMenu);
80 81
81 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); 82 QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
82 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); 83 connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
83 exportPageAction->addTo(toolsPopupMenu); 84 exportPageAction->addTo(toolsPopupMenu);
84 85
85 toolsPopupMenu->insertSeparator(); 86 toolsPopupMenu->insertSeparator();
86 87
87 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); 88 QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
88 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); 89 connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
89 thumbnailViewAction->addTo(toolsPopupMenu); 90 thumbnailViewAction->addTo(toolsPopupMenu);
90 91
91 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); 92 QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this);
92 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); 93 connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation()));
93 pageInformationAction->addTo(toolsPopupMenu); 94 pageInformationAction->addTo(toolsPopupMenu);
94 95
95 toolsPopupMenu->insertSeparator(); 96 toolsPopupMenu->insertSeparator();
96 97
97 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); 98 m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this);
98 m_pAntiAliasingAction->setToggleAction(true); 99 m_pAntiAliasingAction->setToggleAction(true);
99 m_pAntiAliasingAction->addTo(toolsPopupMenu); 100 m_pAntiAliasingAction->addTo(toolsPopupMenu);
100 101
101 menuBar->insertItem(tr("Tools"), toolsPopupMenu); 102 menuBar->insertItem(tr("Tools"), toolsPopupMenu);
102 103
103 // init page toolbar 104 // init page toolbar
104 105
105 QToolBar* pageToolBar = new QToolBar(this); 106 QToolBar* pageToolBar = new QToolBar(this);
106 107
@@ -540,128 +541,124 @@ void DrawPad::setEraseTool()
540void DrawPad::changePenWidth(int value) 541void DrawPad::changePenWidth(int value)
541{ 542{
542 m_pen.setWidth(value); 543 m_pen.setWidth(value);
543} 544}
544 545
545void DrawPad::changePenColor(const QColor& color) 546void DrawPad::changePenColor(const QColor& color)
546{ 547{
547 m_pen.setColor(color); 548 m_pen.setColor(color);
548 549
549 QPainter painter; 550 QPainter painter;
550 painter.begin(m_pPenColorToolButton->pixmap()); 551 painter.begin(m_pPenColorToolButton->pixmap());
551 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); 552 painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
552 painter.end(); 553 painter.end();
553 554
554 m_pPenColorToolButton->popup()->hide(); 555 m_pPenColorToolButton->popup()->hide();
555} 556}
556 557
557void DrawPad::changeBrushColor(const QColor& color) 558void DrawPad::changeBrushColor(const QColor& color)
558{ 559{
559 m_brush = QBrush(color); 560 m_brush = QBrush(color);
560 561
561 QPainter painter; 562 QPainter painter;
562 painter.begin(m_pBrushColorToolButton->pixmap()); 563 painter.begin(m_pBrushColorToolButton->pixmap());
563 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); 564 painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
564 painter.end(); 565 painter.end();
565 566
566 m_pBrushColorToolButton->popup()->hide(); 567 m_pBrushColorToolButton->popup()->hide();
567} 568}
568 569
569void DrawPad::updateView() 570void DrawPad::updateView()
570{ 571{
571 uint pagePosition = m_pDrawPadCanvas->pagePosition(); 572 uint pagePosition = m_pDrawPadCanvas->pagePosition();
572 uint pageCount = m_pDrawPadCanvas->pageCount(); 573 uint pageCount = m_pDrawPadCanvas->pageCount();
573 574
574 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); 575 setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) );
575 576
576 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); 577 m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled());
577 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); 578 m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled());
578 579
579 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 580 m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
580 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 581 m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
581 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 582 m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
582 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 583 m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
583} 584}
584 585
585void DrawPad::deleteAll() 586void DrawPad::deleteAll()
586{ 587{
587 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 588 QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
588 QMessageBox::Information, QMessageBox::Yes, 589 QMessageBox::Information, QMessageBox::Yes,
589 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 590 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
590 QMessageBox::NoButton, this); 591 QMessageBox::NoButton, this);
591 592
592 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 593 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
593 messageBox.setButtonText(QMessageBox::No, tr("No")); 594 messageBox.setButtonText(QMessageBox::No, tr("No"));
594 595
595 if (messageBox.exec() == QMessageBox::Yes) { 596 if (messageBox.exec() == QMessageBox::Yes) {
596 m_pDrawPadCanvas->deleteAll(); 597 m_pDrawPadCanvas->deleteAll();
597 } 598 }
598} 599}
599 600
600void DrawPad::importPage() 601void DrawPad::importPage()
601{ 602{
602 ImportDialog importDialog(this); 603 ImportDialog importDialog(this);
603 604
604 importDialog.showMaximized(); 605 if ( QPEApplication::execDialog( &importDialog ) == QDialog::Accepted ) {
605
606 if (importDialog.exec() == QDialog::Accepted) {
607 const DocLnk* docLnk = importDialog.selected(); 606 const DocLnk* docLnk = importDialog.selected();
608 607
609 if (docLnk) { 608 if (docLnk) {
610 m_pDrawPadCanvas->importPage(docLnk->file()); 609 m_pDrawPadCanvas->importPage(docLnk->file());
611 delete docLnk; 610 delete docLnk;
612 } 611 }
613 } 612 }
614} 613}
615 614
616void DrawPad::exportPage() 615void DrawPad::exportPage()
617{ 616{
618 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); 617 ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
619 618
620 exportDialog.showMaximized(); 619 if ( QPEApplication::execDialog( &exportDialog ) == QDialog::Accepted ) {
621
622 if (exportDialog.exec() == QDialog::Accepted) {
623 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), 620 m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
624 exportDialog.selectedName(), exportDialog.selectedFormat()); 621 exportDialog.selectedName(), exportDialog.selectedFormat());
625 } 622 }
626} 623}
627 624
628void DrawPad::thumbnailView() 625void DrawPad::thumbnailView()
629{ 626{
630 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); 627 ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this);
631 628
632 thumbnailView.showMaximized(); 629 QPEApplication::showWidget( &thumbnailView );
633 thumbnailView.exec(); 630 thumbnailView.exec();
634} 631}
635 632
636void DrawPad::pageInformation() 633void DrawPad::pageInformation()
637{ 634{
638 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); 635 PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage());
639 636
640 if (pageInformationDialog.exec() == QDialog::Accepted) { 637 if (pageInformationDialog.exec() == QDialog::Accepted) {
641 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); 638 m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
642 } 639 }
643} 640}
644 641
645void DrawPad::loadConfig() 642void DrawPad::loadConfig()
646{ 643{
647 Config config("drawpad"); 644 Config config("drawpad");
648 config.setGroup("General"); 645 config.setGroup("General");
649 646
650 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); 647 m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
651 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); 648 m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
652 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); 649 changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
653 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); 650 changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
654 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); 651 m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
655} 652}
656 653
657void DrawPad::saveConfig() 654void DrawPad::saveConfig()
658{ 655{
659 Config config("drawpad"); 656 Config config("drawpad");
660 config.setGroup("General"); 657 config.setGroup("General");
661 658
662 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); 659 config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
663 config.writeEntry("AntiAliasing", antiAliasing()); 660 config.writeEntry("AntiAliasing", antiAliasing());
664 config.writeEntry("PenWidth", (int)m_pen.width()); 661 config.writeEntry("PenWidth", (int)m_pen.width());
665 config.writeEntry("PenColor", m_pen.color().name()); 662 config.writeEntry("PenColor", m_pen.color().name());
666 config.writeEntry("BrushColor", m_brush.color().name()); 663 config.writeEntry("BrushColor", m_brush.color().name());
667} 664}