author | ar <ar> | 2004-02-14 16:58:36 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-14 16:58:36 (UTC) |
commit | c6bca75c479533d064a782a5f27d3dfb3aa1c042 (patch) (unidiff) | |
tree | 69abff2d3ac0a763b203f1551b33a3cc38ff0dcc | |
parent | 1ab6282d6869ca200133a0e47323ae9a760b3400 (diff) | |
download | opie-c6bca75c479533d064a782a5f27d3dfb3aa1c042.zip opie-c6bca75c479533d064a782a5f27d3dfb3aa1c042.tar.gz opie-c6bca75c479533d064a782a5f27d3dfb3aa1c042.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 13 |
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,170 +1,171 @@ | |||
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 | ||
51 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) | 52 | DrawPad::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 | ||
107 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); | 108 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); |
108 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 109 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
109 | newPageAction->addTo(pageToolBar); | 110 | newPageAction->addTo(pageToolBar); |
110 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); | 111 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); |
111 | 112 | ||
112 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); | 113 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); |
113 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 114 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
114 | clearPageAction->addTo(pageToolBar); | 115 | clearPageAction->addTo(pageToolBar); |
115 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); | 116 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); |
116 | 117 | ||
117 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); | 118 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); |
118 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 119 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
119 | deletePageAction->addTo(pageToolBar); | 120 | deletePageAction->addTo(pageToolBar); |
120 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); | 121 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); |
121 | 122 | ||
122 | QToolBar* emptyToolBar = new QToolBar(this); | 123 | QToolBar* emptyToolBar = new QToolBar(this); |
123 | emptyToolBar->setHorizontalStretchable(true); | 124 | emptyToolBar->setHorizontalStretchable(true); |
124 | 125 | ||
125 | // init navigation toolbar | 126 | // init navigation toolbar |
126 | 127 | ||
127 | QToolBar* navigationToolBar = new QToolBar(this); | 128 | QToolBar* navigationToolBar = new QToolBar(this); |
128 | 129 | ||
129 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); | 130 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); |
130 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 131 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
131 | m_pUndoAction->addTo(navigationToolBar); | 132 | m_pUndoAction->addTo(navigationToolBar); |
132 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); | 133 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); |
133 | 134 | ||
134 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); | 135 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); |
135 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 136 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
136 | m_pRedoAction->addTo(navigationToolBar); | 137 | m_pRedoAction->addTo(navigationToolBar); |
137 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); | 138 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); |
138 | 139 | ||
139 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 140 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
140 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 141 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
141 | m_pFirstPageAction->addTo(navigationToolBar); | 142 | m_pFirstPageAction->addTo(navigationToolBar); |
142 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); | 143 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); |
143 | 144 | ||
144 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 145 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
145 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 146 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
146 | m_pPreviousPageAction->addTo(navigationToolBar); | 147 | m_pPreviousPageAction->addTo(navigationToolBar); |
147 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); | 148 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); |
148 | 149 | ||
149 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 150 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
150 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 151 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
151 | m_pNextPageAction->addTo(navigationToolBar); | 152 | m_pNextPageAction->addTo(navigationToolBar); |
152 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); | 153 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); |
153 | 154 | ||
154 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 155 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
155 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 156 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
156 | m_pLastPageAction->addTo(navigationToolBar); | 157 | m_pLastPageAction->addTo(navigationToolBar); |
157 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); | 158 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); |
158 | 159 | ||
159 | // init draw mode toolbar | 160 | // init draw mode toolbar |
160 | 161 | ||
161 | QToolBar* drawModeToolBar = new QToolBar(this); | 162 | QToolBar* drawModeToolBar = new QToolBar(this); |
162 | 163 | ||
163 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 164 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
164 | m_pLineToolButton->setToggleButton(true); | 165 | m_pLineToolButton->setToggleButton(true); |
165 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); | 166 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); |
166 | 167 | ||
167 | 168 | ||
168 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 169 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
169 | 170 | ||
170 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); | 171 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); |
@@ -476,192 +477,188 @@ void DrawPad::setFilledEllipseTool() | |||
476 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 477 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
477 | 478 | ||
478 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 479 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
479 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 480 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
480 | 481 | ||
481 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 482 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
482 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 483 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
483 | 484 | ||
484 | m_pLineToolButton->setOn(false); | 485 | m_pLineToolButton->setOn(false); |
485 | m_pRectangleToolButton->setOn(false); | 486 | m_pRectangleToolButton->setOn(false); |
486 | m_pEllipseToolButton->setOn(true); | 487 | m_pEllipseToolButton->setOn(true); |
487 | m_pTextToolAction->setOn(false); | 488 | m_pTextToolAction->setOn(false); |
488 | m_pFillToolAction->setOn(false); | 489 | m_pFillToolAction->setOn(false); |
489 | m_pEraseToolAction->setOn(false); | 490 | m_pEraseToolAction->setOn(false); |
490 | } | 491 | } |
491 | 492 | ||
492 | void DrawPad::setTextTool() | 493 | void DrawPad::setTextTool() |
493 | { | 494 | { |
494 | if (m_pTool) { | 495 | if (m_pTool) { |
495 | delete m_pTool; | 496 | delete m_pTool; |
496 | } | 497 | } |
497 | 498 | ||
498 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 499 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
499 | 500 | ||
500 | m_pLineToolButton->setOn(false); | 501 | m_pLineToolButton->setOn(false); |
501 | m_pRectangleToolButton->setOn(false); | 502 | m_pRectangleToolButton->setOn(false); |
502 | m_pEllipseToolButton->setOn(false); | 503 | m_pEllipseToolButton->setOn(false); |
503 | m_pTextToolAction->setOn(true); | 504 | m_pTextToolAction->setOn(true); |
504 | m_pFillToolAction->setOn(false); | 505 | m_pFillToolAction->setOn(false); |
505 | m_pEraseToolAction->setOn(false); | 506 | m_pEraseToolAction->setOn(false); |
506 | } | 507 | } |
507 | 508 | ||
508 | void DrawPad::setFillTool() | 509 | void DrawPad::setFillTool() |
509 | { | 510 | { |
510 | if (m_pTool) { | 511 | if (m_pTool) { |
511 | delete m_pTool; | 512 | delete m_pTool; |
512 | } | 513 | } |
513 | 514 | ||
514 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 515 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
515 | 516 | ||
516 | m_pLineToolButton->setOn(false); | 517 | m_pLineToolButton->setOn(false); |
517 | m_pRectangleToolButton->setOn(false); | 518 | m_pRectangleToolButton->setOn(false); |
518 | m_pEllipseToolButton->setOn(false); | 519 | m_pEllipseToolButton->setOn(false); |
519 | m_pTextToolAction->setOn(false); | 520 | m_pTextToolAction->setOn(false); |
520 | m_pFillToolAction->setOn(true); | 521 | m_pFillToolAction->setOn(true); |
521 | m_pEraseToolAction->setOn(false); | 522 | m_pEraseToolAction->setOn(false); |
522 | } | 523 | } |
523 | 524 | ||
524 | void DrawPad::setEraseTool() | 525 | void DrawPad::setEraseTool() |
525 | { | 526 | { |
526 | if (m_pTool) { | 527 | if (m_pTool) { |
527 | delete m_pTool; | 528 | delete m_pTool; |
528 | } | 529 | } |
529 | 530 | ||
530 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 531 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
531 | 532 | ||
532 | m_pLineToolButton->setOn(false); | 533 | m_pLineToolButton->setOn(false); |
533 | m_pRectangleToolButton->setOn(false); | 534 | m_pRectangleToolButton->setOn(false); |
534 | m_pEllipseToolButton->setOn(false); | 535 | m_pEllipseToolButton->setOn(false); |
535 | m_pTextToolAction->setOn(false); | 536 | m_pTextToolAction->setOn(false); |
536 | m_pFillToolAction->setOn(false); | 537 | m_pFillToolAction->setOn(false); |
537 | m_pEraseToolAction->setOn(true); | 538 | m_pEraseToolAction->setOn(true); |
538 | } | 539 | } |
539 | 540 | ||
540 | void DrawPad::changePenWidth(int value) | 541 | void DrawPad::changePenWidth(int value) |
541 | { | 542 | { |
542 | m_pen.setWidth(value); | 543 | m_pen.setWidth(value); |
543 | } | 544 | } |
544 | 545 | ||
545 | void DrawPad::changePenColor(const QColor& color) | 546 | void 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 | ||
557 | void DrawPad::changeBrushColor(const QColor& color) | 558 | void 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 | ||
569 | void DrawPad::updateView() | 570 | void 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 | ||
585 | void DrawPad::deleteAll() | 586 | void 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 | ||
600 | void DrawPad::importPage() | 601 | void 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 | ||
616 | void DrawPad::exportPage() | 615 | void 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 | ||
628 | void DrawPad::thumbnailView() | 625 | void 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 | ||
636 | void DrawPad::pageInformation() | 633 | void 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 | ||
645 | void DrawPad::loadConfig() | 642 | void 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 | ||
657 | void DrawPad::saveConfig() | 654 | void 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 | } |