Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
save Settings to QgsSettings
  • Loading branch information
frida-161 committed Nov 29, 2021
1 parent 0889bb9 commit ec78d2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -88,10 +88,12 @@ def __init__(self, iface):

# form inputs
self.startfrom = 1
self.maxrecords = 10
self.timeout = 10
self.disable_ssl_verification = False
self.constraints = []
self.maxrecords = self.settings.value('/MetaSearch/returnRecords', 10)
self.timeout = self.settings.value('/MetaSearch/timeout', 10)
# QgsSettings.value returns 'false' not False(!)
self.disable_ssl_verification = self.settings.value(
'/MetaSearch/disableSSL', 'false') != 'false'

# Services tab
self.cmbConnectionsServices.activated.connect(self.save_connection)
Expand Down Expand Up @@ -139,12 +141,31 @@ def __init__(self, iface):

def manageGui(self):
"""open window"""
def _on_timeout_change(value):
self.settings.setValue('/MetaSearch/timeout', value)
self.timeout = value

def _on_records_change(value):
self.settings.setValue('/MetaSearch/returnRecords', value)
self.maxrecords = value

def _on_ssl_state_change(state):
self.settings.setValue('/MetaSearch/disableSSL', bool(state))
self.disable_ssl_verification = bool(state)

self.tabWidget.setCurrentIndex(0)
self.populate_connection_list()
self.btnRawAPIResponse.setEnabled(False)
self.spnRecords.setValue(
int(self.settings.value('/MetaSearch/returnRecords', 10)))

# load settings
self.spnRecords.setValue(self.maxrecords)
self.spnRecords.valueChanged.connect(_on_records_change)
self.spnTimeout.setValue(self.timeout)
self.spnTimeout.valueChanged.connect(_on_timeout_change)
self.disableSSLVerification.setCheckState(
int(self.disable_ssl_verification) * 2)
self.disableSSLVerification.stateChanged.connect(_on_ssl_state_change)


key = '/MetaSearch/%s' % self.cmbConnectionsSearch.currentText()
self.catalog_url = self.settings.value('%s/url' % key)
Expand Down Expand Up @@ -433,9 +454,6 @@ def search(self):
# clear all fields and disable buttons
self.clear_results()

# save some settings
self.settings.setValue('/MetaSearch/returnRecords',
self.spnRecords.cleanText())

# set current catalog
current_text = self.cmbConnectionsSearch.currentText()
Expand All @@ -447,10 +465,6 @@ def search(self):

# start position and number of records to return
self.startfrom = 1
self.maxrecords = self.spnRecords.value()

# set timeout
self.timeout = self.spnTimeout.value()

# bbox
# CRS is WGS84 with axis order longitude, latitude
Expand Down Expand Up @@ -838,7 +852,6 @@ def show_metadata(self):

identifier = get_item_data(item, 'identifier')

self.disable_ssl_verification = self.disableSSLVerification.isChecked()
auth = None

if self.disable_ssl_verification:
Expand Down Expand Up @@ -933,7 +946,6 @@ def reject(self):
def _get_catalog(self):
"""convenience function to init catalog wrapper"""

self.disable_ssl_verification = self.disableSSLVerification.isChecked()
auth = None

if self.disable_ssl_verification:
Expand Down
File renamed without changes.

0 comments on commit ec78d2f

Please sign in to comment.