-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 | |||
@@ -34,6 +34,7 @@ | |||
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> |
@@ -228,12 +229,12 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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")); |
@@ -269,10 +270,14 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
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)) { |
@@ -619,3 +624,27 @@ void DrawPad::pageInformation() | |||
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 | |||
@@ -23,6 +23,7 @@ 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 | ||
@@ -70,6 +71,9 @@ private slots: | |||
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; |
@@ -101,6 +105,8 @@ private: | |||
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 | |||
@@ -346,6 +346,19 @@ void DrawPadCanvas::selectPage(Page* page) | |||
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()); |
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 | |||
@@ -48,6 +48,7 @@ public: | |||
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: |