Changed: #1206 log plugin saves changes now and loads/unloads displayer on the fly

This commit is contained in:
aquiles 2011-05-28 22:06:01 +02:00
parent c39bd25ef3
commit 16e379084f
7 changed files with 403 additions and 271 deletions

View file

@ -1,93 +1,100 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by> // Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version. // License, or (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details. // GNU Affero General Public License for more details.
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CORE_CONSTANTS_H #ifndef CORE_CONSTANTS_H
#define CORE_CONSTANTS_H #define CORE_CONSTANTS_H
namespace Core namespace Core
{ {
namespace Constants namespace Constants
{ {
const char * const OVQT_VERSION_LONG = "0.0.1"; const char * const OVQT_VERSION_LONG = "0.0.1";
const char * const OVQT_VENDOR = "Ryzom Core"; const char * const OVQT_VENDOR = "Ryzom Core";
const char * const OVQT_YEAR = "2010, 2011"; const char * const OVQT_YEAR = "2010, 2011";
const char * const OVQT_CORE_PLUGIN = "Core"; const char * const OVQT_CORE_PLUGIN = "Core";
//mainwindow //mainwindow
const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow"; const char * const MAIN_WINDOW = "ObjectViewerQt.MainWindow";
//menubar //menubar
const char * const MENU_BAR = "ObjectViewerQt.MenuBar"; const char * const MENU_BAR = "ObjectViewerQt.MenuBar";
//menus //menus
const char * const M_FILE = "ObjectViewerQt.Menu.File"; const char * const M_FILE = "ObjectViewerQt.Menu.File";
const char * const M_EDIT = "ObjectViewerQt.Menu.Edit"; const char * const M_EDIT = "ObjectViewerQt.Menu.Edit";
const char * const M_VIEW = "ObjectViewerQt.Menu.View"; const char * const M_VIEW = "ObjectViewerQt.Menu.View";
const char * const M_SCENE = "ObjectViewerQt.Menu.Scene"; const char * const M_SCENE = "ObjectViewerQt.Menu.Scene";
const char * const M_TOOLS = "ObjectViewerQt.Menu.Tools"; const char * const M_TOOLS = "ObjectViewerQt.Menu.Tools";
const char * const M_WINDOW = "ObjectViewerQt.Menu.Window"; const char * const M_WINDOW = "ObjectViewerQt.Menu.Window";
const char * const M_HELP = "ObjectViewerQt.Menu.Help"; const char * const M_HELP = "ObjectViewerQt.Menu.Help";
const char * const M_SHEET = "ObjectViewerQt.Menu.Sheet"; const char * const M_SHEET = "ObjectViewerQt.Menu.Sheet";
//actions //actions
const char * const NEW = "ObjectViewerQt.New"; const char * const NEW = "ObjectViewerQt.New";
const char * const OPEN = "ObjectViewerQt.Open"; const char * const OPEN = "ObjectViewerQt.Open";
const char * const EXIT = "ObjectViewerQt.Exit"; const char * const EXIT = "ObjectViewerQt.Exit";
const char * const SETTINGS = "ObjectViewerQt.Settings"; const char * const SETTINGS = "ObjectViewerQt.Settings";
const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen"; const char * const TOGGLE_FULLSCREEN = "ObjectViewerQt.ToggleFullScreen";
const char * const CLOSE = "ObjectViewerQt.Close"; const char * const CLOSE = "ObjectViewerQt.Close";
const char * const CLOSEALL = "ObjectViewerQt.CloseAll"; const char * const CLOSEALL = "ObjectViewerQt.CloseAll";
const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers"; const char * const CLOSEOTHERS = "ObjectViewerQt.CloseOthers";
const char * const ABOUT = "ObjectViewerQt.About"; const char * const ABOUT = "ObjectViewerQt.About";
const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins"; const char * const ABOUT_PLUGINS = "ObjectViewerQt.AboutPlugins";
const char * const ABOUT_QT = "ObjectViewerQt.AboutQt"; const char * const ABOUT_QT = "ObjectViewerQt.AboutQt";
//settings //settings
const char * const SETTINGS_CATEGORY_GENERAL = "general"; const char * const SETTINGS_CATEGORY_GENERAL = "general";
const char * const SETTINGS_CATEGORY_GENERAL_ICON = ":/icons/ic_nel_generic_settings.png"; const char * const SETTINGS_CATEGORY_GENERAL_ICON = ":/icons/ic_nel_generic_settings.png";
const char * const SETTINGS_TR_CATEGORY_GENERAL = QT_TR_NOOP("General"); const char * const SETTINGS_TR_CATEGORY_GENERAL = QT_TR_NOOP("General");
const char * const MAIN_WINDOW_SECTION = "MainWindow"; const char * const MAIN_WINDOW_SECTION = "MainWindow";
const char * const MAIN_WINDOW_STATE = "WindowState"; const char * const MAIN_WINDOW_STATE = "WindowState";
const char * const MAIN_WINDOW_GEOMETRY = "WindowGeometry"; const char * const MAIN_WINDOW_GEOMETRY = "WindowGeometry";
const char * const QT_STYLE = "QtStyle"; const char * const QT_STYLE = "QtStyle";
const char * const QT_PALETTE = "QtPalette"; const char * const QT_PALETTE = "QtPalette";
const char * const LANGUAGE = "Language"; const char * const LANGUAGE = "Language";
const char * const PLUGINS_PATH = "PluginPath"; const char * const PLUGINS_PATH = "PluginPath";
const char * const DATA_PATH_SECTION = "DataPath"; const char * const DATA_PATH_SECTION = "DataPath";
const char * const SEARCH_PATHS = "SearchPaths"; const char * const SEARCH_PATHS = "SearchPaths";
const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes"; const char * const RECURSIVE_SEARCH_PATHS = "RecursiveSearchPathes";
const char * const LEVELDESIGN_PATH = "LevelDesignPath"; const char * const LEVELDESIGN_PATH = "LevelDesignPath";
const char * const ASSETS_PATH = "AssetsPath"; const char * const ASSETS_PATH = "AssetsPath";
const char * const REMAP_EXTENSIONS = "RemapExtensions"; const char * const REMAP_EXTENSIONS = "RemapExtensions";
//resources const char * const LOG_SECTION = "LogSettings";
const char * const ICON_NEL = ":/core/images/nel.png"; const char * const LOG_ERROR = "LogError";
const char * const ICON_SETTINGS = ":/core/images/preferences.png"; const char * const LOG_WARNING = "LogWarning";
const char * const ICON_PILL = ":/core/icons/ic_nel_pill.png"; const char * const LOG_DEBUG = "LogDebug";
const char * const ICON_OPEN = ":/core/icons/ic_nel_open.png"; const char * const LOG_ASSERT = "LogAssert";
const char * const ICON_CRASH = ":/core/icons/ic_nel_crash.png"; const char * const LOG_INFO = "LogInfo";
} // namespace Constants //resources
} // namespace Core const char * const ICON_NEL = ":/core/images/nel.png";
const char * const ICON_SETTINGS = ":/core/images/preferences.png";
#endif // CORE_CONSTANTS_H const char * const ICON_PILL = ":/core/icons/ic_nel_pill.png";
const char * const ICON_OPEN = ":/core/icons/ic_nel_open.png";
const char * const ICON_CRASH = ":/core/icons/ic_nel_crash.png";
} // namespace Constants
} // namespace Core
#endif // CORE_CONSTANTS_H

