Changed: Added QSettings load/save to Zone Painter plugin

hg/feature/gsoc2012-fabien
sfb 14 years ago
parent 61e65e6bde
commit a8a052c2d8

@ -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;

@ -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();

Loading…
Cancel
Save