summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp39
-rw-r--r--noncore/graphics/drawpad/drawpad.h6
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp13
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h1
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
@@ -33,8 +33,9 @@
#include <opie/colordialog.h>
#include <opie/colorpopupmenu.h>
#include <qpe/applnk.h>
+#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
@@ -227,14 +228,14 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
// init draw parameters toolbar
QPEToolBar* drawParametersToolBar = new QPEToolBar(this);
- QSpinBox* penWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
- connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
+ m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
+ connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
- QToolTip::add(penWidthSpinBox, tr("Pen Width"));
- penWidthSpinBox->setValue(1);
- penWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
+ QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
+ m_pPenWidthSpinBox->setValue(1);
+ m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor.png"));
@@ -268,12 +269,16 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
file.close();
} else {
m_pDrawPadCanvas->initialPage();
}
+
+ loadConfig();
}
DrawPad::~DrawPad()
{
+ saveConfig();
+
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_WriteOnly)) {
m_pDrawPadCanvas->save(&file);
@@ -618,4 +623,28 @@ void DrawPad::pageInformation()
if (pageInformationDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
}
}
+
+void DrawPad::loadConfig()
+{
+ Config config("drawpad");
+ config.setGroup("General");
+
+ m_pAntiAliasingAction->setOn(config.readBoolEntry("AntiAliasing", false));
+ m_pPenWidthSpinBox->setValue(config.readNumEntry("PenWidth", 1));
+ changePenColor(QColor(config.readEntry("PenColor", Qt::black.name())));
+ changeBrushColor(QColor(config.readEntry("BrushColor", Qt::white.name())));
+ m_pDrawPadCanvas->selectPage(config.readNumEntry("PagePosition", 1));
+}
+
+void DrawPad::saveConfig()
+{
+ Config config("drawpad");
+ config.setGroup("General");
+
+ config.writeEntry("PagePosition", (int)m_pDrawPadCanvas->pagePosition());
+ config.writeEntry("AntiAliasing", antiAliasing());
+ config.writeEntry("PenWidth", (int)m_pen.width());
+ config.writeEntry("PenColor", m_pen.color().name());
+ config.writeEntry("BrushColor", m_brush.color().name());
+}
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
@@ -22,8 +22,9 @@ class DrawPadCanvas;
class Tool;
class QAction;
class QColor;
+class QSpinBox;
class QToolButton;
class QWidgetStack;
class DrawPad : public QMainWindow
@@ -69,8 +70,11 @@ private slots:
void thumbnailView();
void pageInformation();
private:
+ void loadConfig();
+ void saveConfig();
+
DrawPadCanvas* m_pDrawPadCanvas;
Tool* m_pTool;
QPen m_pen;
@@ -100,7 +104,9 @@ private:
QToolButton* m_pRectangleToolButton;
QToolButton* m_pEllipseToolButton;
QToolButton* m_pPenColorToolButton;
QToolButton* m_pBrushColorToolButton;
+
+ QSpinBox* m_pPenWidthSpinBox;
};
#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
@@ -345,8 +345,21 @@ void DrawPadCanvas::selectPage(Page* page)
emit pagesChanged();
emit pageBackupsChanged();
}
+void DrawPadCanvas::selectPage(uint pagePosition)
+{
+ m_pages.at(pagePosition - 1);
+ m_pageBackups.clear();
+ m_pageBackups.append(new Page(*(m_pages.current())));
+
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
+
+ emit pagesChanged();
+ emit pageBackupsChanged();
+}
+
void DrawPadCanvas::backupPage()
{
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
@@ -47,8 +47,9 @@ public:
uint pagePosition();
uint pageCount();
void selectPage(Page* page);
+ void selectPage(uint pagePosition);
void backupPage();
public slots:
void deleteAll();