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"
10 #include "nel/misc/debug.h"
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>
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));
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
);
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
)
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
)