author | leseb <leseb> | 2002-04-06 22:20:19 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-04-06 22:20:19 (UTC) |
commit | 75bc9d885aa131334a0b906a1a58134740c40783 (patch) (unidiff) | |
tree | 08a05fe92e1e2f1dc67604f9040bf669e5b4c84a | |
parent | 8e092bf08c2873dcdec4694573cf715b7a590e41 (diff) | |
download | opie-75bc9d885aa131334a0b906a1a58134740c40783.zip opie-75bc9d885aa131334a0b906a1a58134740c40783.tar.gz opie-75bc9d885aa131334a0b906a1a58134740c40783.tar.bz2 |
- Save album in PNG format instead of XPM
- Small fixes
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 12 | ||||
-rw-r--r-- | noncore/graphics/drawpad/newpagedialog.cpp | 22 | ||||
-rw-r--r-- | noncore/graphics/drawpad/newpagedialog.h | 4 |
4 files changed, 24 insertions, 16 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index aae9ab0..1375792 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -1,508 +1,510 @@ | |||
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 "colordialog.h" | 16 | #include "colordialog.h" |
17 | #include "colorpanel.h" | 17 | #include "colorpanel.h" |
18 | #include "drawpadcanvas.h" | 18 | #include "drawpadcanvas.h" |
19 | #include "ellipsetool.h" | 19 | #include "ellipsetool.h" |
20 | #include "erasetool.h" | 20 | #include "erasetool.h" |
21 | #include "exportdialog.h" | 21 | #include "exportdialog.h" |
22 | #include "filledellipsetool.h" | 22 | #include "filledellipsetool.h" |
23 | #include "filledrectangletool.h" | 23 | #include "filledrectangletool.h" |
24 | #include "filltool.h" | 24 | #include "filltool.h" |
25 | #include "importdialog.h" | 25 | #include "importdialog.h" |
26 | #include "linetool.h" | 26 | #include "linetool.h" |
27 | #include "pointtool.h" | 27 | #include "pointtool.h" |
28 | #include "rectangletool.h" | 28 | #include "rectangletool.h" |
29 | 29 | ||
30 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/qpemenubar.h> | 32 | #include <qpe/qpemenubar.h> |
33 | #include <qpe/qpetoolbar.h> | 33 | #include <qpe/qpetoolbar.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | 35 | ||
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qpainter.h> | 38 | #include <qpainter.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
41 | #include <qtooltip.h> | 41 | #include <qtooltip.h> |
42 | 42 | ||
43 | DrawPad::DrawPad(QWidget* parent, const char* name) | 43 | DrawPad::DrawPad(QWidget* parent, const char* name) |
44 | : QMainWindow(parent, name) | 44 | : QMainWindow(parent, name) |
45 | { | 45 | { |
46 | // init members | 46 | // init members |
47 | 47 | ||
48 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); | 48 | m_pDrawPadCanvas = new DrawPadCanvas(this, this); |
49 | 49 | ||
50 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); | 50 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons())); |
51 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); | 51 | connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption())); |
52 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); | 52 | connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons())); |
53 | 53 | ||
54 | setCentralWidget(m_pDrawPadCanvas); | 54 | setCentralWidget(m_pDrawPadCanvas); |
55 | 55 | ||
56 | // init menu | 56 | // init menu |
57 | 57 | ||
58 | setToolBarsMovable(false); | 58 | setToolBarsMovable(false); |
59 | 59 | ||
60 | QPEToolBar* menuToolBar = new QPEToolBar(this); | 60 | QPEToolBar* menuToolBar = new QPEToolBar(this); |
61 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); | 61 | QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); |
62 | 62 | ||
63 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 63 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); |
64 | 64 | ||
65 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 65 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
66 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); | 66 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); |
67 | deleteAllAction->addTo(toolsPopupMenu); | 67 | deleteAllAction->addTo(toolsPopupMenu); |
68 | 68 | ||
69 | toolsPopupMenu->insertSeparator(); | 69 | toolsPopupMenu->insertSeparator(); |
70 | 70 | ||
71 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); | 71 | QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); |
72 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); | 72 | connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); |
73 | importPageAction->addTo(toolsPopupMenu); | 73 | importPageAction->addTo(toolsPopupMenu); |
74 | 74 | ||
75 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); | 75 | QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); |
76 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); | 76 | connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); |
77 | exportPageAction->addTo(toolsPopupMenu); | 77 | exportPageAction->addTo(toolsPopupMenu); |
78 | 78 | ||
79 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); | 79 | menuBar->insertItem(tr("Tools"), toolsPopupMenu); |
80 | 80 | ||
81 | // init page toolbar | 81 | // init page toolbar |
82 | 82 | ||
83 | QPEToolBar* pageToolBar = new QPEToolBar(this); | 83 | QPEToolBar* pageToolBar = new QPEToolBar(this); |
84 | 84 | ||
85 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); | 85 | QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); |
86 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); | 86 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); |
87 | newPageAction->addTo(pageToolBar); | 87 | newPageAction->addTo(pageToolBar); |
88 | 88 | ||
89 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 89 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
90 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); | 90 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); |
91 | clearPageAction->addTo(pageToolBar); | 91 | clearPageAction->addTo(pageToolBar); |
92 | 92 | ||
93 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 93 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
94 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); | 94 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); |
95 | deletePageAction->addTo(pageToolBar); | 95 | deletePageAction->addTo(pageToolBar); |
96 | 96 | ||
97 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 97 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
98 | emptyToolBar->setHorizontalStretchable(true); | 98 | emptyToolBar->setHorizontalStretchable(true); |
99 | 99 | ||
100 | // init navigation toolbar | 100 | // init navigation toolbar |
101 | 101 | ||
102 | QPEToolBar* navigationToolBar = new QPEToolBar(this); | 102 | QPEToolBar* navigationToolBar = new QPEToolBar(this); |
103 | 103 | ||
104 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); | 104 | m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); |
105 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); | 105 | connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); |
106 | m_pUndoAction->addTo(navigationToolBar); | 106 | m_pUndoAction->addTo(navigationToolBar); |
107 | 107 | ||
108 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); | 108 | m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); |
109 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); | 109 | connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); |
110 | m_pRedoAction->addTo(navigationToolBar); | 110 | m_pRedoAction->addTo(navigationToolBar); |
111 | 111 | ||
112 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); | 112 | m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); |
113 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); | 113 | connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); |
114 | m_pFirstPageAction->addTo(navigationToolBar); | 114 | m_pFirstPageAction->addTo(navigationToolBar); |
115 | 115 | ||
116 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); | 116 | m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); |
117 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); | 117 | connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); |
118 | m_pPreviousPageAction->addTo(navigationToolBar); | 118 | m_pPreviousPageAction->addTo(navigationToolBar); |
119 | 119 | ||
120 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); | 120 | m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); |
121 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); | 121 | connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); |
122 | m_pNextPageAction->addTo(navigationToolBar); | 122 | m_pNextPageAction->addTo(navigationToolBar); |
123 | 123 | ||
124 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); | 124 | m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); |
125 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); | 125 | connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); |
126 | m_pLastPageAction->addTo(navigationToolBar); | 126 | m_pLastPageAction->addTo(navigationToolBar); |
127 | 127 | ||
128 | // init draw mode toolbar | 128 | // init draw mode toolbar |
129 | 129 | ||
130 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); | 130 | QPEToolBar* drawModeToolBar = new QPEToolBar(this); |
131 | 131 | ||
132 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); | 132 | m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), QString::null, 0, this); |
133 | m_pPointToolAction->setToggleAction(true); | 133 | m_pPointToolAction->setToggleAction(true); |
134 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); | 134 | connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); |
135 | m_pPointToolAction->addTo(drawModeToolBar); | 135 | m_pPointToolAction->addTo(drawModeToolBar); |
136 | 136 | ||
137 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); | 137 | m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), QString::null, 0, this); |
138 | m_pLineToolAction->setToggleAction(true); | 138 | m_pLineToolAction->setToggleAction(true); |
139 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); | 139 | connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); |
140 | m_pLineToolAction->addTo(drawModeToolBar); | 140 | m_pLineToolAction->addTo(drawModeToolBar); |
141 | 141 | ||
142 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); | 142 | m_pRectangleToolButton = new QToolButton(drawModeToolBar); |
143 | m_pRectangleToolButton->setToggleButton(true); | 143 | m_pRectangleToolButton->setToggleButton(true); |
144 | 144 | ||
145 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); | 145 | QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); |
146 | 146 | ||
147 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); | 147 | m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); |
148 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); | 148 | connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool())); |
149 | m_pRectangleToolAction->addTo(rectanglePopupMenu); | 149 | m_pRectangleToolAction->addTo(rectanglePopupMenu); |
150 | 150 | ||
151 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); | 151 | m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this); |
152 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); | 152 | connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool())); |
153 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); | 153 | m_pFilledRectangleToolAction->addTo(rectanglePopupMenu); |
154 | 154 | ||
155 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); | 155 | m_pRectangleToolButton->setPopup(rectanglePopupMenu); |
156 | m_pRectangleToolButton->setPopupDelay(0); | ||
156 | 157 | ||
157 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); | 158 | m_pEllipseToolButton = new QToolButton(drawModeToolBar); |
158 | m_pEllipseToolButton->setToggleButton(true); | 159 | m_pEllipseToolButton->setToggleButton(true); |
159 | 160 | ||
160 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); | 161 | QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); |
161 | 162 | ||
162 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); | 163 | m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); |
163 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); | 164 | connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool())); |
164 | m_pEllipseToolAction->addTo(ellipsePopupMenu); | 165 | m_pEllipseToolAction->addTo(ellipsePopupMenu); |
165 | 166 | ||
166 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); | 167 | m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this); |
167 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); | 168 | connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); |
168 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); | 169 | m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); |
169 | 170 | ||
170 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); | 171 | m_pEllipseToolButton->setPopup(ellipsePopupMenu); |
172 | m_pEllipseToolButton->setPopupDelay(0); | ||
171 | 173 | ||
172 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); | 174 | m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); |
173 | m_pFillToolAction->setToggleAction(true); | 175 | m_pFillToolAction->setToggleAction(true); |
174 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); | 176 | connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); |
175 | m_pFillToolAction->addTo(drawModeToolBar); | 177 | m_pFillToolAction->addTo(drawModeToolBar); |
176 | 178 | ||
177 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); | 179 | m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); |
178 | m_pEraseToolAction->setToggleAction(true); | 180 | m_pEraseToolAction->setToggleAction(true); |
179 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); | 181 | connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); |
180 | m_pEraseToolAction->addTo(drawModeToolBar); | 182 | m_pEraseToolAction->addTo(drawModeToolBar); |
181 | 183 | ||
182 | m_pTool = 0; | 184 | m_pTool = 0; |
183 | setRectangleTool(); | 185 | setRectangleTool(); |
184 | setEllipseTool(); | 186 | setEllipseTool(); |
185 | setPointTool(); | 187 | setPointTool(); |
186 | 188 | ||
187 | emptyToolBar = new QPEToolBar(this); | 189 | emptyToolBar = new QPEToolBar(this); |
188 | emptyToolBar->setHorizontalStretchable(true); | 190 | emptyToolBar->setHorizontalStretchable(true); |
189 | emptyToolBar->addSeparator(); | 191 | emptyToolBar->addSeparator(); |
190 | 192 | ||
191 | // init draw parameters toolbar | 193 | // init draw parameters toolbar |
192 | 194 | ||
193 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 195 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
194 | 196 | ||
195 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 197 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
196 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 198 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
197 | 199 | ||
198 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 200 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); |
199 | penWidthSpinBox->setValue(1); | 201 | penWidthSpinBox->setValue(1); |
200 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 202 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
201 | 203 | ||
202 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 204 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
203 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 205 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
204 | 206 | ||
205 | QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); | 207 | QPopupMenu* penColorPopupMenu = new QPopupMenu(m_pPenColorToolButton); |
206 | 208 | ||
207 | ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); | 209 | ColorPanel* penColorPanel = new ColorPanel(penColorPopupMenu); |
208 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 210 | connect(penColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
209 | 211 | ||
210 | penColorPopupMenu->insertItem(penColorPanel); | 212 | penColorPopupMenu->insertItem(penColorPanel); |
211 | penColorPopupMenu->insertSeparator(); | 213 | penColorPopupMenu->insertSeparator(); |
212 | 214 | ||
213 | QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 215 | QAction* choosePenColorAction = new QAction(tr("More"), tr("More..."), 0, this); |
214 | connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); | 216 | connect(choosePenColorAction, SIGNAL(activated()), this, SLOT(choosePenColor())); |
215 | choosePenColorAction->addTo(penColorPopupMenu); | 217 | choosePenColorAction->addTo(penColorPopupMenu); |
216 | 218 | ||
217 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 219 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
218 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 220 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
219 | m_pPenColorToolButton->setPopupDelay(0); | 221 | m_pPenColorToolButton->setPopupDelay(0); |
220 | 222 | ||
221 | penColorPanel->buttonSelected(Qt::black); | 223 | penColorPanel->buttonSelected(Qt::black); |
222 | 224 | ||
223 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); | 225 | m_pBrushColorToolButton = new QToolButton(drawParametersToolBar); |
224 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); | 226 | m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor.png")); |
225 | 227 | ||
226 | QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); | 228 | QPopupMenu* brushColorPopupMenu = new QPopupMenu(m_pBrushColorToolButton); |
227 | 229 | ||
228 | ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); | 230 | ColorPanel* brushColorPanel = new ColorPanel(brushColorPopupMenu); |
229 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); | 231 | connect(brushColorPanel, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&))); |
230 | 232 | ||
231 | brushColorPopupMenu->insertItem(brushColorPanel); | 233 | brushColorPopupMenu->insertItem(brushColorPanel); |
232 | brushColorPopupMenu->insertSeparator(); | 234 | brushColorPopupMenu->insertSeparator(); |
233 | 235 | ||
234 | QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); | 236 | QAction* chooseBrushColorAction = new QAction(tr("More"), tr("More..."), 0, this); |
235 | connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); | 237 | connect(chooseBrushColorAction, SIGNAL(activated()), this, SLOT(chooseBrushColor())); |
236 | chooseBrushColorAction->addTo(brushColorPopupMenu); | 238 | chooseBrushColorAction->addTo(brushColorPopupMenu); |
237 | 239 | ||
238 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); | 240 | QToolTip::add(m_pBrushColorToolButton, tr("Fill Color")); |
239 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); | 241 | m_pBrushColorToolButton->setPopup(brushColorPopupMenu); |
240 | m_pBrushColorToolButton->setPopupDelay(0); | 242 | m_pBrushColorToolButton->setPopupDelay(0); |
241 | 243 | ||
242 | brushColorPanel->buttonSelected(Qt::white); | 244 | brushColorPanel->buttonSelected(Qt::white); |
243 | 245 | ||
244 | // init pages | 246 | // init pages |
245 | 247 | ||
246 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 248 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
247 | 249 | ||
248 | if (file.open(IO_ReadOnly)) { | 250 | if (file.open(IO_ReadOnly)) { |
249 | m_pDrawPadCanvas->load(&file); | 251 | m_pDrawPadCanvas->load(&file); |
250 | file.close(); | 252 | file.close(); |
251 | } else { | 253 | } else { |
252 | m_pDrawPadCanvas->initialPage(); | 254 | m_pDrawPadCanvas->initialPage(); |
253 | } | 255 | } |
254 | } | 256 | } |
255 | 257 | ||
256 | DrawPad::~DrawPad() | 258 | DrawPad::~DrawPad() |
257 | { | 259 | { |
258 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 260 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
259 | 261 | ||
260 | if (file.open(IO_WriteOnly)) { | 262 | if (file.open(IO_WriteOnly)) { |
261 | m_pDrawPadCanvas->save(&file); | 263 | m_pDrawPadCanvas->save(&file); |
262 | file.close(); | 264 | file.close(); |
263 | } | 265 | } |
264 | } | 266 | } |
265 | 267 | ||
266 | void DrawPad::setPointTool() | 268 | void DrawPad::setPointTool() |
267 | { | 269 | { |
268 | if (m_pTool) { | 270 | if (m_pTool) { |
269 | delete m_pTool; | 271 | delete m_pTool; |
270 | } | 272 | } |
271 | 273 | ||
272 | m_pTool = new PointTool(this, m_pDrawPadCanvas); | 274 | m_pTool = new PointTool(this, m_pDrawPadCanvas); |
273 | 275 | ||
274 | m_pPointToolAction->setOn(true); | 276 | m_pPointToolAction->setOn(true); |
275 | m_pLineToolAction->setOn(false); | 277 | m_pLineToolAction->setOn(false); |
276 | m_pRectangleToolButton->setOn(false); | 278 | m_pRectangleToolButton->setOn(false); |
277 | m_pEllipseToolButton->setOn(false); | 279 | m_pEllipseToolButton->setOn(false); |
278 | m_pFillToolAction->setOn(false); | 280 | m_pFillToolAction->setOn(false); |
279 | m_pEraseToolAction->setOn(false); | 281 | m_pEraseToolAction->setOn(false); |
280 | } | 282 | } |
281 | 283 | ||
282 | void DrawPad::setLineTool() | 284 | void DrawPad::setLineTool() |
283 | { | 285 | { |
284 | if (m_pTool) { | 286 | if (m_pTool) { |
285 | delete m_pTool; | 287 | delete m_pTool; |
286 | } | 288 | } |
287 | 289 | ||
288 | m_pTool = new LineTool(this, m_pDrawPadCanvas); | 290 | m_pTool = new LineTool(this, m_pDrawPadCanvas); |
289 | 291 | ||
290 | m_pPointToolAction->setOn(false); | 292 | m_pPointToolAction->setOn(false); |
291 | m_pLineToolAction->setOn(true); | 293 | m_pLineToolAction->setOn(true); |
292 | m_pRectangleToolButton->setOn(false); | 294 | m_pRectangleToolButton->setOn(false); |
293 | m_pEllipseToolButton->setOn(false); | 295 | m_pEllipseToolButton->setOn(false); |
294 | m_pFillToolAction->setOn(false); | 296 | m_pFillToolAction->setOn(false); |
295 | m_pEraseToolAction->setOn(false); | 297 | m_pEraseToolAction->setOn(false); |
296 | } | 298 | } |
297 | 299 | ||
298 | void DrawPad::setRectangleTool() | 300 | void DrawPad::setRectangleTool() |
299 | { | 301 | { |
300 | if (m_pTool) { | 302 | if (m_pTool) { |
301 | delete m_pTool; | 303 | delete m_pTool; |
302 | } | 304 | } |
303 | 305 | ||
304 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); | 306 | m_pTool = new RectangleTool(this, m_pDrawPadCanvas); |
305 | 307 | ||
306 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); | 308 | m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet()); |
307 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); | 309 | QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text()); |
308 | 310 | ||
309 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 311 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
310 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); | 312 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated())); |
311 | 313 | ||
312 | m_pPointToolAction->setOn(false); | 314 | m_pPointToolAction->setOn(false); |
313 | m_pLineToolAction->setOn(false); | 315 | m_pLineToolAction->setOn(false); |
314 | m_pRectangleToolButton->setOn(true); | 316 | m_pRectangleToolButton->setOn(true); |
315 | m_pEllipseToolButton->setOn(false); | 317 | m_pEllipseToolButton->setOn(false); |
316 | m_pFillToolAction->setOn(false); | 318 | m_pFillToolAction->setOn(false); |
317 | m_pEraseToolAction->setOn(false); | 319 | m_pEraseToolAction->setOn(false); |
318 | } | 320 | } |
319 | 321 | ||
320 | void DrawPad::setFilledRectangleTool() | 322 | void DrawPad::setFilledRectangleTool() |
321 | { | 323 | { |
322 | if (m_pTool) { | 324 | if (m_pTool) { |
323 | delete m_pTool; | 325 | delete m_pTool; |
324 | } | 326 | } |
325 | 327 | ||
326 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); | 328 | m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas); |
327 | 329 | ||
328 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); | 330 | m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet()); |
329 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); | 331 | QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text()); |
330 | 332 | ||
331 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); | 333 | disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0); |
332 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); | 334 | connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated())); |
333 | 335 | ||
334 | m_pPointToolAction->setOn(false); | 336 | m_pPointToolAction->setOn(false); |
335 | m_pLineToolAction->setOn(false); | 337 | m_pLineToolAction->setOn(false); |
336 | m_pRectangleToolButton->setOn(true); | 338 | m_pRectangleToolButton->setOn(true); |
337 | m_pEllipseToolButton->setOn(false); | 339 | m_pEllipseToolButton->setOn(false); |
338 | m_pFillToolAction->setOn(false); | 340 | m_pFillToolAction->setOn(false); |
339 | m_pEraseToolAction->setOn(false); | 341 | m_pEraseToolAction->setOn(false); |
340 | } | 342 | } |
341 | 343 | ||
342 | void DrawPad::setEllipseTool() | 344 | void DrawPad::setEllipseTool() |
343 | { | 345 | { |
344 | if (m_pTool) { | 346 | if (m_pTool) { |
345 | delete m_pTool; | 347 | delete m_pTool; |
346 | } | 348 | } |
347 | 349 | ||
348 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); | 350 | m_pTool = new EllipseTool(this, m_pDrawPadCanvas); |
349 | 351 | ||
350 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); | 352 | m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet()); |
351 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); | 353 | QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text()); |
352 | 354 | ||
353 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 355 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
354 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); | 356 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated())); |
355 | 357 | ||
356 | m_pPointToolAction->setOn(false); | 358 | m_pPointToolAction->setOn(false); |
357 | m_pLineToolAction->setOn(false); | 359 | m_pLineToolAction->setOn(false); |
358 | m_pRectangleToolButton->setOn(false); | 360 | m_pRectangleToolButton->setOn(false); |
359 | m_pEllipseToolButton->setOn(true); | 361 | m_pEllipseToolButton->setOn(true); |
360 | m_pFillToolAction->setOn(false); | 362 | m_pFillToolAction->setOn(false); |
361 | m_pEraseToolAction->setOn(false); | 363 | m_pEraseToolAction->setOn(false); |
362 | } | 364 | } |
363 | 365 | ||
364 | void DrawPad::setFilledEllipseTool() | 366 | void DrawPad::setFilledEllipseTool() |
365 | { | 367 | { |
366 | if (m_pTool) { | 368 | if (m_pTool) { |
367 | delete m_pTool; | 369 | delete m_pTool; |
368 | } | 370 | } |
369 | 371 | ||
370 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); | 372 | m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas); |
371 | 373 | ||
372 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); | 374 | m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet()); |
373 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); | 375 | QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text()); |
374 | 376 | ||
375 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); | 377 | disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0); |
376 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); | 378 | connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated())); |
377 | 379 | ||
378 | m_pPointToolAction->setOn(false); | 380 | m_pPointToolAction->setOn(false); |
379 | m_pLineToolAction->setOn(false); | 381 | m_pLineToolAction->setOn(false); |
380 | m_pRectangleToolButton->setOn(false); | 382 | m_pRectangleToolButton->setOn(false); |
381 | m_pEllipseToolButton->setOn(true); | 383 | m_pEllipseToolButton->setOn(true); |
382 | m_pFillToolAction->setOn(false); | 384 | m_pFillToolAction->setOn(false); |
383 | m_pEraseToolAction->setOn(false); | 385 | m_pEraseToolAction->setOn(false); |
384 | } | 386 | } |
385 | 387 | ||
386 | void DrawPad::setFillTool() | 388 | void DrawPad::setFillTool() |
387 | { | 389 | { |
388 | if (m_pTool) { | 390 | if (m_pTool) { |
389 | delete m_pTool; | 391 | delete m_pTool; |
390 | } | 392 | } |
391 | 393 | ||
392 | m_pTool = new FillTool(this, m_pDrawPadCanvas); | 394 | m_pTool = new FillTool(this, m_pDrawPadCanvas); |
393 | 395 | ||
394 | m_pPointToolAction->setOn(false); | 396 | m_pPointToolAction->setOn(false); |
395 | m_pLineToolAction->setOn(false); | 397 | m_pLineToolAction->setOn(false); |
396 | m_pRectangleToolButton->setOn(false); | 398 | m_pRectangleToolButton->setOn(false); |
397 | m_pEllipseToolButton->setOn(false); | 399 | m_pEllipseToolButton->setOn(false); |
398 | m_pFillToolAction->setOn(true); | 400 | m_pFillToolAction->setOn(true); |
399 | m_pEraseToolAction->setOn(false); | 401 | m_pEraseToolAction->setOn(false); |
400 | } | 402 | } |
401 | 403 | ||
402 | void DrawPad::setEraseTool() | 404 | void DrawPad::setEraseTool() |
403 | { | 405 | { |
404 | if (m_pTool) { | 406 | if (m_pTool) { |
405 | delete m_pTool; | 407 | delete m_pTool; |
406 | } | 408 | } |
407 | 409 | ||
408 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); | 410 | m_pTool = new EraseTool(this, m_pDrawPadCanvas); |
409 | 411 | ||
410 | m_pPointToolAction->setOn(false); | 412 | m_pPointToolAction->setOn(false); |
411 | m_pLineToolAction->setOn(false); | 413 | m_pLineToolAction->setOn(false); |
412 | m_pRectangleToolButton->setOn(false); | 414 | m_pRectangleToolButton->setOn(false); |
413 | m_pEllipseToolButton->setOn(false); | 415 | m_pEllipseToolButton->setOn(false); |
414 | m_pFillToolAction->setOn(false); | 416 | m_pFillToolAction->setOn(false); |
415 | m_pEraseToolAction->setOn(true); | 417 | m_pEraseToolAction->setOn(true); |
416 | } | 418 | } |
417 | 419 | ||
418 | void DrawPad::changePenWidth(int value) | 420 | void DrawPad::changePenWidth(int value) |
419 | { | 421 | { |
420 | m_pen.setWidth(value); | 422 | m_pen.setWidth(value); |
421 | } | 423 | } |
422 | 424 | ||
423 | void DrawPad::changePenColor(const QColor& color) | 425 | void DrawPad::changePenColor(const QColor& color) |
424 | { | 426 | { |
425 | m_pen.setColor(color); | 427 | m_pen.setColor(color); |
426 | 428 | ||
427 | QPainter painter; | 429 | QPainter painter; |
428 | painter.begin(m_pPenColorToolButton->pixmap()); | 430 | painter.begin(m_pPenColorToolButton->pixmap()); |
429 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); | 431 | painter.fillRect(QRect(0, 12, 14, 2), m_pen.color()); |
430 | painter.end(); | 432 | painter.end(); |
431 | 433 | ||
432 | m_pPenColorToolButton->popup()->hide(); | 434 | m_pPenColorToolButton->popup()->hide(); |
433 | } | 435 | } |
434 | 436 | ||
435 | void DrawPad::changeBrushColor(const QColor& color) | 437 | void DrawPad::changeBrushColor(const QColor& color) |
436 | { | 438 | { |
437 | m_brush = QBrush(color); | 439 | m_brush = QBrush(color); |
438 | 440 | ||
439 | QPainter painter; | 441 | QPainter painter; |
440 | painter.begin(m_pBrushColorToolButton->pixmap()); | 442 | painter.begin(m_pBrushColorToolButton->pixmap()); |
441 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); | 443 | painter.fillRect(QRect(0, 12, 14, 2), m_brush.color()); |
442 | painter.end(); | 444 | painter.end(); |
443 | 445 | ||
444 | m_pBrushColorToolButton->popup()->hide(); | 446 | m_pBrushColorToolButton->popup()->hide(); |
445 | } | 447 | } |
446 | 448 | ||
447 | void DrawPad::choosePenColor() | 449 | void DrawPad::choosePenColor() |
448 | { | 450 | { |
449 | QColor newPenColor = QColorDialog::getColor(m_pen.color()); | 451 | QColor newPenColor = QColorDialog::getColor(m_pen.color()); |
450 | changePenColor(newPenColor); | 452 | changePenColor(newPenColor); |
451 | } | 453 | } |
452 | 454 | ||
453 | void DrawPad::chooseBrushColor() | 455 | void DrawPad::chooseBrushColor() |
454 | { | 456 | { |
455 | QColor newBrushColor = QColorDialog::getColor(m_brush.color()); | 457 | QColor newBrushColor = QColorDialog::getColor(m_brush.color()); |
456 | changeBrushColor(newBrushColor); | 458 | changeBrushColor(newBrushColor); |
457 | } | 459 | } |
458 | 460 | ||
459 | void DrawPad::updateUndoRedoToolButtons() | 461 | void DrawPad::updateUndoRedoToolButtons() |
460 | { | 462 | { |
461 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); | 463 | m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled()); |
462 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); | 464 | m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled()); |
463 | } | 465 | } |
464 | 466 | ||
465 | void DrawPad::updateNavigationToolButtons() | 467 | void DrawPad::updateNavigationToolButtons() |
466 | { | 468 | { |
467 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 469 | m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
468 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); | 470 | m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); |
469 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 471 | m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
470 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); | 472 | m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); |
471 | } | 473 | } |
472 | 474 | ||
473 | void DrawPad::updateCaption() | 475 | void DrawPad::updateCaption() |
474 | { | 476 | { |
475 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); | 477 | uint pagePosition = m_pDrawPadCanvas->pagePosition(); |
476 | uint pageCount = m_pDrawPadCanvas->pageCount(); | 478 | uint pageCount = m_pDrawPadCanvas->pageCount(); |
477 | 479 | ||
478 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 480 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
479 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 481 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
480 | } | 482 | } |
481 | 483 | ||
482 | void DrawPad::importPage() | 484 | void DrawPad::importPage() |
483 | { | 485 | { |
484 | ImportDialog importDialog(this); | 486 | ImportDialog importDialog(this); |
485 | 487 | ||
486 | importDialog.showMaximized(); | 488 | importDialog.showMaximized(); |
487 | 489 | ||
488 | if (importDialog.exec() == QDialog::Accepted) { | 490 | if (importDialog.exec() == QDialog::Accepted) { |
489 | const DocLnk* docLnk = importDialog.selected(); | 491 | const DocLnk* docLnk = importDialog.selected(); |
490 | 492 | ||
491 | if (docLnk) { | 493 | if (docLnk) { |
492 | m_pDrawPadCanvas->importPage(docLnk->file()); | 494 | m_pDrawPadCanvas->importPage(docLnk->file()); |
493 | delete docLnk; | 495 | delete docLnk; |
494 | } | 496 | } |
495 | } | 497 | } |
496 | } | 498 | } |
497 | 499 | ||
498 | void DrawPad::exportPage() | 500 | void DrawPad::exportPage() |
499 | { | 501 | { |
500 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); | 502 | ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this); |
501 | 503 | ||
502 | exportDialog.showMaximized(); | 504 | exportDialog.showMaximized(); |
503 | 505 | ||
504 | if (exportDialog.exec() == QDialog::Accepted) { | 506 | if (exportDialog.exec() == QDialog::Accepted) { |
505 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), | 507 | m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(), |
506 | exportDialog.selectedName(), exportDialog.selectedFormat()); | 508 | exportDialog.selectedName(), exportDialog.selectedFormat()); |
507 | } | 509 | } |
508 | } | 510 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 8818c03..b8a1c2e 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -1,526 +1,532 @@ | |||
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 "newpagedialog.h" | 17 | #include "newpagedialog.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 <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | #include <qtextcodec.h> | 29 | #include <qtextcodec.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qxml.h> | 31 | #include <qxml.h> |
32 | 32 | ||
33 | #include <zlib.h> | 33 | #include <zlib.h> |
34 | 34 | ||
35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler | 35 | class DrawPadCanvasXmlHandler: public QXmlDefaultHandler |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | DrawPadCanvasXmlHandler(); | 38 | DrawPadCanvasXmlHandler(); |
39 | ~DrawPadCanvasXmlHandler(); | 39 | ~DrawPadCanvasXmlHandler(); |
40 | 40 | ||
41 | QList<QPixmap> pixmaps(); | 41 | QList<QPixmap> pixmaps(); |
42 | 42 | ||
43 | bool startElement(const QString& namespaceURI, const QString& localName, | 43 | bool startElement(const QString& namespaceURI, const QString& localName, |
44 | const QString& qName, const QXmlAttributes& atts); | 44 | const QString& qName, const QXmlAttributes& atts); |
45 | bool endElement(const QString& namespaceURI, const QString& localName, | 45 | bool endElement(const QString& namespaceURI, const QString& localName, |
46 | const QString& qName); | 46 | const QString& qName); |
47 | bool characters(const QString& ch); | 47 | bool characters(const QString& ch); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | enum State { | 50 | enum State { |
51 | Unknown, | 51 | Unknown, |
52 | InData | 52 | InData |
53 | }; | 53 | }; |
54 | 54 | ||
55 | State m_state; | 55 | State m_state; |
56 | ulong m_dataLenght; | 56 | ulong m_dataLenght; |
57 | QString m_dataFormat; | ||
57 | QList<QPixmap> m_pixmaps; | 58 | QList<QPixmap> m_pixmaps; |
58 | }; | 59 | }; |
59 | 60 | ||
60 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() | 61 | DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() |
61 | { | 62 | { |
62 | m_state = Unknown; | 63 | m_state = Unknown; |
63 | } | 64 | } |
64 | 65 | ||
65 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() | 66 | DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() |
66 | { | 67 | { |
67 | } | 68 | } |
68 | 69 | ||
69 | QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() | 70 | QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps() |
70 | { | 71 | { |
71 | return m_pixmaps; | 72 | return m_pixmaps; |
72 | } | 73 | } |
73 | 74 | ||
74 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, | 75 | bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, |
75 | const QString& qName, const QXmlAttributes& atts) | 76 | const QString& qName, const QXmlAttributes& atts) |
76 | { | 77 | { |
77 | Q_CONST_UNUSED(namespaceURI) | 78 | Q_CONST_UNUSED(namespaceURI) |
78 | Q_CONST_UNUSED(localName) | 79 | Q_CONST_UNUSED(localName) |
79 | 80 | ||
80 | if (qName.compare("data") == 0) { | 81 | if (qName.compare("data") == 0) { |
81 | m_state = InData; | 82 | m_state = InData; |
82 | m_dataLenght = atts.value("length").toULong(); | 83 | m_dataLenght = atts.value("length").toULong(); |
84 | m_dataFormat = atts.value("format"); | ||
85 | |||
86 | if (m_dataFormat.isEmpty()) { | ||
87 | m_dataFormat = "XPM"; | ||
88 | } | ||
83 | } | 89 | } |
84 | 90 | ||
85 | return true; | 91 | return true; |
86 | } | 92 | } |
87 | 93 | ||
88 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, | 94 | bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, |
89 | const QString& qName) | 95 | const QString& qName) |
90 | { | 96 | { |
91 | Q_CONST_UNUSED(namespaceURI) | 97 | Q_CONST_UNUSED(namespaceURI) |
92 | Q_CONST_UNUSED(localName) | 98 | Q_CONST_UNUSED(localName) |
93 | 99 | ||
94 | if (qName.compare("data") == 0) { | 100 | if (qName.compare("data") == 0) { |
95 | m_state = Unknown; | 101 | m_state = Unknown; |
96 | } | 102 | } |
97 | 103 | ||
98 | return true; | 104 | return true; |
99 | } | 105 | } |
100 | 106 | ||
101 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) | 107 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) |
102 | { | 108 | { |
103 | if (m_state == InData) { | 109 | if (m_state == InData) { |
104 | QByteArray byteArray(ch.length() / 2); | 110 | QByteArray byteArray(ch.length() / 2); |
105 | 111 | ||
106 | for (int i = 0; i < (int)ch.length() / 2; i++) { | 112 | for (int i = 0; i < (int)ch.length() / 2; i++) { |
107 | char h = ch[2 * i].latin1(); | 113 | char h = ch[2 * i].latin1(); |
108 | char l = ch[2 * i + 1].latin1(); | 114 | char l = ch[2 * i + 1].latin1(); |
109 | uchar r = 0; | 115 | uchar r = 0; |
110 | 116 | ||
111 | if (h <= '9') { | 117 | if (h <= '9') { |
112 | r += h - '0'; | 118 | r += h - '0'; |
113 | } else { | 119 | } else { |
114 | r += h - 'a' + 10; | 120 | r += h - 'a' + 10; |
115 | } | 121 | } |
116 | 122 | ||
117 | r = r << 4; | 123 | r = r << 4; |
118 | 124 | ||
119 | if (l <= '9') { | 125 | if (l <= '9') { |
120 | r += l - '0'; | 126 | r += l - '0'; |
121 | } else { | 127 | } else { |
122 | r += l - 'a' + 10; | 128 | r += l - 'a' + 10; |
123 | } | 129 | } |
124 | 130 | ||
125 | byteArray[i] = r; | 131 | byteArray[i] = r; |
126 | } | 132 | } |
127 | 133 | ||
128 | if (m_dataLenght < ch.length() * 5) { | 134 | if (m_dataLenght < ch.length() * 5) { |
129 | m_dataLenght = ch.length() * 5; | 135 | m_dataLenght = ch.length() * 5; |
130 | } | 136 | } |
131 | 137 | ||
132 | QByteArray byteArrayUnzipped(m_dataLenght); | 138 | QByteArray byteArrayUnzipped(m_dataLenght); |
133 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); | 139 | ::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size()); |
134 | 140 | ||
135 | QImage image; | 141 | QImage image; |
136 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, "XPM"); | 142 | image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat); |
137 | 143 | ||
138 | QPixmap* pixmap = new QPixmap(image.width(), image.height()); | 144 | QPixmap* pixmap = new QPixmap(image.width(), image.height()); |
139 | pixmap->convertFromImage(image); | 145 | pixmap->convertFromImage(image); |
140 | m_pixmaps.append(pixmap); | 146 | m_pixmaps.append(pixmap); |
141 | } | 147 | } |
142 | 148 | ||
143 | return true; | 149 | return true; |
144 | } | 150 | } |
145 | 151 | ||
146 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) | 152 | DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name) |
147 | : QScrollView(parent, name) | 153 | : QScrollView(parent, name) |
148 | { | 154 | { |
149 | m_pDrawPad = drawPad; | 155 | m_pDrawPad = drawPad; |
150 | m_pages.setAutoDelete(true); | 156 | m_pages.setAutoDelete(true); |
151 | m_pageBackups.setAutoDelete(true); | 157 | m_pageBackups.setAutoDelete(true); |
152 | } | 158 | } |
153 | 159 | ||
154 | DrawPadCanvas::~DrawPadCanvas() | 160 | DrawPadCanvas::~DrawPadCanvas() |
155 | { | 161 | { |
156 | } | 162 | } |
157 | 163 | ||
158 | void DrawPadCanvas::load(QIODevice* ioDevice) | 164 | void DrawPadCanvas::load(QIODevice* ioDevice) |
159 | { | 165 | { |
160 | QTextStream textStream(ioDevice); | 166 | QTextStream textStream(ioDevice); |
161 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 167 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
162 | 168 | ||
163 | QXmlInputSource xmlInputSource(textStream); | 169 | QXmlInputSource xmlInputSource(textStream); |
164 | QXmlSimpleReader xmlSimpleReader; | 170 | QXmlSimpleReader xmlSimpleReader; |
165 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; | 171 | DrawPadCanvasXmlHandler drawPadCanvasXmlHandler; |
166 | 172 | ||
167 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); | 173 | xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler); |
168 | xmlSimpleReader.parse(xmlInputSource); | 174 | xmlSimpleReader.parse(xmlInputSource); |
169 | 175 | ||
170 | m_pages = drawPadCanvasXmlHandler.pixmaps(); | 176 | m_pages = drawPadCanvasXmlHandler.pixmaps(); |
171 | 177 | ||
172 | if (m_pages.isEmpty()) { | 178 | if (m_pages.isEmpty()) { |
173 | m_pages.append(new QPixmap(contentsRect().size())); | 179 | m_pages.append(new QPixmap(contentsRect().size())); |
174 | m_pages.current()->fill(Qt::white); | 180 | m_pages.current()->fill(Qt::white); |
175 | } | 181 | } |
176 | 182 | ||
177 | m_pageBackups.clear(); | 183 | m_pageBackups.clear(); |
178 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 184 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
179 | 185 | ||
180 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 186 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
181 | viewport()->update(); | 187 | viewport()->update(); |
182 | 188 | ||
183 | emit pagesChanged(); | 189 | emit pagesChanged(); |
184 | emit pageBackupsChanged(); | 190 | emit pageBackupsChanged(); |
185 | } | 191 | } |
186 | 192 | ||
187 | void DrawPadCanvas::initialPage() | 193 | void DrawPadCanvas::initialPage() |
188 | { | 194 | { |
189 | m_pages.append(new QPixmap(234, 233)); | 195 | m_pages.append(new QPixmap(234, 233)); |
190 | m_pages.current()->fill(Qt::white); | 196 | m_pages.current()->fill(Qt::white); |
191 | 197 | ||
192 | m_pageBackups.clear(); | 198 | m_pageBackups.clear(); |
193 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 199 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
194 | 200 | ||
195 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 201 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
196 | viewport()->update(); | 202 | viewport()->update(); |
197 | 203 | ||
198 | emit pagesChanged(); | 204 | emit pagesChanged(); |
199 | emit pageBackupsChanged(); | 205 | emit pageBackupsChanged(); |
200 | } | 206 | } |
201 | 207 | ||
202 | void DrawPadCanvas::save(QIODevice* ioDevice) | 208 | void DrawPadCanvas::save(QIODevice* ioDevice) |
203 | { | 209 | { |
204 | QTextStream textStream(ioDevice); | 210 | QTextStream textStream(ioDevice); |
205 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); | 211 | textStream.setCodec(QTextCodec::codecForName("UTF-8")); |
206 | 212 | ||
207 | textStream << "<drawpad>" << endl; | 213 | textStream << "<drawpad>" << endl; |
208 | textStream << " <images>" << endl; | 214 | textStream << " <images>" << endl; |
209 | 215 | ||
210 | QListIterator<QPixmap> bufferIterator(m_pages); | 216 | QListIterator<QPixmap> bufferIterator(m_pages); |
211 | 217 | ||
212 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 218 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
213 | textStream << " <image>" << endl; | 219 | textStream << " <image>" << endl; |
214 | 220 | ||
215 | QImage image = bufferIterator.current()->convertToImage(); | 221 | QImage image = bufferIterator.current()->convertToImage(); |
216 | QByteArray byteArray; | 222 | QByteArray byteArray; |
217 | QBuffer buffer(byteArray); | 223 | QBuffer buffer(byteArray); |
218 | QImageIO imageIO(&buffer, "XPM"); | 224 | QImageIO imageIO(&buffer, "PNG"); |
219 | 225 | ||
220 | buffer.open(IO_WriteOnly); | 226 | buffer.open(IO_WriteOnly); |
221 | imageIO.setImage(image); | 227 | imageIO.setImage(image); |
222 | imageIO.write(); | 228 | imageIO.write(); |
223 | buffer.close(); | 229 | buffer.close(); |
224 | 230 | ||
225 | ulong size = byteArray.size() * 2; | 231 | ulong size = byteArray.size() * 2; |
226 | QByteArray byteArrayZipped(size); | 232 | QByteArray byteArrayZipped(size); |
227 | ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size()); | 233 | ::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size()); |
228 | 234 | ||
229 | textStream << " <data length=\"" << byteArray.size() << "\">"; | 235 | textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">"; |
230 | 236 | ||
231 | static const char hexchars[] = "0123456789abcdef"; | 237 | static const char hexchars[] = "0123456789abcdef"; |
232 | 238 | ||
233 | for (int i = 0; i < (int)size; i++ ) { | 239 | for (int i = 0; i < (int)size; i++ ) { |
234 | uchar s = (uchar)byteArrayZipped[i]; | 240 | uchar s = (uchar)byteArrayZipped[i]; |
235 | textStream << hexchars[s >> 4]; | 241 | textStream << hexchars[s >> 4]; |
236 | textStream << hexchars[s & 0x0f]; | 242 | textStream << hexchars[s & 0x0f]; |
237 | } | 243 | } |
238 | 244 | ||
239 | textStream << "</data>" << endl; | 245 | textStream << "</data>" << endl; |
240 | textStream << " </image>" << endl; | 246 | textStream << " </image>" << endl; |
241 | } | 247 | } |
242 | 248 | ||
243 | textStream << " </images>" << endl; | 249 | textStream << " </images>" << endl; |
244 | textStream << "</drawpad>"; | 250 | textStream << "</drawpad>"; |
245 | } | 251 | } |
246 | 252 | ||
247 | void DrawPadCanvas::importPage(const QString& fileName) | 253 | void DrawPadCanvas::importPage(const QString& fileName) |
248 | { | 254 | { |
249 | QPixmap* importedPixmap = new QPixmap(); | 255 | QPixmap* importedPixmap = new QPixmap(); |
250 | 256 | ||
251 | importedPixmap->load(fileName); | 257 | importedPixmap->load(fileName); |
252 | m_pages.insert(m_pages.at() + 1, importedPixmap); | 258 | m_pages.insert(m_pages.at() + 1, importedPixmap); |
253 | 259 | ||
254 | m_pageBackups.clear(); | 260 | m_pageBackups.clear(); |
255 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 261 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
256 | 262 | ||
257 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 263 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
258 | viewport()->update(); | 264 | viewport()->update(); |
259 | 265 | ||
260 | emit pagesChanged(); | 266 | emit pagesChanged(); |
261 | emit pageBackupsChanged(); | 267 | emit pageBackupsChanged(); |
262 | } | 268 | } |
263 | 269 | ||
264 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) | 270 | void DrawPadCanvas::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format) |
265 | { | 271 | { |
266 | if (fromPage == toPage) { | 272 | if (fromPage == toPage) { |
267 | DocLnk docLnk; | 273 | DocLnk docLnk; |
268 | MimeType mimeType(format); | 274 | MimeType mimeType(format); |
269 | 275 | ||
270 | docLnk.setName(name); | 276 | docLnk.setName(name); |
271 | docLnk.setType(mimeType.id()); | 277 | docLnk.setType(mimeType.id()); |
272 | 278 | ||
273 | FileManager fileManager; | 279 | FileManager fileManager; |
274 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 280 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
275 | QImageIO imageIO(ioDevice, format); | 281 | QImageIO imageIO(ioDevice, format); |
276 | 282 | ||
277 | QImage image = m_pages.current()->convertToImage(); | 283 | QImage image = m_pages.current()->convertToImage(); |
278 | imageIO.setImage(image); | 284 | imageIO.setImage(image); |
279 | imageIO.write(); | 285 | imageIO.write(); |
280 | delete ioDevice; | 286 | delete ioDevice; |
281 | } else { | 287 | } else { |
282 | for (uint i = fromPage; i <= toPage; i++) { | 288 | for (uint i = fromPage; i <= toPage; i++) { |
283 | DocLnk docLnk; | 289 | DocLnk docLnk; |
284 | MimeType mimeType(format); | 290 | MimeType mimeType(format); |
285 | 291 | ||
286 | docLnk.setName(name + QString::number(i)); | 292 | docLnk.setName(name + QString::number(i)); |
287 | docLnk.setType(mimeType.id()); | 293 | docLnk.setType(mimeType.id()); |
288 | 294 | ||
289 | FileManager fileManager; | 295 | FileManager fileManager; |
290 | QIODevice* ioDevice = fileManager.saveFile(docLnk); | 296 | QIODevice* ioDevice = fileManager.saveFile(docLnk); |
291 | QImageIO imageIO(ioDevice, format); | 297 | QImageIO imageIO(ioDevice, format); |
292 | 298 | ||
293 | QImage image = m_pages.at(i - 1)->convertToImage(); | 299 | QImage image = m_pages.at(i - 1)->convertToImage(); |
294 | imageIO.setImage(image); | 300 | imageIO.setImage(image); |
295 | imageIO.write(); | 301 | imageIO.write(); |
296 | delete ioDevice; | 302 | delete ioDevice; |
297 | } | 303 | } |
298 | } | 304 | } |
299 | } | 305 | } |
300 | 306 | ||
301 | QPixmap* DrawPadCanvas::currentPage() | 307 | QPixmap* DrawPadCanvas::currentPage() |
302 | { | 308 | { |
303 | return m_pages.current(); | 309 | return m_pages.current(); |
304 | } | 310 | } |
305 | 311 | ||
306 | uint DrawPadCanvas::pagePosition() | 312 | uint DrawPadCanvas::pagePosition() |
307 | { | 313 | { |
308 | return (m_pages.at() + 1); | 314 | return (m_pages.at() + 1); |
309 | } | 315 | } |
310 | 316 | ||
311 | uint DrawPadCanvas::pageCount() | 317 | uint DrawPadCanvas::pageCount() |
312 | { | 318 | { |
313 | return m_pages.count(); | 319 | return m_pages.count(); |
314 | } | 320 | } |
315 | 321 | ||
316 | void DrawPadCanvas::deleteAll() | 322 | void DrawPadCanvas::deleteAll() |
317 | { | 323 | { |
318 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 324 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), |
319 | QMessageBox::Information, QMessageBox::Yes, | 325 | QMessageBox::Information, QMessageBox::Yes, |
320 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 326 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
321 | QMessageBox::NoButton, this); | 327 | QMessageBox::NoButton, this); |
322 | 328 | ||
323 | if (messageBox.exec() == QMessageBox::Yes) { | 329 | if (messageBox.exec() == QMessageBox::Yes) { |
324 | m_pages.clear(); | 330 | m_pages.clear(); |
325 | 331 | ||
326 | m_pages.append(new QPixmap(contentsRect().size())); | 332 | m_pages.append(new QPixmap(contentsRect().size())); |
327 | m_pages.current()->fill(Qt::white); | 333 | m_pages.current()->fill(Qt::white); |
328 | 334 | ||
329 | m_pageBackups.clear(); | 335 | m_pageBackups.clear(); |
330 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 336 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
331 | 337 | ||
332 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 338 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
333 | viewport()->update(); | 339 | viewport()->update(); |
334 | 340 | ||
335 | emit pagesChanged(); | 341 | emit pagesChanged(); |
336 | emit pageBackupsChanged(); | 342 | emit pageBackupsChanged(); |
337 | } | 343 | } |
338 | } | 344 | } |
339 | 345 | ||
340 | void DrawPadCanvas::newPage() | 346 | void DrawPadCanvas::newPage() |
341 | { | 347 | { |
342 | QRect rect = contentsRect(); | 348 | QRect rect = contentsRect(); |
343 | 349 | ||
344 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), | 350 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), |
345 | m_pDrawPad->brush().color(), this); | 351 | m_pDrawPad->brush().color(), this); |
346 | 352 | ||
347 | if (newPageDialog.exec() == QDialog::Accepted) { | 353 | if (newPageDialog.exec() == QDialog::Accepted) { |
348 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), | 354 | m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(), |
349 | newPageDialog.selectedHeight())); | 355 | newPageDialog.selectedHeight())); |
350 | m_pages.current()->fill(newPageDialog.selectedColor()); | 356 | m_pages.current()->fill(newPageDialog.selectedColor()); |
351 | 357 | ||
352 | m_pageBackups.clear(); | 358 | m_pageBackups.clear(); |
353 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 359 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
354 | 360 | ||
355 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 361 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
356 | viewport()->update(); | 362 | viewport()->update(); |
357 | 363 | ||
358 | emit pagesChanged(); | 364 | emit pagesChanged(); |
359 | emit pageBackupsChanged(); | 365 | emit pageBackupsChanged(); |
360 | } | 366 | } |
361 | } | 367 | } |
362 | 368 | ||
363 | void DrawPadCanvas::clearPage() | 369 | void DrawPadCanvas::clearPage() |
364 | { | 370 | { |
365 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 371 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), |
366 | QMessageBox::Information, QMessageBox::Yes, | 372 | QMessageBox::Information, QMessageBox::Yes, |
367 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 373 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
368 | QMessageBox::NoButton, this); | 374 | QMessageBox::NoButton, this); |
369 | 375 | ||
370 | if (messageBox.exec() == QMessageBox::Yes) { | 376 | if (messageBox.exec() == QMessageBox::Yes) { |
371 | m_pages.current()->fill(Qt::white); | 377 | m_pages.current()->fill(Qt::white); |
372 | 378 | ||
373 | viewport()->update(); | 379 | viewport()->update(); |
374 | } | 380 | } |
375 | } | 381 | } |
376 | 382 | ||
377 | void DrawPadCanvas::deletePage() | 383 | void DrawPadCanvas::deletePage() |
378 | { | 384 | { |
379 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 385 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), |
380 | QMessageBox::Information, QMessageBox::Yes, | 386 | QMessageBox::Information, QMessageBox::Yes, |
381 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | 387 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, |
382 | QMessageBox::NoButton, this); | 388 | QMessageBox::NoButton, this); |
383 | 389 | ||
384 | if (messageBox.exec() == QMessageBox::Yes) { | 390 | if (messageBox.exec() == QMessageBox::Yes) { |
385 | m_pages.remove(m_pages.current()); | 391 | m_pages.remove(m_pages.current()); |
386 | 392 | ||
387 | if (m_pages.isEmpty()) { | 393 | if (m_pages.isEmpty()) { |
388 | m_pages.append(new QPixmap(contentsRect().size())); | 394 | m_pages.append(new QPixmap(contentsRect().size())); |
389 | m_pages.current()->fill(Qt::white); | 395 | m_pages.current()->fill(Qt::white); |
390 | } | 396 | } |
391 | 397 | ||
392 | m_pageBackups.clear(); | 398 | m_pageBackups.clear(); |
393 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 399 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
394 | 400 | ||
395 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 401 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
396 | viewport()->update(); | 402 | viewport()->update(); |
397 | 403 | ||
398 | emit pagesChanged(); | 404 | emit pagesChanged(); |
399 | emit pageBackupsChanged(); | 405 | emit pageBackupsChanged(); |
400 | } | 406 | } |
401 | } | 407 | } |
402 | 408 | ||
403 | bool DrawPadCanvas::undoEnabled() | 409 | bool DrawPadCanvas::undoEnabled() |
404 | { | 410 | { |
405 | return (m_pageBackups.current() != m_pageBackups.getFirst()); | 411 | return (m_pageBackups.current() != m_pageBackups.getFirst()); |
406 | } | 412 | } |
407 | 413 | ||
408 | bool DrawPadCanvas::redoEnabled() | 414 | bool DrawPadCanvas::redoEnabled() |
409 | { | 415 | { |
410 | return (m_pageBackups.current() != m_pageBackups.getLast()); | 416 | return (m_pageBackups.current() != m_pageBackups.getLast()); |
411 | } | 417 | } |
412 | 418 | ||
413 | bool DrawPadCanvas::goPreviousPageEnabled() | 419 | bool DrawPadCanvas::goPreviousPageEnabled() |
414 | { | 420 | { |
415 | return (m_pages.current() != m_pages.getFirst()); | 421 | return (m_pages.current() != m_pages.getFirst()); |
416 | } | 422 | } |
417 | 423 | ||
418 | bool DrawPadCanvas::goNextPageEnabled() | 424 | bool DrawPadCanvas::goNextPageEnabled() |
419 | { | 425 | { |
420 | return (m_pages.current() != m_pages.getLast()); | 426 | return (m_pages.current() != m_pages.getLast()); |
421 | } | 427 | } |
422 | 428 | ||
423 | void DrawPadCanvas::undo() | 429 | void DrawPadCanvas::undo() |
424 | { | 430 | { |
425 | *(m_pages.current()) = *(m_pageBackups.prev()); | 431 | *(m_pages.current()) = *(m_pageBackups.prev()); |
426 | 432 | ||
427 | viewport()->update(); | 433 | viewport()->update(); |
428 | 434 | ||
429 | emit pageBackupsChanged(); | 435 | emit pageBackupsChanged(); |
430 | } | 436 | } |
431 | 437 | ||
432 | void DrawPadCanvas::redo() | 438 | void DrawPadCanvas::redo() |
433 | { | 439 | { |
434 | *(m_pages.current()) = *(m_pageBackups.next()); | 440 | *(m_pages.current()) = *(m_pageBackups.next()); |
435 | 441 | ||
436 | viewport()->update(); | 442 | viewport()->update(); |
437 | 443 | ||
438 | emit pageBackupsChanged(); | 444 | emit pageBackupsChanged(); |
439 | } | 445 | } |
440 | 446 | ||
441 | void DrawPadCanvas::goFirstPage() | 447 | void DrawPadCanvas::goFirstPage() |
442 | { | 448 | { |
443 | m_pages.first(); | 449 | m_pages.first(); |
444 | m_pageBackups.clear(); | 450 | m_pageBackups.clear(); |
445 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 451 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
446 | 452 | ||
447 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 453 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
448 | viewport()->update(); | 454 | viewport()->update(); |
449 | 455 | ||
450 | emit pagesChanged(); | 456 | emit pagesChanged(); |
451 | emit pageBackupsChanged(); | 457 | emit pageBackupsChanged(); |
452 | } | 458 | } |
453 | 459 | ||
454 | void DrawPadCanvas::goPreviousPage() | 460 | void DrawPadCanvas::goPreviousPage() |
455 | { | 461 | { |
456 | m_pages.prev(); | 462 | m_pages.prev(); |
457 | m_pageBackups.clear(); | 463 | m_pageBackups.clear(); |
458 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 464 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
459 | 465 | ||
460 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 466 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
461 | viewport()->update(); | 467 | viewport()->update(); |
462 | 468 | ||
463 | emit pagesChanged(); | 469 | emit pagesChanged(); |
464 | emit pageBackupsChanged(); | 470 | emit pageBackupsChanged(); |
465 | } | 471 | } |
466 | 472 | ||
467 | void DrawPadCanvas::goNextPage() | 473 | void DrawPadCanvas::goNextPage() |
468 | { | 474 | { |
469 | m_pages.next(); | 475 | m_pages.next(); |
470 | m_pageBackups.clear(); | 476 | m_pageBackups.clear(); |
471 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 477 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
472 | 478 | ||
473 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 479 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
474 | viewport()->update(); | 480 | viewport()->update(); |
475 | 481 | ||
476 | emit pagesChanged(); | 482 | emit pagesChanged(); |
477 | emit pageBackupsChanged(); | 483 | emit pageBackupsChanged(); |
478 | } | 484 | } |
479 | 485 | ||
480 | void DrawPadCanvas::goLastPage() | 486 | void DrawPadCanvas::goLastPage() |
481 | { | 487 | { |
482 | m_pages.last(); | 488 | m_pages.last(); |
483 | m_pageBackups.clear(); | 489 | m_pageBackups.clear(); |
484 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 490 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
485 | 491 | ||
486 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 492 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
487 | viewport()->update(); | 493 | viewport()->update(); |
488 | 494 | ||
489 | emit pagesChanged(); | 495 | emit pagesChanged(); |
490 | emit pageBackupsChanged(); | 496 | emit pageBackupsChanged(); |
491 | } | 497 | } |
492 | 498 | ||
493 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) | 499 | void DrawPadCanvas::contentsMousePressEvent(QMouseEvent* e) |
494 | { | 500 | { |
495 | m_pDrawPad->tool()->mousePressEvent(e); | 501 | m_pDrawPad->tool()->mousePressEvent(e); |
496 | } | 502 | } |
497 | 503 | ||
498 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) | 504 | void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e) |
499 | { | 505 | { |
500 | m_pDrawPad->tool()->mouseReleaseEvent(e); | 506 | m_pDrawPad->tool()->mouseReleaseEvent(e); |
501 | 507 | ||
502 | QPixmap* currentBackup = m_pageBackups.current(); | 508 | QPixmap* currentBackup = m_pageBackups.current(); |
503 | while (m_pageBackups.last() != currentBackup) { | 509 | while (m_pageBackups.last() != currentBackup) { |
504 | m_pageBackups.removeLast(); | 510 | m_pageBackups.removeLast(); |
505 | } | 511 | } |
506 | 512 | ||
507 | while (m_pageBackups.count() >= (5 + 1)) { | 513 | while (m_pageBackups.count() >= (5 + 1)) { |
508 | m_pageBackups.removeFirst(); | 514 | m_pageBackups.removeFirst(); |
509 | } | 515 | } |
510 | 516 | ||
511 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); | 517 | m_pageBackups.append(new QPixmap(*(m_pages.current()))); |
512 | 518 | ||
513 | emit pageBackupsChanged(); | 519 | emit pageBackupsChanged(); |
514 | } | 520 | } |
515 | 521 | ||
516 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) | 522 | void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e) |
517 | { | 523 | { |
518 | m_pDrawPad->tool()->mouseMoveEvent(e); | 524 | m_pDrawPad->tool()->mouseMoveEvent(e); |
519 | } | 525 | } |
520 | 526 | ||
521 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 527 | void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
522 | { | 528 | { |
523 | QRect clipRect(cx, cy, cw, ch); | 529 | QRect clipRect(cx, cy, cw, ch); |
524 | 530 | ||
525 | p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect); | 531 | p->drawPixmap(clipRect.topLeft(), *(m_pages.current()), clipRect); |
526 | } | 532 | } |
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp index b1b26ef..5c31978 100644 --- a/noncore/graphics/drawpad/newpagedialog.cpp +++ b/noncore/graphics/drawpad/newpagedialog.cpp | |||
@@ -1,102 +1,102 @@ | |||
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> | 17 | #include <qgroupbox.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qradiobutton.h> | 20 | #include <qradiobutton.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | 22 | ||
23 | NewPageDialog::NewPageDialog(uint width, uint height, const QColor& foregroundColor, | 23 | NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor, |
24 | const QColor& backgroundColor, QWidget* parent, const char* name) | 24 | const QColor& brushColor, QWidget* parent, const char* name) |
25 | : QDialog(parent, name, true) | 25 | : QDialog(parent, name, true) |
26 | { | 26 | { |
27 | setCaption(tr("New Page")); | 27 | setCaption(tr("New Page")); |
28 | 28 | ||
29 | m_foregroundColor = foregroundColor; | 29 | m_penColor = penColor; |
30 | m_backgroundColor = backgroundColor; | 30 | m_brushColor = brushColor; |
31 | 31 | ||
32 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Page Size"), this); | 32 | QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Page Size"), this); |
33 | 33 | ||
34 | QLabel* widthLabel = new QLabel(tr("Width :"), sizeGroupBox); | 34 | QLabel* widthLabel = new QLabel(tr("Width :"), sizeGroupBox); |
35 | QLabel* heightLabel = new QLabel(tr("Height :"), sizeGroupBox); | 35 | QLabel* heightLabel = new QLabel(tr("Height :"), sizeGroupBox); |
36 | 36 | ||
37 | m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); | 37 | m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); |
38 | m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); | 38 | m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox); |
39 | 39 | ||
40 | m_pWidthSpinBox->setValue(width); | 40 | m_pWidthSpinBox->setValue(width); |
41 | m_pHeightSpinBox->setValue(height); | 41 | m_pHeightSpinBox->setValue(height); |
42 | 42 | ||
43 | m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Contents"), this); | 43 | m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this); |
44 | 44 | ||
45 | QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup); | 45 | QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup); |
46 | QRadioButton* foregroundColorRadioButton = new QRadioButton(tr("Foreground Color"), m_pContentButtonGroup); | 46 | QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup); |
47 | QRadioButton* backgroundColorRadioButton = new QRadioButton(tr("Background Color"), m_pContentButtonGroup); | 47 | QRadioButton* brushColorRadioButton = new QRadioButton(tr("Brush Color"), m_pContentButtonGroup); |
48 | 48 | ||
49 | m_pContentButtonGroup->setButton(0); | 49 | m_pContentButtonGroup->setButton(0); |
50 | 50 | ||
51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 51 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
52 | sizeGroupBox->layout()->setSpacing(4); | 52 | sizeGroupBox->layout()->setSpacing(4); |
53 | m_pContentButtonGroup->layout()->setSpacing(4); | 53 | m_pContentButtonGroup->layout()->setSpacing(4); |
54 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); | 54 | QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); |
55 | QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout()); | 55 | QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout()); |
56 | 56 | ||
57 | sizeLayout->addWidget(widthLabel, 0, 0); | 57 | sizeLayout->addWidget(widthLabel, 0, 0); |
58 | sizeLayout->addWidget(heightLabel, 1, 0); | 58 | sizeLayout->addWidget(heightLabel, 1, 0); |
59 | sizeLayout->addWidget(m_pWidthSpinBox, 0, 1); | 59 | sizeLayout->addWidget(m_pWidthSpinBox, 0, 1); |
60 | sizeLayout->addWidget(m_pHeightSpinBox, 1, 1); | 60 | sizeLayout->addWidget(m_pHeightSpinBox, 1, 1); |
61 | 61 | ||
62 | sizeLayout->setColStretch(1, 1); | 62 | sizeLayout->setColStretch(1, 1); |
63 | 63 | ||
64 | contentLayout->addWidget(whiteColorRadioButton); | 64 | contentLayout->addWidget(whiteColorRadioButton); |
65 | contentLayout->addWidget(foregroundColorRadioButton); | 65 | contentLayout->addWidget(penColorRadioButton); |
66 | contentLayout->addWidget(backgroundColorRadioButton); | 66 | contentLayout->addWidget(brushColorRadioButton); |
67 | 67 | ||
68 | mainLayout->addWidget(sizeGroupBox); | 68 | mainLayout->addWidget(sizeGroupBox); |
69 | mainLayout->addWidget(m_pContentButtonGroup); | 69 | mainLayout->addWidget(m_pContentButtonGroup); |
70 | } | 70 | } |
71 | 71 | ||
72 | NewPageDialog::~NewPageDialog() | 72 | NewPageDialog::~NewPageDialog() |
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | uint NewPageDialog::selectedWidth() | 76 | uint NewPageDialog::selectedWidth() |
77 | { | 77 | { |
78 | return (m_pWidthSpinBox->value()); | 78 | return (m_pWidthSpinBox->value()); |
79 | } | 79 | } |
80 | 80 | ||
81 | uint NewPageDialog::selectedHeight() | 81 | uint NewPageDialog::selectedHeight() |
82 | { | 82 | { |
83 | return (m_pHeightSpinBox->value()); | 83 | return (m_pHeightSpinBox->value()); |
84 | } | 84 | } |
85 | 85 | ||
86 | const QColor& NewPageDialog::selectedColor() | 86 | const QColor& NewPageDialog::selectedColor() |
87 | { | 87 | { |
88 | switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) { | 88 | switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) { |
89 | case 0: | 89 | case 0: |
90 | return (Qt::white); | 90 | return (Qt::white); |
91 | break; | 91 | break; |
92 | case 1: | 92 | case 1: |
93 | return (m_foregroundColor); | 93 | return (m_penColor); |
94 | break; | 94 | break; |
95 | case 2: | 95 | case 2: |
96 | return (m_backgroundColor); | 96 | return (m_brushColor); |
97 | break; | 97 | break; |
98 | default: | 98 | default: |
99 | return (Qt::white); | 99 | return (Qt::white); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | } | 102 | } |
diff --git a/noncore/graphics/drawpad/newpagedialog.h b/noncore/graphics/drawpad/newpagedialog.h index f418340..d680394 100644 --- a/noncore/graphics/drawpad/newpagedialog.h +++ b/noncore/graphics/drawpad/newpagedialog.h | |||
@@ -1,45 +1,45 @@ | |||
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 | #ifndef NEWPAGEDIALOG_H | 14 | #ifndef NEWPAGEDIALOG_H |
15 | #define NEWPAGEDIALOG_H | 15 | #define NEWPAGEDIALOG_H |
16 | 16 | ||
17 | #include <qdialog.h> | 17 | #include <qdialog.h> |
18 | 18 | ||
19 | class QButtonGroup; | 19 | class QButtonGroup; |
20 | class QSpinBox; | 20 | class QSpinBox; |
21 | 21 | ||
22 | class NewPageDialog : public QDialog | 22 | class NewPageDialog : public QDialog |
23 | { | 23 | { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | 25 | ||
26 | public: | 26 | public: |
27 | NewPageDialog(uint width, uint height, const QColor& foregroundColor, | 27 | NewPageDialog(uint width, uint height, const QColor& foregroundColor, |
28 | const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0); | 28 | const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0); |
29 | ~NewPageDialog(); | 29 | ~NewPageDialog(); |
30 | 30 | ||
31 | uint selectedWidth(); | 31 | uint selectedWidth(); |
32 | uint selectedHeight(); | 32 | uint selectedHeight(); |
33 | const QColor& selectedColor(); | 33 | const QColor& selectedColor(); |
34 | 34 | ||
35 | private: | 35 | private: |
36 | QSpinBox* m_pWidthSpinBox; | 36 | QSpinBox* m_pWidthSpinBox; |
37 | QSpinBox* m_pHeightSpinBox; | 37 | QSpinBox* m_pHeightSpinBox; |
38 | 38 | ||
39 | QColor m_foregroundColor; | 39 | QColor m_penColor; |
40 | QColor m_backgroundColor; | 40 | QColor m_brushColor; |
41 | 41 | ||
42 | QButtonGroup* m_pContentButtonGroup; | 42 | QButtonGroup* m_pContentButtonGroup; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | #endif // NEWPAGEDIALOG_H | 45 | #endif // NEWPAGEDIALOG_H |