# -*- coding: utf-8 -*- """ /*************************************************************************** MnCheck A QGIS plugin Contrôle des données FTTH format MN Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/ ------------------- begin : 2018-12-07 git sha : $Format:%H$ copyright : (C) 2018 by Manche Numérique 2019 email : olivier.massot@manchenumerique.fr ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ """ import logging from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QAction from core import logconf from core.constants import MAIN from ui.dlg_main import DlgMain __VERSION__ = "0.1.0" logger = logging.getLogger("mncheck") logconf.start("mncheck", logging.DEBUG) class MnCheck: def __init__(self, iface): self.iface = iface self.actions = [] self.menu = '&MnCheck' self.toolbar = self.iface.addToolBar('MnCheck') self.toolbar.setObjectName('MnCheck') def add_action(self, icon_path, text, callback, enabled_flag=True, add_to_menu=True, add_to_toolbar=True, status_tip=None, whats_this=None, parent=None): icon = QIcon(icon_path) action = QAction(icon, text, parent) action.triggered.connect(callback) action.setEnabled(enabled_flag) if status_tip is not None: action.setStatusTip(status_tip) if whats_this is not None: action.setWhatsThis(whats_this) if add_to_toolbar: self.toolbar.addAction(action) if add_to_menu: self.iface.addPluginToMenu(self.menu, action) self.actions.append(action) return action def initGui(self): """Create the menu entries and toolbar icons inside the QGIS GUI.""" self.add_action(MAIN / 'icon.png', text='MnCheck', callback=self.run, parent=self.iface.mainWindow()) def unload(self): """Removes the plugin menu item and icon from QGIS GUI.""" for action in self.actions: self.iface.removePluginMenu('&MnCheck', action) self.iface.removeToolBarIcon(action) del self.toolbar def run(self): """Run method that performs all the real work""" dlg = DlgMain(self.iface) dlg.show() dlg.exec_()