class OLOverview(object): def __init__(self, iface, olLayerTypeRegistry): self._iface = iface self._olLayerTypeRegistry = olLayerTypeRegistry self._dockwidget = None self._oloWidget = None # Private def _setDocWidget(self): self._dockwidget = QDockWidget(QApplication.translate("OpenLayersOverviewWidget", "OpenLayers Overview"), self._iface.mainWindow()) self._dockwidget.setObjectName("dwOpenlayersOverview") self._oloWidget = OpenLayersOverviewWidget(self._iface, self._dockwidget, self._olLayerTypeRegistry) self._dockwidget.setWidget(self._oloWidget) def _initGui(self): self._setDocWidget() self._iface.addDockWidget(Qt.LeftDockWidgetArea, self._dockwidget) def _unload(self): self._dockwidget.close() self._iface.removeDockWidget(self._dockwidget) del self._oloWidget self._dockwidget = None # Public def setVisible(self, visible): if visible: if self._dockwidget is None: self._initGui() else: if not self._dockwidget is None: self._unload()
class ValueTool: def __init__(self, iface): # save reference to the QGIS interface self.iface = iface def initGui(self): # create action that will start plugin configuration # self.action = QAction(QIcon(":/plugins/valuetool/icon.png"), "Value Tool", self.iface.getMainWindow()) # self.action.setWhatsThis("Value Tool") # QObject.connect(self.action, SIGNAL("activated()"), self.run) # # add toolbar button and menu item # self.iface.addToolBarIcon(self.action) # self.iface.addPluginMenu("Analyses", self.action) # # add the tool to select feature # self.tool = selectPointTool(self.iface.getMapCanvas(),self.action) # create the widget to display information self.valuewidget = ValueWidget(self.iface) # create the dockwidget with the correct parent and add the valuewidget self.valuedockwidget = QDockWidget("Value Tool", self.iface.mainWindow()) self.valuedockwidget.setObjectName("Value Tool") self.valuedockwidget.setWidget(self.valuewidget) QObject.connect(self.valuedockwidget, SIGNAL('visibilityChanged ( bool )'), self.showHideDockWidget) self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.valuedockwidget) # self.valuewidget.show() # ##Qt.AllDockWidgetAreas def unload(self): self.valuedockwidget.close() self.valuewidget.disconnect() # remove the dockwidget from iface self.iface.removeDockWidget(self.valuedockwidget) # remove the plugin menu item and icon # self.iface.removePluginMenu("Analyses",self.action) # self.iface.removeToolBarIcon(self.action) def showHideDockWidget(self): if self.valuedockwidget.isVisible( ) and self.valuewidget.cbxActive.isChecked(): state = Qt.Checked else: state = Qt.Unchecked self.valuewidget.changeActive(state)
class ValueTool: def __init__(self, iface): # save reference to the QGIS interface self.iface = iface def initGui(self): # create action that will start plugin configuration # self.action = QAction(QIcon(":/plugins/valuetool/icon.png"), "Value Tool", self.iface.getMainWindow()) # self.action.setWhatsThis("Value Tool") # QObject.connect(self.action, SIGNAL("activated()"), self.run) # # add toolbar button and menu item # self.iface.addToolBarIcon(self.action) # self.iface.addPluginMenu("Analyses", self.action) # # add the tool to select feature # self.tool = selectPointTool(self.iface.getMapCanvas(),self.action) # create the widget to display information self.valuewidget = ValueWidget(self.iface) # create the dockwidget with the correct parent and add the valuewidget self.valuedockwidget = QDockWidget("Value Tool", self.iface.mainWindow()) self.valuedockwidget.setObjectName("Value Tool") self.valuedockwidget.setWidget(self.valuewidget) QObject.connect(self.valuedockwidget, SIGNAL('visibilityChanged ( bool )'), self.showHideDockWidget) self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.valuedockwidget) # self.valuewidget.show() # ##Qt.AllDockWidgetAreas def unload(self): self.valuedockwidget.close() self.valuewidget.disconnect() # remove the dockwidget from iface self.iface.removeDockWidget(self.valuedockwidget) # remove the plugin menu item and icon # self.iface.removePluginMenu("Analyses",self.action) # self.iface.removeToolBarIcon(self.action) def showHideDockWidget(self): if self.valuedockwidget.isVisible() and self.valuewidget.cbxActive.isChecked(): state = Qt.Checked else: state = Qt.Unchecked self.valuewidget.changeActive(state)