1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "core_plugin.h"
23 #include "settings_dialog.h"
24 #include "core_constants.h"
25 #include "search_paths_settings_page.h"
26 #include "general_settings_page.h"
27 #include "../../extension_system/iplugin_spec.h"
30 #include "nel/misc/debug.h"
33 #include <QtCore/QObject>
34 #include <QtGui/QMessageBox>
35 #include <QtGui/QMainWindow>
36 #include <QtGui/QMenu>
37 #include <QtGui/QAction>
38 #include <QtGui/QMenuBar>
42 CorePlugin::CorePlugin()
48 CorePlugin::~CorePlugin()
50 Q_FOREACH(QObject
*obj
, m_autoReleaseObjects
)
52 m_plugMan
->removeObject(obj
);
54 qDeleteAll(m_autoReleaseObjects
);
55 m_autoReleaseObjects
.clear();
61 bool CorePlugin::initialize(ExtensionSystem::IPluginManager
*pluginManager
, QString
*errorString
)
63 Q_UNUSED(errorString
);
64 m_plugMan
= pluginManager
;
66 m_mainWindow
= new MainWindow(pluginManager
);
67 bool success
= m_mainWindow
->initialize(errorString
);
69 GeneralSettingsPage
*generalSettings
= new GeneralSettingsPage(this);
70 SearchPathsSettingsPage
*searchPathPage
= new SearchPathsSettingsPage(false, this);
71 SearchPathsSettingsPage
*recureseSearchPathPage
= new SearchPathsSettingsPage(true, this);
73 generalSettings
->applyGeneralSettings();
74 searchPathPage
->applySearchPaths();
75 recureseSearchPathPage
->applySearchPaths();
76 addAutoReleasedObject(generalSettings
);
77 addAutoReleasedObject(searchPathPage
);
78 addAutoReleasedObject(recureseSearchPathPage
);
82 void CorePlugin::extensionsInitialized()
84 m_mainWindow
->extensionsInitialized();
87 void CorePlugin::shutdown()
91 void CorePlugin::setNelContext(NLMISC::INelContext
*nelContext
)
94 // Ensure that a context doesn't exist yet.
95 // This only applies to platforms without PIC, e.g. Windows.
96 nlassert(!NLMISC::INelContext::isContextInitialised());
97 #endif // NL_OS_WINDOWS
98 m_libContext
= new NLMISC::CLibraryContext(*nelContext
);
101 void CorePlugin::addAutoReleasedObject(QObject
*obj
)
103 m_plugMan
->addObject(obj
);
104 m_autoReleaseObjects
.prepend(obj
);
107 Q_EXPORT_PLUGIN(CorePlugin
)