author | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-26 14:17:12 (UTC) |
commit | 531bb3c03f5576523a3c7ccecc714362507f69e1 (patch) (side-by-side diff) | |
tree | 8bdda021e3ddd110ca75df06a1f6a5fbf0429a6c /noncore/graphics/drawpad/drawpad.cpp | |
parent | 527c3a7240bee3fe1d7c000aecc8ff0a01219fdd (diff) | |
download | opie-531bb3c03f5576523a3c7ccecc714362507f69e1.zip opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.gz opie-531bb3c03f5576523a3c7ccecc714362507f69e1.tar.bz2 |
Add application config
Diffstat (limited to 'noncore/graphics/drawpad/drawpad.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 39 |
1 files changed, 34 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 @@ #include "newpagedialog.h" #include "page.h" #include "pageinformationdialog.h" #include "pointtool.h" #include "rectangletool.h" #include "texttool.h" #include "thumbnailview.h" #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> #include <qaction.h> #include <qfile.h> #include <qmessagebox.h> #include <qpainter.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qtooltip.h> @@ -219,30 +220,30 @@ DrawPad::DrawPad(QWidget* parent, const char* name) setRectangleTool(); setEllipseTool(); setPointTool(); emptyToolBar = new QPEToolBar(this); emptyToolBar->setHorizontalStretchable(true); emptyToolBar->addSeparator(); // 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")); ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, m_pPenColorToolButton); connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&))); QToolTip::add(m_pPenColorToolButton, tr("Pen Color")); m_pPenColorToolButton->setPopup(penColorPopupMenu); m_pPenColorToolButton->setPopupDelay(0); changePenColor(Qt::black); @@ -260,28 +261,32 @@ DrawPad::DrawPad(QWidget* parent, const char* name) changeBrushColor(Qt::white); // init pages QFile file(Global::applicationFileName("drawpad", "drawpad.xml")); if (file.open(IO_ReadOnly)) { m_pDrawPadCanvas->load(&file); 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); file.close(); } } bool DrawPad::antiAliasing() { return (m_pAntiAliasingAction->isOn()); } @@ -610,12 +615,36 @@ void DrawPad::thumbnailView() thumbnailView.showMaximized(); thumbnailView.exec(); } void DrawPad::pageInformation() { PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); 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()); +} |