author | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
commit | 531bb3c03f5576523a3c7ccecc714362507f69e1 (patch) (unidiff) | |
tree | 8bdda021e3ddd110ca75df06a1f6a5fbf0429a6c /noncore | |
parent | 527c3a7240bee3fe1d7c000aecc8ff0a01219fdd (diff) | |
download | opie-531bb3c03f5576523a3c7ccecc714362507f69e1.zip opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.gz opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.bz2 |
Add application config
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 39 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 1 |
4 files changed, 54 insertions, 5 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index b29f5ba..4eb47a5 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -25,24 +25,25 @@ | |||
25 | #include "newpagedialog.h" | 25 | #include "newpagedialog.h" |
26 | #include "page.h" | 26 | #include "page.h" |
27 | #include "pageinformationdialog.h" | 27 | #include "pageinformationdialog.h" |
28 | #include "pointtool.h" | 28 | #include "pointtool.h" |
29 | #include "rectangletool.h" | 29 | #include "rectangletool.h" |
30 | #include "texttool.h" | 30 | #include "texttool.h" |
31 | #include "thumbnailview.h" | 31 | #include "thumbnailview.h" |
32 | 32 | ||
33 | #include <opie/colordialog.h> | 33 | #include <opie/colordialog.h> |
34 | #include <opie/colorpopupmenu.h> | 34 | #include <opie/colorpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | ||
37 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
38 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | 42 | ||
42 | #include <qaction.h> | 43 | #include <qaction.h> |
43 | #include <qfile.h> | 44 | #include <qfile.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qpainter.h> | 46 | #include <qpainter.h> |
46 | #include <qspinbox.h> | 47 | #include <qspinbox.h> |
47 | #include <qtoolbutton.h> | 48 | #include <qtoolbutton.h> |
48 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
@@ -219,30 +220,30 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
219 | setRectangleTool(); | 220 | setRectangleTool(); |
220 | setEllipseTool(); | 221 | setEllipseTool(); |
221 | setPointTool(); | 222 | setPointTool(); |
222 | 223 | ||
223 | emptyToolBar = new QPEToolBar(this); | 224 | emptyToolBar = new QPEToolBar(this); |
224 | emptyToolBar->setHorizontalStretchable(true); | 225 | emptyToolBar->setHorizontalStretchable(true); |
225 | emptyToolBar->addSeparator(); | 226 | emptyToolBar->addSeparator(); |
226 | 227 | ||
227 | // init draw parameters toolbar | 228 | // init draw parameters toolbar |
228 | 229 | ||
229 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); | 230 | QPEToolBar* drawParametersToolBar = new QPEToolBar(this); |
230 | 231 | ||
231 | QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); | 232 | m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar); |
232 | connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); | 233 | connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int))); |
233 | 234 | ||
234 | QToolTip::add(penWidthSpinBox, tr("Pen Width")); | 235 | QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width")); |
235 | penWidthSpinBox->setValue(1); | 236 | m_pPenWidthSpinBox->setValue(1); |
236 | penWidthSpinBox->setFocusPolicy(QWidget::NoFocus); | 237 | m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus); |
237 | 238 | ||
238 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); | 239 | m_pPenColorToolButton = new QToolButton(drawParametersToolBar); |
239 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); | 240 | m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png")); |
240 | 241 | ||
241 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); | 242 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); |
242 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); | 243 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); |
243 | 244 | ||
244 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); | 245 | QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); |
245 | m_pPenColorToolButton->setPopup(penColorPopupMenu); | 246 | m_pPenColorToolButton->setPopup(penColorPopupMenu); |
246 | m_pPenColorToolButton->setPopupDelay(0); | 247 | m_pPenColorToolButton->setPopupDelay(0); |
247 | 248 | ||
248 | changePenColor(Qt::black); | 249 | changePenColor(Qt::black); |
@@ -260,28 +261,32 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
260 | changeBrushColor(Qt::white); | 261 | changeBrushColor(Qt::white); |
261 | 262 | ||
262 | // init pages | 263 | // init pages |
263 | 264 | ||
264 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 265 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
265 | 266 | ||
266 | if (file.open(IO_ReadOnly)) { | 267 | if (file.open(IO_ReadOnly)) { |
267 | m_pDrawPadCanvas->load(&file); | 268 | m_pDrawPadCanvas->load(&file); |
268 | file.close(); | 269 | file.close(); |
269 | } else { | 270 | } else { |
270 | m_pDrawPadCanvas->initialPage(); | 271 | m_pDrawPadCanvas->initialPage(); |
271 | } | 272 | } |
273 | |||
274 | loadConfig(); | ||
272 | } | 275 | } |
273 | 276 | ||
274 | DrawPad::~DrawPad() | 277 | DrawPad::~DrawPad() |
275 | { | 278 | { |
279 | saveConfig(); | ||
280 | |||
276 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); | 281 | QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); |
277 | 282 | ||
278 | if (file.open(IO_WriteOnly)) { | 283 | if (file.open(IO_WriteOnly)) { |
279 | m_pDrawPadCanvas->save(&file); | 284 | m_pDrawPadCanvas->save(&file); |
280 | file.close(); | 285 | file.close(); |
281 | } | 286 | } |
282 | } | 287 | } |
283 | 288 | ||
284 | bool DrawPad::antiAliasing() | 289 | bool DrawPad::antiAliasing() |
285 | { | 290 | { |
286 | return (m_pAntiAliasingAction->isOn()); | 291 | return (m_pAntiAliasingAction->isOn()); |
287 | } | 292 | } |
@@ -610,12 +615,36 @@ void DrawPad::thumbnailView() | |||
610 | thumbnailView.showMaximized(); | 615 | thumbnailView.showMaximized(); |
611 | thumbnailView.exec(); | 616 | thumbnailView.exec(); |
612 | } | 617 | } |
613 | 618 | ||
614 | void DrawPad::pageInformation() | 619 | void DrawPad::pageInformation() |
615 | { | 620 | { |
616 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 621 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
617 | 622 | ||
618 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 623 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
619 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | 624 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); |
620 | } | 625 | } |
621 | } | 626 | } |
627 | |||
628 | void DrawPad::loadConfig() | ||
629 | { | ||
630 | Config config("drawpad"); | ||
631 | config.setGroup("General"); | ||
632 | |||
633 | m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false)); | ||
634 | m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1)); | ||
635 | changePenColor(QColor(config.readEntry("PenColor", Qt::black.name()))); | ||
636 | changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name()))); | ||
637 | m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1)); | ||
638 | } | ||
639 | |||
640 | void DrawPad::saveConfig() | ||
641 | { | ||
642 | Config config("drawpad"); | ||
643 | config.setGroup("General"); | ||
644 | |||
645 | config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition()); | ||
646 | config.writeEntry("AntiAliasing", antiAliasing()); | ||
647 | config.writeEntry("PenWidth", (int)m_pen.width()); | ||
648 | config.writeEntry("PenColor", m_pen.color().name()); | ||
649 | config.writeEntry("BrushColor", m_brush.color().name()); | ||
650 | } | ||
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h index 8e29c61..c57606c 100644 --- a/noncore/graphics/drawpad/drawpad.h +++ b/noncore/graphics/drawpad/drawpad.h | |||
@@ -14,24 +14,25 @@ | |||
14 | #ifndef DRAWPAD_H | 14 | #ifndef DRAWPAD_H |
15 | #define DRAWPAD_H | 15 | #define DRAWPAD_H |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | 18 | ||
19 | #include <qpen.h> | 19 | #include <qpen.h> |
20 | 20 | ||
21 | class DrawPadCanvas; | 21 | class DrawPadCanvas; |
22 | class Tool; | 22 | class Tool; |
23 | 23 | ||
24 | class QAction; | 24 | class QAction; |
25 | class QColor; | 25 | class QColor; |
26 | class QSpinBox; | ||
26 | class QToolButton; | 27 | class QToolButton; |
27 | class QWidgetStack; | 28 | class QWidgetStack; |
28 | 29 | ||
29 | class DrawPad : public QMainWindow | 30 | class DrawPad : public QMainWindow |
30 | { | 31 | { |
31 | Q_OBJECT | 32 | Q_OBJECT |
32 | 33 | ||
33 | public: | 34 | public: |
34 | DrawPad(QWidget* parent = 0, const char* name = 0); | 35 | DrawPad(QWidget* parent = 0, const char* name = 0); |
35 | ~DrawPad(); | 36 | ~DrawPad(); |
36 | 37 | ||
37 | Tool* tool() { return m_pTool; } | 38 | Tool* tool() { return m_pTool; } |
@@ -61,24 +62,27 @@ private slots: | |||
61 | 62 | ||
62 | void updateUndoRedoToolButtons(); | 63 | void updateUndoRedoToolButtons(); |
63 | void updateNavigationToolButtons(); | 64 | void updateNavigationToolButtons(); |
64 | void updateCaption(); | 65 | void updateCaption(); |
65 | 66 | ||
66 | void deleteAll(); | 67 | void deleteAll(); |
67 | void importPage(); | 68 | void importPage(); |
68 | void exportPage(); | 69 | void exportPage(); |
69 | void thumbnailView(); | 70 | void thumbnailView(); |
70 | void pageInformation(); | 71 | void pageInformation(); |
71 | 72 | ||
72 | private: | 73 | private: |
74 | void loadConfig(); | ||
75 | void saveConfig(); | ||
76 | |||
73 | DrawPadCanvas* m_pDrawPadCanvas; | 77 | DrawPadCanvas* m_pDrawPadCanvas; |
74 | 78 | ||
75 | Tool* m_pTool; | 79 | Tool* m_pTool; |
76 | QPen m_pen; | 80 | QPen m_pen; |
77 | QBrush m_brush; | 81 | QBrush m_brush; |
78 | 82 | ||
79 | QAction* m_pAntiAliasingAction; | 83 | QAction* m_pAntiAliasingAction; |
80 | 84 | ||
81 | QAction* m_pUndoAction; | 85 | QAction* m_pUndoAction; |
82 | QAction* m_pRedoAction; | 86 | QAction* m_pRedoAction; |
83 | 87 | ||
84 | QAction* m_pFirstPageAction; | 88 | QAction* m_pFirstPageAction; |
@@ -92,15 +96,17 @@ private: | |||
92 | QAction* m_pFilledRectangleToolAction; | 96 | QAction* m_pFilledRectangleToolAction; |
93 | QAction* m_pEllipseToolAction; | 97 | QAction* m_pEllipseToolAction; |
94 | QAction* m_pFilledEllipseToolAction; | 98 | QAction* m_pFilledEllipseToolAction; |
95 | QAction* m_pTextToolAction; | 99 | QAction* m_pTextToolAction; |
96 | QAction* m_pFillToolAction; | 100 | QAction* m_pFillToolAction; |
97 | QAction* m_pEraseToolAction; | 101 | QAction* m_pEraseToolAction; |
98 | 102 | ||
99 | QToolButton* m_pLineToolButton; | 103 | QToolButton* m_pLineToolButton; |
100 | QToolButton* m_pRectangleToolButton; | 104 | QToolButton* m_pRectangleToolButton; |
101 | QToolButton* m_pEllipseToolButton; | 105 | QToolButton* m_pEllipseToolButton; |
102 | QToolButton* m_pPenColorToolButton; | 106 | QToolButton* m_pPenColorToolButton; |
103 | QToolButton* m_pBrushColorToolButton; | 107 | QToolButton* m_pBrushColorToolButton; |
108 | |||
109 | QSpinBox* m_pPenWidthSpinBox; | ||
104 | }; | 110 | }; |
105 | 111 | ||
106 | #endif // DRAWPAD_H | 112 | #endif // DRAWPAD_H |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 5437068..05dd408 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -337,24 +337,37 @@ void DrawPadCanvas::selectPage(Page* page) | |||
337 | { | 337 | { |
338 | m_pages.findRef(page); | 338 | m_pages.findRef(page); |
339 | m_pageBackups.clear(); | 339 | m_pageBackups.clear(); |
340 | m_pageBackups.append(new Page(*(m_pages.current()))); | 340 | m_pageBackups.append(new Page(*(m_pages.current()))); |
341 | 341 | ||
342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 342 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
343 | viewport()->update(); | 343 | viewport()->update(); |
344 | 344 | ||
345 | emit pagesChanged(); | 345 | emit pagesChanged(); |
346 | emit pageBackupsChanged(); | 346 | emit pageBackupsChanged(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void DrawPadCanvas::selectPage(uint pagePosition) | ||
350 | { | ||
351 | m_pages.at(pagePosition - 1); | ||
352 | m_pageBackups.clear(); | ||
353 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
354 | |||
355 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
356 | viewport()->update(); | ||
357 | |||
358 | emit pagesChanged(); | ||
359 | emit pageBackupsChanged(); | ||
360 | } | ||
361 | |||
349 | void DrawPadCanvas::backupPage() | 362 | void DrawPadCanvas::backupPage() |
350 | { | 363 | { |
351 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); | 364 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); |
352 | 365 | ||
353 | Page* currentBackup = m_pageBackups.current(); | 366 | Page* currentBackup = m_pageBackups.current(); |
354 | while (m_pageBackups.last() != currentBackup) { | 367 | while (m_pageBackups.last() != currentBackup) { |
355 | m_pageBackups.removeLast(); | 368 | m_pageBackups.removeLast(); |
356 | } | 369 | } |
357 | 370 | ||
358 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { | 371 | while (m_pageBackups.count() >= (PAGE_BACKUPS + 1)) { |
359 | m_pageBackups.removeFirst(); | 372 | m_pageBackups.removeFirst(); |
360 | } | 373 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index dcaff5c..2283e5e 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -39,24 +39,25 @@ public: | |||
39 | 39 | ||
40 | bool undoEnabled(); | 40 | bool undoEnabled(); |
41 | bool redoEnabled(); | 41 | bool redoEnabled(); |
42 | bool goPreviousPageEnabled(); | 42 | bool goPreviousPageEnabled(); |
43 | bool goNextPageEnabled(); | 43 | bool goNextPageEnabled(); |
44 | 44 | ||
45 | Page* currentPage(); | 45 | Page* currentPage(); |
46 | QList<Page> pages(); | 46 | QList<Page> pages(); |
47 | uint pagePosition(); | 47 | uint pagePosition(); |
48 | uint pageCount(); | 48 | uint pageCount(); |
49 | 49 | ||
50 | void selectPage(Page* page); | 50 | void selectPage(Page* page); |
51 | void selectPage(uint pagePosition); | ||
51 | void backupPage(); | 52 | void backupPage(); |
52 | 53 | ||
53 | public slots: | 54 | public slots: |
54 | void deleteAll(); | 55 | void deleteAll(); |
55 | void newPage(QString title, uint width, uint height, const QColor& color); | 56 | void newPage(QString title, uint width, uint height, const QColor& color); |
56 | void clearPage(); | 57 | void clearPage(); |
57 | void deletePage(); | 58 | void deletePage(); |
58 | void movePageUp(); | 59 | void movePageUp(); |
59 | void movePageDown(); | 60 | void movePageDown(); |
60 | 61 | ||
61 | void undo(); | 62 | void undo(); |
62 | void redo(); | 63 | void redo(); |