-
Notifications
You must be signed in to change notification settings - Fork 0
/
fieldannotations.py
94 lines (76 loc) · 3.52 KB
/
fieldannotations.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
"""
/***************************************************************************
ThemeSwitcher
A QGIS plugin
This plugin adds a popup to easily switch between layer themes
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2024-07-23
git sha : $Format:%H$
copyright : (C) 2024 by Roel Huybrechts
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 qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
# Initialize Qt resources from file resources.py
from .resources import *
from .field_annotations.annotate import AnnotationState
from .field_annotations.config import Config
from .field_annotations.data import AnnotationDb
from .field_annotations.mapview import AnnotationView
from .field_annotations.toolbar import FieldAnnotationsToolbar
from .field_annotations.translate import Translatable
from .field_annotations.actions import ConfigurationDialogAction
import os.path
class FieldAnnotations(Translatable):
"""QGIS Plugin Implementation."""
def __init__(self, iface):
"""Initialise the plugin.
Setup the translation.
Parameters
----------
iface : QGisInterface
Link to the main QGIS interface.
"""
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'FieldAnnotations_{}.qm'.format(locale))
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
self.pluginName = self.tr('Field annotations')
# Declare instance attributes
self.toolbar = None
self.config = Config(self)
self.annotationState = AnnotationState(self)
self.annotationDb = AnnotationDb(self)
self.annotationView = AnnotationView(self)
self.configDialogAction = ConfigurationDialogAction(self)
def initGui(self):
"""Create the toolbar."""
self.toolbar = self.iface.addToolBar(self.pluginName)
FieldAnnotationsToolbar(self.toolbar, self)
self.iface.addPluginToMenu(self.pluginName, self.configDialogAction)
def unload(self):
"""Called when disabling the plugin or exiting QGIS.
Remove the toolbar and close the dialog.
"""
self.toolbar.parentWidget().removeToolBar(self.toolbar)
self.iface.removePluginMenu(self.pluginName, self.configDialogAction)