author | harlekin <harlekin> | 2003-12-10 21:45:06 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-10 21:45:06 (UTC) |
commit | 7c21195c1dde6cc91c41e5b15ef5acce568a2f54 (patch) (unidiff) | |
tree | 83914e1119fa662dc7a4d37e72624118c62aecaf | |
parent | c80a4d0e0b0ed83757d8494e7f32c8b4b0b6e8d0 (diff) | |
download | opie-7c21195c1dde6cc91c41e5b15ef5acce568a2f54.zip opie-7c21195c1dde6cc91c41e5b15ef5acce568a2f54.tar.gz opie-7c21195c1dde6cc91c41e5b15ef5acce568a2f54.tar.bz2 |
reduce includes
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/ellipsetool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/erasetool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/exportdialog.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filledellipsetool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/importdialog.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/linetool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/main.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/newpagedialog.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pointtool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/texttool.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/tool.cpp | 2 |
16 files changed, 0 insertions, 18 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 86a10a5..71c9695 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,668 +1,667 @@ | |||
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> | 39 | #include <qmenubar.h> |
40 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qfile.h> | 44 | #include <qfile.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpainter.h> | ||
47 | #include <qspinbox.h> | 46 | #include <qspinbox.h> |
48 | #include <qtoolbutton.h> | 47 | #include <qtoolbutton.h> |
49 | #include <qtooltip.h> | 48 | #include <qtooltip.h> |
50 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
51 | 50 | ||
52 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) | 51 | DrawPad::DrawPad(QWidget* parent, const char* name, WFlags fl ) |
53 | : QMainWindow(parent, name, WStyle_ContextHelp) | 52 | : QMainWindow(parent, name, WStyle_ContextHelp) |
54 | { | 53 | { |
55 | // init members | 54 | // init members |
56 | 55 | ||
57 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 56 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
58 | 57 | ||
59 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); | 58 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); |
60 | 59 | ||
61 | setCentralWidget(m_pDrawPadCanvas); | 60 | setCentralWidget(m_pDrawPadCanvas); |
62 | 61 | ||
63 | // init menu | 62 | // init menu |
64 | 63 | ||
65 | setToolBarsMovable(false); | 64 | setToolBarsMovable(false); |
66 | 65 | ||
67 | QToolBar* menuToolBar = new QToolBar(this); | 66 | QToolBar* menuToolBar = new QToolBar(this); |
68 | QMenuBar* menuBar = new QMenuBar(menuToolBar); | 67 | QMenuBar* menuBar = new QMenuBar(menuToolBar); |
69 | 68 | ||
70 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); | 69 | QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); |
71 | 70 | ||
72 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 71 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
73 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); | 72 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
74 | deleteAllAction->addTo(toolsPopupMenu); | 73 | deleteAllAction->addTo(toolsPopupMenu); |
75 | 74 | ||
76 | toolsPopupMenu->insertSeparator(); | 75 | toolsPopupMenu->insertSeparator(); |
77 | 76 | ||
78 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 77 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
79 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 78 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
80 | importPageAction->addTo(toolsPopupMenu); | 79 | importPageAction->addTo(toolsPopupMenu); |
81 | 80 | ||
82 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 81 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
83 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 82 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
84 | exportPageAction->addTo(toolsPopupMenu); | 83 | exportPageAction->addTo(toolsPopupMenu); |
85 | 84 | ||
86 | toolsPopupMenu->insertSeparator(); | 85 | toolsPopupMenu->insertSeparator(); |
87 | 86 | ||
88 | 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); |
89 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); | 88 | connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); |
90 | thumbnailViewAction->addTo(toolsPopupMenu); | 89 | thumbnailViewAction->addTo(toolsPopupMenu); |
91 | 90 | ||
92 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); | 91 | QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); |
93 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); | 92 | connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); |
94 | pageInformationAction->addTo(toolsPopupMenu); | 93 | pageInformationAction->addTo(toolsPopupMenu); |
95 | 94 | ||
96 | toolsPopupMenu->insertSeparator(); | 95 | toolsPopupMenu->insertSeparator(); |
97 | 96 | ||
98 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); | 97 | m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); |
99 | m_pAntiAliasingAction->setToggleAction(true); | 98 | m_pAntiAliasingAction->setToggleAction(true); |
100 | m_pAntiAliasingAction->addTo(toolsPopupMenu); | 99 | m_pAntiAliasingAction->addTo(toolsPopupMenu); |
101 | 100 | ||
102 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 101 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
103 | 102 | ||
104 | // init page toolbar | 103 | // init page toolbar |
105 | 104 | ||
106 | QToolBar* pageToolBar = new QToolBar(this); | 105 | QToolBar* pageToolBar = new QToolBar(this); |
107 | 106 | ||
108 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); | 107 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); |
109 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); | 108 | connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); |
110 | newPageAction->addTo(pageToolBar); | 109 | newPageAction->addTo(pageToolBar); |
111 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); | 110 | newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); |
112 | 111 | ||
113 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); | 112 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); |
114 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); | 113 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
115 | clearPageAction->addTo(pageToolBar); | 114 | clearPageAction->addTo(pageToolBar); |
116 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); | 115 | clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); |
117 | 116 | ||
118 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); | 117 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); |
119 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); | 118 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
120 | deletePageAction->addTo(pageToolBar); | 119 | deletePageAction->addTo(pageToolBar); |
121 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); | 120 | deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); |
122 | 121 | ||
123 | QToolBar* emptyToolBar = new QToolBar(this); | 122 | QToolBar* emptyToolBar = new QToolBar(this); |
124 | emptyToolBar->setHorizontalStretchable(true); | 123 | emptyToolBar->setHorizontalStretchable(true); |
125 | 124 | ||
126 | // init navigation toolbar | 125 | // init navigation toolbar |
127 | 126 | ||
128 | QToolBar* navigationToolBar = new QToolBar(this); | 127 | QToolBar* navigationToolBar = new QToolBar(this); |
129 | 128 | ||
130 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); | 129 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this); |
131 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 130 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
132 | m_pUndoAction->addTo(navigationToolBar); | 131 | m_pUndoAction->addTo(navigationToolBar); |
133 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); | 132 | m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); |
134 | 133 | ||
135 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); | 134 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("redo"), QString::null, 0, this); |
136 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 135 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
137 | m_pRedoAction->addTo(navigationToolBar); | 136 | m_pRedoAction->addTo(navigationToolBar); |
138 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); | 137 | m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); |
139 | 138 | ||
140 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 139 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
141 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 140 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
142 | m_pFirstPageAction->addTo(navigationToolBar); | 141 | m_pFirstPageAction->addTo(navigationToolBar); |
143 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); | 142 | m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); |
144 | 143 | ||
145 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 144 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
146 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 145 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
147 | m_pPreviousPageAction->addTo(navigationToolBar); | 146 | m_pPreviousPageAction->addTo(navigationToolBar); |
148 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); | 147 | m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); |
149 | 148 | ||
150 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 149 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
151 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 150 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
152 | m_pNextPageAction->addTo(navigationToolBar); | 151 | m_pNextPageAction->addTo(navigationToolBar); |
153 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); | 152 | m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); |
154 | 153 | ||
155 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 154 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
156 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 155 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
157 | m_pLastPageAction->addTo(navigationToolBar); | 156 | m_pLastPageAction->addTo(navigationToolBar); |
158 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); | 157 | m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); |
159 | 158 | ||
160 | // init draw mode toolbar | 159 | // init draw mode toolbar |
161 | 160 | ||
162 | QToolBar* drawModeToolBar = new QToolBar(this); | 161 | QToolBar* drawModeToolBar = new QToolBar(this); |
163 | 162 | ||
164 | m_pLineToolButton = new QToolButton(drawModeToolBar); | 163 | m_pLineToolButton = new QToolButton(drawModeToolBar); |
165 | m_pLineToolButton->setToggleButton(true); | 164 | m_pLineToolButton->setToggleButton(true); |
166 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); | 165 | QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); |
167 | 166 | ||
168 | 167 | ||
169 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); | 168 | QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); |
170 | 169 | ||
171 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); | 170 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); |
172 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 171 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
173 | m_pPointToolAction->addTo(linePopupMenu); | 172 | m_pPointToolAction->addTo(linePopupMenu); |
174 | 173 | ||
175 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); | 174 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); |
176 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 175 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
177 | m_pLineToolAction->addTo(linePopupMenu); | 176 | m_pLineToolAction->addTo(linePopupMenu); |
178 | 177 | ||
179 | m_pLineToolButton->setPopup(linePopupMenu); | 178 | m_pLineToolButton->setPopup(linePopupMenu); |
180 | m_pLineToolButton->setPopupDelay(0); | 179 | m_pLineToolButton->setPopupDelay(0); |
181 | 180 | ||
182 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 181 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
183 | m_pRectangleToolButton->setToggleButton(true); | 182 | m_pRectangleToolButton->setToggleButton(true); |
184 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); | 183 | QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); |
185 | 184 | ||
186 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 185 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
187 | 186 | ||
188 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); | 187 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 0, this); |
189 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 188 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
190 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 189 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
191 | 190 | ||
192 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); | 191 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 0, this); |
193 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 192 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
194 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 193 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
195 | 194 | ||
196 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 195 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
197 | m_pRectangleToolButton->setPopupDelay(0); | 196 | m_pRectangleToolButton->setPopupDelay(0); |
198 | 197 | ||
199 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 198 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
200 | m_pEllipseToolButton->setToggleButton(true); | 199 | m_pEllipseToolButton->setToggleButton(true); |
201 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); | 200 | QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); |
202 | 201 | ||
203 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 202 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
204 | 203 | ||
205 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); | 204 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 0, this); |
206 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 205 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
207 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 206 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
208 | 207 | ||
209 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); | 208 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); |
210 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 209 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
211 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 210 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
212 | 211 | ||
213 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 212 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
214 | m_pEllipseToolButton->setPopupDelay(0); | 213 | m_pEllipseToolButton->setPopupDelay(0); |
215 | 214 | ||
216 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); | 215 | m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); |
217 | m_pTextToolAction->setToggleAction(true); | 216 | m_pTextToolAction->setToggleAction(true); |
218 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); | 217 | connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); |
219 | m_pTextToolAction->addTo(drawModeToolBar); | 218 | m_pTextToolAction->addTo(drawModeToolBar); |
220 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); | 219 | m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); |
221 | 220 | ||
222 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); | 221 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); |
223 | m_pFillToolAction->setToggleAction(true); | 222 | m_pFillToolAction->setToggleAction(true); |
224 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 223 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
225 | m_pFillToolAction->addTo(drawModeToolBar); | 224 | m_pFillToolAction->addTo(drawModeToolBar); |
226 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); | 225 | m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); |
227 | 226 | ||
228 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); | 227 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); |
229 | m_pEraseToolAction->setToggleAction(true); | 228 | m_pEraseToolAction->setToggleAction(true); |
230 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 229 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
231 | m_pEraseToolAction->addTo(drawModeToolBar); | 230 | m_pEraseToolAction->addTo(drawModeToolBar); |
232 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); | 231 | m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); |
233 | 232 | ||
234 | m_pTool = 0; | 233 | m_pTool = 0; |
235 | setRectangleTool(); | 234 | setRectangleTool(); |
236 | setEllipseTool(); | 235 | setEllipseTool(); |
237 | setPointTool(); | 236 | setPointTool(); |
238 | 237 | ||
239 | emptyToolBar = new QToolBar(this); | 238 | emptyToolBar = new QToolBar(this); |
240 | emptyToolBar->setHorizontalStretchable(true); | 239 | emptyToolBar->setHorizontalStretchable(true); |
241 | emptyToolBar->addSeparator(); | 240 | emptyToolBar->addSeparator(); |
242 | 241 | ||
243 | // init draw parameters toolbar | 242 | // init draw parameters toolbar |
244 | 243 | ||
245 | QToolBar* drawParametersToolBar = new QToolBar(this); | 244 | QToolBar* drawParametersToolBar = new QToolBar(this); |
246 | 245 | ||
247 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 246 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
248 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 247 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
249 | 248 | ||
250 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); | 249 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
251 | m_pPenWidthSpinBox->setValue(1); | 250 | m_pPenWidthSpinBox->setValue(1); |
252 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 251 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
253 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); | 252 | QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) ); |
254 | 253 | ||
255 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 254 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
256 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); | 255 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); |
257 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); | 256 | QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); |
258 | 257 | ||
259 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); | 258 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton); |
260 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 259 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
261 | 260 | ||
262 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 261 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
263 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 262 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
264 | m_pPenColorToolButton->setPopupDelay(0); | 263 | m_pPenColorToolButton->setPopupDelay(0); |
265 | 264 | ||
266 | changePenColor(Qt::black); | 265 | changePenColor(Qt::black); |
267 | 266 | ||
268 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 267 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
269 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); | 268 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); |
270 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); | 269 | QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); |
271 | 270 | ||
272 | OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); | 271 | OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton); |
273 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 272 | connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
274 | 273 | ||
275 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 274 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
276 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 275 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
277 | m_pBrushColorToolButton->setPopupDelay(0); | 276 | m_pBrushColorToolButton->setPopupDelay(0); |
278 | 277 | ||
279 | changeBrushColor(Qt::white); | 278 | changeBrushColor(Qt::white); |
280 | 279 | ||
281 | finishStartup(); | 280 | finishStartup(); |
282 | } | 281 | } |
283 | 282 | ||
284 | 283 | ||
285 | void DrawPad::finishStartup() | 284 | void DrawPad::finishStartup() |
286 | { | 285 | { |
287 | // init pages | 286 | // init pages |
288 | 287 | ||
289 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 288 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
290 | 289 | ||
291 | if (file.open(IO_ReadOnly)) { | 290 | if (file.open(IO_ReadOnly)) { |
292 | m_pDrawPadCanvas->load(&file); | 291 | m_pDrawPadCanvas->load(&file); |
293 | file.close(); | 292 | file.close(); |
294 | } else { | 293 | } else { |
295 | m_pDrawPadCanvas->initialPage(); | 294 | m_pDrawPadCanvas->initialPage(); |
296 | } | 295 | } |
297 | 296 | ||
298 | loadConfig(); | 297 | loadConfig(); |
299 | 298 | ||
300 | } | 299 | } |
301 | 300 | ||
302 | DrawPad::~DrawPad() | 301 | DrawPad::~DrawPad() |
303 | { | 302 | { |
304 | saveConfig(); | 303 | saveConfig(); |
305 | 304 | ||
306 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 305 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
307 | 306 | ||
308 | if (file.open(IO_WriteOnly)) { | 307 | if (file.open(IO_WriteOnly)) { |
309 | m_pDrawPadCanvas->save(&file); | 308 | m_pDrawPadCanvas->save(&file); |
310 | file.close(); | 309 | file.close(); |
311 | } | 310 | } |
312 | } | 311 | } |
313 | 312 | ||
314 | bool DrawPad::antiAliasing() | 313 | bool DrawPad::antiAliasing() |
315 | { | 314 | { |
316 | return (m_pAntiAliasingAction->isOn()); | 315 | return (m_pAntiAliasingAction->isOn()); |
317 | } | 316 | } |
318 | 317 | ||
319 | void DrawPad::newPage() | 318 | void DrawPad::newPage() |
320 | { | 319 | { |
321 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 320 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
322 | 321 | ||
323 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 322 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
324 | 323 | ||
325 | if (newPageDialog.exec() == QDialog::Accepted) { | 324 | if (newPageDialog.exec() == QDialog::Accepted) { |
326 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 325 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
327 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 326 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
328 | } | 327 | } |
329 | } | 328 | } |
330 | 329 | ||
331 | void DrawPad::clearPage() | 330 | void DrawPad::clearPage() |
332 | { | 331 | { |
333 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 332 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
334 | QMessageBox::Information, QMessageBox::Yes, | 333 | QMessageBox::Information, QMessageBox::Yes, |
335 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 334 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
336 | QMessageBox::NoButton, this); | 335 | QMessageBox::NoButton, this); |
337 | 336 | ||
338 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 337 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
339 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 338 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
340 | 339 | ||
341 | if (messageBox.exec() == QMessageBox::Yes) { | 340 | if (messageBox.exec() == QMessageBox::Yes) { |
342 | m_pDrawPadCanvas->clearPage(); | 341 | m_pDrawPadCanvas->clearPage(); |
343 | } | 342 | } |
344 | } | 343 | } |
345 | 344 | ||
346 | void DrawPad::deletePage() | 345 | void DrawPad::deletePage() |
347 | { | 346 | { |
348 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 347 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
349 | QMessageBox::Information, QMessageBox::Yes, | 348 | QMessageBox::Information, QMessageBox::Yes, |
350 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 349 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
351 | QMessageBox::NoButton, this); | 350 | QMessageBox::NoButton, this); |
352 | 351 | ||
353 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 352 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
354 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 353 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
355 | 354 | ||
356 | if (messageBox.exec() == QMessageBox::Yes) { | 355 | if (messageBox.exec() == QMessageBox::Yes) { |
357 | m_pDrawPadCanvas->deletePage(); | 356 | m_pDrawPadCanvas->deletePage(); |
358 | } | 357 | } |
359 | } | 358 | } |
360 | 359 | ||
361 | void DrawPad::setPointTool() | 360 | void DrawPad::setPointTool() |
362 | { | 361 | { |
363 | if (m_pTool) { | 362 | if (m_pTool) { |
364 | delete m_pTool; | 363 | delete m_pTool; |
365 | } | 364 | } |
366 | 365 | ||
367 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 366 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
368 | 367 | ||
369 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); | 368 | m_pLineToolButton->setIconSet(m_pPointToolAction->iconSet()); |
370 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); | 369 | QToolTip::add(m_pLineToolButton, m_pPointToolAction->text()); |
371 | 370 | ||
372 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 371 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
373 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); | 372 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pPointToolAction, SIGNAL(activated())); |
374 | 373 | ||
375 | m_pLineToolButton->setOn(true); | 374 | m_pLineToolButton->setOn(true); |
376 | m_pRectangleToolButton->setOn(false); | 375 | m_pRectangleToolButton->setOn(false); |
377 | m_pEllipseToolButton->setOn(false); | 376 | m_pEllipseToolButton->setOn(false); |
378 | m_pTextToolAction->setOn(false); | 377 | m_pTextToolAction->setOn(false); |
379 | m_pFillToolAction->setOn(false); | 378 | m_pFillToolAction->setOn(false); |
380 | m_pEraseToolAction->setOn(false); | 379 | m_pEraseToolAction->setOn(false); |
381 | } | 380 | } |
382 | 381 | ||
383 | void DrawPad::setLineTool() | 382 | void DrawPad::setLineTool() |
384 | { | 383 | { |
385 | if (m_pTool) { | 384 | if (m_pTool) { |
386 | delete m_pTool; | 385 | delete m_pTool; |
387 | } | 386 | } |
388 | 387 | ||
389 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 388 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
390 | 389 | ||
391 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); | 390 | m_pLineToolButton->setIconSet(m_pLineToolAction->iconSet()); |
392 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); | 391 | QToolTip::add(m_pLineToolButton, m_pLineToolAction->text()); |
393 | 392 | ||
394 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); | 393 | disconnect(m_pLineToolButton, SIGNAL(clicked()), 0, 0); |
395 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); | 394 | connect(m_pLineToolButton, SIGNAL(clicked()), m_pLineToolAction, SIGNAL(activated())); |
396 | 395 | ||
397 | m_pLineToolButton->setOn(true); | 396 | m_pLineToolButton->setOn(true); |
398 | m_pRectangleToolButton->setOn(false); | 397 | m_pRectangleToolButton->setOn(false); |
399 | m_pEllipseToolButton->setOn(false); | 398 | m_pEllipseToolButton->setOn(false); |
400 | m_pTextToolAction->setOn(false); | 399 | m_pTextToolAction->setOn(false); |
401 | m_pFillToolAction->setOn(false); | 400 | m_pFillToolAction->setOn(false); |
402 | m_pEraseToolAction->setOn(false); | 401 | m_pEraseToolAction->setOn(false); |
403 | } | 402 | } |
404 | 403 | ||
405 | void DrawPad::setRectangleTool() | 404 | void DrawPad::setRectangleTool() |
406 | { | 405 | { |
407 | if (m_pTool) { | 406 | if (m_pTool) { |
408 | delete m_pTool; | 407 | delete m_pTool; |
409 | } | 408 | } |
410 | 409 | ||
411 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 410 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
412 | 411 | ||
413 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 412 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
414 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 413 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
415 | 414 | ||
416 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 415 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
417 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 416 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
418 | 417 | ||
419 | m_pLineToolButton->setOn(false); | 418 | m_pLineToolButton->setOn(false); |
420 | m_pRectangleToolButton->setOn(true); | 419 | m_pRectangleToolButton->setOn(true); |
421 | m_pEllipseToolButton->setOn(false); | 420 | m_pEllipseToolButton->setOn(false); |
422 | m_pTextToolAction->setOn(false); | 421 | m_pTextToolAction->setOn(false); |
423 | m_pFillToolAction->setOn(false); | 422 | m_pFillToolAction->setOn(false); |
424 | m_pEraseToolAction->setOn(false); | 423 | m_pEraseToolAction->setOn(false); |
425 | } | 424 | } |
426 | 425 | ||
427 | void DrawPad::setFilledRectangleTool() | 426 | void DrawPad::setFilledRectangleTool() |
428 | { | 427 | { |
429 | if (m_pTool) { | 428 | if (m_pTool) { |
430 | delete m_pTool; | 429 | delete m_pTool; |
431 | } | 430 | } |
432 | 431 | ||
433 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 432 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
434 | 433 | ||
435 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 434 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
436 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 435 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
437 | 436 | ||
438 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 437 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
439 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 438 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
440 | 439 | ||
441 | m_pLineToolButton->setOn(false); | 440 | m_pLineToolButton->setOn(false); |
442 | m_pRectangleToolButton->setOn(true); | 441 | m_pRectangleToolButton->setOn(true); |
443 | m_pEllipseToolButton->setOn(false); | 442 | m_pEllipseToolButton->setOn(false); |
444 | m_pTextToolAction->setOn(false); | 443 | m_pTextToolAction->setOn(false); |
445 | m_pFillToolAction->setOn(false); | 444 | m_pFillToolAction->setOn(false); |
446 | m_pEraseToolAction->setOn(false); | 445 | m_pEraseToolAction->setOn(false); |
447 | } | 446 | } |
448 | 447 | ||
449 | void DrawPad::setEllipseTool() | 448 | void DrawPad::setEllipseTool() |
450 | { | 449 | { |
451 | if (m_pTool) { | 450 | if (m_pTool) { |
452 | delete m_pTool; | 451 | delete m_pTool; |
453 | } | 452 | } |
454 | 453 | ||
455 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 454 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
456 | 455 | ||
457 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 456 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
458 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 457 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
459 | 458 | ||
460 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 459 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
461 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 460 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
462 | 461 | ||
463 | m_pLineToolButton->setOn(false); | 462 | m_pLineToolButton->setOn(false); |
464 | m_pRectangleToolButton->setOn(false); | 463 | m_pRectangleToolButton->setOn(false); |
465 | m_pEllipseToolButton->setOn(true); | 464 | m_pEllipseToolButton->setOn(true); |
466 | m_pTextToolAction->setOn(false); | 465 | m_pTextToolAction->setOn(false); |
467 | m_pFillToolAction->setOn(false); | 466 | m_pFillToolAction->setOn(false); |
468 | m_pEraseToolAction->setOn(false); | 467 | m_pEraseToolAction->setOn(false); |
469 | } | 468 | } |
470 | 469 | ||
471 | void DrawPad::setFilledEllipseTool() | 470 | void DrawPad::setFilledEllipseTool() |
472 | { | 471 | { |
473 | if (m_pTool) { | 472 | if (m_pTool) { |
474 | delete m_pTool; | 473 | delete m_pTool; |
475 | } | 474 | } |
476 | 475 | ||
477 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 476 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
478 | 477 | ||
479 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 478 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
480 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 479 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
481 | 480 | ||
482 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 481 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
483 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 482 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
484 | 483 | ||
485 | m_pLineToolButton->setOn(false); | 484 | m_pLineToolButton->setOn(false); |
486 | m_pRectangleToolButton->setOn(false); | 485 | m_pRectangleToolButton->setOn(false); |
487 | m_pEllipseToolButton->setOn(true); | 486 | m_pEllipseToolButton->setOn(true); |
488 | m_pTextToolAction->setOn(false); | 487 | m_pTextToolAction->setOn(false); |
489 | m_pFillToolAction->setOn(false); | 488 | m_pFillToolAction->setOn(false); |
490 | m_pEraseToolAction->setOn(false); | 489 | m_pEraseToolAction->setOn(false); |
491 | } | 490 | } |
492 | 491 | ||
493 | void DrawPad::setTextTool() | 492 | void DrawPad::setTextTool() |
494 | { | 493 | { |
495 | if (m_pTool) { | 494 | if (m_pTool) { |
496 | delete m_pTool; | 495 | delete m_pTool; |
497 | } | 496 | } |
498 | 497 | ||
499 | m_pTool = new TextTool(this, m_pDrawPadCanvas); | 498 | m_pTool = new TextTool(this, m_pDrawPadCanvas); |
500 | 499 | ||
501 | m_pLineToolButton->setOn(false); | 500 | m_pLineToolButton->setOn(false); |
502 | m_pRectangleToolButton->setOn(false); | 501 | m_pRectangleToolButton->setOn(false); |
503 | m_pEllipseToolButton->setOn(false); | 502 | m_pEllipseToolButton->setOn(false); |
504 | m_pTextToolAction->setOn(true); | 503 | m_pTextToolAction->setOn(true); |
505 | m_pFillToolAction->setOn(false); | 504 | m_pFillToolAction->setOn(false); |
506 | m_pEraseToolAction->setOn(false); | 505 | m_pEraseToolAction->setOn(false); |
507 | } | 506 | } |
508 | 507 | ||
509 | void DrawPad::setFillTool() | 508 | void DrawPad::setFillTool() |
510 | { | 509 | { |
511 | if (m_pTool) { | 510 | if (m_pTool) { |
512 | delete m_pTool; | 511 | delete m_pTool; |
513 | } | 512 | } |
514 | 513 | ||
515 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 514 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
516 | 515 | ||
517 | m_pLineToolButton->setOn(false); | 516 | m_pLineToolButton->setOn(false); |
518 | m_pRectangleToolButton->setOn(false); | 517 | m_pRectangleToolButton->setOn(false); |
519 | m_pEllipseToolButton->setOn(false); | 518 | m_pEllipseToolButton->setOn(false); |
520 | m_pTextToolAction->setOn(false); | 519 | m_pTextToolAction->setOn(false); |
521 | m_pFillToolAction->setOn(true); | 520 | m_pFillToolAction->setOn(true); |
522 | m_pEraseToolAction->setOn(false); | 521 | m_pEraseToolAction->setOn(false); |
523 | } | 522 | } |
524 | 523 | ||
525 | void DrawPad::setEraseTool() | 524 | void DrawPad::setEraseTool() |
526 | { | 525 | { |
527 | if (m_pTool) { | 526 | if (m_pTool) { |
528 | delete m_pTool; | 527 | delete m_pTool; |
529 | } | 528 | } |
530 | 529 | ||
531 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 530 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
532 | 531 | ||
533 | m_pLineToolButton->setOn(false); | 532 | m_pLineToolButton->setOn(false); |
534 | m_pRectangleToolButton->setOn(false); | 533 | m_pRectangleToolButton->setOn(false); |
535 | m_pEllipseToolButton->setOn(false); | 534 | m_pEllipseToolButton->setOn(false); |
536 | m_pTextToolAction->setOn(false); | 535 | m_pTextToolAction->setOn(false); |
537 | m_pFillToolAction->setOn(false); | 536 | m_pFillToolAction->setOn(false); |
538 | m_pEraseToolAction->setOn(true); | 537 | m_pEraseToolAction->setOn(true); |
539 | } | 538 | } |
540 | 539 | ||
541 | void DrawPad::changePenWidth(int value) | 540 | void DrawPad::changePenWidth(int value) |
542 | { | 541 | { |
543 | m_pen.setWidth(value); | 542 | m_pen.setWidth(value); |
544 | } | 543 | } |
545 | 544 | ||
546 | void DrawPad::changePenColor(const QColor& color) | 545 | void DrawPad::changePenColor(const QColor& color) |
547 | { | 546 | { |
548 | m_pen.setColor(color); | 547 | m_pen.setColor(color); |
549 | 548 | ||
550 | QPainter painter; | 549 | QPainter painter; |
551 | painter.begin(m_pPenColorToolButton->pixmap()); | 550 | painter.begin(m_pPenColorToolButton->pixmap()); |
552 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 551 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
553 | painter.end(); | 552 | painter.end(); |
554 | 553 | ||
555 | m_pPenColorToolButton->popup()->hide(); | 554 | m_pPenColorToolButton->popup()->hide(); |
556 | } | 555 | } |
557 | 556 | ||
558 | void DrawPad::changeBrushColor(const QColor& color) | 557 | void DrawPad::changeBrushColor(const QColor& color) |
559 | { | 558 | { |
560 | m_brush = QBrush(color); | 559 | m_brush = QBrush(color); |
561 | 560 | ||
562 | QPainter painter; | 561 | QPainter painter; |
563 | painter.begin(m_pBrushColorToolButton->pixmap()); | 562 | painter.begin(m_pBrushColorToolButton->pixmap()); |
564 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 563 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
565 | painter.end(); | 564 | painter.end(); |
566 | 565 | ||
567 | m_pBrushColorToolButton->popup()->hide(); | 566 | m_pBrushColorToolButton->popup()->hide(); |
568 | } | 567 | } |
569 | 568 | ||
570 | void DrawPad::updateView() | 569 | void DrawPad::updateView() |
571 | { | 570 | { |
572 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 571 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
573 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 572 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
574 | 573 | ||
575 | setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); | 574 | setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); |
576 | 575 | ||
577 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); | 576 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); |
578 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); | 577 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); |
579 | 578 | ||
580 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 579 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
581 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 580 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
582 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 581 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
583 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 582 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
584 | } | 583 | } |
585 | 584 | ||
586 | void DrawPad::deleteAll() | 585 | void DrawPad::deleteAll() |
587 | { | 586 | { |
588 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 587 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
589 | QMessageBox::Information, QMessageBox::Yes, | 588 | QMessageBox::Information, QMessageBox::Yes, |
590 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 589 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
591 | QMessageBox::NoButton, this); | 590 | QMessageBox::NoButton, this); |
592 | 591 | ||
593 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 592 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
594 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 593 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
595 | 594 | ||
596 | if (messageBox.exec() == QMessageBox::Yes) { | 595 | if (messageBox.exec() == QMessageBox::Yes) { |
597 | m_pDrawPadCanvas->deleteAll(); | 596 | m_pDrawPadCanvas->deleteAll(); |
598 | } | 597 | } |
599 | } | 598 | } |
600 | 599 | ||
601 | void DrawPad::importPage() | 600 | void DrawPad::importPage() |
602 | { | 601 | { |
603 | ImportDialog importDialog(this); | 602 | ImportDialog importDialog(this); |
604 | 603 | ||
605 | importDialog.showMaximized(); | 604 | importDialog.showMaximized(); |
606 | 605 | ||
607 | if (importDialog.exec() == QDialog::Accepted) { | 606 | if (importDialog.exec() == QDialog::Accepted) { |
608 | const DocLnk* docLnk = importDialog.selected(); | 607 | const DocLnk* docLnk = importDialog.selected(); |
609 | 608 | ||
610 | if (docLnk) { | 609 | if (docLnk) { |
611 | m_pDrawPadCanvas->importPage(docLnk->file()); | 610 | m_pDrawPadCanvas->importPage(docLnk->file()); |
612 | delete docLnk; | 611 | delete docLnk; |
613 | } | 612 | } |
614 | } | 613 | } |
615 | } | 614 | } |
616 | 615 | ||
617 | void DrawPad::exportPage() | 616 | void DrawPad::exportPage() |
618 | { | 617 | { |
619 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 618 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
620 | 619 | ||
621 | exportDialog.showMaximized(); | 620 | exportDialog.showMaximized(); |
622 | 621 | ||
623 | if (exportDialog.exec() == QDialog::Accepted) { | 622 | if (exportDialog.exec() == QDialog::Accepted) { |
624 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 623 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
625 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 624 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
626 | } | 625 | } |
627 | } | 626 | } |
628 | 627 | ||
629 | void DrawPad::thumbnailView() | 628 | void DrawPad::thumbnailView() |
630 | { | 629 | { |
631 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); | 630 | ThumbnailView thumbnailView(this, m_pDrawPadCanvas, this); |
632 | 631 | ||
633 | thumbnailView.showMaximized(); | 632 | thumbnailView.showMaximized(); |
634 | thumbnailView.exec(); | 633 | thumbnailView.exec(); |
635 | } | 634 | } |
636 | 635 | ||
637 | void DrawPad::pageInformation() | 636 | void DrawPad::pageInformation() |
638 | { | 637 | { |
639 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 638 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
640 | 639 | ||
641 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 640 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
642 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 641 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
643 | } | 642 | } |
644 | } | 643 | } |
645 | 644 | ||
646 | void DrawPad::loadConfig() | 645 | void DrawPad::loadConfig() |
647 | { | 646 | { |
648 | Config config("drawpad"); | 647 | Config config("drawpad"); |
649 | config.setGroup("General"); | 648 | config.setGroup("General"); |
650 | 649 | ||
651 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); | 650 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); |
652 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); | 651 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); |
653 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); | 652 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); |
654 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); | 653 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); |
655 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); | 654 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); |
656 | } | 655 | } |
657 | 656 | ||
658 | void DrawPad::saveConfig() | 657 | void DrawPad::saveConfig() |
659 | { | 658 | { |
660 | Config config("drawpad"); | 659 | Config config("drawpad"); |
661 | config.setGroup("General"); | 660 | config.setGroup("General"); |
662 | 661 | ||
663 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); | 662 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); |
664 | config.writeEntry("AntiAliasing", antiAliasing()); | 663 | config.writeEntry("AntiAliasing", antiAliasing()); |
665 | config.writeEntry("PenWidth", (int)m_pen.width()); | 664 | config.writeEntry("PenWidth", (int)m_pen.width()); |
666 | config.writeEntry("PenColor", m_pen.color().name()); | 665 | config.writeEntry("PenColor", m_pen.color().name()); |
667 | config.writeEntry("BrushColor", m_brush.color().name()); | 666 | config.writeEntry("BrushColor", m_brush.color().name()); |
668 | } | 667 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index dec498b..446096c 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -1,522 +1,520 @@ | |||
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 "drawpadcanvas.h" | 14 | #include "drawpadcanvas.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "page.h" | 17 | #include "page.h" |
18 | #include "tool.h" | 18 | #include "tool.h" |
19 | 19 | ||
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/filemanager.h> | 21 | #include <qpe/filemanager.h> |
22 | #include <qpe/mimetype.h> | 22 | #include <qpe/mimetype.h> |
23 | 23 | ||
24 | #include <qbuffer.h> | 24 | #include <qbuffer.h> |
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qpainter.h> | ||
27 | #include <qtextcodec.h> | 26 | #include <qtextcodec.h> |
28 | #include <qtextstream.h> | ||
29 | #include <qxml.h> | 27 | #include <qxml.h> |
30 | 28 | ||
31 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 29 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
32 | { | 30 | { |
33 | public: | 31 | public: |
34 | DrawPadCanvasXmlHandler(); | 32 | DrawPadCanvasXmlHandler(); |
35 | ~DrawPadCanvasXmlHandler(); | 33 | ~DrawPadCanvasXmlHandler(); |
36 | 34 | ||
37 | QList<Page> pages(); | 35 | QList<Page> pages(); |
38 | 36 | ||
39 | bool startElement(const QString& namespaceURI, const QString& localName, | 37 | bool startElement(const QString& namespaceURI, const QString& localName, |
40 | const QString& qName, const QXmlAttributes& atts); | 38 | const QString& qName, const QXmlAttributes& atts); |
41 | bool endElement(const QString& namespaceURI, const QString& localName, | 39 | bool endElement(const QString& namespaceURI, const QString& localName, |
42 | const QString& qName); | 40 | const QString& qName); |
43 | bool characters(const QString& ch); | 41 | bool characters(const QString& ch); |
44 | 42 | ||
45 | private: | 43 | private: |
46 | enum State { | 44 | enum State { |
47 | Unknown, | 45 | Unknown, |
48 | InTitle, | 46 | InTitle, |
49 | InDate, | 47 | InDate, |
50 | InData | 48 | InData |
51 | }; | 49 | }; |
52 | 50 | ||
53 | State m_state; | 51 | State m_state; |
54 | QString m_title; | 52 | QString m_title; |
55 | QDateTime m_date; | 53 | QDateTime m_date; |
56 | ulong m_dataLenght; | 54 | ulong m_dataLenght; |
57 | QString m_dataFormat; | 55 | QString m_dataFormat; |
58 | QList<Page> m_pages; | 56 | QList<Page> m_pages; |
59 | }; | 57 | }; |
60 | 58 | ||
61 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() | 59 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() |
62 | { | 60 | { |
63 | m_state = Unknown; | 61 | m_state = Unknown; |
64 | } | 62 | } |
65 | 63 | ||
66 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() | 64 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() |
67 | { | 65 | { |
68 | } | 66 | } |
69 | 67 | ||
70 | QList<Page> DrawPadCanvasXmlHandler::pages() | 68 | QList<Page> DrawPadCanvasXmlHandler::pages() |
71 | { | 69 | { |
72 | return m_pages; | 70 | return m_pages; |
73 | } | 71 | } |
74 | 72 | ||
75 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, | 73 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, |
76 | const QString& qName, const QXmlAttributes& atts) | 74 | const QString& qName, const QXmlAttributes& atts) |
77 | { | 75 | { |
78 | Q_CONST_UNUSED(namespaceURI) | 76 | Q_CONST_UNUSED(namespaceURI) |
79 | Q_CONST_UNUSED(localName) | 77 | Q_CONST_UNUSED(localName) |
80 | 78 | ||
81 | if (qName == "image") { | 79 | if (qName == "image") { |
82 | m_title = QString(); | 80 | m_title = QString(); |
83 | m_date = QDateTime::currentDateTime(); | 81 | m_date = QDateTime::currentDateTime(); |
84 | } else if (qName == "title") { | 82 | } else if (qName == "title") { |
85 | m_state = InTitle; | 83 | m_state = InTitle; |
86 | } else if (qName == "date") { | 84 | } else if (qName == "date") { |
87 | m_state = InDate; | 85 | m_state = InDate; |
88 | } else if (qName == "data") { | 86 | } else if (qName == "data") { |
89 | m_state = InData; | 87 | m_state = InData; |
90 | m_dataLenght = atts.value("length").toULong(); | 88 | m_dataLenght = atts.value("length").toULong(); |
91 | m_dataFormat = atts.value("format"); | 89 | m_dataFormat = atts.value("format"); |
92 | } | 90 | } |
93 | 91 | ||
94 | return true; | 92 | return true; |
95 | } | 93 | } |
96 | 94 | ||
97 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, | 95 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, |
98 | const QString& qName) | 96 | const QString& qName) |
99 | { | 97 | { |
100 | Q_CONST_UNUSED(namespaceURI) | 98 | Q_CONST_UNUSED(namespaceURI) |
101 | Q_CONST_UNUSED(localName) | 99 | Q_CONST_UNUSED(localName) |
102 | 100 | ||
103 | if (qName == "title") { | 101 | if (qName == "title") { |
104 | m_state = Unknown; | 102 | m_state = Unknown; |
105 | } else if (qName == "date") { | 103 | } else if (qName == "date") { |
106 | m_state = Unknown; | 104 | m_state = Unknown; |
107 | } else if (qName == "data") { | 105 | } else if (qName == "data") { |
108 | m_state = Unknown; | 106 | m_state = Unknown; |
109 | } | 107 | } |
110 | 108 | ||
111 | return true; | 109 | return true; |
112 | } | 110 | } |
113 | 111 | ||
114 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) | 112 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) |
115 | { | 113 | { |
116 | if (m_state == InTitle) { | 114 | if (m_state == InTitle) { |
117 | m_title = ch; | 115 | m_title = ch; |
118 | } else if (m_state == InDate) { | 116 | } else if (m_state == InDate) { |
119 | m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); | 117 | m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); |
120 | } else if (m_state == InData) { | 118 | } else if (m_state == InData) { |
121 | QByteArray byteArray(ch.length() / 2); | 119 | QByteArray byteArray(ch.length() / 2); |
122 | 120 | ||
123 | for (int i = 0; i < (int)ch.length() / 2; i++) { | 121 | for (int i = 0; i < (int)ch.length() / 2; i++) { |
124 | char h = ch[2 * i].latin1(); | 122 | char h = ch[2 * i].latin1(); |
125 | char l = ch[2 * i + 1].latin1(); | 123 | char l = ch[2 * i + 1].latin1(); |
126 | uchar r = 0; | 124 | uchar r = 0; |
127 | 125 | ||
128 | if (h <= '9') { | 126 | if (h <= '9') { |
129 | r += h - '0'; | 127 | r += h - '0'; |
130 | } else { | 128 | } else { |
131 | r += h - 'a' + 10; | 129 | r += h - 'a' + 10; |
132 | } | 130 | } |
133 | 131 | ||
134 | r = r << 4; | 132 | r = r << 4; |
135 | 133 | ||
136 | if (l <= '9') { | 134 | if (l <= '9') { |
137 | r += l - '0'; | 135 | r += l - '0'; |
138 | } else { | 136 | } else { |
139 | r += l - 'a' + 10; | 137 | r += l - 'a' + 10; |
140 | } | 138 | } |
141 | 139 | ||
142 | byteArray[i] = r; | 140 | byteArray[i] = r; |
143 | } | 141 | } |
144 | 142 | ||
145 | QImage image; | 143 | QImage image; |
146 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | 144 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); |
147 | 145 | ||
148 | Page* page = new Page(m_title, image.width(), image.height()); | 146 | Page* page = new Page(m_title, image.width(), image.height()); |
149 | page->setLastModified(m_date); | 147 | page->setLastModified(m_date); |
150 | page->pixmap()->convertFromImage(image); | 148 | page->pixmap()->convertFromImage(image); |
151 | m_pages.append(page); | 149 | m_pages.append(page); |
152 | } | 150 | } |
153 | 151 | ||
154 | return true; | 152 | return true; |
155 | } | 153 | } |
156 | 154 | ||
157 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) | 155 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) |
158 | : QScrollView(parent, name) | 156 | : QScrollView(parent, name) |
159 | { | 157 | { |
160 | m_pDrawPad = drawPad; | 158 | m_pDrawPad = drawPad; |
161 | m_pages.setAutoDelete(true); | 159 | m_pages.setAutoDelete(true); |
162 | 160 | ||
163 | viewport()->setBackgroundMode(QWidget::NoBackground); | 161 | viewport()->setBackgroundMode(QWidget::NoBackground); |
164 | } | 162 | } |
165 | 163 | ||
166 | DrawPadCanvas::~DrawPadCanvas() | 164 | DrawPadCanvas::~DrawPadCanvas() |
167 | { | 165 | { |
168 | } | 166 | } |
169 | 167 | ||
170 | void DrawPadCanvas::load(QIODevice* ioDevice) | 168 | void DrawPadCanvas::load(QIODevice* ioDevice) |
171 | { | 169 | { |
172 | QTextStream textStream(ioDevice); | 170 | QTextStream textStream(ioDevice); |
173 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 171 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
174 | 172 | ||
175 | QXmlInputSource xmlInputSource(textStream); | 173 | QXmlInputSource xmlInputSource(textStream); |
176 | QXmlSimpleReader xmlSimpleReader; | 174 | QXmlSimpleReader xmlSimpleReader; |
177 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 175 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
178 | 176 | ||
179 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 177 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
180 | xmlSimpleReader.parse(xmlInputSource); | 178 | xmlSimpleReader.parse(xmlInputSource); |
181 | 179 | ||
182 | m_pages = drawPadCanvasXmlHandler.pages(); | 180 | m_pages = drawPadCanvasXmlHandler.pages(); |
183 | 181 | ||
184 | if (m_pages.isEmpty()) { | 182 | if (m_pages.isEmpty()) { |
185 | m_pages.append(new Page("", | 183 | m_pages.append(new Page("", |
186 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | 184 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), |
187 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | 185 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); |
188 | m_pages.current()->pixmap()->fill(Qt::white); | 186 | m_pages.current()->pixmap()->fill(Qt::white); |
189 | } | 187 | } |
190 | 188 | ||
191 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 189 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
192 | viewport()->update(); | 190 | viewport()->update(); |
193 | 191 | ||
194 | emit pagesChanged(); | 192 | emit pagesChanged(); |
195 | } | 193 | } |
196 | 194 | ||
197 | void DrawPadCanvas::initialPage() | 195 | void DrawPadCanvas::initialPage() |
198 | { | 196 | { |
199 | m_pages.append(new Page("", | 197 | m_pages.append(new Page("", |
200 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | 198 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), |
201 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | 199 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); |
202 | //236, 232)); no more fixed sizes | 200 | //236, 232)); no more fixed sizes |
203 | 201 | ||
204 | m_pages.current()->pixmap()->fill(Qt::white); | 202 | m_pages.current()->pixmap()->fill(Qt::white); |
205 | 203 | ||
206 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 204 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
207 | viewport()->update(); | 205 | viewport()->update(); |
208 | 206 | ||
209 | emit pagesChanged(); | 207 | emit pagesChanged(); |
210 | } | 208 | } |
211 | 209 | ||
212 | void DrawPadCanvas::save(QIODevice* ioDevice) | 210 | void DrawPadCanvas::save(QIODevice* ioDevice) |
213 | { | 211 | { |
214 | QTextStream textStream(ioDevice); | 212 | QTextStream textStream(ioDevice); |
215 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 213 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
216 | 214 | ||
217 | textStream << "<drawpad>" << endl; | 215 | textStream << "<drawpad>" << endl; |
218 | textStream << " <images>" << endl; | 216 | textStream << " <images>" << endl; |
219 | 217 | ||
220 | QListIterator<Page> bufferIterator(m_pages); | 218 | QListIterator<Page> bufferIterator(m_pages); |
221 | 219 | ||
222 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 220 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
223 | textStream << " <image>" << endl; | 221 | textStream << " <image>" << endl; |
224 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; | 222 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; |
225 | 223 | ||
226 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); | 224 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); |
227 | textStream << " <date>" << intDate << "</date>" << endl; | 225 | textStream << " <date>" << intDate << "</date>" << endl; |
228 | 226 | ||
229 | QImage image = bufferIterator.current()->pixmap()->convertToImage(); | 227 | QImage image = bufferIterator.current()->pixmap()->convertToImage(); |
230 | QByteArray byteArray; | 228 | QByteArray byteArray; |
231 | QBuffer buffer(byteArray); | 229 | QBuffer buffer(byteArray); |
232 | QImageIO imageIO(&buffer, "PNG"); | 230 | QImageIO imageIO(&buffer, "PNG"); |
233 | 231 | ||
234 | buffer.open(IO_WriteOnly); | 232 | buffer.open(IO_WriteOnly); |
235 | imageIO.setImage(image); | 233 | imageIO.setImage(image); |
236 | imageIO.write(); | 234 | imageIO.write(); |
237 | buffer.close(); | 235 | buffer.close(); |
238 | 236 | ||
239 | textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; | 237 | textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; |
240 | 238 | ||
241 | static const char hexchars[] = "0123456789abcdef"; | 239 | static const char hexchars[] = "0123456789abcdef"; |
242 | 240 | ||
243 | for (int i = 0; i < (int)byteArray.size(); i++ ) { | 241 | for (int i = 0; i < (int)byteArray.size(); i++ ) { |
244 | uchar s = (uchar)byteArray[i]; | 242 | uchar s = (uchar)byteArray[i]; |
245 | textStream << hexchars[s >> 4]; | 243 | textStream << hexchars[s >> 4]; |
246 | textStream << hexchars[s & 0x0f]; | 244 | textStream << hexchars[s & 0x0f]; |
247 | } | 245 | } |
248 | 246 | ||
249 | textStream << "</data>" << endl; | 247 | textStream << "</data>" << endl; |
250 | textStream << " </image>" << endl; | 248 | textStream << " </image>" << endl; |
251 | } | 249 | } |
252 | 250 | ||
253 | textStream << " </images>" << endl; | 251 | textStream << " </images>" << endl; |
254 | textStream << "</drawpad>"; | 252 | textStream << "</drawpad>"; |
255 | } | 253 | } |
256 | 254 | ||
257 | void DrawPadCanvas::importPage(const QString& fileName) | 255 | void DrawPadCanvas::importPage(const QString& fileName) |
258 | { | 256 | { |
259 | Page* importedPage = new Page(); | 257 | Page* importedPage = new Page(); |
260 | 258 | ||
261 | importedPage->pixmap()->load(fileName); | 259 | importedPage->pixmap()->load(fileName); |
262 | m_pages.insert(m_pages.at() + 1, importedPage); | 260 | m_pages.insert(m_pages.at() + 1, importedPage); |
263 | 261 | ||
264 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 262 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
265 | viewport()->update(); | 263 | viewport()->update(); |
266 | 264 | ||
267 | emit pagesChanged(); | 265 | emit pagesChanged(); |
268 | } | 266 | } |
269 | 267 | ||
270 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 268 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
271 | { | 269 | { |
272 | if (fromPage == toPage) { | 270 | if (fromPage == toPage) { |
273 | DocLnk docLnk; | 271 | DocLnk docLnk; |
274 | MimeType mimeType(format); | 272 | MimeType mimeType(format); |
275 | 273 | ||
276 | docLnk.setName(name); | 274 | docLnk.setName(name); |
277 | docLnk.setType(mimeType.id()); | 275 | docLnk.setType(mimeType.id()); |
278 | 276 | ||
279 | FileManager fileManager; | 277 | FileManager fileManager; |
280 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 278 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
281 | QImageIO imageIO(ioDevice, format); | 279 | QImageIO imageIO(ioDevice, format); |
282 | 280 | ||
283 | QImage image = m_pages.current()->pixmap()->convertToImage(); | 281 | QImage image = m_pages.current()->pixmap()->convertToImage(); |
284 | imageIO.setImage(image); | 282 | imageIO.setImage(image); |
285 | imageIO.write(); | 283 | imageIO.write(); |
286 | delete ioDevice; | 284 | delete ioDevice; |
287 | } else { | 285 | } else { |
288 | for (uint i = fromPage; i <= toPage; i++) { | 286 | for (uint i = fromPage; i <= toPage; i++) { |
289 | DocLnk docLnk; | 287 | DocLnk docLnk; |
290 | MimeType mimeType(format); | 288 | MimeType mimeType(format); |
291 | 289 | ||
292 | docLnk.setName(name + QString::number(i)); | 290 | docLnk.setName(name + QString::number(i)); |
293 | docLnk.setType(mimeType.id()); | 291 | docLnk.setType(mimeType.id()); |
294 | 292 | ||
295 | FileManager fileManager; | 293 | FileManager fileManager; |
296 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 294 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
297 | QImageIO imageIO(ioDevice, format); | 295 | QImageIO imageIO(ioDevice, format); |
298 | 296 | ||
299 | QImage image = m_pages.at(i - 1)->pixmap()->convertToImage(); | 297 | QImage image = m_pages.at(i - 1)->pixmap()->convertToImage(); |
300 | imageIO.setImage(image); | 298 | imageIO.setImage(image); |
301 | imageIO.write(); | 299 | imageIO.write(); |
302 | delete ioDevice; | 300 | delete ioDevice; |
303 | } | 301 | } |
304 | } | 302 | } |
305 | } | 303 | } |
306 | 304 | ||
307 | Page* DrawPadCanvas::currentPage() | 305 | Page* DrawPadCanvas::currentPage() |
308 | { | 306 | { |
309 | return m_pages.current(); | 307 | return m_pages.current(); |
310 | } | 308 | } |
311 | 309 | ||
312 | QList<Page> DrawPadCanvas::pages() | 310 | QList<Page> DrawPadCanvas::pages() |
313 | { | 311 | { |
314 | return m_pages; | 312 | return m_pages; |
315 | } | 313 | } |
316 | 314 | ||
317 | uint DrawPadCanvas::pagePosition() | 315 | uint DrawPadCanvas::pagePosition() |
318 | { | 316 | { |
319 | return (m_pages.at() + 1); | 317 | return (m_pages.at() + 1); |
320 | } | 318 | } |
321 | 319 | ||
322 | uint DrawPadCanvas::pageCount() | 320 | uint DrawPadCanvas::pageCount() |
323 | { | 321 | { |
324 | return m_pages.count(); | 322 | return m_pages.count(); |
325 | } | 323 | } |
326 | 324 | ||
327 | void DrawPadCanvas::selectPage(Page* page) | 325 | void DrawPadCanvas::selectPage(Page* page) |
328 | { | 326 | { |
329 | m_pages.findRef(page); | 327 | m_pages.findRef(page); |
330 | 328 | ||
331 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 329 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
332 | viewport()->update(); | 330 | viewport()->update(); |
333 | 331 | ||
334 | emit pagesChanged(); | 332 | emit pagesChanged(); |
335 | } | 333 | } |
336 | 334 | ||
337 | void DrawPadCanvas::backupPage() | 335 | void DrawPadCanvas::backupPage() |
338 | { | 336 | { |
339 | m_pages.current()->backup(); | 337 | m_pages.current()->backup(); |
340 | 338 | ||
341 | emit pagesChanged(); | 339 | emit pagesChanged(); |
342 | } | 340 | } |
343 | 341 | ||
344 | void DrawPadCanvas::selectPage(uint pagePosition) | 342 | void DrawPadCanvas::selectPage(uint pagePosition) |
345 | { | 343 | { |
346 | m_pages.at(pagePosition - 1); | 344 | m_pages.at(pagePosition - 1); |
347 | 345 | ||
348 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 346 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
349 | viewport()->update(); | 347 | viewport()->update(); |
350 | 348 | ||
351 | emit pagesChanged(); | 349 | emit pagesChanged(); |
352 | } | 350 | } |
353 | 351 | ||
354 | void DrawPadCanvas::deleteAll() | 352 | void DrawPadCanvas::deleteAll() |
355 | { | 353 | { |
356 | m_pages.clear(); | 354 | m_pages.clear(); |
357 | 355 | ||
358 | m_pages.append(new Page("", | 356 | m_pages.append(new Page("", |
359 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | 357 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), |
360 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | 358 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); |
361 | 359 | ||
362 | m_pages.current()->pixmap()->fill(Qt::white); | 360 | m_pages.current()->pixmap()->fill(Qt::white); |
363 | 361 | ||
364 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 362 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
365 | viewport()->update(); | 363 | viewport()->update(); |
366 | 364 | ||
367 | emit pagesChanged(); | 365 | emit pagesChanged(); |
368 | } | 366 | } |
369 | 367 | ||
370 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) | 368 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
371 | { | 369 | { |
372 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); | 370 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
373 | m_pages.current()->pixmap()->fill(color); | 371 | m_pages.current()->pixmap()->fill(color); |
374 | 372 | ||
375 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 373 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
376 | viewport()->update(); | 374 | viewport()->update(); |
377 | 375 | ||
378 | emit pagesChanged(); | 376 | emit pagesChanged(); |
379 | } | 377 | } |
380 | 378 | ||
381 | void DrawPadCanvas::clearPage() | 379 | void DrawPadCanvas::clearPage() |
382 | { | 380 | { |
383 | m_pages.current()->pixmap()->fill(Qt::white); | 381 | m_pages.current()->pixmap()->fill(Qt::white); |
384 | 382 | ||
385 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 383 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
386 | viewport()->update(); | 384 | viewport()->update(); |
387 | } | 385 | } |
388 | 386 | ||
389 | void DrawPadCanvas::deletePage() | 387 | void DrawPadCanvas::deletePage() |
390 | { | 388 | { |
391 | m_pages.remove(m_pages.current()); | 389 | m_pages.remove(m_pages.current()); |
392 | 390 | ||
393 | if (m_pages.isEmpty()) { | 391 | if (m_pages.isEmpty()) { |
394 | m_pages.append(new Page("", | 392 | m_pages.append(new Page("", |
395 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), | 393 | clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0), |
396 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); | 394 | clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0))); |
397 | 395 | ||
398 | m_pages.current()->pixmap()->fill(Qt::white); | 396 | m_pages.current()->pixmap()->fill(Qt::white); |
399 | } | 397 | } |
400 | 398 | ||
401 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 399 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
402 | viewport()->update(); | 400 | viewport()->update(); |
403 | 401 | ||
404 | emit pagesChanged(); | 402 | emit pagesChanged(); |
405 | } | 403 | } |
406 | 404 | ||
407 | void DrawPadCanvas::movePageUp() | 405 | void DrawPadCanvas::movePageUp() |
408 | { | 406 | { |
409 | int index = m_pages.at(); | 407 | int index = m_pages.at(); |
410 | Page* page = m_pages.take(); | 408 | Page* page = m_pages.take(); |
411 | m_pages.insert(index - 1, page); | 409 | m_pages.insert(index - 1, page); |
412 | 410 | ||
413 | emit pagesChanged(); | 411 | emit pagesChanged(); |
414 | } | 412 | } |
415 | 413 | ||
416 | void DrawPadCanvas::movePageDown() | 414 | void DrawPadCanvas::movePageDown() |
417 | { | 415 | { |
418 | int index = m_pages.at(); | 416 | int index = m_pages.at(); |
419 | Page* page = m_pages.take(); | 417 | Page* page = m_pages.take(); |
420 | m_pages.insert(index + 1, page); | 418 | m_pages.insert(index + 1, page); |
421 | 419 | ||
422 | emit pagesChanged(); | 420 | emit pagesChanged(); |
423 | } | 421 | } |
424 | 422 | ||
425 | bool DrawPadCanvas::goPreviousPageEnabled() | 423 | bool DrawPadCanvas::goPreviousPageEnabled() |
426 | { | 424 | { |
427 | return (m_pages.current() != m_pages.getFirst()); | 425 | return (m_pages.current() != m_pages.getFirst()); |
428 | } | 426 | } |
429 | 427 | ||
430 | bool DrawPadCanvas::goNextPageEnabled() | 428 | bool DrawPadCanvas::goNextPageEnabled() |
431 | { | 429 | { |
432 | return (m_pages.current() != m_pages.getLast()); | 430 | return (m_pages.current() != m_pages.getLast()); |
433 | } | 431 | } |
434 | 432 | ||
435 | void DrawPadCanvas::undo() | 433 | void DrawPadCanvas::undo() |
436 | { | 434 | { |
437 | m_pages.current()->undo(); | 435 | m_pages.current()->undo(); |
438 | 436 | ||
439 | viewport()->update(); | 437 | viewport()->update(); |
440 | 438 | ||
441 | emit pagesChanged(); | 439 | emit pagesChanged(); |
442 | } | 440 | } |
443 | 441 | ||
444 | void DrawPadCanvas::redo() | 442 | void DrawPadCanvas::redo() |
445 | { | 443 | { |
446 | m_pages.current()->redo(); | 444 | m_pages.current()->redo(); |
447 | 445 | ||
448 | viewport()->update(); | 446 | viewport()->update(); |
449 | 447 | ||
450 | emit pagesChanged(); | 448 | emit pagesChanged(); |
451 | } | 449 | } |
452 | 450 | ||
453 | void DrawPadCanvas::goFirstPage() | 451 | void DrawPadCanvas::goFirstPage() |
454 | { | 452 | { |
455 | m_pages.first(); | 453 | m_pages.first(); |
456 | 454 | ||
457 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 455 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
458 | viewport()->update(); | 456 | viewport()->update(); |
459 | 457 | ||
460 | emit pagesChanged(); | 458 | emit pagesChanged(); |
461 | } | 459 | } |
462 | 460 | ||
463 | void DrawPadCanvas::goPreviousPage() | 461 | void DrawPadCanvas::goPreviousPage() |
464 | { | 462 | { |
465 | m_pages.prev(); | 463 | m_pages.prev(); |
466 | 464 | ||
467 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 465 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
468 | viewport()->update(); | 466 | viewport()->update(); |
469 | 467 | ||
470 | emit pagesChanged(); | 468 | emit pagesChanged(); |
471 | } | 469 | } |
472 | 470 | ||
473 | void DrawPadCanvas::goNextPage() | 471 | void DrawPadCanvas::goNextPage() |
474 | { | 472 | { |
475 | m_pages.next(); | 473 | m_pages.next(); |
476 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 474 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
477 | viewport()->update(); | 475 | viewport()->update(); |
478 | 476 | ||
479 | emit pagesChanged(); | 477 | emit pagesChanged(); |
480 | } | 478 | } |
481 | 479 | ||
482 | void DrawPadCanvas::goLastPage() | 480 | void DrawPadCanvas::goLastPage() |
483 | { | 481 | { |
484 | m_pages.last(); | 482 | m_pages.last(); |
485 | 483 | ||
486 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 484 | resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
487 | viewport()->update(); | 485 | viewport()->update(); |
488 | 486 | ||
489 | emit pagesChanged(); | 487 | emit pagesChanged(); |
490 | } | 488 | } |
491 | 489 | ||
492 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 490 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
493 | { | 491 | { |
494 | m_pDrawPad->tool()->mousePressEvent(e); | 492 | m_pDrawPad->tool()->mousePressEvent(e); |
495 | } | 493 | } |
496 | 494 | ||
497 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 495 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
498 | { | 496 | { |
499 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 497 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
500 | } | 498 | } |
501 | 499 | ||
502 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 500 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
503 | { | 501 | { |
504 | m_pDrawPad->tool()->mouseMoveEvent(e); | 502 | m_pDrawPad->tool()->mouseMoveEvent(e); |
505 | } | 503 | } |
506 | 504 | ||
507 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 505 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
508 | { | 506 | { |
509 | QRect clipRect(cx, cy, cw, ch); | 507 | QRect clipRect(cx, cy, cw, ch); |
510 | QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); | 508 | QRect pixmapRect(0, 0, m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height()); |
511 | QRect drawRect = pixmapRect.intersect(clipRect); | 509 | QRect drawRect = pixmapRect.intersect(clipRect); |
512 | 510 | ||
513 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); | 511 | p->drawPixmap(drawRect.topLeft(), *(m_pages.current()->pixmap()), drawRect); |
514 | 512 | ||
515 | if (drawRect.right() < clipRect.right()) { | 513 | if (drawRect.right() < clipRect.right()) { |
516 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); | 514 | p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark()); |
517 | } | 515 | } |
518 | 516 | ||
519 | if (drawRect.bottom() < clipRect.bottom()) { | 517 | if (drawRect.bottom() < clipRect.bottom()) { |
520 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); | 518 | p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark()); |
521 | } | 519 | } |
522 | } | 520 | } |
diff --git a/noncore/graphics/drawpad/ellipsetool.cpp b/noncore/graphics/drawpad/ellipsetool.cpp index 0cdb731..2173c97 100644 --- a/noncore/graphics/drawpad/ellipsetool.cpp +++ b/noncore/graphics/drawpad/ellipsetool.cpp | |||
@@ -1,81 +1,80 @@ | |||
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 "ellipsetool.h" | 14 | #include "ellipsetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qpixmap.h> | ||
21 | 20 | ||
22 | EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 21 | EllipseTool::EllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 22 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 23 | { |
25 | } | 24 | } |
26 | 25 | ||
27 | EllipseTool::~EllipseTool() | 26 | EllipseTool::~EllipseTool() |
28 | { | 27 | { |
29 | } | 28 | } |
30 | 29 | ||
31 | void EllipseTool::drawFinalShape(QPainter& p) | 30 | void EllipseTool::drawFinalShape(QPainter& p) |
32 | { | 31 | { |
33 | p.setRasterOp(Qt::NotROP); | 32 | p.setRasterOp(Qt::NotROP); |
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 33 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | 34 | p.setRasterOp(Qt::CopyROP); |
36 | 35 | ||
37 | if (m_pDrawPad->antiAliasing()) { | 36 | if (m_pDrawPad->antiAliasing()) { |
38 | QRect r = m_polyline.boundingRect(); | 37 | QRect r = m_polyline.boundingRect(); |
39 | r = r.normalize(); | 38 | r = r.normalize(); |
40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
41 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
42 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
44 | 43 | ||
45 | QPixmap areaPixmap(r.width(), r.height()); | 44 | QPixmap areaPixmap(r.width(), r.height()); |
46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 45 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
47 | 46 | ||
48 | QImage areaImage = areaPixmap.convertToImage(); | 47 | QImage areaImage = areaPixmap.convertToImage(); |
49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 48 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
50 | 49 | ||
51 | QPixmap bigAreaPixmap; | 50 | QPixmap bigAreaPixmap; |
52 | bigAreaPixmap.convertFromImage(bigAreaImage); | 51 | bigAreaPixmap.convertFromImage(bigAreaImage); |
53 | 52 | ||
54 | QPen bigAreaPen = m_pDrawPad->pen(); | 53 | QPen bigAreaPen = m_pDrawPad->pen(); |
55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 54 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
56 | 55 | ||
57 | QPainter bigAreaPainter; | 56 | QPainter bigAreaPainter; |
58 | bigAreaPainter.begin(&bigAreaPixmap); | 57 | bigAreaPainter.begin(&bigAreaPixmap); |
59 | bigAreaPainter.setPen(bigAreaPen); | 58 | bigAreaPainter.setPen(bigAreaPen); |
60 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 59 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
61 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 60 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
62 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 61 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
63 | bigAreaPainter.end(); | 62 | bigAreaPainter.end(); |
64 | 63 | ||
65 | bigAreaImage = bigAreaPixmap.convertToImage(); | 64 | bigAreaImage = bigAreaPixmap.convertToImage(); |
66 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 65 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
67 | areaPixmap.convertFromImage(areaImage); | 66 | areaPixmap.convertFromImage(areaImage); |
68 | 67 | ||
69 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 68 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
70 | } else { | 69 | } else { |
71 | p.setPen(m_pDrawPad->pen()); | 70 | p.setPen(m_pDrawPad->pen()); |
72 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | 71 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); |
73 | } | 72 | } |
74 | } | 73 | } |
75 | 74 | ||
76 | void EllipseTool::drawTemporaryShape(QPainter& p) | 75 | void EllipseTool::drawTemporaryShape(QPainter& p) |
77 | { | 76 | { |
78 | p.setRasterOp(Qt::NotROP); | 77 | p.setRasterOp(Qt::NotROP); |
79 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | 78 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
80 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 79 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
81 | } | 80 | } |
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp index 2326da5..5d123c4 100644 --- a/noncore/graphics/drawpad/erasetool.cpp +++ b/noncore/graphics/drawpad/erasetool.cpp | |||
@@ -1,76 +1,75 @@ | |||
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 "erasetool.h" | 14 | #include "erasetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qpainter.h> | ||
21 | 20 | ||
22 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 21 | EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 22 | : Tool(drawPad, drawPadCanvas) |
24 | { | 23 | { |
25 | m_mousePressed = false; | 24 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 25 | m_polyline.resize(3); |
27 | } | 26 | } |
28 | 27 | ||
29 | EraseTool::~EraseTool() | 28 | EraseTool::~EraseTool() |
30 | { | 29 | { |
31 | } | 30 | } |
32 | 31 | ||
33 | void EraseTool::mousePressEvent(QMouseEvent* e) | 32 | void EraseTool::mousePressEvent(QMouseEvent* e) |
34 | { | 33 | { |
35 | m_pDrawPadCanvas->backupPage(); | 34 | m_pDrawPadCanvas->backupPage(); |
36 | 35 | ||
37 | m_mousePressed = true; | 36 | m_mousePressed = true; |
38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 37 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
39 | } | 38 | } |
40 | 39 | ||
41 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) | 40 | void EraseTool::mouseReleaseEvent(QMouseEvent* e) |
42 | { | 41 | { |
43 | Q_UNUSED(e) | 42 | Q_UNUSED(e) |
44 | 43 | ||
45 | m_mousePressed = false; | 44 | m_mousePressed = false; |
46 | } | 45 | } |
47 | 46 | ||
48 | void EraseTool::mouseMoveEvent(QMouseEvent* e) | 47 | void EraseTool::mouseMoveEvent(QMouseEvent* e) |
49 | { | 48 | { |
50 | if (m_mousePressed) { | 49 | if (m_mousePressed) { |
51 | QPainter painter; | 50 | QPainter painter; |
52 | QPen pen(Qt::white, m_pDrawPad->pen().width()); | 51 | QPen pen(Qt::white, m_pDrawPad->pen().width()); |
53 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); | 52 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
54 | painter.setPen(pen); | 53 | painter.setPen(pen); |
55 | m_polyline[2] = m_polyline[1]; | 54 | m_polyline[2] = m_polyline[1]; |
56 | m_polyline[1] = m_polyline[0]; | 55 | m_polyline[1] = m_polyline[0]; |
57 | m_polyline[0] = e->pos(); | 56 | m_polyline[0] = e->pos(); |
58 | painter.drawPolyline(m_polyline); | 57 | painter.drawPolyline(m_polyline); |
59 | painter.end(); | 58 | painter.end(); |
60 | 59 | ||
61 | QRect r = m_polyline.boundingRect(); | 60 | QRect r = m_polyline.boundingRect(); |
62 | r = r.normalize(); | 61 | r = r.normalize(); |
63 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 62 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
64 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 63 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
65 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 64 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
66 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 65 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
67 | 66 | ||
68 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 67 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
69 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 68 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
70 | 69 | ||
71 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 70 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
72 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); | 71 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
73 | 72 | ||
74 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 73 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
75 | } | 74 | } |
76 | } | 75 | } |
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp index adbd612..d63f428 100644 --- a/noncore/graphics/drawpad/exportdialog.cpp +++ b/noncore/graphics/drawpad/exportdialog.cpp | |||
@@ -1,176 +1,175 @@ | |||
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 "exportdialog.h" | 14 | #include "exportdialog.h" |
15 | 15 | ||
16 | #include <opie/ofileselector.h> | 16 | #include <opie/ofileselector.h> |
17 | 17 | ||
18 | #include <qbuttongroup.h> | 18 | #include <qbuttongroup.h> |
19 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
20 | #include <qgroupbox.h> | ||
21 | #include <qimage.h> | 20 | #include <qimage.h> |
22 | #include <qlabel.h> | 21 | #include <qlabel.h> |
23 | #include <qlayout.h> | 22 | #include <qlayout.h> |
24 | #include <qlineedit.h> | 23 | #include <qlineedit.h> |
25 | #include <qradiobutton.h> | 24 | #include <qradiobutton.h> |
26 | #include <qspinbox.h> | 25 | #include <qspinbox.h> |
27 | 26 | ||
28 | #include <stdlib.h> | 27 | #include <stdlib.h> |
29 | 28 | ||
30 | ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) | 29 | ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) |
31 | : QDialog(parent, name, true) | 30 | : QDialog(parent, name, true) |
32 | { | 31 | { |
33 | setCaption(tr("DrawPad - Export")); | 32 | setCaption(tr("DrawPad - Export")); |
34 | 33 | ||
35 | m_pageAt = pageAt; | 34 | m_pageAt = pageAt; |
36 | m_pageCount = pageCount; | 35 | m_pageCount = pageCount; |
37 | 36 | ||
38 | QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); | 37 | QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); |
39 | connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); | 38 | connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); |
40 | 39 | ||
41 | QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); | 40 | QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); |
42 | QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); | 41 | QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); |
43 | QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); | 42 | QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); |
44 | 43 | ||
45 | QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); | 44 | QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); |
46 | 45 | ||
47 | m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); | 46 | m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); |
48 | connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); | 47 | connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); |
49 | 48 | ||
50 | m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); | 49 | m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); |
51 | connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); | 50 | connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); |
52 | 51 | ||
53 | selectionButtonGroup->setButton(1); | 52 | selectionButtonGroup->setButton(1); |
54 | selectionChanged(1); | 53 | selectionChanged(1); |
55 | 54 | ||
56 | m_pFromPageSpinBox->setValue(pageAt); | 55 | m_pFromPageSpinBox->setValue(pageAt); |
57 | m_pToPageSpinBox->setValue(pageAt); | 56 | m_pToPageSpinBox->setValue(pageAt); |
58 | 57 | ||
59 | QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); | 58 | QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); |
60 | 59 | ||
61 | QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); | 60 | QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); |
62 | QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); | 61 | QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); |
63 | 62 | ||
64 | m_pNameLineEdit = new QLineEdit(exportGroupBox); | 63 | m_pNameLineEdit = new QLineEdit(exportGroupBox); |
65 | 64 | ||
66 | m_pFormatComboBox = new QComboBox(exportGroupBox); | 65 | m_pFormatComboBox = new QComboBox(exportGroupBox); |
67 | m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); | 66 | m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); |
68 | 67 | ||
69 | MimeTypes types; types.insert( tr("All Images"), "image/*" ); | 68 | MimeTypes types; types.insert( tr("All Images"), "image/*" ); |
70 | OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector, | 69 | OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector, |
71 | OFileSelector::Normal, | 70 | OFileSelector::Normal, |
72 | QString::null, QString::null, | 71 | QString::null, QString::null, |
73 | types ); | 72 | types ); |
74 | fileSelector->setNameVisible( false ); | 73 | fileSelector->setNameVisible( false ); |
75 | 74 | ||
76 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 75 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
77 | selectionButtonGroup->layout()->setSpacing(4); | 76 | selectionButtonGroup->layout()->setSpacing(4); |
78 | exportGroupBox->layout()->setSpacing(4); | 77 | exportGroupBox->layout()->setSpacing(4); |
79 | QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); | 78 | QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); |
80 | QHBoxLayout* rangeLayout = new QHBoxLayout(); | 79 | QHBoxLayout* rangeLayout = new QHBoxLayout(); |
81 | QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); | 80 | QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); |
82 | 81 | ||
83 | selectionLayout->addWidget(selectAllRadioButton, 0, 0); | 82 | selectionLayout->addWidget(selectAllRadioButton, 0, 0); |
84 | selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); | 83 | selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); |
85 | selectionLayout->addWidget(selectRangeRadioButton, 0, 1); | 84 | selectionLayout->addWidget(selectRangeRadioButton, 0, 1); |
86 | selectionLayout->addLayout(rangeLayout, 1, 1); | 85 | selectionLayout->addLayout(rangeLayout, 1, 1); |
87 | 86 | ||
88 | rangeLayout->addWidget(m_pFromPageSpinBox); | 87 | rangeLayout->addWidget(m_pFromPageSpinBox); |
89 | rangeLayout->addWidget(toLabel); | 88 | rangeLayout->addWidget(toLabel); |
90 | rangeLayout->addWidget(m_pToPageSpinBox); | 89 | rangeLayout->addWidget(m_pToPageSpinBox); |
91 | 90 | ||
92 | exportLayout->addWidget(nameLabel, 0, 0); | 91 | exportLayout->addWidget(nameLabel, 0, 0); |
93 | exportLayout->addWidget(formatLabel, 1, 0); | 92 | exportLayout->addWidget(formatLabel, 1, 0); |
94 | 93 | ||
95 | exportLayout->addWidget(m_pNameLineEdit, 0, 1); | 94 | exportLayout->addWidget(m_pNameLineEdit, 0, 1); |
96 | exportLayout->addWidget(m_pFormatComboBox, 1, 1); | 95 | exportLayout->addWidget(m_pFormatComboBox, 1, 1); |
97 | 96 | ||
98 | exportLayout->setColStretch(1, 1); | 97 | exportLayout->setColStretch(1, 1); |
99 | 98 | ||
100 | mainLayout->addWidget(selectionButtonGroup); | 99 | mainLayout->addWidget(selectionButtonGroup); |
101 | mainLayout->addWidget(exportGroupBox); | 100 | mainLayout->addWidget(exportGroupBox); |
102 | mainLayout->addWidget(fileSelector); | 101 | mainLayout->addWidget(fileSelector); |
103 | 102 | ||
104 | m_pNameLineEdit->setFocus(); | 103 | m_pNameLineEdit->setFocus(); |
105 | } | 104 | } |
106 | 105 | ||
107 | ExportDialog::~ExportDialog() | 106 | ExportDialog::~ExportDialog() |
108 | { | 107 | { |
109 | } | 108 | } |
110 | 109 | ||
111 | uint ExportDialog::selectedFromPage() | 110 | uint ExportDialog::selectedFromPage() |
112 | { | 111 | { |
113 | return (m_pFromPageSpinBox->value()); | 112 | return (m_pFromPageSpinBox->value()); |
114 | } | 113 | } |
115 | 114 | ||
116 | uint ExportDialog::selectedToPage() | 115 | uint ExportDialog::selectedToPage() |
117 | { | 116 | { |
118 | return (m_pToPageSpinBox->value()); | 117 | return (m_pToPageSpinBox->value()); |
119 | } | 118 | } |
120 | 119 | ||
121 | QString ExportDialog::selectedName() | 120 | QString ExportDialog::selectedName() |
122 | { | 121 | { |
123 | return (m_pNameLineEdit->text()); | 122 | return (m_pNameLineEdit->text()); |
124 | } | 123 | } |
125 | 124 | ||
126 | QString ExportDialog::selectedFormat() | 125 | QString ExportDialog::selectedFormat() |
127 | { | 126 | { |
128 | return (m_pFormatComboBox->currentText()); | 127 | return (m_pFormatComboBox->currentText()); |
129 | } | 128 | } |
130 | 129 | ||
131 | void ExportDialog::accept() | 130 | void ExportDialog::accept() |
132 | { | 131 | { |
133 | if (!(m_pNameLineEdit->text().isEmpty())) { | 132 | if (!(m_pNameLineEdit->text().isEmpty())) { |
134 | QDialog::accept(); | 133 | QDialog::accept(); |
135 | } | 134 | } |
136 | } | 135 | } |
137 | 136 | ||
138 | void ExportDialog::selectionChanged(int id) | 137 | void ExportDialog::selectionChanged(int id) |
139 | { | 138 | { |
140 | switch (id) { | 139 | switch (id) { |
141 | case 0: | 140 | case 0: |
142 | m_pFromPageSpinBox->setValue(1); | 141 | m_pFromPageSpinBox->setValue(1); |
143 | m_pToPageSpinBox->setValue(m_pageCount); | 142 | m_pToPageSpinBox->setValue(m_pageCount); |
144 | 143 | ||
145 | m_pFromPageSpinBox->setEnabled(false); | 144 | m_pFromPageSpinBox->setEnabled(false); |
146 | m_pToPageSpinBox->setEnabled(false); | 145 | m_pToPageSpinBox->setEnabled(false); |
147 | break; | 146 | break; |
148 | case 1: | 147 | case 1: |
149 | m_pFromPageSpinBox->setValue(m_pageAt); | 148 | m_pFromPageSpinBox->setValue(m_pageAt); |
150 | m_pToPageSpinBox->setValue(m_pageAt); | 149 | m_pToPageSpinBox->setValue(m_pageAt); |
151 | 150 | ||
152 | m_pFromPageSpinBox->setEnabled(false); | 151 | m_pFromPageSpinBox->setEnabled(false); |
153 | m_pToPageSpinBox->setEnabled(false); | 152 | m_pToPageSpinBox->setEnabled(false); |
154 | break; | 153 | break; |
155 | case 2: | 154 | case 2: |
156 | m_pFromPageSpinBox->setEnabled(true); | 155 | m_pFromPageSpinBox->setEnabled(true); |
157 | m_pToPageSpinBox->setEnabled(true); | 156 | m_pToPageSpinBox->setEnabled(true); |
158 | break; | 157 | break; |
159 | default: | 158 | default: |
160 | break; | 159 | break; |
161 | } | 160 | } |
162 | } | 161 | } |
163 | 162 | ||
164 | void ExportDialog::fromPageChanged(int value) | 163 | void ExportDialog::fromPageChanged(int value) |
165 | { | 164 | { |
166 | if (m_pToPageSpinBox->value() < value) { | 165 | if (m_pToPageSpinBox->value() < value) { |
167 | m_pToPageSpinBox->setValue(value); | 166 | m_pToPageSpinBox->setValue(value); |
168 | } | 167 | } |
169 | } | 168 | } |
170 | 169 | ||
171 | void ExportDialog::toPageChanged(int value) | 170 | void ExportDialog::toPageChanged(int value) |
172 | { | 171 | { |
173 | if (m_pFromPageSpinBox->value() > value) { | 172 | if (m_pFromPageSpinBox->value() > value) { |
174 | m_pFromPageSpinBox->setValue(value); | 173 | m_pFromPageSpinBox->setValue(value); |
175 | } | 174 | } |
176 | } | 175 | } |
diff --git a/noncore/graphics/drawpad/filledellipsetool.cpp b/noncore/graphics/drawpad/filledellipsetool.cpp index 6b5bbc6..41b8571 100644 --- a/noncore/graphics/drawpad/filledellipsetool.cpp +++ b/noncore/graphics/drawpad/filledellipsetool.cpp | |||
@@ -1,83 +1,82 @@ | |||
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 "filledellipsetool.h" | 14 | #include "filledellipsetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qpixmap.h> | ||
21 | 20 | ||
22 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 21 | FilledEllipseTool::FilledEllipseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 22 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 23 | { |
25 | } | 24 | } |
26 | 25 | ||
27 | FilledEllipseTool::~FilledEllipseTool() | 26 | FilledEllipseTool::~FilledEllipseTool() |
28 | { | 27 | { |
29 | } | 28 | } |
30 | 29 | ||
31 | void FilledEllipseTool::drawFinalShape(QPainter& p) | 30 | void FilledEllipseTool::drawFinalShape(QPainter& p) |
32 | { | 31 | { |
33 | p.setRasterOp(Qt::NotROP); | 32 | p.setRasterOp(Qt::NotROP); |
34 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 33 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
35 | p.setRasterOp(Qt::CopyROP); | 34 | p.setRasterOp(Qt::CopyROP); |
36 | 35 | ||
37 | if (m_pDrawPad->antiAliasing()) { | 36 | if (m_pDrawPad->antiAliasing()) { |
38 | QRect r = m_polyline.boundingRect(); | 37 | QRect r = m_polyline.boundingRect(); |
39 | r = r.normalize(); | 38 | r = r.normalize(); |
40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
41 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
42 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
44 | 43 | ||
45 | QPixmap areaPixmap(r.width(), r.height()); | 44 | QPixmap areaPixmap(r.width(), r.height()); |
46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 45 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
47 | 46 | ||
48 | QImage areaImage = areaPixmap.convertToImage(); | 47 | QImage areaImage = areaPixmap.convertToImage(); |
49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 48 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
50 | 49 | ||
51 | QPixmap bigAreaPixmap; | 50 | QPixmap bigAreaPixmap; |
52 | bigAreaPixmap.convertFromImage(bigAreaImage); | 51 | bigAreaPixmap.convertFromImage(bigAreaImage); |
53 | 52 | ||
54 | QPen bigAreaPen = m_pDrawPad->pen(); | 53 | QPen bigAreaPen = m_pDrawPad->pen(); |
55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 54 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
56 | 55 | ||
57 | QPainter bigAreaPainter; | 56 | QPainter bigAreaPainter; |
58 | bigAreaPainter.begin(&bigAreaPixmap); | 57 | bigAreaPainter.begin(&bigAreaPixmap); |
59 | bigAreaPainter.setPen(bigAreaPen); | 58 | bigAreaPainter.setPen(bigAreaPen); |
60 | bigAreaPainter.setBrush(m_pDrawPad->brush()); | 59 | bigAreaPainter.setBrush(m_pDrawPad->brush()); |
61 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, | 60 | bigAreaPainter.drawEllipse(QRect(bigAreaPen.width() + 1, bigAreaPen.width() + 1, |
62 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), | 61 | bigAreaPixmap.width() - 2 * (bigAreaPen.width() + 1), |
63 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); | 62 | bigAreaPixmap.height() - 2 * (bigAreaPen.width() + 1))); |
64 | bigAreaPainter.end(); | 63 | bigAreaPainter.end(); |
65 | 64 | ||
66 | bigAreaImage = bigAreaPixmap.convertToImage(); | 65 | bigAreaImage = bigAreaPixmap.convertToImage(); |
67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 66 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
68 | areaPixmap.convertFromImage(areaImage); | 67 | areaPixmap.convertFromImage(areaImage); |
69 | 68 | ||
70 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 69 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
71 | } else { | 70 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | 71 | p.setPen(m_pDrawPad->pen()); |
73 | p.setBrush(m_pDrawPad->brush()); | 72 | p.setBrush(m_pDrawPad->brush()); |
74 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); | 73 | p.drawEllipse(QRect(m_polyline[2], m_polyline[0])); |
75 | } | 74 | } |
76 | } | 75 | } |
77 | 76 | ||
78 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) | 77 | void FilledEllipseTool::drawTemporaryShape(QPainter& p) |
79 | { | 78 | { |
80 | p.setRasterOp(Qt::NotROP); | 79 | p.setRasterOp(Qt::NotROP); |
81 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); | 80 | p.drawRect(QRect(m_polyline[2], m_polyline[1])); |
82 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); | 81 | p.drawRect(QRect(m_polyline[2], m_polyline[0])); |
83 | } | 82 | } |
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index b47aa60..fedf3a5 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -1,165 +1,164 @@ | |||
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 "filltool.h" | 14 | #include "filltool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qimage.h> | ||
21 | 20 | ||
22 | const int FILL_THRESHOLD = 65536; | 21 | const int FILL_THRESHOLD = 65536; |
23 | 22 | ||
24 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 23 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
25 | : Tool(drawPad, drawPadCanvas) | 24 | : Tool(drawPad, drawPadCanvas) |
26 | { | 25 | { |
27 | } | 26 | } |
28 | 27 | ||
29 | FillTool::~FillTool() | 28 | FillTool::~FillTool() |
30 | { | 29 | { |
31 | } | 30 | } |
32 | 31 | ||
33 | void FillTool::mousePressEvent(QMouseEvent* e) | 32 | void FillTool::mousePressEvent(QMouseEvent* e) |
34 | { | 33 | { |
35 | int x = e->x(); | 34 | int x = e->x(); |
36 | int y = e->y(); | 35 | int y = e->y(); |
37 | 36 | ||
38 | m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage(); | 37 | m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage(); |
39 | 38 | ||
40 | if (m_image.depth() <= 8) { | 39 | if (m_image.depth() <= 8) { |
41 | m_image = m_image.convertDepth(32); | 40 | m_image = m_image.convertDepth(32); |
42 | } | 41 | } |
43 | 42 | ||
44 | m_fillRgb = m_pDrawPad->brush().color().rgb(); | 43 | m_fillRgb = m_pDrawPad->brush().color().rgb(); |
45 | m_oldRgb = m_image.pixel(x, y); | 44 | m_oldRgb = m_image.pixel(x, y); |
46 | 45 | ||
47 | if (m_oldRgb != m_fillRgb) { | 46 | if (m_oldRgb != m_fillRgb) { |
48 | m_pDrawPadCanvas->backupPage(); | 47 | m_pDrawPadCanvas->backupPage(); |
49 | 48 | ||
50 | if (m_pDrawPad->antiAliasing()) { | 49 | if (m_pDrawPad->antiAliasing()) { |
51 | m_mask.create(m_image.width(), m_image.height(), 8, 2); | 50 | m_mask.create(m_image.width(), m_image.height(), 8, 2); |
52 | m_mask.fill(0); | 51 | m_mask.fill(0); |
53 | 52 | ||
54 | fillMaskLine(x, y); | 53 | fillMaskLine(x, y); |
55 | 54 | ||
56 | for (int i = 0; i < m_image.width(); i++) { | 55 | for (int i = 0; i < m_image.width(); i++) { |
57 | for (int j = 0; j < m_image.height(); j++) { | 56 | for (int j = 0; j < m_image.height(); j++) { |
58 | if (m_mask.pixelIndex(i, j) == 1) { | 57 | if (m_mask.pixelIndex(i, j) == 1) { |
59 | setInterpolatedPixel(i, j); | 58 | setInterpolatedPixel(i, j); |
60 | } | 59 | } |
61 | } | 60 | } |
62 | } | 61 | } |
63 | 62 | ||
64 | } else { | 63 | } else { |
65 | fillLine(x, y); | 64 | fillLine(x, y); |
66 | } | 65 | } |
67 | 66 | ||
68 | m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image); | 67 | m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image); |
69 | m_pDrawPadCanvas->viewport()->update(); | 68 | m_pDrawPadCanvas->viewport()->update(); |
70 | } | 69 | } |
71 | } | 70 | } |
72 | 71 | ||
73 | void FillTool::mouseReleaseEvent(QMouseEvent* e) | 72 | void FillTool::mouseReleaseEvent(QMouseEvent* e) |
74 | { | 73 | { |
75 | Q_UNUSED(e) | 74 | Q_UNUSED(e) |
76 | } | 75 | } |
77 | 76 | ||
78 | void FillTool::mouseMoveEvent(QMouseEvent* e) | 77 | void FillTool::mouseMoveEvent(QMouseEvent* e) |
79 | { | 78 | { |
80 | Q_UNUSED(e) | 79 | Q_UNUSED(e) |
81 | } | 80 | } |
82 | 81 | ||
83 | void FillTool::fillLine(int x, int y) | 82 | void FillTool::fillLine(int x, int y) |
84 | { | 83 | { |
85 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { | 84 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { |
86 | if (m_image.pixel(x, y) == m_oldRgb) { | 85 | if (m_image.pixel(x, y) == m_oldRgb) { |
87 | int x1, x2; | 86 | int x1, x2; |
88 | 87 | ||
89 | x1 = x - 1; | 88 | x1 = x - 1; |
90 | x2 = x + 1; | 89 | x2 = x + 1; |
91 | 90 | ||
92 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { | 91 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { |
93 | x1--; | 92 | x1--; |
94 | } | 93 | } |
95 | 94 | ||
96 | while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) { | 95 | while ((x2 < m_image.width()) && (m_image.pixel(x2, y) == m_oldRgb)) { |
97 | x2++; | 96 | x2++; |
98 | } | 97 | } |
99 | 98 | ||
100 | for (int i = x1 + 1; i < x2; i++) { | 99 | for (int i = x1 + 1; i < x2; i++) { |
101 | m_image.setPixel(i, y, m_fillRgb); | 100 | m_image.setPixel(i, y, m_fillRgb); |
102 | } | 101 | } |
103 | 102 | ||
104 | for (int i = x1 + 1; i < x2; i++) { | 103 | for (int i = x1 + 1; i < x2; i++) { |
105 | fillLine(i, y - 1); | 104 | fillLine(i, y - 1); |
106 | } | 105 | } |
107 | 106 | ||
108 | for (int i = x1 + 1; i < x2; i++) { | 107 | for (int i = x1 + 1; i < x2; i++) { |
109 | fillLine(i, y + 1); | 108 | fillLine(i, y + 1); |
110 | } | 109 | } |
111 | } | 110 | } |
112 | } | 111 | } |
113 | } | 112 | } |
114 | 113 | ||
115 | void FillTool::fillMaskLine(int x, int y) | 114 | void FillTool::fillMaskLine(int x, int y) |
116 | { | 115 | { |
117 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { | 116 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { |
118 | if (m_mask.pixelIndex(x, y) == 0) { | 117 | if (m_mask.pixelIndex(x, y) == 0) { |
119 | if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) { | 118 | if (rgbDistance(m_image.pixel(x, y), m_oldRgb) < FILL_THRESHOLD) { |
120 | int x1, x2; | 119 | int x1, x2; |
121 | 120 | ||
122 | x1 = x - 1; | 121 | x1 = x - 1; |
123 | x2 = x + 1; | 122 | x2 = x + 1; |
124 | 123 | ||
125 | while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) { | 124 | while ((x1 >= 0) && (rgbDistance(m_image.pixel(x1, y), m_oldRgb) < FILL_THRESHOLD)) { |
126 | x1--; | 125 | x1--; |
127 | } | 126 | } |
128 | 127 | ||
129 | while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) { | 128 | while ((x2 < m_image.width()) && (rgbDistance(m_image.pixel(x2, y), m_oldRgb) < FILL_THRESHOLD)) { |
130 | x2++; | 129 | x2++; |
131 | } | 130 | } |
132 | 131 | ||
133 | for (int i = x1 + 1; i < x2; i++) { | 132 | for (int i = x1 + 1; i < x2; i++) { |
134 | m_mask.setPixel(i, y, 1); | 133 | m_mask.setPixel(i, y, 1); |
135 | } | 134 | } |
136 | 135 | ||
137 | for (int i = x1 + 1; i < x2; i++) { | 136 | for (int i = x1 + 1; i < x2; i++) { |
138 | fillMaskLine(i, y - 1); | 137 | fillMaskLine(i, y - 1); |
139 | } | 138 | } |
140 | 139 | ||
141 | for (int i = x1 + 1; i < x2; i++) { | 140 | for (int i = x1 + 1; i < x2; i++) { |
142 | fillMaskLine(i, y + 1); | 141 | fillMaskLine(i, y + 1); |
143 | } | 142 | } |
144 | } | 143 | } |
145 | } | 144 | } |
146 | } | 145 | } |
147 | } | 146 | } |
148 | 147 | ||
149 | void FillTool::setInterpolatedPixel(int x, int y) | 148 | void FillTool::setInterpolatedPixel(int x, int y) |
150 | { | 149 | { |
151 | int fillRed = QMIN(QMAX(qRed(m_fillRgb) + qRed(m_image.pixel(x, y)) - qRed(m_oldRgb), 0), 255); | 150 | int fillRed = QMIN(QMAX(qRed(m_fillRgb) + qRed(m_image.pixel(x, y)) - qRed(m_oldRgb), 0), 255); |
152 | int fillGreen = QMIN(QMAX(qGreen(m_fillRgb) + qGreen(m_image.pixel(x, y)) - qGreen(m_oldRgb), 0), 255); | 151 | int fillGreen = QMIN(QMAX(qGreen(m_fillRgb) + qGreen(m_image.pixel(x, y)) - qGreen(m_oldRgb), 0), 255); |
153 | int fillBlue = QMIN(QMAX(qBlue(m_fillRgb) + qBlue(m_image.pixel(x, y)) - qBlue(m_oldRgb), 0), 255); | 152 | int fillBlue = QMIN(QMAX(qBlue(m_fillRgb) + qBlue(m_image.pixel(x, y)) - qBlue(m_oldRgb), 0), 255); |
154 | 153 | ||
155 | m_image.setPixel(x, y, qRgb(fillRed, fillGreen, fillBlue)); | 154 | m_image.setPixel(x, y, qRgb(fillRed, fillGreen, fillBlue)); |
156 | } | 155 | } |
157 | 156 | ||
158 | int FillTool::rgbDistance(QRgb rgb1, QRgb rgb2) | 157 | int FillTool::rgbDistance(QRgb rgb1, QRgb rgb2) |
159 | { | 158 | { |
160 | int redDistance = qRed(rgb2) - qRed(rgb1); | 159 | int redDistance = qRed(rgb2) - qRed(rgb1); |
161 | int greenDistance = qGreen(rgb2) - qGreen(rgb1); | 160 | int greenDistance = qGreen(rgb2) - qGreen(rgb1); |
162 | int blueDistance = qBlue(rgb2) - qBlue(rgb1); | 161 | int blueDistance = qBlue(rgb2) - qBlue(rgb1); |
163 | 162 | ||
164 | return (redDistance * redDistance + greenDistance * greenDistance + blueDistance * blueDistance); | 163 | return (redDistance * redDistance + greenDistance * greenDistance + blueDistance * blueDistance); |
165 | } | 164 | } |
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp index 9a59a20..ce2e7ee 100644 --- a/noncore/graphics/drawpad/importdialog.cpp +++ b/noncore/graphics/drawpad/importdialog.cpp | |||
@@ -1,117 +1,116 @@ | |||
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 "importdialog.h" | 14 | #include "importdialog.h" |
15 | 15 | ||
16 | #include <qpe/applnk.h> | ||
17 | #include <opie/ofileselector.h> | 16 | #include <opie/ofileselector.h> |
18 | 17 | ||
19 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
20 | #include <qimage.h> | 19 | #include <qimage.h> |
21 | #include <qlabel.h> | 20 | #include <qlabel.h> |
22 | #include <qlayout.h> | 21 | #include <qlayout.h> |
23 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
24 | 23 | ||
25 | ImportDialog::ImportDialog(QWidget* parent, const char* name) | 24 | ImportDialog::ImportDialog(QWidget* parent, const char* name) |
26 | : QDialog(parent, name, true) | 25 | : QDialog(parent, name, true) |
27 | { | 26 | { |
28 | setCaption(tr("DrawPad - Import")); | 27 | setCaption(tr("DrawPad - Import")); |
29 | 28 | ||
30 | MimeTypes types; types.insert( tr("All images"),"image/*" ); | 29 | MimeTypes types; types.insert( tr("All images"),"image/*" ); |
31 | m_pFileSelector = new OFileSelector(this, | 30 | m_pFileSelector = new OFileSelector(this, |
32 | OFileSelector::FileSelector, | 31 | OFileSelector::FileSelector, |
33 | OFileSelector::Normal, | 32 | OFileSelector::Normal, |
34 | QString::null, | 33 | QString::null, |
35 | QString::null, types ); | 34 | QString::null, types ); |
36 | m_pFileSelector->setNameVisible( false ); | 35 | m_pFileSelector->setNameVisible( false ); |
37 | connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); | 36 | connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); |
38 | 37 | ||
39 | m_pPreviewLabel = new QLabel(this); | 38 | m_pPreviewLabel = new QLabel(this); |
40 | m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 39 | m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
41 | m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); | 40 | m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
42 | m_pPreviewLabel->setFixedSize(114, 114); | 41 | m_pPreviewLabel->setFixedSize(114, 114); |
43 | m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); | 42 | m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); |
44 | 43 | ||
45 | m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); | 44 | m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); |
46 | m_pAutomaticPreviewCheckBox->setChecked(true); | 45 | m_pAutomaticPreviewCheckBox->setChecked(true); |
47 | 46 | ||
48 | QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); | 47 | QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); |
49 | connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); | 48 | connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); |
50 | 49 | ||
51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 50 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
52 | QHBoxLayout* previewLayout = new QHBoxLayout(4); | 51 | QHBoxLayout* previewLayout = new QHBoxLayout(4); |
53 | QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); | 52 | QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); |
54 | 53 | ||
55 | previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); | 54 | previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); |
56 | previewSecondLayout->addWidget(previewPushButton); | 55 | previewSecondLayout->addWidget(previewPushButton); |
57 | previewSecondLayout->addStretch(); | 56 | previewSecondLayout->addStretch(); |
58 | 57 | ||
59 | previewLayout->addWidget(m_pPreviewLabel); | 58 | previewLayout->addWidget(m_pPreviewLabel); |
60 | previewLayout->addLayout(previewSecondLayout); | 59 | previewLayout->addLayout(previewSecondLayout); |
61 | 60 | ||
62 | mainLayout->addWidget(m_pFileSelector); | 61 | mainLayout->addWidget(m_pFileSelector); |
63 | mainLayout->addLayout(previewLayout); | 62 | mainLayout->addLayout(previewLayout); |
64 | 63 | ||
65 | preview(); | 64 | preview(); |
66 | } | 65 | } |
67 | 66 | ||
68 | ImportDialog::~ImportDialog() | 67 | ImportDialog::~ImportDialog() |
69 | { | 68 | { |
70 | } | 69 | } |
71 | 70 | ||
72 | const DocLnk* ImportDialog::selected() | 71 | const DocLnk* ImportDialog::selected() |
73 | { | 72 | { |
74 | // FIXME change from pointer to reference -zecke | 73 | // FIXME change from pointer to reference -zecke |
75 | DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() ); | 74 | DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() ); |
76 | return lnk; | 75 | return lnk; |
77 | } | 76 | } |
78 | 77 | ||
79 | void ImportDialog::fileChanged() | 78 | void ImportDialog::fileChanged() |
80 | { | 79 | { |
81 | if (m_pAutomaticPreviewCheckBox->isChecked()) { | 80 | if (m_pAutomaticPreviewCheckBox->isChecked()) { |
82 | preview(); | 81 | preview(); |
83 | } | 82 | } |
84 | } | 83 | } |
85 | 84 | ||
86 | void ImportDialog::preview() | 85 | void ImportDialog::preview() |
87 | { | 86 | { |
88 | const DocLnk* docLnk = selected(); | 87 | const DocLnk* docLnk = selected(); |
89 | 88 | ||
90 | if (docLnk) { | 89 | if (docLnk) { |
91 | QImage image(docLnk->file()); | 90 | QImage image(docLnk->file()); |
92 | 91 | ||
93 | int previewWidth = m_pPreviewLabel->contentsRect().width(); | 92 | int previewWidth = m_pPreviewLabel->contentsRect().width(); |
94 | int previewHeight = m_pPreviewLabel->contentsRect().height(); | 93 | int previewHeight = m_pPreviewLabel->contentsRect().height(); |
95 | 94 | ||
96 | float widthScale = 1.0; | 95 | float widthScale = 1.0; |
97 | float heightScale = 1.0; | 96 | float heightScale = 1.0; |
98 | 97 | ||
99 | if (previewWidth < image.width()) { | 98 | if (previewWidth < image.width()) { |
100 | widthScale = (float)previewWidth / float(image.width()); | 99 | widthScale = (float)previewWidth / float(image.width()); |
101 | } | 100 | } |
102 | 101 | ||
103 | if (previewHeight < image.height()) { | 102 | if (previewHeight < image.height()) { |
104 | heightScale = (float)previewHeight / float(image.height()); | 103 | heightScale = (float)previewHeight / float(image.height()); |
105 | } | 104 | } |
106 | 105 | ||
107 | float scale = (widthScale < heightScale ? widthScale : heightScale); | 106 | float scale = (widthScale < heightScale ? widthScale : heightScale); |
108 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | 107 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); |
109 | 108 | ||
110 | QPixmap previewPixmap; | 109 | QPixmap previewPixmap; |
111 | previewPixmap.convertFromImage(previewImage); | 110 | previewPixmap.convertFromImage(previewImage); |
112 | 111 | ||
113 | m_pPreviewLabel->setPixmap(previewPixmap); | 112 | m_pPreviewLabel->setPixmap(previewPixmap); |
114 | 113 | ||
115 | delete docLnk; | 114 | delete docLnk; |
116 | } | 115 | } |
117 | } | 116 | } |
diff --git a/noncore/graphics/drawpad/linetool.cpp b/noncore/graphics/drawpad/linetool.cpp index b6baa2a..5ea068c 100644 --- a/noncore/graphics/drawpad/linetool.cpp +++ b/noncore/graphics/drawpad/linetool.cpp | |||
@@ -1,82 +1,81 @@ | |||
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 "linetool.h" | 14 | #include "linetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | 18 | ||
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qpixmap.h> | ||
21 | 20 | ||
22 | LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 21 | LineTool::LineTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : ShapeTool(drawPad, drawPadCanvas) | 22 | : ShapeTool(drawPad, drawPadCanvas) |
24 | { | 23 | { |
25 | } | 24 | } |
26 | 25 | ||
27 | LineTool::~LineTool() | 26 | LineTool::~LineTool() |
28 | { | 27 | { |
29 | } | 28 | } |
30 | 29 | ||
31 | void LineTool::drawFinalShape(QPainter& p) | 30 | void LineTool::drawFinalShape(QPainter& p) |
32 | { | 31 | { |
33 | p.setRasterOp(Qt::NotROP); | 32 | p.setRasterOp(Qt::NotROP); |
34 | p.drawLine(m_polyline[2], m_polyline[0]); | 33 | p.drawLine(m_polyline[2], m_polyline[0]); |
35 | p.setRasterOp(Qt::CopyROP); | 34 | p.setRasterOp(Qt::CopyROP); |
36 | 35 | ||
37 | if (m_pDrawPad->antiAliasing()) { | 36 | if (m_pDrawPad->antiAliasing()) { |
38 | QRect r = m_polyline.boundingRect(); | 37 | QRect r = m_polyline.boundingRect(); |
39 | r = r.normalize(); | 38 | r = r.normalize(); |
40 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 39 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
41 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 40 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
42 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 41 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
43 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 42 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
44 | 43 | ||
45 | QPixmap areaPixmap(r.width(), r.height()); | 44 | QPixmap areaPixmap(r.width(), r.height()); |
46 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); | 45 | bitBlt(&areaPixmap, QPoint(0, 0), p.device(), r); |
47 | 46 | ||
48 | QImage areaImage = areaPixmap.convertToImage(); | 47 | QImage areaImage = areaPixmap.convertToImage(); |
49 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 48 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
50 | 49 | ||
51 | QPixmap bigAreaPixmap; | 50 | QPixmap bigAreaPixmap; |
52 | bigAreaPixmap.convertFromImage(bigAreaImage); | 51 | bigAreaPixmap.convertFromImage(bigAreaImage); |
53 | 52 | ||
54 | QPen bigAreaPen = m_pDrawPad->pen(); | 53 | QPen bigAreaPen = m_pDrawPad->pen(); |
55 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 54 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
56 | 55 | ||
57 | QPainter bigAreaPainter; | 56 | QPainter bigAreaPainter; |
58 | bigAreaPainter.begin(&bigAreaPixmap); | 57 | bigAreaPainter.begin(&bigAreaPixmap); |
59 | bigAreaPainter.setPen(bigAreaPen); | 58 | bigAreaPainter.setPen(bigAreaPen); |
60 | 59 | ||
61 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, | 60 | bigAreaPainter.drawLine((m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1, |
62 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 61 | (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
63 | 62 | ||
64 | bigAreaPainter.end(); | 63 | bigAreaPainter.end(); |
65 | 64 | ||
66 | bigAreaImage = bigAreaPixmap.convertToImage(); | 65 | bigAreaImage = bigAreaPixmap.convertToImage(); |
67 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 66 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
68 | areaPixmap.convertFromImage(areaImage); | 67 | areaPixmap.convertFromImage(areaImage); |
69 | 68 | ||
70 | p.drawPixmap(r.x(), r.y(), areaPixmap); | 69 | p.drawPixmap(r.x(), r.y(), areaPixmap); |
71 | } else { | 70 | } else { |
72 | p.setPen(m_pDrawPad->pen()); | 71 | p.setPen(m_pDrawPad->pen()); |
73 | p.drawLine(m_polyline[2], m_polyline[0]); | 72 | p.drawLine(m_polyline[2], m_polyline[0]); |
74 | } | 73 | } |
75 | } | 74 | } |
76 | 75 | ||
77 | void LineTool::drawTemporaryShape(QPainter& p) | 76 | void LineTool::drawTemporaryShape(QPainter& p) |
78 | { | 77 | { |
79 | p.setRasterOp(Qt::NotROP); | 78 | p.setRasterOp(Qt::NotROP); |
80 | p.drawLine(m_polyline[2], m_polyline[1]); | 79 | p.drawLine(m_polyline[2], m_polyline[1]); |
81 | p.drawLine(m_polyline[2], m_polyline[0]); | 80 | p.drawLine(m_polyline[2], m_polyline[0]); |
82 | } | 81 | } |
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp index 87bc621..c87cc0f 100644 --- a/noncore/graphics/drawpad/main.cpp +++ b/noncore/graphics/drawpad/main.cpp | |||
@@ -1,19 +1,18 @@ | |||
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 <qpe/qpeapplication.h> | ||
17 | #include <opie/oapplicationfactory.h> | 16 | #include <opie/oapplicationfactory.h> |
18 | 17 | ||
19 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) | 18 | OPIE_EXPORT_APP( OApplicationFactory<DrawPad> ) |
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp index e6e7fcb..dc8999a 100644 --- a/noncore/graphics/drawpad/newpagedialog.cpp +++ b/noncore/graphics/drawpad/newpagedialog.cpp | |||
@@ -1,119 +1,118 @@ | |||
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 "newpagedialog.h" | 14 | #include "newpagedialog.h" |
15 | 15 | ||
16 | #include <qbuttongroup.h> | 16 | #include <qbuttongroup.h> |
17 | #include <qgroupbox.h> | ||
18 | #include <qlabel.h> | 17 | #include <qlabel.h> |
19 | #include <qlayout.h> | 18 | #include <qlayout.h> |
20 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
21 | #include <qradiobutton.h> | 20 | #include <qradiobutton.h> |
22 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
23 | 22 | ||
24 | NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor, | 23 | NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor, |
25 | const QColor& brushColor, QWidget* parent, const char* name) | 24 | const QColor& brushColor, QWidget* parent, const char* name) |
26 | : QDialog(parent, name, true) | 25 | : QDialog(parent, name, true) |
27 | { | 26 | { |
28 | setCaption(tr("New Page")); | 27 | setCaption(tr("New Page")); |
29 | 28 | ||
30 | m_penColor = penColor; | 29 | m_penColor = penColor; |
31 | m_brushColor = brushColor; | 30 | m_brushColor = brushColor; |
32 | 31 | ||
33 | QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); | 32 | QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); |
34 | 33 | ||
35 | QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); | 34 | QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); |
36 | m_pTitleLineEdit = new QLineEdit(generalGroupBox); | 35 | m_pTitleLineEdit = new QLineEdit(generalGroupBox); |
37 | 36 | ||
38 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); | 37 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); |
39 | 38 | ||
40 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); | 39 | QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); |
41 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); | 40 | QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); |
42 | 41 | ||
43 | m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); | 42 | m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); |
44 | m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); | 43 | m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); |
45 | 44 | ||
46 | m_pWidthSpinBox->setValue(width); | 45 | m_pWidthSpinBox->setValue(width); |
47 | m_pHeightSpinBox->setValue(height); | 46 | m_pHeightSpinBox->setValue(height); |
48 | 47 | ||
49 | m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this); | 48 | m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this); |
50 | 49 | ||
51 | QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup); | 50 | QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup); |
52 | QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup); | 51 | QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup); |
53 | QRadioButton* brushColorRadioButton = new QRadioButton(tr("Fill Color"), m_pContentButtonGroup); | 52 | QRadioButton* brushColorRadioButton = new QRadioButton(tr("Fill Color"), m_pContentButtonGroup); |
54 | 53 | ||
55 | m_pContentButtonGroup->setButton(0); | 54 | m_pContentButtonGroup->setButton(0); |
56 | 55 | ||
57 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 56 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
58 | generalGroupBox->layout()->setSpacing(4); | 57 | generalGroupBox->layout()->setSpacing(4); |
59 | sizeGroupBox->layout()->setSpacing(4); | 58 | sizeGroupBox->layout()->setSpacing(4); |
60 | m_pContentButtonGroup->layout()->setSpacing(4); | 59 | m_pContentButtonGroup->layout()->setSpacing(4); |
61 | QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1); | 60 | QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1); |
62 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); | 61 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); |
63 | QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout()); | 62 | QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout()); |
64 | 63 | ||
65 | generalLayout->addWidget(titleLabel, 0, 0); | 64 | generalLayout->addWidget(titleLabel, 0, 0); |
66 | generalLayout->addWidget(m_pTitleLineEdit, 0, 1); | 65 | generalLayout->addWidget(m_pTitleLineEdit, 0, 1); |
67 | 66 | ||
68 | sizeLayout->addWidget(widthLabel, 0, 0); | 67 | sizeLayout->addWidget(widthLabel, 0, 0); |
69 | sizeLayout->addWidget(heightLabel, 1, 0); | 68 | sizeLayout->addWidget(heightLabel, 1, 0); |
70 | sizeLayout->addWidget(m_pWidthSpinBox, 0, 1); | 69 | sizeLayout->addWidget(m_pWidthSpinBox, 0, 1); |
71 | sizeLayout->addWidget(m_pHeightSpinBox, 1, 1); | 70 | sizeLayout->addWidget(m_pHeightSpinBox, 1, 1); |
72 | 71 | ||
73 | sizeLayout->setColStretch(1, 1); | 72 | sizeLayout->setColStretch(1, 1); |
74 | 73 | ||
75 | contentLayout->addWidget(whiteColorRadioButton); | 74 | contentLayout->addWidget(whiteColorRadioButton); |
76 | contentLayout->addWidget(penColorRadioButton); | 75 | contentLayout->addWidget(penColorRadioButton); |
77 | contentLayout->addWidget(brushColorRadioButton); | 76 | contentLayout->addWidget(brushColorRadioButton); |
78 | 77 | ||
79 | mainLayout->addWidget(generalGroupBox); | 78 | mainLayout->addWidget(generalGroupBox); |
80 | mainLayout->addWidget(sizeGroupBox); | 79 | mainLayout->addWidget(sizeGroupBox); |
81 | mainLayout->addWidget(m_pContentButtonGroup); | 80 | mainLayout->addWidget(m_pContentButtonGroup); |
82 | } | 81 | } |
83 | 82 | ||
84 | NewPageDialog::~NewPageDialog() | 83 | NewPageDialog::~NewPageDialog() |
85 | { | 84 | { |
86 | } | 85 | } |
87 | 86 | ||
88 | QString NewPageDialog::selectedTitle() | 87 | QString NewPageDialog::selectedTitle() |
89 | { | 88 | { |
90 | return (m_pTitleLineEdit->text()); | 89 | return (m_pTitleLineEdit->text()); |
91 | } | 90 | } |
92 | 91 | ||
93 | uint NewPageDialog::selectedWidth() | 92 | uint NewPageDialog::selectedWidth() |
94 | { | 93 | { |
95 | return (m_pWidthSpinBox->value()); | 94 | return (m_pWidthSpinBox->value()); |
96 | } | 95 | } |
97 | 96 | ||
98 | uint NewPageDialog::selectedHeight() | 97 | uint NewPageDialog::selectedHeight() |
99 | { | 98 | { |
100 | return (m_pHeightSpinBox->value()); | 99 | return (m_pHeightSpinBox->value()); |
101 | } | 100 | } |
102 | 101 | ||
103 | const QColor& NewPageDialog::selectedColor() | 102 | const QColor& NewPageDialog::selectedColor() |
104 | { | 103 | { |
105 | switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) { | 104 | switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) { |
106 | case 0: | 105 | case 0: |
107 | return (Qt::white); | 106 | return (Qt::white); |
108 | break; | 107 | break; |
109 | case 1: | 108 | case 1: |
110 | return (m_penColor); | 109 | return (m_penColor); |
111 | break; | 110 | break; |
112 | case 2: | 111 | case 2: |
113 | return (m_brushColor); | 112 | return (m_brushColor); |
114 | break; | 113 | break; |
115 | default: | 114 | default: |
116 | return (Qt::white); | 115 | return (Qt::white); |
117 | break; | 116 | break; |
118 | } | 117 | } |
119 | } | 118 | } |
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp index b9b52bc..4fb7ad1 100644 --- a/noncore/graphics/drawpad/pointtool.cpp +++ b/noncore/graphics/drawpad/pointtool.cpp | |||
@@ -1,111 +1,110 @@ | |||
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 "pointtool.h" | 14 | #include "pointtool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qimage.h> | 20 | #include <qimage.h> |
21 | #include <qpainter.h> | ||
22 | 21 | ||
23 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
24 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
25 | { | 24 | { |
26 | m_mousePressed = false; | 25 | m_mousePressed = false; |
27 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
28 | } | 27 | } |
29 | 28 | ||
30 | PointTool::~PointTool() | 29 | PointTool::~PointTool() |
31 | { | 30 | { |
32 | } | 31 | } |
33 | 32 | ||
34 | void PointTool::mousePressEvent(QMouseEvent* e) | 33 | void PointTool::mousePressEvent(QMouseEvent* e) |
35 | { | 34 | { |
36 | m_pDrawPadCanvas->backupPage(); | 35 | m_pDrawPadCanvas->backupPage(); |
37 | 36 | ||
38 | m_mousePressed = true; | 37 | m_mousePressed = true; |
39 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
40 | } | 39 | } |
41 | 40 | ||
42 | void PointTool::mouseReleaseEvent(QMouseEvent* e) | 41 | void PointTool::mouseReleaseEvent(QMouseEvent* e) |
43 | { | 42 | { |
44 | Q_UNUSED(e) | 43 | Q_UNUSED(e) |
45 | 44 | ||
46 | m_mousePressed = false; | 45 | m_mousePressed = false; |
47 | } | 46 | } |
48 | 47 | ||
49 | void PointTool::mouseMoveEvent(QMouseEvent* e) | 48 | void PointTool::mouseMoveEvent(QMouseEvent* e) |
50 | { | 49 | { |
51 | if (m_mousePressed) { | 50 | if (m_mousePressed) { |
52 | m_polyline[2] = m_polyline[1]; | 51 | m_polyline[2] = m_polyline[1]; |
53 | m_polyline[1] = m_polyline[0]; | 52 | m_polyline[1] = m_polyline[0]; |
54 | m_polyline[0] = e->pos(); | 53 | m_polyline[0] = e->pos(); |
55 | 54 | ||
56 | QRect r = m_polyline.boundingRect(); | 55 | QRect r = m_polyline.boundingRect(); |
57 | r = r.normalize(); | 56 | r = r.normalize(); |
58 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 57 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
59 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 58 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
60 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 59 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
61 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 60 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
62 | 61 | ||
63 | QPainter painter; | 62 | QPainter painter; |
64 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); | 63 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
65 | 64 | ||
66 | if (m_pDrawPad->antiAliasing()) { | 65 | if (m_pDrawPad->antiAliasing()) { |
67 | QPixmap areaPixmap(r.width(), r.height()); | 66 | QPixmap areaPixmap(r.width(), r.height()); |
68 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); | 67 | bitBlt(&areaPixmap, QPoint(0, 0), painter.device(), r); |
69 | 68 | ||
70 | QImage areaImage = areaPixmap.convertToImage(); | 69 | QImage areaImage = areaPixmap.convertToImage(); |
71 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); | 70 | QImage bigAreaImage = areaImage.smoothScale(areaImage.width() * 3, areaImage.height() * 3); |
72 | 71 | ||
73 | QPixmap bigAreaPixmap; | 72 | QPixmap bigAreaPixmap; |
74 | bigAreaPixmap.convertFromImage(bigAreaImage); | 73 | bigAreaPixmap.convertFromImage(bigAreaImage); |
75 | 74 | ||
76 | QPen bigAreaPen = m_pDrawPad->pen(); | 75 | QPen bigAreaPen = m_pDrawPad->pen(); |
77 | bigAreaPen.setWidth(bigAreaPen.width() * 3); | 76 | bigAreaPen.setWidth(bigAreaPen.width() * 3); |
78 | 77 | ||
79 | QPainter bigAreaPainter; | 78 | QPainter bigAreaPainter; |
80 | bigAreaPainter.begin(&bigAreaPixmap); | 79 | bigAreaPainter.begin(&bigAreaPixmap); |
81 | bigAreaPainter.setPen(bigAreaPen); | 80 | bigAreaPainter.setPen(bigAreaPen); |
82 | 81 | ||
83 | QPointArray bigAreaPolyline(3); | 82 | QPointArray bigAreaPolyline(3); |
84 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); | 83 | bigAreaPolyline.setPoint(0, (m_polyline[0].x() - r.x()) * 3 + 1, (m_polyline[0].y() - r.y()) * 3 + 1); |
85 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); | 84 | bigAreaPolyline.setPoint(1, (m_polyline[1].x() - r.x()) * 3 + 1, (m_polyline[1].y() - r.y()) * 3 + 1); |
86 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); | 85 | bigAreaPolyline.setPoint(2, (m_polyline[2].x() - r.x()) * 3 + 1, (m_polyline[2].y() - r.y()) * 3 + 1); |
87 | 86 | ||
88 | bigAreaPainter.drawPolyline(bigAreaPolyline); | 87 | bigAreaPainter.drawPolyline(bigAreaPolyline); |
89 | bigAreaPainter.end(); | 88 | bigAreaPainter.end(); |
90 | 89 | ||
91 | bigAreaImage = bigAreaPixmap.convertToImage(); | 90 | bigAreaImage = bigAreaPixmap.convertToImage(); |
92 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); | 91 | areaImage = bigAreaImage.smoothScale(bigAreaImage.width() / 3, bigAreaImage.height() / 3); |
93 | areaPixmap.convertFromImage(areaImage); | 92 | areaPixmap.convertFromImage(areaImage); |
94 | 93 | ||
95 | painter.drawPixmap(r.x(), r.y(), areaPixmap); | 94 | painter.drawPixmap(r.x(), r.y(), areaPixmap); |
96 | } else { | 95 | } else { |
97 | painter.setPen(m_pDrawPad->pen()); | 96 | painter.setPen(m_pDrawPad->pen()); |
98 | painter.drawPolyline(m_polyline); | 97 | painter.drawPolyline(m_polyline); |
99 | } | 98 | } |
100 | 99 | ||
101 | painter.end(); | 100 | painter.end(); |
102 | 101 | ||
103 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 102 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
104 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 103 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
105 | 104 | ||
106 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 105 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
107 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); | 106 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
108 | 107 | ||
109 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 108 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
110 | } | 109 | } |
111 | } | 110 | } |
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index 22e3dd6..6e4276d 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -1,94 +1,93 @@ | |||
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 "shapetool.h" | 14 | #include "shapetool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qpainter.h> | ||
21 | 20 | ||
22 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 21 | ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 22 | : Tool(drawPad, drawPadCanvas) |
24 | { | 23 | { |
25 | m_mousePressed = false; | 24 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 25 | m_polyline.resize(3); |
27 | } | 26 | } |
28 | 27 | ||
29 | ShapeTool::~ShapeTool() | 28 | ShapeTool::~ShapeTool() |
30 | { | 29 | { |
31 | } | 30 | } |
32 | 31 | ||
33 | void ShapeTool::mousePressEvent(QMouseEvent* e) | 32 | void ShapeTool::mousePressEvent(QMouseEvent* e) |
34 | { | 33 | { |
35 | m_pDrawPadCanvas->backupPage(); | 34 | m_pDrawPadCanvas->backupPage(); |
36 | 35 | ||
37 | m_mousePressed = true; | 36 | m_mousePressed = true; |
38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 37 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
39 | } | 38 | } |
40 | 39 | ||
41 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | 40 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) |
42 | { | 41 | { |
43 | Q_UNUSED(e) | 42 | Q_UNUSED(e) |
44 | 43 | ||
45 | QPainter painter; | 44 | QPainter painter; |
46 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); | 45 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
47 | drawFinalShape(painter); | 46 | drawFinalShape(painter); |
48 | painter.end(); | 47 | painter.end(); |
49 | 48 | ||
50 | QRect r = m_polyline.boundingRect(); | 49 | QRect r = m_polyline.boundingRect(); |
51 | r = r.normalize(); | 50 | r = r.normalize(); |
52 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 51 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
53 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 52 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
54 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 53 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
55 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 54 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
56 | 55 | ||
57 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 56 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
58 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 57 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
59 | 58 | ||
60 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 59 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
61 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); | 60 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
62 | 61 | ||
63 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 62 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
64 | 63 | ||
65 | m_mousePressed = false; | 64 | m_mousePressed = false; |
66 | } | 65 | } |
67 | 66 | ||
68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) | 67 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) |
69 | { | 68 | { |
70 | if (m_mousePressed) { | 69 | if (m_mousePressed) { |
71 | m_polyline[0] = e->pos(); | 70 | m_polyline[0] = e->pos(); |
72 | QPainter painter; | 71 | QPainter painter; |
73 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); | 72 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
74 | drawTemporaryShape(painter); | 73 | drawTemporaryShape(painter); |
75 | painter.end(); | 74 | painter.end(); |
76 | 75 | ||
77 | QRect r = m_polyline.boundingRect(); | 76 | QRect r = m_polyline.boundingRect(); |
78 | r = r.normalize(); | 77 | r = r.normalize(); |
79 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 78 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
80 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 79 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
81 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 80 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
82 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 81 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
83 | 82 | ||
84 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 83 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 84 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
86 | 85 | ||
87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 86 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
88 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); | 87 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
89 | 88 | ||
90 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 89 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
91 | 90 | ||
92 | m_polyline[1] = m_polyline[0]; | 91 | m_polyline[1] = m_polyline[0]; |
93 | } | 92 | } |
94 | } | 93 | } |
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp index 9037abd..3a89e80 100644 --- a/noncore/graphics/drawpad/texttool.cpp +++ b/noncore/graphics/drawpad/texttool.cpp | |||
@@ -1,79 +1,78 @@ | |||
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 "texttool.h" | 14 | #include "texttool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "page.h" | 18 | #include "page.h" |
19 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qpainter.h> | ||
23 | 22 | ||
24 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) | 23 | TextToolDialog::TextToolDialog(QWidget* parent, const char* name) |
25 | : QDialog(parent, name, true) | 24 | : QDialog(parent, name, true) |
26 | { | 25 | { |
27 | setCaption(tr("Insert Text")); | 26 | setCaption(tr("Insert Text")); |
28 | 27 | ||
29 | m_pLineEdit = new QLineEdit(this); | 28 | m_pLineEdit = new QLineEdit(this); |
30 | 29 | ||
31 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 30 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
32 | 31 | ||
33 | mainLayout->addWidget(m_pLineEdit); | 32 | mainLayout->addWidget(m_pLineEdit); |
34 | } | 33 | } |
35 | 34 | ||
36 | TextToolDialog::~TextToolDialog() | 35 | TextToolDialog::~TextToolDialog() |
37 | { | 36 | { |
38 | } | 37 | } |
39 | 38 | ||
40 | QString TextToolDialog::text() | 39 | QString TextToolDialog::text() |
41 | { | 40 | { |
42 | return m_pLineEdit->text(); | 41 | return m_pLineEdit->text(); |
43 | } | 42 | } |
44 | 43 | ||
45 | TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 44 | TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
46 | : Tool(drawPad, drawPadCanvas) | 45 | : Tool(drawPad, drawPadCanvas) |
47 | { | 46 | { |
48 | } | 47 | } |
49 | 48 | ||
50 | TextTool::~TextTool() | 49 | TextTool::~TextTool() |
51 | { | 50 | { |
52 | } | 51 | } |
53 | 52 | ||
54 | void TextTool::mousePressEvent(QMouseEvent* e) | 53 | void TextTool::mousePressEvent(QMouseEvent* e) |
55 | { | 54 | { |
56 | TextToolDialog textToolDialog(m_pDrawPad); | 55 | TextToolDialog textToolDialog(m_pDrawPad); |
57 | 56 | ||
58 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { | 57 | if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) { |
59 | m_pDrawPadCanvas->backupPage(); | 58 | m_pDrawPadCanvas->backupPage(); |
60 | 59 | ||
61 | QPainter painter; | 60 | QPainter painter; |
62 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); | 61 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
63 | painter.setPen(m_pDrawPad->pen()); | 62 | painter.setPen(m_pDrawPad->pen()); |
64 | painter.drawText(e->x(), e->y(), textToolDialog.text()); | 63 | painter.drawText(e->x(), e->y(), textToolDialog.text()); |
65 | painter.end(); | 64 | painter.end(); |
66 | 65 | ||
67 | m_pDrawPadCanvas->viewport()->update(); | 66 | m_pDrawPadCanvas->viewport()->update(); |
68 | } | 67 | } |
69 | } | 68 | } |
70 | 69 | ||
71 | void TextTool::mouseReleaseEvent(QMouseEvent* e) | 70 | void TextTool::mouseReleaseEvent(QMouseEvent* e) |
72 | { | 71 | { |
73 | Q_UNUSED(e) | 72 | Q_UNUSED(e) |
74 | } | 73 | } |
75 | 74 | ||
76 | void TextTool::mouseMoveEvent(QMouseEvent* e) | 75 | void TextTool::mouseMoveEvent(QMouseEvent* e) |
77 | { | 76 | { |
78 | Q_UNUSED(e) | 77 | Q_UNUSED(e) |
79 | } | 78 | } |
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 90ba39c..1ccf484 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -1,389 +1,388 @@ | |||
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 "thumbnailview.h" | 14 | #include "thumbnailview.h" |
15 | 15 | ||
16 | #include "drawpad.h" | 16 | #include "drawpad.h" |
17 | #include "drawpadcanvas.h" | 17 | #include "drawpadcanvas.h" |
18 | #include "newpagedialog.h" | 18 | #include "newpagedialog.h" |
19 | #include "page.h" | 19 | #include "page.h" |
20 | 20 | ||
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/timestring.h> | 23 | #include <qpe/timestring.h> |
24 | 24 | ||
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include <qimage.h> | ||
27 | #include <qlayout.h> | 26 | #include <qlayout.h> |
28 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
29 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
30 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
31 | 30 | ||
32 | #define THUMBNAIL_SIZE 48 | 31 | #define THUMBNAIL_SIZE 48 |
33 | 32 | ||
34 | PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | 33 | PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) |
35 | : QListBoxItem(parent) | 34 | : QListBoxItem(parent) |
36 | { | 35 | { |
37 | m_pPage = page; | 36 | m_pPage = page; |
38 | 37 | ||
39 | QImage image = m_pPage->pixmap()->convertToImage(); | 38 | QImage image = m_pPage->pixmap()->convertToImage(); |
40 | 39 | ||
41 | int previewWidth = THUMBNAIL_SIZE; | 40 | int previewWidth = THUMBNAIL_SIZE; |
42 | int previewHeight = THUMBNAIL_SIZE; | 41 | int previewHeight = THUMBNAIL_SIZE; |
43 | 42 | ||
44 | float widthScale = 1.0; | 43 | float widthScale = 1.0; |
45 | float heightScale = 1.0; | 44 | float heightScale = 1.0; |
46 | 45 | ||
47 | if (previewWidth < image.width()) { | 46 | if (previewWidth < image.width()) { |
48 | widthScale = (float)previewWidth / float(image.width()); | 47 | widthScale = (float)previewWidth / float(image.width()); |
49 | } | 48 | } |
50 | 49 | ||
51 | if (previewHeight < image.height()) { | 50 | if (previewHeight < image.height()) { |
52 | heightScale = (float)previewHeight / float(image.height()); | 51 | heightScale = (float)previewHeight / float(image.height()); |
53 | } | 52 | } |
54 | 53 | ||
55 | float scale = (widthScale < heightScale ? widthScale : heightScale); | 54 | float scale = (widthScale < heightScale ? widthScale : heightScale); |
56 | QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | 55 | QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); |
57 | 56 | ||
58 | m_thumbnail.convertFromImage(thumbnailImage); | 57 | m_thumbnail.convertFromImage(thumbnailImage); |
59 | 58 | ||
60 | m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); | 59 | m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); |
61 | m_dimensionText = QObject::tr( "Dimension: %1x%2" ). | 60 | m_dimensionText = QObject::tr( "Dimension: %1x%2" ). |
62 | arg( m_pPage->pixmap()->width() ). | 61 | arg( m_pPage->pixmap()->width() ). |
63 | arg( m_pPage->pixmap()->height() ); | 62 | arg( m_pPage->pixmap()->height() ); |
64 | m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); | 63 | m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); |
65 | 64 | ||
66 | QColor baseColor = parent->colorGroup().base(); | 65 | QColor baseColor = parent->colorGroup().base(); |
67 | int h, s, v; | 66 | int h, s, v; |
68 | baseColor.hsv(&h, &s, &v); | 67 | baseColor.hsv(&h, &s, &v); |
69 | 68 | ||
70 | if (v > 128) { | 69 | if (v > 128) { |
71 | m_alternateColor = baseColor.dark(115); | 70 | m_alternateColor = baseColor.dark(115); |
72 | } else if (baseColor != Qt::black) { | 71 | } else if (baseColor != Qt::black) { |
73 | m_alternateColor = baseColor.light(115); | 72 | m_alternateColor = baseColor.light(115); |
74 | } else { | 73 | } else { |
75 | m_alternateColor = QColor(32, 32, 32); | 74 | m_alternateColor = QColor(32, 32, 32); |
76 | } | 75 | } |
77 | } | 76 | } |
78 | 77 | ||
79 | PageListBoxItem::~PageListBoxItem() | 78 | PageListBoxItem::~PageListBoxItem() |
80 | { | 79 | { |
81 | } | 80 | } |
82 | 81 | ||
83 | int PageListBoxItem::height(const QListBox*) const | 82 | int PageListBoxItem::height(const QListBox*) const |
84 | { | 83 | { |
85 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); | 84 | return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); |
86 | } | 85 | } |
87 | 86 | ||
88 | int PageListBoxItem::width(const QListBox* lb) const | 87 | int PageListBoxItem::width(const QListBox* lb) const |
89 | { | 88 | { |
90 | QFontMetrics fontMetrics = lb->fontMetrics(); | 89 | QFontMetrics fontMetrics = lb->fontMetrics(); |
91 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), | 90 | int maxtextLength = QMAX(fontMetrics.width(m_titleText), |
92 | QMAX(fontMetrics.width(m_dimensionText), | 91 | QMAX(fontMetrics.width(m_dimensionText), |
93 | fontMetrics.width(m_dateText))); | 92 | fontMetrics.width(m_dateText))); |
94 | 93 | ||
95 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); | 94 | return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); |
96 | } | 95 | } |
97 | 96 | ||
98 | void PageListBoxItem::paint(QPainter *painter) | 97 | void PageListBoxItem::paint(QPainter *painter) |
99 | { | 98 | { |
100 | QRect itemRect = listBox()->itemRect(this); | 99 | QRect itemRect = listBox()->itemRect(this); |
101 | 100 | ||
102 | if (!selected() && (listBox()->index(this) % 2)) { | 101 | if (!selected() && (listBox()->index(this) % 2)) { |
103 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); | 102 | painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); |
104 | } | 103 | } |
105 | 104 | ||
106 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, | 105 | painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, |
107 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, | 106 | 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, |
108 | m_thumbnail); | 107 | m_thumbnail); |
109 | 108 | ||
110 | QFont standardFont = painter->font(); | 109 | QFont standardFont = painter->font(); |
111 | QFont boldFont = painter->font(); | 110 | QFont boldFont = painter->font(); |
112 | boldFont.setBold(TRUE); | 111 | boldFont.setBold(TRUE); |
113 | 112 | ||
114 | QFontMetrics fontMetrics = painter->fontMetrics(); | 113 | QFontMetrics fontMetrics = painter->fontMetrics(); |
115 | QRect textRect(THUMBNAIL_SIZE + 6, 2, | 114 | QRect textRect(THUMBNAIL_SIZE + 6, 2, |
116 | itemRect.width() - THUMBNAIL_SIZE - 8, | 115 | itemRect.width() - THUMBNAIL_SIZE - 8, |
117 | itemRect.height() - 4); | 116 | itemRect.height() - 4); |
118 | 117 | ||
119 | painter->setFont(boldFont); | 118 | painter->setFont(boldFont); |
120 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); | 119 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); |
121 | 120 | ||
122 | painter->setFont(standardFont); | 121 | painter->setFont(standardFont); |
123 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); | 122 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); |
124 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); | 123 | painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); |
125 | 124 | ||
126 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { | 125 | if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { |
127 | painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); | 126 | painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | 129 | ||
131 | Page* PageListBoxItem::page() const | 130 | Page* PageListBoxItem::page() const |
132 | { | 131 | { |
133 | return m_pPage; | 132 | return m_pPage; |
134 | } | 133 | } |
135 | 134 | ||
136 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) | 135 | QString PageListBoxItem::dateTimeString(QDateTime dateTime) |
137 | { | 136 | { |
138 | QString result; | 137 | QString result; |
139 | 138 | ||
140 | Config config("qpe"); | 139 | Config config("qpe"); |
141 | config.setGroup("Date"); | 140 | config.setGroup("Date"); |
142 | 141 | ||
143 | QChar separator = config.readEntry("Separator", "/")[0]; | 142 | QChar separator = config.readEntry("Separator", "/")[0]; |
144 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); | 143 | DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); |
145 | 144 | ||
146 | for (int i = 0; i < 3; i++) { | 145 | for (int i = 0; i < 3; i++) { |
147 | switch((shortOrder >> (i * 3)) & 0x0007) { | 146 | switch((shortOrder >> (i * 3)) & 0x0007) { |
148 | case 0x0001: | 147 | case 0x0001: |
149 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); | 148 | result.append( QString().sprintf("%02d", dateTime.date().day()) ); |
150 | break; | 149 | break; |
151 | case 0x0002: | 150 | case 0x0002: |
152 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); | 151 | result.append( QString().sprintf("%02d", dateTime.date().month()) ); |
153 | break; | 152 | break; |
154 | case 0x0004: | 153 | case 0x0004: |
155 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); | 154 | result.append( QString().sprintf("%04d", dateTime.date().year()) ); |
156 | break; | 155 | break; |
157 | default: | 156 | default: |
158 | break; | 157 | break; |
159 | } | 158 | } |
160 | 159 | ||
161 | if (i < 2) { | 160 | if (i < 2) { |
162 | result.append( separator ); | 161 | result.append( separator ); |
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||
166 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); | 165 | result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); |
167 | 166 | ||
168 | return result; | 167 | return result; |
169 | } | 168 | } |
170 | 169 | ||
171 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 170 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
172 | : QListBox(parent, name) | 171 | : QListBox(parent, name) |
173 | { | 172 | { |
174 | m_pDrawPadCanvas = drawPadCanvas; | 173 | m_pDrawPadCanvas = drawPadCanvas; |
175 | 174 | ||
176 | setVScrollBarMode(QScrollView::AlwaysOn); | 175 | setVScrollBarMode(QScrollView::AlwaysOn); |
177 | 176 | ||
178 | updateView(); | 177 | updateView(); |
179 | } | 178 | } |
180 | 179 | ||
181 | PageListBox::~PageListBox() | 180 | PageListBox::~PageListBox() |
182 | { | 181 | { |
183 | } | 182 | } |
184 | 183 | ||
185 | void PageListBox::updateView() | 184 | void PageListBox::updateView() |
186 | { | 185 | { |
187 | clear(); | 186 | clear(); |
188 | 187 | ||
189 | if (m_pDrawPadCanvas) { | 188 | if (m_pDrawPadCanvas) { |
190 | QList<Page> pageList = m_pDrawPadCanvas->pages(); | 189 | QList<Page> pageList = m_pDrawPadCanvas->pages(); |
191 | QListIterator<Page> it(pageList); | 190 | QListIterator<Page> it(pageList); |
192 | 191 | ||
193 | for (; it.current(); ++it) { | 192 | for (; it.current(); ++it) { |
194 | new PageListBoxItem(it.current(), this); | 193 | new PageListBoxItem(it.current(), this); |
195 | } | 194 | } |
196 | 195 | ||
197 | select(m_pDrawPadCanvas->currentPage()); | 196 | select(m_pDrawPadCanvas->currentPage()); |
198 | } | 197 | } |
199 | } | 198 | } |
200 | 199 | ||
201 | void PageListBox::select(Page* page) | 200 | void PageListBox::select(Page* page) |
202 | { | 201 | { |
203 | uint i = 0; | 202 | uint i = 0; |
204 | uint itemCount = count(); | 203 | uint itemCount = count(); |
205 | 204 | ||
206 | while (i < itemCount) { | 205 | while (i < itemCount) { |
207 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); | 206 | PageListBoxItem* currentItem = (PageListBoxItem*)item(i); |
208 | 207 | ||
209 | if (currentItem->page() == page) { | 208 | if (currentItem->page() == page) { |
210 | setCurrentItem(currentItem); | 209 | setCurrentItem(currentItem); |
211 | break; | 210 | break; |
212 | } | 211 | } |
213 | 212 | ||
214 | i++; | 213 | i++; |
215 | } | 214 | } |
216 | } | 215 | } |
217 | 216 | ||
218 | Page* PageListBox::selected() const | 217 | Page* PageListBox::selected() const |
219 | { | 218 | { |
220 | Page* page; | 219 | Page* page; |
221 | 220 | ||
222 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); | 221 | PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); |
223 | 222 | ||
224 | if (selectedItem) { | 223 | if (selectedItem) { |
225 | page = selectedItem->page(); | 224 | page = selectedItem->page(); |
226 | } else { | 225 | } else { |
227 | page = NULL; | 226 | page = NULL; |
228 | } | 227 | } |
229 | 228 | ||
230 | return page; | 229 | return page; |
231 | } | 230 | } |
232 | 231 | ||
233 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 232 | ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
234 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) | 233 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) |
235 | { | 234 | { |
236 | inLoop = false; | 235 | inLoop = false; |
237 | 236 | ||
238 | m_pDrawPad = drawPad; | 237 | m_pDrawPad = drawPad; |
239 | m_pDrawPadCanvas = drawPadCanvas; | 238 | m_pDrawPadCanvas = drawPadCanvas; |
240 | 239 | ||
241 | setCaption(tr("DrawPad - Thumbnail View")); | 240 | setCaption(tr("DrawPad - Thumbnail View")); |
242 | 241 | ||
243 | QToolButton* newPageButton = new QToolButton(this); | 242 | QToolButton* newPageButton = new QToolButton(this); |
244 | newPageButton->setIconSet(Resource::loadIconSet("new")); | 243 | newPageButton->setIconSet(Resource::loadIconSet("new")); |
245 | newPageButton->setAutoRaise(true); | 244 | newPageButton->setAutoRaise(true); |
246 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); | 245 | connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); |
247 | QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); | 246 | QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); |
248 | 247 | ||
249 | QToolButton* clearPageButton = new QToolButton(this); | 248 | QToolButton* clearPageButton = new QToolButton(this); |
250 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | 249 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); |
251 | clearPageButton->setAutoRaise(true); | 250 | clearPageButton->setAutoRaise(true); |
252 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); | 251 | connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); |
253 | QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); | 252 | QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); |
254 | 253 | ||
255 | QToolButton* deletePageButton = new QToolButton(this); | 254 | QToolButton* deletePageButton = new QToolButton(this); |
256 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 255 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); |
257 | deletePageButton->setAutoRaise(true); | 256 | deletePageButton->setAutoRaise(true); |
258 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | 257 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); |
259 | QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); | 258 | QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); |
260 | 259 | ||
261 | m_pMovePageUpButton = new QToolButton(this); | 260 | m_pMovePageUpButton = new QToolButton(this); |
262 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); | 261 | m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); |
263 | m_pMovePageUpButton->setAutoRaise(true); | 262 | m_pMovePageUpButton->setAutoRaise(true); |
264 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); | 263 | connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); |
265 | QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); | 264 | QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); |
266 | 265 | ||
267 | m_pMovePageDownButton = new QToolButton(this); | 266 | m_pMovePageDownButton = new QToolButton(this); |
268 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); | 267 | m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); |
269 | m_pMovePageDownButton->setAutoRaise(true); | 268 | m_pMovePageDownButton->setAutoRaise(true); |
270 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); | 269 | connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); |
271 | QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); | 270 | QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); |
272 | 271 | ||
273 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); | 272 | m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); |
274 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); | 273 | connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); |
275 | 274 | ||
276 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 275 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
277 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | 276 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); |
278 | 277 | ||
279 | buttonLayout->addWidget(newPageButton); | 278 | buttonLayout->addWidget(newPageButton); |
280 | buttonLayout->addWidget(clearPageButton); | 279 | buttonLayout->addWidget(clearPageButton); |
281 | buttonLayout->addWidget(deletePageButton); | 280 | buttonLayout->addWidget(deletePageButton); |
282 | buttonLayout->addStretch(); | 281 | buttonLayout->addStretch(); |
283 | buttonLayout->addWidget(m_pMovePageUpButton); | 282 | buttonLayout->addWidget(m_pMovePageUpButton); |
284 | buttonLayout->addWidget(m_pMovePageDownButton); | 283 | buttonLayout->addWidget(m_pMovePageDownButton); |
285 | 284 | ||
286 | mainLayout->addLayout(buttonLayout); | 285 | mainLayout->addLayout(buttonLayout); |
287 | mainLayout->addWidget(m_pPageListBox); | 286 | mainLayout->addWidget(m_pPageListBox); |
288 | 287 | ||
289 | updateView(); | 288 | updateView(); |
290 | } | 289 | } |
291 | 290 | ||
292 | ThumbnailView::~ThumbnailView() | 291 | ThumbnailView::~ThumbnailView() |
293 | { | 292 | { |
294 | hide(); | 293 | hide(); |
295 | } | 294 | } |
296 | 295 | ||
297 | void ThumbnailView::updateView() | 296 | void ThumbnailView::updateView() |
298 | { | 297 | { |
299 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 298 | m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
300 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 299 | m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
301 | } | 300 | } |
302 | 301 | ||
303 | void ThumbnailView::hide() | 302 | void ThumbnailView::hide() |
304 | { | 303 | { |
305 | QWidget::hide(); | 304 | QWidget::hide(); |
306 | 305 | ||
307 | if (inLoop) { | 306 | if (inLoop) { |
308 | inLoop = false; | 307 | inLoop = false; |
309 | qApp->exit_loop(); | 308 | qApp->exit_loop(); |
310 | } | 309 | } |
311 | } | 310 | } |
312 | 311 | ||
313 | void ThumbnailView::exec() | 312 | void ThumbnailView::exec() |
314 | { | 313 | { |
315 | show(); | 314 | show(); |
316 | 315 | ||
317 | if (!inLoop) { | 316 | if (!inLoop) { |
318 | inLoop = true; | 317 | inLoop = true; |
319 | qApp->enter_loop(); | 318 | qApp->enter_loop(); |
320 | } | 319 | } |
321 | } | 320 | } |
322 | 321 | ||
323 | void ThumbnailView::newPage() | 322 | void ThumbnailView::newPage() |
324 | { | 323 | { |
325 | QRect rect = m_pDrawPadCanvas->contentsRect(); | 324 | QRect rect = m_pDrawPadCanvas->contentsRect(); |
326 | 325 | ||
327 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 326 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
328 | m_pDrawPad->brush().color(), this); | 327 | m_pDrawPad->brush().color(), this); |
329 | 328 | ||
330 | if (newPageDialog.exec() == QDialog::Accepted) { | 329 | if (newPageDialog.exec() == QDialog::Accepted) { |
331 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), | 330 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
332 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); | 331 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
333 | m_pPageListBox->updateView(); | 332 | m_pPageListBox->updateView(); |
334 | updateView(); | 333 | updateView(); |
335 | } | 334 | } |
336 | } | 335 | } |
337 | 336 | ||
338 | void ThumbnailView::clearPage() | 337 | void ThumbnailView::clearPage() |
339 | { | 338 | { |
340 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), | 339 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), |
341 | QMessageBox::Information, QMessageBox::Yes, | 340 | QMessageBox::Information, QMessageBox::Yes, |
342 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 341 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
343 | QMessageBox::NoButton, this); | 342 | QMessageBox::NoButton, this); |
344 | 343 | ||
345 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 344 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
346 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 345 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
347 | 346 | ||
348 | if (messageBox.exec() == QMessageBox::Yes) { | 347 | if (messageBox.exec() == QMessageBox::Yes) { |
349 | m_pDrawPadCanvas->clearPage(); | 348 | m_pDrawPadCanvas->clearPage(); |
350 | m_pPageListBox->updateView(); | 349 | m_pPageListBox->updateView(); |
351 | } | 350 | } |
352 | } | 351 | } |
353 | 352 | ||
354 | void ThumbnailView::deletePage() | 353 | void ThumbnailView::deletePage() |
355 | { | 354 | { |
356 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), | 355 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), |
357 | QMessageBox::Information, QMessageBox::Yes, | 356 | QMessageBox::Information, QMessageBox::Yes, |
358 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 357 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
359 | QMessageBox::NoButton, this); | 358 | QMessageBox::NoButton, this); |
360 | 359 | ||
361 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 360 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); |
362 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 361 | messageBox.setButtonText(QMessageBox::No, tr("No")); |
363 | 362 | ||
364 | if (messageBox.exec() == QMessageBox::Yes) { | 363 | if (messageBox.exec() == QMessageBox::Yes) { |
365 | m_pDrawPadCanvas->deletePage(); | 364 | m_pDrawPadCanvas->deletePage(); |
366 | m_pPageListBox->updateView(); | 365 | m_pPageListBox->updateView(); |
367 | updateView(); | 366 | updateView(); |
368 | } | 367 | } |
369 | } | 368 | } |
370 | 369 | ||
371 | void ThumbnailView::movePageUp() | 370 | void ThumbnailView::movePageUp() |
372 | { | 371 | { |
373 | m_pDrawPadCanvas->movePageUp(); | 372 | m_pDrawPadCanvas->movePageUp(); |
374 | m_pPageListBox->updateView(); | 373 | m_pPageListBox->updateView(); |
375 | updateView(); | 374 | updateView(); |
376 | } | 375 | } |
377 | 376 | ||
378 | void ThumbnailView::movePageDown() | 377 | void ThumbnailView::movePageDown() |
379 | { | 378 | { |
380 | m_pDrawPadCanvas->movePageDown(); | 379 | m_pDrawPadCanvas->movePageDown(); |
381 | m_pPageListBox->updateView(); | 380 | m_pPageListBox->updateView(); |
382 | updateView(); | 381 | updateView(); |
383 | } | 382 | } |
384 | 383 | ||
385 | void ThumbnailView::changePage() | 384 | void ThumbnailView::changePage() |
386 | { | 385 | { |
387 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); | 386 | m_pDrawPadCanvas->selectPage(m_pPageListBox->selected()); |
388 | updateView(); | 387 | updateView(); |
389 | } | 388 | } |
diff --git a/noncore/graphics/drawpad/tool.cpp b/noncore/graphics/drawpad/tool.cpp index 0d36912..656078e 100644 --- a/noncore/graphics/drawpad/tool.cpp +++ b/noncore/graphics/drawpad/tool.cpp | |||
@@ -1,28 +1,26 @@ | |||
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 "tool.h" | 14 | #include "tool.h" |
15 | 15 | ||
16 | #include "drawpad.h" | ||
17 | #include "drawpadcanvas.h" | ||
18 | 16 | ||
19 | Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 17 | Tool::Tool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
20 | : QObject() | 18 | : QObject() |
21 | { | 19 | { |
22 | m_pDrawPad = drawPad; | 20 | m_pDrawPad = drawPad; |
23 | m_pDrawPadCanvas = drawPadCanvas; | 21 | m_pDrawPadCanvas = drawPadCanvas; |
24 | } | 22 | } |
25 | 23 | ||
26 | Tool::~Tool() | 24 | Tool::~Tool() |
27 | { | 25 | { |
28 | } | 26 | } |