/
__init__.py
74 lines (61 loc) · 2.62 KB
/
__init__.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
73
74
# -*- coding: utf-8 -*-
"""
/***************************************************************************
Name : Auxiliary Window
Description : Plugin for open synchronized window with selected layers
Date : June, 2015
copyright : (C) 2015 by Luiz Motta
email : motta.luiz@gmail.com
***************************************************************************/
/***************************************************************************
* *
* 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.QtGui import ( QAction, QIcon )
from PyQt4.QtCore import pyqtSlot
from qgis.core import ( QgsProject )
import os
from auxiliarywindow import ContainerAuxiliaryWindow
def classFactory(iface):
return AuxiliaryWindowPlugin( iface )
class AuxiliaryWindowPlugin:
def __init__(self, iface):
self.iface = iface
self.plugin = ContainerAuxiliaryWindow( iface.mainWindow() )
self.namePlugin = "&Auxiliary Window"
def _connect(self, isConnect = True):
signal_slot = (
{ 'signal': QgsProject.instance().readProject, 'slot': self.plugin.onReadProject },
{ 'signal': QgsProject.instance().writeProject, 'slot': self.plugin.onWriteProject }
)
if isConnect:
for item in signal_slot:
item['signal'].connect( item['slot'] )
else:
for item in signal_slot:
item['signal'].disconnect( item['slot'] )
def initGui(self):
title = "Auxiliary window"
icon = QIcon( os.path.join( os.path.dirname(__file__), 'auxiliarywindow.png' ) )
self.action = QAction( icon, title, self.iface.mainWindow() )
self.action.setObjectName( "AuxiliaryWindow" )
self.action.setWhatsThis( title )
self.action.setStatusTip( title )
self.action.triggered.connect( self.run )
self.iface.addToolBarIcon( self.action )
self.iface.addPluginToMenu( self.namePlugin, self.action)
self._connect()
def unload(self):
self.iface.removeToolBarIcon( self.action )
self.iface.removePluginMenu( self.namePlugin, self.action)
del self.action
self._connect( False )
self.plugin.close()
@pyqtSlot()
def run(self):
self.plugin.run()