-
Notifications
You must be signed in to change notification settings - Fork 14
/
plugin.py
72 lines (60 loc) · 3.23 KB
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : RT MapServer Exporter
Description : A plugin to export qgs project to mapfile
Date : Oct 21, 2012
copyright : (C) 2012 by Giuseppe Sucameli (Faunalia)
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import resources_rc
class Plugin:
def __init__(self, iface):
self.iface = iface
def initGui(self):
self.action = QAction(QIcon(":/rt_mapserver_exporter/icons/logo"), "Export project to mapfile", self.iface.mainWindow())
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
self.aboutAction = QAction( QIcon( ":/rt_mapserver_exporter/icons/about" ), "About", self.iface.mainWindow() )
QObject.connect( self.aboutAction, SIGNAL("triggered()"), self.about )
if hasattr(self.iface, "addPluginToWebMenu"):
self.iface.addWebToolBarIcon(self.action)
self.iface.addPluginToWebMenu("RT MapServer Exporter", self.action)
self.iface.addPluginToWebMenu("RT MapServer Exporter", self.aboutAction)
else:
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu("RT MapServer Exporter", self.action)
self.iface.addPluginToMenu("RT MapServer Exporter", self.aboutAction)
def unload(self):
if hasattr(self.iface, "removePluginWebMenu"):
self.iface.removeWebToolBarIcon(self.action)
self.iface.removePluginWebMenu("RT MapServer Exporter", self.action)
self.iface.removePluginWebMenu("RT MapServer Exporter", self.aboutAction)
else:
self.iface.removeToolBarIcon(self.action)
self.iface.removePluginMenu("RT MapServer Exporter", self.action)
self.iface.removePluginMenu("RT MapServer Exporter", self.aboutAction)
def about(self):
""" display the about dialog """
from .DlgAbout import DlgAbout
dlg = DlgAbout( self.iface.mainWindow() )
dlg.exec_()
def run(self):
try:
import mapscript
from .mapfileexportdlg import MapfileExportDlg
dialog = MapfileExportDlg(self.iface, self.iface.mainWindow())
dialog.show()
dialog.exec_()
except ImportError:
QMessageBox.warning(None, "Import Error", "Missing module: 'mapscript'. Please install 'mapscript-python' first.")