View file

@ -1,7 +1,7 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES}) ${QT_INCLUDES})
FILE(GLOB SRC *.cpp *.h) FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h

View file

@ -1,24 +1,29 @@
/* // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
Log Plugin Qt // Copyright (C) 2010 Winch Gate Property Limited
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> // Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
//
This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by // it under the terms of the GNU Affero General Public License as
the Free Software Foundation, either version 3 of the License, or // published by the Free Software Foundation, either version 3 of the
(at your option) any later version. // License, or (at your option) any later version.
//
This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. // GNU Affero General Public License for more details.
//
You should have received a copy of the GNU General Public License // You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Project includes
#include "log_plugin.h" #include "log_plugin.h"
#include "log_settings_page.h" #include "log_settings_page.h"
#include "qt_displayer.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/imenu_manager.h"
#include "../../extension_system/iplugin_spec.h"
// Qt includes // Qt includes
#include <QtCore/QObject> #include <QtCore/QObject>
@ -35,103 +40,153 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
// Project includes namespace Plugin
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/imenu_manager.h"
#include "qt_displayer.h"
using namespace Plugin;
namespace ExtensionSystem
{ {
class IPluginSpec;
}
CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent) CLogPlugin::CLogPlugin(QWidget *parent): QDockWidget(parent)
{ {
_ui.setupUi(this); m_ui.setupUi(this);
} }
CLogPlugin::~CLogPlugin() CLogPlugin::~CLogPlugin()
{ {
//_plugMan->removeObject(_logSettingsPage); Q_FOREACH(QObject *obj, m_autoReleaseObjects)
delete _logSettingsPage; {
m_plugMan->removeObject(obj);
}
qDeleteAll(m_autoReleaseObjects);
m_autoReleaseObjects.clear();
NLMISC::ErrorLog->removeDisplayer(_displayer); NLMISC::ErrorLog->removeDisplayer(m_displayer);
NLMISC::WarningLog->removeDisplayer(_displayer); NLMISC::WarningLog->removeDisplayer(m_displayer);
NLMISC::DebugLog->removeDisplayer(_displayer); NLMISC::DebugLog->removeDisplayer(m_displayer);
NLMISC::AssertLog->removeDisplayer(_displayer); NLMISC::AssertLog->removeDisplayer(m_displayer);
NLMISC::InfoLog->removeDisplayer(_displayer); NLMISC::InfoLog->removeDisplayer(m_displayer);
delete _displayer; delete m_displayer;
} }
bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) bool CLogPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{ {
Q_UNUSED(errorString); Q_UNUSED(errorString);
_plugMan = pluginManager; m_plugMan = pluginManager;
_logSettingsPage = new CLogSettingsPage(this); m_logSettingsPage = new CLogSettingsPage(this);
//_plugMan->addObject(_logSettingsPage); addAutoReleasedObject(m_logSettingsPage);
return true; return true;
} }
void CLogPlugin::extensionsInitialized() void CLogPlugin::extensionsInitialized()
{ {
NLMISC::ErrorLog->addDisplayer(_displayer); setDisplayers();
NLMISC::WarningLog->addDisplayer(_displayer);
NLMISC::DebugLog->addDisplayer(_displayer);
NLMISC::AssertLog->addDisplayer(_displayer);
NLMISC::InfoLog->addDisplayer(_displayer);
Core::ICore *core = Core::ICore::instance(); Core::ICore *core = Core::ICore::instance();
Core::IMenuManager *menuManager = core->menuManager(); Core::IMenuManager *menuManager = core->menuManager();
QMenu *viewMenu = menuManager->menu(Core::Constants::M_VIEW); QMenu *viewMenu = menuManager->menu(Core::Constants::M_VIEW);
QMainWindow *wnd = Core::ICore::instance()->mainWindow(); QMainWindow *wnd = Core::ICore::instance()->mainWindow();
wnd->addDockWidget(Qt::RightDockWidgetArea, this); wnd->addDockWidget(Qt::RightDockWidgetArea, this);
hide(); hide();
viewMenu->addAction(this->toggleViewAction()); viewMenu->addAction(this->toggleViewAction());
} }
void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext) void CLogPlugin::setNelContext(NLMISC::INelContext *nelContext)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet. // Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows. // This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised()); nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // fdef NL_OS_WINDOWS^M #endif // fdef NL_OS_WINDOWS^M
_LibContext = new NLMISC::CLibraryContext(*nelContext); m_libContext = new NLMISC::CLibraryContext(*nelContext);
_displayer = new NLQT::CQtDisplayer(_ui.plainTextEdit); m_displayer = new NLQT::CQtDisplayer(m_ui.plainTextEdit);
}
QString CLogPlugin::name() const
{
return "LogPlugin";
}
QString CLogPlugin::version() const
{
return "1.1";
}
QString CLogPlugin::vendor() const
{
return "aquiles";
}
QString CLogPlugin::description() const
{
return "DockWidget to display all log messages from NeL.";
}
QStringList CLogPlugin::dependencies() const
{
QStringList list;
list.append(Core::Constants::OVQT_CORE_PLUGIN);
return list;
}
void CLogPlugin::addAutoReleasedObject(QObject *obj)
{
m_plugMan->addObject(obj);
m_autoReleaseObjects.prepend(obj);
}
void CLogPlugin::setDisplayers()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::LOG_SECTION);
bool error = settings->value(Core::Constants::LOG_ERROR, true).toBool();
bool warning = settings->value(Core::Constants::LOG_WARNING, true).toBool();
bool debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool();
bool assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool();
bool info = settings->value(Core::Constants::LOG_INFO, true).toBool();
settings->endGroup();
if (error) {
if (!NLMISC::ErrorLog->attached(m_displayer))
NLMISC::ErrorLog->addDisplayer(m_displayer);
} else {
if (m_displayer) {
NLMISC::ErrorLog->removeDisplayer(m_displayer);
}
}
if (warning) {
if (!NLMISC::WarningLog->attached(m_displayer))
NLMISC::WarningLog->addDisplayer(m_displayer);
} else {
if (m_displayer) {
NLMISC::WarningLog->removeDisplayer(m_displayer);
}
}
if (debug) {
if (!NLMISC::DebugLog->attached(m_displayer))
NLMISC::DebugLog->addDisplayer(m_displayer);
} else {
if (m_displayer) {
NLMISC::DebugLog->removeDisplayer(m_displayer);
}
}
if (assert) {
if (!NLMISC::AssertLog->attached(m_displayer))
NLMISC::AssertLog->addDisplayer(m_displayer);
} else {
if (m_displayer) {
NLMISC::AssertLog->removeDisplayer(m_displayer);
}
}
if (info) {
if (!NLMISC::InfoLog->attached(m_displayer))
NLMISC::InfoLog->addDisplayer(m_displayer);
} else {
if (m_displayer) {
NLMISC::InfoLog->removeDisplayer(m_displayer);
}
}
}
} }
Q_EXPORT_PLUGIN(Plugin::CLogPlugin)
QString CLogPlugin::name() const
{
return "LogPlugin";
}
QString CLogPlugin::version() const
{
return "1.0";
}
QString CLogPlugin::vendor() const
{
return "aquiles";
}
QString CLogPlugin::description() const
{
return "DockWidget to display all log messages from NeL.";
}
QStringList CLogPlugin::dependencies() const
{
QStringList list;
list.append(Core::Constants::OVQT_CORE_PLUGIN);
return list;
}
Q_EXPORT_PLUGIN(CLogPlugin)

View file

@ -1,6 +1,6 @@
/* /*
Log Plugin Qt Log Plugin Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -20,16 +20,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef LOG_PLUGIN_H #ifndef LOG_PLUGIN_H
#define LOG_PLUGIN_H #define LOG_PLUGIN_H
// Project includes
#include "ui_log_form.h"
#include "../../extension_system/iplugin.h" #include "../../extension_system/iplugin.h"
// NeL includes
#include "nel/misc/app_context.h" #include "nel/misc/app_context.h"
// Qt includes // Qt includes
#include <QDockWidget> #include <QDockWidget>
// Project includes
#include "ui_log_form.h"
namespace NLMISC namespace NLMISC
{ {
class CLibraryContext; class CLibraryContext;
@ -52,7 +52,7 @@ namespace Plugin
class CLogPlugin : public QDockWidget, public ExtensionSystem::IPlugin class CLogPlugin : public QDockWidget, public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin) Q_INTERFACES(ExtensionSystem::IPlugin)
public: public:
CLogPlugin(QWidget *parent = 0); CLogPlugin(QWidget *parent = 0);
~CLogPlugin(); ~CLogPlugin();
@ -61,7 +61,7 @@ namespace Plugin
void extensionsInitialized(); void extensionsInitialized();
void setNelContext(NLMISC::INelContext *nelContext); void setNelContext(NLMISC::INelContext *nelContext);
NLQT::CQtDisplayer* displayer() { return _displayer; } NLQT::CQtDisplayer* displayer() { return m_displayer; }
QString name() const; QString name() const;
QString version() const; QString version() const;
@ -69,16 +69,21 @@ namespace Plugin
QString description() const; QString description() const;
QStringList dependencies() const; QStringList dependencies() const;
void addAutoReleasedObject(QObject *obj);
void setDisplayers();
protected: protected:
NLMISC::CLibraryContext *_LibContext; NLMISC::CLibraryContext *m_libContext;
private: private:
ExtensionSystem::IPluginManager *_plugMan; ExtensionSystem::IPluginManager *m_plugMan;
CLogSettingsPage *_logSettingsPage; QList<QObject *> m_autoReleaseObjects;
CLogSettingsPage *m_logSettingsPage;
Ui::CLogPlugin _ui; Ui::CLogPlugin m_ui;
NLQT::CQtDisplayer *_displayer; NLQT::CQtDisplayer *m_displayer;
}; };

View file

@ -1,6 +1,6 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by> // Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -15,31 +15,43 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "log_settings_page.h" #include "log_settings_page.h"
#include "log_plugin.h"
// Qt includes #include "../core/core_constants.h"
#include <QtGui/QWidget> #include "../core/icore.h"
#include "../../extension_system/plugin_manager.h"
// NeL includes // NeL includes
// Project includes // Qt includes
#include <QtGui/QWidget>
#include <QtCore/QSettings>
namespace ExtensionSystem namespace ExtensionSystem
{ {
class IPluginManager; class IPluginManager;
} }
namespace Plugin namespace Plugin
{ {
class CLogPlugin;
CLogSettingsPage::CLogSettingsPage(QObject *parent) CLogSettingsPage::CLogSettingsPage(QObject *parent)
: IOptionsPage(parent), : IOptionsPage(parent),
_currentPage(NULL) m_currentPage(NULL),
m_error(true),
m_warning(true),
m_debug(true),
m_assert(true),
m_info(true)
{ {
} }
QString CLogSettingsPage::id() const QString CLogSettingsPage::id() const
{ {
return QLatin1String("Log"); return QLatin1String("log");
} }
QString CLogSettingsPage::trName() const QString CLogSettingsPage::trName() const
@ -49,32 +61,78 @@ namespace Plugin
QString CLogSettingsPage::category() const QString CLogSettingsPage::category() const
{ {
return QLatin1String("General"); return QLatin1String(Core::Constants::SETTINGS_CATEGORY_GENERAL);
} }
QString CLogSettingsPage::trCategory() const QString CLogSettingsPage::trCategory() const
{ {
return tr("General"); return tr(Core::Constants::SETTINGS_TR_CATEGORY_GENERAL);
}
QIcon CLogSettingsPage::categoryIcon() const
{
return QIcon();
} }
QWidget *CLogSettingsPage::createPage(QWidget *parent) QWidget *CLogSettingsPage::createPage(QWidget *parent)
{ {
_currentPage = new QWidget(parent); m_currentPage = new QWidget(parent);
_ui.setupUi(_currentPage); m_ui.setupUi(m_currentPage);
return _currentPage;
readSettings();
m_ui.errorCheck->setChecked(m_error);
m_ui.warningCheck->setChecked(m_warning);
m_ui.debugCheck->setChecked(m_debug);
m_ui.assertCheck->setChecked(m_assert);
m_ui.infoCheck->setChecked(m_info);
return m_currentPage;
} }
void CLogSettingsPage::apply() void CLogSettingsPage::apply()
{ {
//ExtensionSystem::IPluginSpec *spec, _plugMan->plugins() m_error = m_ui.errorCheck->isChecked();
//ExtensionSystem::IPluginManager; m_warning = m_ui.warningCheck->isChecked();
//if (_ui.errorCheck->isChecked()) { m_debug = m_ui.debugCheck->isChecked();
//displayer(); m_assert = m_ui.assertCheck->isChecked();
//} m_info = m_ui.infoCheck->isChecked();
//if (_ui.warningCheck->isChecked());
//if (_ui.debugCheck->isChecked()); writeSettings();
//if (_ui.assertCheck->isChecked()); ExtensionSystem::IPluginManager *p = Core::ICore::instance()->pluginManager();
//if (_ui.infoCheck->isChecked()); ExtensionSystem::IPlugin *plugin = p->pluginByName("LogPlugin")->plugin();
CLogPlugin* lp = dynamic_cast<CLogPlugin*>(plugin);
if (lp)
{
lp->setDisplayers();
}
}
void CLogSettingsPage::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::LOG_SECTION);
m_error = settings->value(Core::Constants::LOG_ERROR, true).toBool();
m_warning = settings->value(Core::Constants::LOG_WARNING, true).toBool();
m_debug = settings->value(Core::Constants::LOG_DEBUG, true).toBool();
m_assert = settings->value(Core::Constants::LOG_ASSERT, true).toBool();
m_info = settings->value(Core::Constants::LOG_INFO, true).toBool();
settings->endGroup();
}
void CLogSettingsPage::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::LOG_SECTION);
settings->setValue(Core::Constants::LOG_ERROR, m_error);
settings->setValue(Core::Constants::LOG_WARNING, m_warning);
settings->setValue(Core::Constants::LOG_DEBUG, m_debug);
settings->setValue(Core::Constants::LOG_ASSERT, m_assert);
settings->setValue(Core::Constants::LOG_INFO, m_info);
settings->endGroup();
settings->sync();
} }
} /* namespace Plugin */ } /* namespace Plugin */

