本文整理汇总了Python中qgis.PyQt.QtCore.QSettings方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QSettings方法的具体用法?Python QtCore.QSettings怎么用?Python QtCore.QSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore
的用法示例。
在下文中一共展示了QtCore.QSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getProxiesConf
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例2: exportVectorLayer
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例3: getConnectionNameFromLayer
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例4: readSettings
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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)
示例5: storeConnection
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例6: storeConnectionConfiguration
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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()
示例7: setDefaultConnectionParameters
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例8: on_dropDatabasePushButton_clicked
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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()
示例9: setServerConfiguration
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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)
示例10: getCustomSizesDict
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例11: validationToolbarConfig
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
}
示例12: updateValidationToolbarConfig
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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()
示例13: getProxyConfiguration
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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)
示例14: storeConnection
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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
示例15: get_proxy_config
# 需要导入模块: from qgis.PyQt import QtCore [as 别名]
# 或者: from qgis.PyQt.QtCore import QSettings [as 别名]
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