Python qgis.PyQt.QtCore.QSettings() Examples
The following are 30
code examples of qgis.PyQt.QtCore.QSettings().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qgis.PyQt.QtCore
, or try the search function
.
Example #1
Source File: opeNoise.py From openoise-map with GNU General Public License v3.0 | 6 votes |
def __init__(self, iface): # 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] localePath = os.path.join(self.plugin_dir, 'i18n', 'opeNoise_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # noinspection PyMethodMayBeStatic
Example #2
Source File: mapillary_coverage.py From go2mapillary with GNU General Public License v3.0 | 6 votes |
def getProxiesConf(): s = QSettings() # getting proxy from qgis options settings proxyEnabled = s.value("proxy/proxyEnabled", "") proxyType = s.value("proxy/proxyType", "") proxyHost = s.value("proxy/proxyHost", "") proxyPort = s.value("proxy/proxyPort", "") proxyUser = s.value("proxy/proxyUser", "") proxyPassword = s.value("proxy/proxyPassword", "") if proxyEnabled == "true" and proxyType == 'HttpProxy': # test if there are proxy settings proxyDict = { "http": "http://%s:%s@%s:%s" % (proxyUser, proxyPassword, proxyHost, proxyPort), "https": "http://%s:%s@%s:%s" % (proxyUser, proxyPassword, proxyHost, proxyPort) } return proxyDict else: return None
Example #3
Source File: exporter.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 6 votes |
def exportVectorLayer(layer): '''accepts a QgsVectorLayer or a string with a filepath''' settings = QtCore.QSettings() systemEncoding = settings.value( "/UI/encoding", "System" ) if isinstance(layer, QgsMapLayer): filename = str(layer.source()) destFilename = str(layer.name()) else: filename = str(layer) destFilename = str(os.path.splitext(os.path.basename(filename))[0]) if (not filename.lower().endswith("shp")): if not isinstance(layer, QgsMapLayer): layer = QgsVectorLayer(filename, "layer", "ogr") if not layer.isValid() or layer.type() != QgsMapLayer.VectorLayer: raise Exception ("Error reading file {} or it is not a valid vector layer file".format(filename)) output = tempFilenameInTempFolder(destFilename + ".shp") QgsVectorFileWriter.writeAsVectorFormat(layer, output, systemEncoding, layer.crs(), "ESRI Shapefile") QgsMessageLog.logMessage("Layer '%s' had to be exported to shapefile for importing. Data might be lost." % layer.name(), level = Qgis.Warning) return output else: return filename
Example #4
Source File: catalog.py From qgis-geoserver-plugin with GNU General Public License v2.0 | 6 votes |
def getConnectionNameFromLayer(self, layer): connName = "postgis_store" uri = QgsDataSourceURI(layer.dataProvider().dataSourceUri()) host = uri.host() database = uri.database() port = uri.port() settings = QtCore.QSettings() settings.beginGroup(u'/PostgreSQL/connections') for name in settings.childGroups(): settings.beginGroup(name) host2 = str(settings.value('host')) database2 = str(settings.value('database')) port2 = str(settings.value('port')) settings.endGroup() if port == port2 and database == database2 and host == host2: connName = name + "_" + str(uri.schema()) settings.endGroup() return connName
Example #5
Source File: settings.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 6 votes |
def readSettings(self): '''Load the user selected settings. The settings are retained even when the user quits QGIS.''' qset = QSettings() self.geomXName = qset.value('/ShapeTools/GeomXName', 'geom_x') self.geomYName = qset.value('/ShapeTools/GeomYName', 'geom_y') self.maxSegLength = float(qset.value('/ShapeTools/MaxSegLength', 20.0)) # In km self.maxSegments = int(qset.value('/ShapeTools/MaxSegments', 1000)) self.mtAzMode = int(qset.value('/ShapeTools/MtAzMode', 0)) self.measureSignificantDigits = int(qset.value('/ShapeTools/MeasureSignificantDigits', 2)) color = qset.value('/ShapeTools/RubberBandColor', '#dea743') self.rubberBandColor = QColor(color) value = int(qset.value('/ShapeTools/RubberBandOpacity', 192)) self.rubberBandColor.setAlpha(value) color = qset.value('/ShapeTools/MeasureLineColor', '#000000') self.measureLineColor = QColor(color) color = qset.value('/ShapeTools/MeasureTextColor', '#000000') self.measureTextColor = QColor(color) acronym = qset.value('/ShapeTools/Ellipsoid', 'WGS84') self.setEllipsoid(acronym)
Example #6
Source File: serverDBExplorer.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def storeConnectionConfiguration(self, server, database): ''' Stores connection configuration in thw QSettings server: server name database: database name ''' name = self.connectionEdit.text() (host, port, user, password) = self.getServerConfiguration(server) settings = QSettings() if not settings.contains('PostgreSQL/servers/'+name+'/host'): settings.beginGroup('PostgreSQL/connections/'+name) settings.setValue('database', database) settings.setValue('host', host) settings.setValue('port', port) settings.setValue('username', user) settings.setValue('password', password) settings.endGroup()
Example #7
Source File: viewServers.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def setDefaultConnectionParameters(self, connection, host, port, user, password): defaultConnectionDict = dict() if host and port and user and password: defaultConnectionDict['host'] = host defaultConnectionDict['port'] = port defaultConnectionDict['user'] = user defaultConnectionDict['password'] = password # set all connection on QSettings to not default and this connetion to default settings = QSettings() settings.beginGroup('PostgreSQL/servers') connections = settings.childGroups() settings.endGroup() for conn in connections: settings.beginGroup('PostgreSQL/servers/{0}'.format(conn)) settings.setValue('isDefault', conn == connection) settings.endGroup() else: defaultConnectionDict = dict() return defaultConnectionDict
Example #8
Source File: exploreDb.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def on_dropDatabasePushButton_clicked(self): ''' Drops a database and updates QSettings ''' currentItem = self.dbListWidget.currentItem() if not currentItem: return if QMessageBox.question(self, self.tr('Question'), self.tr('Do you really want to drop database: ')+currentItem.text().split(' ')[0], QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Cancel: return QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) localDbName = self.localDb.getDatabaseName() self.renewDb() try: self.serverWidget.abstractDb.dropDatabase(localDbName) QApplication.restoreOverrideCursor() QMessageBox.warning(self, self.tr('Success!'), self.tr('Database ')+localDbName+self.tr(' dropped successfully!')) self.clearQSettings(localDbName) except Exception as e: QApplication.restoreOverrideCursor() QMessageBox.critical(self, self.tr('Critical!'), ':'.join(e.args)) self.clearAll() self.populateListWithDatabasesFromServer()
Example #9
Source File: serverConfigurator.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def setServerConfiguration(self, name): ''' Sets server confogiration by its name ''' self.isEdit = 1 self.oldName=name settings = QSettings() settings.beginGroup('PostgreSQL/servers/'+name) host = settings.value('host') port = settings.value('port') user = settings.value('username') password = settings.value('password') settings.endGroup() self.servEdit.setText(name) self.hostEdit.setText(host) self.portEdit.setText(port) self.userEdit.setText(user) self.passwordEdit.setText(password)
Example #10
Source File: options.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def validationToolbarConfig(self): """ Reads all parameters for Validation Toolbar. :return: (dict) set of parameters for Validation Toolbar. """ settings = QSettings() settings.beginGroup('PythonPlugins/DsgTools/Options') loadModelOutput = settings.value('loadModelOutput') checkBeforeRunModel = settings.value('checkBeforeRunModel') removeModelsOnExit = settings.value('removeModelsOnExit') removeModelsOnNewProject = settings.value('removeModelsOnNewProject') defaultModelPath = settings.value('defaultModelPath') settings.endGroup() return { "loadModelOutput" : loadModelOutput in (True, "true"), "checkBeforeRunModel" : checkBeforeRunModel in (True, "true"), "removeModelsOnExit" : removeModelsOnExit in (True, "true"), "removeModelsOnNewProject" : removeModelsOnNewProject in (True, "true"), "defaultModelPath" : defaultModelPath }
Example #11
Source File: options.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def updateValidationToolbarConfig(self): """ Updates current Validation Toolbar parameter values from GUI. """ settings = QSettings() settings.beginGroup('PythonPlugins/DsgTools/Options') settings.setValue('loadModelOutput', self.loadModelOutputCheckBox.isChecked()) settings.setValue('checkBeforeRunModel', self.checkBeforeRunModelCheckBox.isChecked()) settings.setValue('removeModelsOnExit', self.resetModelsCheckBox.isChecked()) settings.setValue('removeModelsOnNewProject', self.removeModelsProjectCheckBox.isChecked()) # oldModelPath = settings.value('defaultModelPath') # newModelPath = self.modelPathComboBox.currentText() settings.setValue('defaultModelPath', self.modelPathComboBox.currentText()) settings.endGroup() # if oldModelPath != newModelPath: # self.modelPathChanged.emit()
Example #12
Source File: BDGExRequestHandler.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def getProxyConfiguration(self): """ Gets the proxy configuration from QSettings """ settings = QSettings() settings.beginGroup('proxy') enabled = settings.value('proxyEnabled') host = settings.value('proxyHost') port = settings.value('proxyPort') user = settings.value('proxyUser') password = settings.value('proxyPassword') type = settings.value('proxyType') excludedUrls = settings.value('proxyExcludedUrls') # try: # urlsList = excludedUrls.split('|') # except: # urlsList = [] settings.endGroup() return (enabled, host, port, user, password, type, excludedUrls)
Example #13
Source File: postgisDb.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def storeConnection(self, server): """ Stores a connection into QSettings """ (host, port, user, password) = self.getServerConfiguration(server) database = self.db.databaseName() connection = server+'_'+database settings = QSettings() if not settings.contains('PostgreSQL/connections/'+connection+'/database'): settings.beginGroup('PostgreSQL/connections/'+connection) settings.setValue('database', database) settings.setValue('host', host) settings.setValue('port', port) settings.setValue('username', user) settings.setValue('password', password) settings.endGroup() return True return False
Example #14
Source File: utils.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def get_proxy_config(self): """ Get proxy config from QSettings and builds proxy parameters :return: dictionary of transfer protocols mapped to addresses, also authentication if set in QSettings :rtype: (dict, requests.auth.HTTPProxyAuth) or (dict, None) """ enabled, host, port, user, password = self.get_proxy_from_qsettings() proxy_dict = {} if enabled and host: port_str = ':{}'.format(port) if port else '' for protocol in ['http', 'https', 'ftp']: proxy_dict[protocol] = '{}://{}{}'.format(protocol, host, port_str) auth = requests.auth.HTTPProxyAuth(user, password) if enabled and user and password else None return proxy_dict, auth
Example #15
Source File: dbConverter.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def userPasswordFromHost(self, hostname, username): """ Gets the password of an user to a server from its name. """ settings = QSettings() settings.beginGroup('PostgreSQL/servers') connections = settings.childGroups() settings.endGroup() for connection in connections: settings.beginGroup('PostgreSQL/servers/{0}'.format(connection)) host = settings.value('host') user = settings.value('username') password = settings.value('password') settings.endGroup() if host == hostname and username == user: return password return None
Example #16
Source File: file_selection_widget.py From quickmapservices with GNU General Public License v2.0 | 6 votes |
def show_selection_dialog(self): # Find the file dialog's working directory settings = QSettings() text = self.leText.text() if os.path.isdir(text): path = text elif os.path.isdir(os.path.dirname(text)): path = os.path.dirname(text) else: path = PluginSettings.last_icon_path() if self.is_folder: folder = QFileDialog.getExistingDirectory(self, self.dialog_title, path) if folder: self.leText.setText(folder) PluginSettings.set_last_icon_path(os.path.dirname(folder)) else: filename = getOpenFileName(self, self.dialog_title, path, self.ext) if filename: self.leText.setText(filename) PluginSettings.set_last_icon_path(os.path.dirname(filename))
Example #17
Source File: serverDBExplorer.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def storeConnection(self, server, database): ''' Stores database connection in the QSettings ''' (host, port, user, password) = self.getServerConfiguration(server) connection = server+'_'+database settings = QSettings() if not settings.contains('PostgreSQL/connections/'+connection+'/database'): settings.beginGroup('PostgreSQL/connections/'+connection) settings.setValue('database', database) settings.setValue('host', host) settings.setValue('port', port) settings.setValue('username', user) settings.setValue('password', password) settings.endGroup() return True return False
Example #18
Source File: minimumAreaTool.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def getCustomSizesDict(self): #get custom sizes from qsettings settings = QSettings() settings.beginGroup('DSGTools/CustomSizes/') currentSettings = settings.childGroups() settings.endGroup() customSizesDict = dict() #get each parameter for settingName in currentSettings: customSizesDict[settingName] = dict() settings = QSettings() settings.beginGroup('DSGTools/CustomSizes/'+settingName) customSizesDict[settingName]['shape'] = settings.value('shape') customSizesDict[settingName]['value'] = settings.value('value') settings.endGroup() return customSizesDict
Example #19
Source File: mapillary_api.py From go2mapillary with GNU General Public License v3.0 | 5 votes |
def getProxySettings(): s = QSettings() #getting proxy from qgis options settings if s.value("proxy/proxyEnabled", "") == "true": return { 'type': s.value("proxy/proxyType", ""), 'host': s.value("proxy/proxyHost", ""), 'port': s.value("proxy/proxyPort", ""), 'user': s.value("proxy/proxyUser", ""), 'password': s.value("proxy/proxyPassword", "") } else: return None
Example #20
Source File: exploreServerWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getServerConfiguration(self, name): """ Gets server configuration name: server name """ settings = QSettings() settings.beginGroup('PostgreSQL/servers/'+name) host = settings.value('host') port = settings.value('port') user = settings.value('username') password = settings.value('password') settings.endGroup() return (host, port, user, password)
Example #21
Source File: exploreServerWidget.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getServers(self): """ Gets server from QSettings """ settings = QSettings() settings.beginGroup('PostgreSQL/servers') currentConnections = settings.childGroups() settings.endGroup() return currentConnections
Example #22
Source File: GdalTools_utils.py From WMF with GNU General Public License v3.0 | 5 votes |
def setGdalBinPath(path): settings = QSettings() settings.setValue("/GdalTools/gdalPath", path) # Retrieves GDAL python modules location
Example #23
Source File: dsg_line_tool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def defineRubberBand(self): """ Defines the rubber band style """ settings = QSettings() myRed = int(settings.value("/qgis/default_measure_color_red", 222)) myGreen = int(settings.value("/qgis/default_measure_color_green", 155)) myBlue = int(settings.value("/qgis/default_measure_color_blue", 67)) self.rubberBand = QgsRubberBand(self.canvas) self.rubberBand.setColor(QColor(myRed, myGreen, myBlue, 100)) self.rubberBand.setWidth(3)
Example #24
Source File: shortcutTool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def hideOrShowMarkers(self): try: self.stackButton.setDefaultAction(self.sender()) except: pass qSettings = QSettings() currentState = qSettings.value(u'qgis/digitizing/marker_only_for_selected') qSettings.setValue(u'qgis/digitizing/marker_only_for_selected', not currentState) self.iface.mapCanvas().refresh()
Example #25
Source File: acquisitionFree.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getParametersFromConfig(self): #Método para obter as configurações da tool do QSettings #Parâmetro de retorno: parameters (Todas os parâmetros do QSettings usado na ferramenta) settings = QtCore.QSettings() settings.beginGroup('PythonPlugins/DsgTools/Options') undoPoints = settings.value('undoPoints') settings.endGroup() return int(undoPoints)
Example #26
Source File: acquisitionFreeController.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def createFeature(self, geom): #Método para criar feição #Parâmetro de entrada: geom (geometria adquirida) if geom : settings = QtCore.QSettings() canvas = self.getIface().mapCanvas() layer = canvas.currentLayer() tolerance = self.getTolerance(layer) geom = self.reprojectGeometry(geom) simplifyGeometry = self.simplifyGeometry(geom, tolerance) fields = layer.fields() feature = core.QgsFeature() feature.setGeometry(simplifyGeometry) feature.initAttributes(fields.count()) provider = layer.dataProvider() for i in range(fields.count()): defaultClauseCandidate = provider.defaultValueClause(i) if defaultClauseCandidate: feature.setAttribute(i, defaultClauseCandidate) formSuppressOnLayer = layer.editFormConfig().suppress() formSuppressOnSettings = self.getFormSuppressStateSettings() if formSuppressOnLayer == core.QgsEditFormConfig.SuppressOff or \ (formSuppressOnLayer == core.QgsEditFormConfig.SuppressDefault \ and formSuppressOnSettings): self.addFeatureWithoutForm(layer, feature) else: self.addFeatureWithForm(layer, feature)
Example #27
Source File: acquisitionFreeController.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getFormSuppressStateSettings(self): #Método para verificar se o formulário de aquisição está suprimido nas configurações do projeto #Parâmetro de retorno: suppressForm ( boleano ) s = QtCore.QSettings() suppressForm = s.value(u"qgis/digitizing/disable_enter_attribute_values_dialog") return suppressForm
Example #28
Source File: genericSelectionTool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getBlackList(self): settings = QSettings() settings.beginGroup('PythonPlugins/DsgTools/Options') valueList = settings.value('valueList') if valueList: valueList = valueList.split(';') return valueList else: return ['moldura']
Example #29
Source File: geometricaAquisition.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getSuppressOptions(self): qgisSettigns = QSettings() qgisSettigns.beginGroup('qgis/digitizing') setting = qgisSettigns.value('disable_enter_attribute_values_dialog') qgisSettigns.endGroup() return setting
Example #30
Source File: assignBandValueTool.py From DsgTools with GNU General Public License v2.0 | 5 votes |
def getSuppressOptions(self): qgisSettings = QSettings() qgisSettings.beginGroup('qgis/digitizing') setting = qgisSettings.value('disable_enter_attribute_values_dialog') qgisSettings.endGroup() return setting