Fix game:addSpawnShapesByZone
[ryzomcore.git] / studio / src / plugins / log / log_settings_page.cpp
blob3fd336097a6ce17c1cbb73aed6a87596095ddee6
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Adrian JAEKEL <aj@elane2k.com>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2011 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
7 // Copyright (C) 2013 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Affero General Public License as
11 // published by the Free Software Foundation, either version 3 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Affero General Public License for more details.
19 // You should have received a copy of the GNU Affero General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 // Project includes
23 #include "log_settings_page.h"
24 #include "log_plugin.h"
25 #include "../core/core_constants.h"
26 #include "../core/icore.h"
27 #include "../../extension_system/plugin_manager.h"
29 // NeL includes
31 // Qt includes
32 #include <QtGui/QWidget>
33 #include <QtCore/QSettings>
35 namespace ExtensionSystem
37 class IPluginManager;
40 namespace Plugin
43 class CLogPlugin;
45 CLogSettingsPage::CLogSettingsPage(CLogPlugin *logPlugin, QObject *parent)
46 : IOptionsPage(parent),
47 m_logPlugin(logPlugin),
48 m_currentPage(NULL),
49 m_error(true),
50 m_warning(true),
51 m_debug(true),
52 m_assert(true),
53 m_info(true)
57 QString CLogSettingsPage::id() const
59 return QLatin1String("log");
62 QString CLogSettingsPage::trName() const
64 return tr("Log");
67 QString CLogSettingsPage::category() const
69 return QLatin1String(Core::Constants::SETTINGS_CATEGORY_GENERAL);
72 QString CLogSettingsPage::trCategory() const
74 return tr(Core::Constants::SETTINGS_TR_CATEGORY_GENERAL);
77 QIcon CLogSettingsPage::categoryIcon() const
79 return QIcon();
82 QWidget *CLogSettingsPage::createPage(QWidget *parent)
84 m_currentPage = new QWidget(parent);
85 m_ui.setupUi(m_currentPage);
87 readSettings();
88 m_ui.errorCheck->setChecked(m_error);
89 m_ui.warningCheck->setChecked(m_warning);
90 m_ui.debugCheck->setChecked(m_debug);
91 m_ui.assertCheck->setChecked(m_assert);
92 m_ui.infoCheck->setChecked(m_info);
94 return m_currentPage;
97 void CLogSettingsPage::apply()
99 m_error = m_ui.errorCheck->isChecked();
100 m_warning = m_ui.warningCheck->isChecked();
101 m_debug = m_ui.debugCheck->isChecked();
102 m_assert = m_ui.assertCheck->isChecked();
103 m_info = m_ui.infoCheck->isChecked();
105 writeSettings();
106 m_logPlugin->setDisplayers();
109 void CLogSettingsPage::readSettings()
111 QSettings *settings = Core::ICore::instance()->settings();
113 settings->beginGroup(Core::Constants::LOG_SECTION);
114 m_error = settings->value(Core::Constants::LOG_ERROR, true).toBool();
115 m_warning = settings->value(Core::Constants::LOG_WARNING, true).toBool();
116 m_debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool();
117 m_assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool();
118 m_info = settings->value(Core::Constants::LOG_INFO, true).toBool();
119 settings->endGroup();
122 void CLogSettingsPage::writeSettings()
124 QSettings *settings = Core::ICore::instance()->settings();
126 settings->beginGroup(Core::Constants::LOG_SECTION);
127 settings->setValue(Core::Constants::LOG_ERROR, m_error);
128 settings->setValue(Core::Constants::LOG_WARNING, m_warning);
129 settings->setValue(Core::Constants::LOG_DEBUG, m_debug);
130 settings->setValue(Core::Constants::LOG_ASSERT, m_assert);
131 settings->setValue(Core::Constants::LOG_INFO, m_info);
132 settings->endGroup();
134 settings->sync();
137 } /* namespace Plugin */