Diffstat (limited to 'noncore/graphics/drawpad/drawpad.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index ef55268..369e7f0 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,136 +1,141 @@ | |||
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 "pageinformationdialog.h" | ||
26 | #include "pointtool.h" | 27 | #include "pointtool.h" |
27 | #include "rectangletool.h" | 28 | #include "rectangletool.h" |
28 | #include "texttool.h" | 29 | #include "texttool.h" |
29 | #include "thumbnailview.h" | 30 | #include "thumbnailview.h" |
30 | 31 | ||
31 | #include <opie/colordialog.h> | 32 | #include <opie/colordialog.h> |
32 | #include <opie/colorpopupmenu.h> | 33 | #include <opie/colorpopupmenu.h> |
33 | 34 | ||
34 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
35 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
36 | #include <qpe/qpemenubar.h> | 37 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpetoolbar.h> | 38 | #include <qpe/qpetoolbar.h> |
38 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
39 | 40 | ||
40 | #include <qaction.h> | 41 | #include <qaction.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
43 | #include <qpainter.h> | 44 | #include <qpainter.h> |
44 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
45 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
46 | #include <qtooltip.h> | 47 | #include <qtooltip.h> |
47 | 48 | ||
48 | DrawPad::DrawPad(QWidget* parent, const char* name) | 49 | DrawPad::DrawPad(QWidget* parent, const char* name) |
49 | : QMainWindow(parent, name) | 50 | : QMainWindow(parent, name) |
50 | { | 51 | { |
51 | // init members | 52 | // init members |
52 | 53 | ||
53 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 54 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
54 | 55 | ||
55 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 56 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
56 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 57 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
57 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 58 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
58 | 59 | ||
59 | setCentralWidget(m_pDrawPadCanvas); | 60 | setCentralWidget(m_pDrawPadCanvas); |
60 | 61 | ||
61 | // init menu | 62 | // init menu |
62 | 63 | ||
63 | setToolBarsMovable(false); | 64 | setToolBarsMovable(false); |
64 | 65 | ||
65 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 66 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
66 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 67 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
67 | 68 | ||
68 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 69 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); |
69 | 70 | ||
70 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 71 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
71 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 72 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
72 | deleteAllAction->addTo(toolsPopupMenu); | 73 | deleteAllAction->addTo(toolsPopupMenu); |
73 | 74 | ||
74 | toolsPopupMenu->insertSeparator(); | 75 | toolsPopupMenu->insertSeparator(); |
75 | 76 | ||
76 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 77 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
77 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 78 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
78 | importPageAction->addTo(toolsPopupMenu); | 79 | importPageAction->addTo(toolsPopupMenu); |
79 | 80 | ||
80 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 81 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
81 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 82 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
82 | exportPageAction->addTo(toolsPopupMenu); | 83 | exportPageAction->addTo(toolsPopupMenu); |
83 | 84 | ||
84 | toolsPopupMenu->insertSeparator(); | 85 | toolsPopupMenu->insertSeparator(); |
85 | 86 | ||
86 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); | 87 | QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); |
87 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 88 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
88 | thumbnailViewAction->addTo(toolsPopupMenu); | 89 | thumbnailViewAction->addTo(toolsPopupMenu); |
90 | |||
91 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | ||
92 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | ||
93 | pageInformationAction->addTo(toolsPopupMenu); | ||
89 | 94 | ||
90 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 95 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
91 | 96 | ||
92 | // init page toolbar | 97 | // init page toolbar |
93 | 98 | ||
94 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 99 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
95 | 100 | ||
96 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 101 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
97 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 102 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
98 | newPageAction->addTo(pageToolBar); | 103 | newPageAction->addTo(pageToolBar); |
99 | 104 | ||
100 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 105 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
101 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 106 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
102 | clearPageAction->addTo(pageToolBar); | 107 | clearPageAction->addTo(pageToolBar); |
103 | 108 | ||
104 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 109 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
105 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 110 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
106 | deletePageAction->addTo(pageToolBar); | 111 | deletePageAction->addTo(pageToolBar); |
107 | 112 | ||
108 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 113 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
109 | emptyToolBar->setHorizontalStretchable(true); | 114 | emptyToolBar->setHorizontalStretchable(true); |
110 | 115 | ||
111 | // init navigation toolbar | 116 | // init navigation toolbar |
112 | 117 | ||
113 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 118 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
114 | 119 | ||
115 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 120 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
116 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 121 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
117 | m_pUndoAction->addTo(navigationToolBar); | 122 | m_pUndoAction->addTo(navigationToolBar); |
118 | 123 | ||
119 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 124 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
120 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 125 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
121 | m_pRedoAction->addTo(navigationToolBar); | 126 | m_pRedoAction->addTo(navigationToolBar); |
122 | 127 | ||
123 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 128 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
124 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 129 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
125 | m_pFirstPageAction->addTo(navigationToolBar); | 130 | m_pFirstPageAction->addTo(navigationToolBar); |
126 | 131 | ||
127 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 132 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
128 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 133 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
129 | m_pPreviousPageAction->addTo(navigationToolBar); | 134 | m_pPreviousPageAction->addTo(navigationToolBar); |
130 | 135 | ||
131 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 136 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
132 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 137 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
133 | m_pNextPageAction->addTo(navigationToolBar); | 138 | m_pNextPageAction->addTo(navigationToolBar); |
134 | 139 | ||
135 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 140 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
136 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 141 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
@@ -548,48 +553,56 @@ void DrawPad::deleteAll() | |||
548 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 553 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
549 | QMessageBox::Information, QMessageBox::Yes, | 554 | QMessageBox::Information, QMessageBox::Yes, |
550 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 555 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
551 | QMessageBox::NoButton, this); | 556 | QMessageBox::NoButton, this); |
552 | 557 | ||
553 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 558 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
554 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 559 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
555 | 560 | ||
556 | if (messageBox.exec() == QMessageBox::Yes) { | 561 | if (messageBox.exec() == QMessageBox::Yes) { |
557 | m_pDrawPadCanvas->deleteAll(); | 562 | m_pDrawPadCanvas->deleteAll(); |
558 | } | 563 | } |
559 | } | 564 | } |
560 | 565 | ||
561 | void DrawPad::importPage() | 566 | void DrawPad::importPage() |
562 | { | 567 | { |
563 | ImportDialog importDialog(this); | 568 | ImportDialog importDialog(this); |
564 | 569 | ||
565 | importDialog.showMaximized(); | 570 | importDialog.showMaximized(); |
566 | 571 | ||
567 | if (importDialog.exec() == QDialog::Accepted) { | 572 | if (importDialog.exec() == QDialog::Accepted) { |
568 | const DocLnk* docLnk = importDialog.selected(); | 573 | const DocLnk* docLnk = importDialog.selected(); |
569 | 574 | ||
570 | if (docLnk) { | 575 | if (docLnk) { |
571 | m_pDrawPadCanvas->importPage(docLnk->file()); | 576 | m_pDrawPadCanvas->importPage(docLnk->file()); |
572 | delete docLnk; | 577 | delete docLnk; |
573 | } | 578 | } |
574 | } | 579 | } |
575 | } | 580 | } |
576 | 581 | ||
577 | void DrawPad::exportPage() | 582 | void DrawPad::exportPage() |
578 | { | 583 | { |
579 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 584 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
580 | 585 | ||
581 | exportDialog.showMaximized(); | 586 | exportDialog.showMaximized(); |
582 | 587 | ||
583 | if (exportDialog.exec() == QDialog::Accepted) { | 588 | if (exportDialog.exec() == QDialog::Accepted) { |
584 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 589 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
585 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 590 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
586 | } | 591 | } |
587 | } | 592 | } |
588 | 593 | ||
589 | void DrawPad::thumbnailView() | 594 | void DrawPad::thumbnailView() |
590 | { | 595 | { |
591 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 596 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
592 | 597 | ||
593 | thumbnailView.showMaximized(); | 598 | thumbnailView.showMaximized(); |
594 | thumbnailView.exec(); | 599 | thumbnailView.exec(); |
595 | } | 600 | } |
601 | |||
602 | void DrawPad::pageInformation() | ||
603 | { | ||
604 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | ||
605 | |||
606 | if (pageInformationDialog.exec() == QDialog::Accepted) { | ||
607 | } | ||
608 | } | ||