View file

@ -29,29 +29,39 @@ class QWidget;
namespace Plugin namespace Plugin
{ {
/** /**
@class CLogSettingsPage @class CLogSettingsPage
*/ */
class CLogSettingsPage : public Core::IOptionsPage class CLogSettingsPage : public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT
public: public:
CLogSettingsPage(QObject *parent = 0); CLogSettingsPage(QObject *parent = 0);
virtual ~CLogSettingsPage() {} virtual ~CLogSettingsPage() {}
virtual QString id() const; virtual QString id() const;
virtual QString trName() const; virtual QString trName() const;
virtual QString category() const; virtual QString category() const;
virtual QString trCategory() const; virtual QString trCategory() const;
virtual QWidget *createPage(QWidget *parent); QIcon categoryIcon() const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply(); virtual void apply();
virtual void finish() {} virtual void finish() {}
private: private:
QWidget *_currentPage; void readSettings();
Ui::CLogSettingsPage _ui; void writeSettings();
};
QWidget *m_currentPage;
Ui::CLogSettingsPage m_ui;
bool m_error;
bool m_warning;
bool m_debug;
bool m_assert;
bool m_info;
};
} // namespace Core } // namespace Core

View file

@ -1,24 +1,21 @@
/* // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
Georges Editor Qt // Copyright (C) 2010 Winch Gate Property Limited
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> // Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
//
This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by // it under the terms of the GNU Affero General Public License as
the Free Software Foundation, either version 3 of the License, or // published by the Free Software Foundation, either version 3 of the
(at your option) any later version. // License, or (at your option) any later version.
//
This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. // GNU Affero General Public License for more details.
//
You should have received a copy of the GNU General Public License // You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Nel includes // Nel includes
#include "qt_displayer.h" #include "qt_displayer.h"
#include <nel/misc/common.h> #include <nel/misc/common.h>
#include <nel/misc/file.h> #include <nel/misc/file.h>