Changed: Added QSettings load/save to Zone Painter plugin

This commit is contained in:
sfb 2011-04-29 13:34:18 -05:00
parent e997b36b4f
commit c0f3c028f8
2 changed files with 27 additions and 0 deletions

View file

@ -5,6 +5,7 @@
#include <QSignalMapper> #include <QSignalMapper>
#include <QColor> #include <QColor>
#include <QColorDialog> #include <QColorDialog>
#include <QSettings>
#include "qnel_widget.h" #include "qnel_widget.h"
#include "painter_dock_widget.h" #include "painter_dock_widget.h"
@ -21,6 +22,9 @@ ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) :
m_nelWidget = new NLQT::QNLWidget(this); m_nelWidget = new NLQT::QNLWidget(this);
setCentralWidget(m_nelWidget); setCentralWidget(m_nelWidget);
// Load the settings.
loadConfig();
// Set up dock widget(s) and toolbar. // Set up dock widget(s) and toolbar.
m_painterDockWidget = new PainterDockWidget(this); m_painterDockWidget = new PainterDockWidget(this);
addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget); addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget);
@ -135,6 +139,26 @@ void ZonePainterMainWindow::setBackgroundColor() {
m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue())); m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue()));
} }
void ZonePainterMainWindow::loadConfig() {
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("ZonePainter");
QColor color;
color = settings->value("BackgroundColor", QColor(80, 80, 80)).value<QColor>();
m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha()));
}
void ZonePainterMainWindow::saveConfig() {
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("ZonePainter" );
QColor color(m_nelWidget->backgroundColor().R, m_nelWidget->backgroundColor().G, m_nelWidget->backgroundColor().B, m_nelWidget->backgroundColor().A);
settings->setValue("BackgroundColor", color);
settings->endGroup();
settings->sync();
}
ZonePainterMainWindow::~ZonePainterMainWindow() ZonePainterMainWindow::~ZonePainterMainWindow()
{ {
delete ui; delete ui;

View file

@ -24,6 +24,9 @@ public:
explicit ZonePainterMainWindow(QWidget *parent = 0); explicit ZonePainterMainWindow(QWidget *parent = 0);
~ZonePainterMainWindow(); ~ZonePainterMainWindow();
void loadConfig();
void saveConfig();
public Q_SLOTS: public Q_SLOTS:
void setToolMode(int value); void setToolMode(int value);
void setToolMode(); void setToolMode();