forked from CEN-RA/Plugin_QGIS
101 lines
2.9 KiB
Python
101 lines
2.9 KiB
Python
__copyright__ = "Copyright 2021, 3Liz"
|
|
__license__ = "GPL version 3"
|
|
__email__ = "info@3liz.org"
|
|
|
|
|
|
from qgis.core import QgsApplication
|
|
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
|
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
|
from qgis.utils import iface
|
|
import qgis
|
|
|
|
|
|
#include <QSettings>
|
|
|
|
import os
|
|
from .tools.resources import (
|
|
plugin_path,
|
|
resources_path,
|
|
maj_verif,
|
|
)
|
|
from .flux_editor import Flux_Editor
|
|
from .about_form import FluxAboutDialog
|
|
|
|
from PyQt5.QtCore import *
|
|
|
|
class PgFlux:
|
|
def __init__(self):
|
|
""" Constructor. """
|
|
self.action_editor = None
|
|
self.issues = None
|
|
self.provider = None
|
|
self.locator_filter = None
|
|
self.dock_action = None
|
|
self.help_action = None
|
|
plugin_dir = os.path.dirname(__file__)
|
|
end_find = plugin_dir.rfind('\\')+1
|
|
global NAME
|
|
NAME = plugin_dir[end_find:]
|
|
maj_verif(NAME)
|
|
|
|
# Display About window on first use
|
|
version = qgis.utils.pluginMetadata('CenRa_Flux','version')
|
|
s = QSettings()
|
|
versionUse = s.value("flux/version", 1, type=str)
|
|
if str(versionUse) != str(version) :
|
|
s.setValue("flux/version", str(version))
|
|
print(versionUse,version)
|
|
self.open_about_dialog()
|
|
|
|
def initGui(self):
|
|
""" Build the plugin GUI. """
|
|
|
|
self.toolBar = iface.addToolBar("CenRa_Flux")
|
|
self.toolBar.setObjectName("CenRa_Flux")
|
|
|
|
icon = QIcon(resources_path('icons', 'icon.png'))
|
|
|
|
# Open the online help
|
|
self.help_action = QAction(icon, "CenRa_Flux", iface.mainWindow())
|
|
iface.pluginHelpMenu().addAction(self.help_action)
|
|
self.help_action.triggered.connect(self.open_help)
|
|
if not self.action_editor:
|
|
self.action_editor = Flux_Editor()
|
|
|
|
self.flux_editor = QAction(icon, 'SigCEN',None)
|
|
self.toolBar.addAction(self.flux_editor)
|
|
self.flux_editor.triggered.connect(self.open_editor)
|
|
|
|
def open_about_dialog(self):
|
|
"""
|
|
About dialog
|
|
"""
|
|
dialog = CopieAboutDialog(iface)
|
|
dialog.exec_()
|
|
def open_help():
|
|
""" Open the online help. """
|
|
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
|
|
|
def open_editor(self):
|
|
self.action_editor.show()
|
|
self.action_editor.raise_()
|
|
|
|
def unload(self):
|
|
""" Unload the plugin. """
|
|
if self.action_editor:
|
|
iface.removePluginMenu('CenRa_Flux',self.flux_editor)
|
|
|
|
|
|
if self.provider:
|
|
QgsApplication.processingRegistry().removeProvider(self.provider)
|
|
del self.provider
|
|
|
|
if self.locator_filter:
|
|
iface.deregisterLocatorFilter(self.locator_filter)
|
|
del self.locator_filter
|
|
|
|
if self.help_action:
|
|
iface.pluginHelpMenu().removeAction(self.help_action)
|
|
del self.help_action
|