-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 | |||
@@ -132,63 +132,65 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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 | ||
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 | |||
@@ -33,74 +33,80 @@ | |||
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++) { |
@@ -112,49 +118,49 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
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); |
@@ -194,60 +200,60 @@ void DrawPadCanvas::initialPage() | |||
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 | ||
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 | |||
@@ -15,31 +15,31 @@ | |||
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 |