1 /***************************************************************************
2 * Copyright (C) 2007 by David Cuadrado *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "settingsdialog.h"
30 #include <dgui/iconloader.h>
31 #include <dgui/application.h>
32 #include <dcore/config.h>
35 #include <yamf/drawing/paintarea.h>
38 #include "ui_general_page.h"
39 #include "ui_paintarea_page.h"
41 SettingsDialog::SettingsDialog(YAMF::Drawing::PaintArea
*const paintArea
, QWidget
*parent
)
42 : DGui::ConfigurationDialog(parent
), m_paintArea(paintArea
)
44 setWindowTitle(tr("Dash settings..."));
47 DCore::Config
*config
= dApp
->config("General");
49 m_generalPage
= new Ui::GeneralPage
;
51 QWidget
*general
= new QWidget
;
52 m_generalPage
->setupUi(general
);
54 m_generalPage
->minutes
->setValue(config
->value("save_project_interval", 15).toInt());
55 m_generalPage
->autoSaveProject
->setChecked(config
->value("auto_save_project", true).toBool());
57 addPage(general
, tr("General"), DGui::IconLoader::self()->load("preferences-system.svg"));
64 config
->beginGroup("TipOfDay");
65 m_generalPage
->showTips
->setChecked(config
->value("show_on_start", true).toBool() );
71 m_paintAreaPage
= new Ui::PaintAreaPage
;
73 QWidget
*paintArea
= new QWidget
;
74 m_paintAreaPage
->setupUi(paintArea
);
76 m_paintAreaPage
->antialiasing
->setChecked(m_paintArea
->renderHints() & QPainter::Antialiasing
);
78 m_paintAreaPage
->showGrid
->setChecked( m_paintArea
->drawGrid() );
79 m_paintAreaPage
->showBorder
->setChecked(m_paintArea
->drawBorder());
82 bool openGL
= dynamic_cast<QGLWidget
*>(m_paintArea
->viewport()) != 0;
83 m_paintAreaPage
->openGL
->setChecked(openGL
);
85 m_paintAreaPage
->openGL
->setEnabled(false);
88 m_paintAreaPage
->backgroundColor
->setColor(m_paintArea
->canvasColor());
90 m_paintAreaPage
->separation
->setValue(m_paintArea
->gridSeparation());
92 addPage(paintArea
, tr("Paint area"), DGui::IconLoader::self()->load("applications-graphics.svg"));
97 SettingsDialog::~SettingsDialog()
100 delete m_paintAreaPage
;
104 void SettingsDialog::apply()
110 void SettingsDialog::ok()
113 DCore::Config
*config
= dApp
->config("General");
115 config
->setValue("save_project_interval", m_generalPage
->autoSaveProject
->isChecked() ? m_generalPage
->minutes
->value() : 0);
116 config
->setValue("auto_save_project", m_generalPage
->autoSaveProject
->isChecked());
123 config
->beginGroup("TipOfDay");
125 config
->setValue("show_on_start", m_generalPage
->showTips
->isChecked());
131 m_paintArea
->setAntialiasing(m_paintAreaPage
->antialiasing
->isChecked());
132 m_paintArea
->setDrawGrid(m_paintAreaPage
->showGrid
->isChecked());
133 m_paintArea
->setDrawBorder(m_paintAreaPage
->showBorder
->isChecked());
135 m_paintArea
->setUseOpenGL(m_paintAreaPage
->openGL
->isChecked());
137 m_paintArea
->setGridSeparation(m_paintAreaPage
->separation
->value());
138 m_paintArea
->setCanvasColor(m_paintAreaPage
->backgroundColor
->color());
140 m_paintArea
->saveSettings();