-
Notifications
You must be signed in to change notification settings - Fork 2
/
getwkt3_config.py
104 lines (92 loc) · 4.02 KB
/
getwkt3_config.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
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
"""
/***************************************************************************
getwkt3Dialog
A QGIS plugin
This plugin displays the selected features' WKT representation.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2018-03-13
git sha : $Format:%H$
copyright : (C) 2018 by Paul Skeen
email : paulskeen@spatialecology.com.au
***************************************************************************/
/***************************************************************************
* *
* 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 os
from PyQt5 import uic
from PyQt5 import QtWidgets
from qgis.core import QgsSettings
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'getwkt3_config_base.ui'))
class getwkt3Config(QtWidgets.QDialog, FORM_CLASS):
""""Setup variables"""
s = QgsSettings()
"""Get dialog class"""
def __init__(self, parent=None):
"""Constructor."""
super(getwkt3Config, self).__init__(parent)
self.setupUi(self)
self.btnAccept.clicked.connect(self.handleHide)
#Load up saved settings
dpmethod = self.s.value("getwkt3/dpmethod")
if dpmethod == 'auto':
self.dp_radAuto.checked = True
elif dpmethod == 'custom':
self.dp_radCustom.checked = True
else:
self.dp_radDefault.checked = True
#Slider value
val = self.s.value("getwkt3/dpcustom")
if not val:
val = 10
self.dp_numCustom.setValue(int(val))
# Setup selected default tool
self.tool_cmbDefault.clear()
self.tool_cmbDefault.addItems(["WKT", "EWKT", "JSON"])
tool = self.s.value("getwkt3/toolmethod")
tool_idx = self.tool_cmbDefault.findText(tool)
if tool_idx == -1:
tool_idx = 0
self.tool_cmbDefault.setCurrentIndex(tool_idx)
#Connect events
self.dp_radDefault.clicked.connect(self.dp_handleChange_Default)
self.dp_radAuto.clicked.connect(self.dp_handleChange_Auto)
self.dp_radCustom.clicked.connect(self.dp_handleChange_Custom)
self.dp_numCustom.valueChanged.connect(self.dp_handleChange_CustomValue)
self.tool_cmbDefault.currentIndexChanged.connect(self.tool_handleDefaultChange)
def handleHide(self):
"""Hide handle"""
self.hide()
def tool_handleDefaultChange(self, value):
"""Handle change to tool default method"""
#Update dp setting
self.s.setValue("getwkt3/toolmethod", self.tool_cmbDefault.currentText())
def dp_handleChange(self, type):
"""Handle change to dp method"""
#Update dp setting
self.s.setValue("getwkt3/dpmethod", type)
def dp_handleChange_Default(self):
"""Handle change to dp method to default"""
#Update dp setting
self.dp_handleChange('default')
def dp_handleChange_Auto(self):
"""Handle change to dp method to auto"""
#Update dp setting
self.dp_handleChange('auto')
def dp_handleChange_Custom(self):
"""Handle change to dp method to custom"""
#Update dp setting
self.dp_handleChange('custom')
def dp_handleChange_CustomValue(self):
"""Handle change to dp custom value"""
#Update dp setting
value = self.dp_numCustom.value()
self.s.setValue("getwkt3/dpcustom",value)