Linux multi-monitor fullscreen support
[ryzomcore.git] / studio / src / plugins / zone_painter / zone_painter_plugin.cpp
blob085a18634d49a79fc3222c5d2f0a1c7684ab53c1
1 // Project includes
2 #include "zone_painter_plugin.h"
3 #include "zone_painter_settings_page.h"
4 #include "../core/icore.h"
5 #include "../core/core_constants.h"
6 #include "../core/menu_manager.h"
7 #include "../../extension_system/iplugin_spec.h"
9 // NeL includes
10 #include "nel/misc/debug.h"
12 // Qt includes
13 #include <QtCore/QObject>
14 #include <QtGui/QMessageBox>
15 #include <QtGui/QMainWindow>
16 #include <QtGui/QMenu>
17 #include <QtGui/QAction>
18 #include <QtGui/QMenuBar>
19 #include <QtGui/QFileDialog>
21 namespace Plugin
23 // NLMISC_SAFE_SINGLETON_IMPL(CZoneManager)
25 ZonePainterPlugin::~ZonePainterPlugin()
27 Q_FOREACH(QObject *obj, m_autoReleaseObjects)
29 m_plugMan->removeObject(obj);
31 qDeleteAll(m_autoReleaseObjects);
32 m_autoReleaseObjects.clear();
35 bool ZonePainterPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
37 Q_UNUSED(errorString);
38 m_plugMan = pluginManager;
40 addAutoReleasedObject(new CZonePainterSettingsPage(this));
41 addAutoReleasedObject(new CZonePainterContext(this));
42 //addAutoReleasedObject(new CCoreListener(this));
44 return true;
47 void ZonePainterPlugin::extensionsInitialized()
49 Core::ICore *core = Core::ICore::instance();
50 Core::MenuManager *menuManager = core->menuManager();
51 QAction *loadZoneAction = new QAction("Load Zone", this);
52 QAction *saveZoneAction = new QAction("Save Zone", this);
54 QMenu *toolsMenu = menuManager->menu(Core::Constants::M_TOOLS);
55 QMenu *zoneMenu = toolsMenu->addMenu("Zone Painter");
56 zoneMenu->addAction(loadZoneAction);
57 connect(loadZoneAction, SIGNAL(triggered()), this, SLOT(clickLoadZoneAction()));
58 zoneMenu->addAction(saveZoneAction);
61 /****** SLOTS ******/
62 void ZonePainterPlugin::clickLoadZoneAction() {
63 QString zoneFile = QFileDialog::getOpenFileName(NULL, tr("Open Zone File"), ".", tr("Zone Files (*.zone);;"));
66 void ZonePainterPlugin::clickSaveZoneAction() {
69 /****** END SLOTS ******/
71 void ZonePainterPlugin::setNelContext(NLMISC::INelContext *nelContext)
73 #ifdef NL_OS_WINDOWS
74 // Ensure that a context doesn't exist yet.
75 // This only applies to platforms without PIC, e.g. Windows.
76 nlassert(!NLMISC::INelContext::isContextInitialised());
77 #endif // NL_OS_WINDOWS
78 m_LibContext = new NLMISC::CLibraryContext(*nelContext);
81 void ZonePainterPlugin::addAutoReleasedObject(QObject *obj)
83 m_plugMan->addObject(obj);
84 m_autoReleaseObjects.prepend(obj);
89 Q_EXPORT_PLUGIN(Plugin::ZonePainterPlugin)