当前位置: 首页>>代码示例>>Python>>正文


Python QgsSettings.setValue方法代码示例

本文整理汇总了Python中qgis.core.QgsSettings.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python QgsSettings.setValue方法的具体用法?Python QgsSettings.setValue怎么用?Python QgsSettings.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsSettings的用法示例。


在下文中一共展示了QgsSettings.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upgradeInstalledPlugins

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
def upgradeInstalledPlugins():
    installer = pyplugin_installer.instance()
    initPluginManager(installer)

    errors = []
    pluginsList = plugins.all().copy()
    for plugin in pluginsList:
        if isBoundlessPlugin(pluginsList[plugin]):
            if pluginsList[plugin]['installed'] and pluginsList[plugin]['status'] == 'upgradeable':
                dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugins.all()[plugin])
                dlg.exec_()
                if dlg.result():
                    errors.append(dlg.result())
                else:
                    updateAvailablePlugins()
                    loadPlugin(plugins.all()[plugin]['id'])
                    plugins.getAllInstalled(testLoad=True)
                    plugins.rebuild()
                    if not plugins.all()[plugin]["error"]:
                        if startPlugin(plugins.all()[plugin]['id']):
                            settings = QSettings()
                            settings.setValue('/PythonPlugins/' + plugins.all()[plugin]['id'], True)

    installer.exportPluginsToManager()
    return errors
开发者ID:boundlessgeo,项目名称:qgis-connect-plugin,代码行数:27,代码来源:utils.py

示例2: addBoundlessRepository

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
def addBoundlessRepository():
    """Add Boundless plugin repository to list of the available
       plugin repositories if it is not presented here
    """
    repoUrl = pluginSetting('repoUrl')

    if repoUrl == '':
        repoUrl = setRepositoryUrl()

    if isRepositoryInDirectory():
        return

    settings = QSettings()
    settings.beginGroup(reposGroup)
    hasBoundlessRepository = False
    for repo in settings.childGroups():
        url = settings.value(repo + '/url', '')
        if url == repoUrl:
            hasBoundlessRepository = True

    # Boundless repository not found, so we add it to the list
    if not hasBoundlessRepository:
        settings.setValue(boundlessRepoName + '/url', repoUrl)
        settings.setValue(boundlessRepoName + '/authcfg', '')
    settings.endGroup()
开发者ID:boundlessgeo,项目名称:qgis-connect-plugin,代码行数:27,代码来源:utils.py

示例3: installAllFromRepository

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
def installAllFromRepository():
    """Install Boundless plugins from remote repository
    """
    installer = pyplugin_installer.instance()
    initPluginManager(installer)

    errors = []
    pluginsList = plugins.all().copy()
    for plugin in pluginsList:
        if isBoundlessPlugin(pluginsList[plugin]):
            if (pluginsList[plugin]['installed'] and pluginsList[plugin]['deprecated']) or \
                    not pluginsList[plugin]['deprecated'] and \
                    pluginsList[plugin]["zip_repository"] != '':
                dlg = QgsPluginInstallerInstallingDialog(iface.mainWindow(), plugins.all()[plugin])
                dlg.exec_()
                if dlg.result():
                    errors.append(dlg.result())
                else:
                    updateAvailablePlugins()
                    loadPlugin(plugins.all()[plugin]['id'])
                    plugins.getAllInstalled(testLoad=True)
                    plugins.rebuild()
                    if not plugins.all()[plugin]["error"]:
                        if startPlugin(plugins.all()[plugin]['id']):
                            settings = QSettings()
                            settings.setValue('/PythonPlugins/' + plugins.all()[plugin]['id'], True)

    installer.exportPluginsToManager()
    return errors
开发者ID:boundlessgeo,项目名称:qgis-connect-plugin,代码行数:31,代码来源:utils.py

示例4: showSelectionDialog

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def showSelectionDialog(self):
        # Find the file dialog's working directory
        settings = QgsSettings()
        text = self.leText.text()
        if os.path.isdir(text):
            path = text
        elif os.path.isdir(os.path.dirname(text)):
            path = os.path.dirname(text)
        elif settings.contains('/Processing/LastInputPath'):
            path = settings.value('/Processing/LastInputPath')
        else:
            path = ''

        if self.isFolder:
            folder = QFileDialog.getExistingDirectory(self,
                                                      self.tr('Select Folder'), path)
            if folder:
                self.leText.setText(folder)
                settings.setValue('/Processing/LastInputPath',
                                  os.path.dirname(folder))
        else:
            filenames, selected_filter = QFileDialog.getOpenFileNames(self,
                                                                      self.tr('Select File'), path, self.tr('{} files').format(self.ext.upper()) + ' (*.' + self.ext + self.tr(');;All files (*.*)'))
            if filenames:
                self.leText.setText(u';'.join(filenames))
                settings.setValue('/Processing/LastInputPath',
                                  os.path.dirname(filenames[0]))
开发者ID:pblottiere,项目名称:QGIS,代码行数:29,代码来源:FileSelectionPanel.py

示例5: selectFile

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def selectFile(self):
        output = self.alg.parameterDefinition('OUTPUT')
        fileFilter = getFileFilter(output)

        settings = QgsSettings()
        if settings.contains('/Processing/LastOutputPath'):
            path = settings.value('/Processing/LastOutputPath')
        else:
            path = ProcessingConfig.getSetting(ProcessingConfig.OUTPUT_FOLDER)
        lastEncoding = settings.value('/Processing/encoding', 'System')
        fileDialog = QgsEncodingFileDialog(self,
                                           self.tr('Save file'),
                                           path,
                                           fileFilter,
                                           lastEncoding)
        fileDialog.setFileMode(QFileDialog.AnyFile)
        fileDialog.setAcceptMode(QFileDialog.AcceptSave)
        fileDialog.setOption(QFileDialog.DontConfirmOverwrite, False)
        if fileDialog.exec_() == QDialog.Accepted:
            files = fileDialog.selectedFiles()
            encoding = str(fileDialog.encoding())
            output.encoding = encoding
            filename = str(files[0])
            selectedFileFilter = str(fileDialog.selectedNameFilter())
            if not filename.lower().endswith(
                    tuple(re.findall("\\*(\\.[a-z]{1,10})", fileFilter))):
                ext = re.search("\\*(\\.[a-z]{1,10})", selectedFileFilter)
                if ext:
                    filename = filename + ext.group(1)
            self.leOutputFile.setText(filename)
            settings.setValue('/Processing/LastOutputPath',
                              os.path.dirname(filename))
            settings.setValue('/Processing/encoding', encoding)
开发者ID:dwsilk,项目名称:QGIS,代码行数:35,代码来源:FieldsCalculatorDialog.py

示例6: updateSeenPluginsList

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
 def updateSeenPluginsList(self):
     settings = QSettings()
     seenPlugins = settings.value(seenPluginGroup, list(self.plugins.keys()), str)
     for i in list(self.plugins.keys()):
         if seenPlugins.count(i) == 0:
             seenPlugins += [i]
     settings.setValue(seenPluginGroup, seenPlugins)
开发者ID:boundlessgeo,项目名称:qgis-connect-plugin,代码行数:9,代码来源:plugins.py

示例7: save

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
 def save(self, qsettings=None):
     if not qsettings:
         qsettings = QgsSettings()
     if self.valuetype == self.SELECTION:
         qsettings.setValue(self.qname, self.options.index(self.value))
     else:
         qsettings.setValue(self.qname, self.value)
开发者ID:mach0,项目名称:QGIS,代码行数:9,代码来源:ProcessingConfig.py

示例8: execute

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def execute(self):
        settings = QgsSettings()
        lastDir = settings.value('Processing/lastModelsDir', '')
        filename, selected_filter = QFileDialog.getOpenFileName(self.toolbox,
                                                                self.tr('Open model', 'AddModelFromFileAction'), lastDir,
                                                                self.tr('Processing model files (*.model *.MODEL)', 'AddModelFromFileAction'))
        if filename:
            try:
                settings.setValue('Processing/lastModelsDir',
                                  QFileInfo(filename).absoluteDir().absolutePath())

                ModelerAlgorithm.fromFile(filename)
            except WrongModelException:
                QMessageBox.warning(
                    self.toolbox,
                    self.tr('Error reading model', 'AddModelFromFileAction'),
                    self.tr('The selected file does not contain a valid model', 'AddModelFromFileAction'))
                return
            except:
                QMessageBox.warning(self.toolbox,
                                    self.tr('Error reading model', 'AddModelFromFileAction'),
                                    self.tr('Cannot read file', 'AddModelFromFileAction'))
                return
            destFilename = os.path.join(ModelerUtils.modelsFolders()[0], os.path.basename(filename))
            shutil.copyfile(filename, destFilename)
            QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()
开发者ID:rskelly,项目名称:QGIS,代码行数:28,代码来源:AddModelFromFileAction.py

示例9: chooseOutputFile

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def chooseOutputFile(self):
        # get last used dir
        settings = QgsSettings()
        lastUsedDir = settings.value(self.lastUsedVectorDirSettingsKey, ".")

        # get selected filter
        selectedFilter = self.cboFileFormat.currentData()

        # ask for a filename
        filename, filter = QFileDialog.getSaveFileName(self, self.tr("Choose where to save the file"), lastUsedDir,
                                                       selectedFilter)
        if filename == "":
            return

        filterString = QgsVectorFileWriter.filterForDriver(selectedFilter)
        ext = filterString[filterString.find('.'):]
        ext = ext[:ext.find(' ')]

        if not filename.lower().endswith(ext):
            filename += ext

        # store the last used dir
        settings.setValue(self.lastUsedVectorDirSettingsKey, QFileInfo(filename).filePath())

        self.editOutputFile.setText(filename)
开发者ID:GeoCat,项目名称:QGIS,代码行数:27,代码来源:dlg_export_vector.py

示例10: load

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def load(self):
        """ populate the mRepositories dict"""
        self.mRepositories = {}
        settings = QgsSettings()
        settings.beginGroup(reposGroup)
        # first, update repositories in QgsSettings if needed
        officialRepoPresent = False
        for key in settings.childGroups():
            url = settings.value(key + "/url", "", type=str)
            if url == officialRepo[1]:
                officialRepoPresent = True
        if not officialRepoPresent:
            settings.setValue(officialRepo[0] + "/url", officialRepo[1])

        for key in settings.childGroups():
            self.mRepositories[key] = {}
            self.mRepositories[key]["url"] = settings.value(key + "/url", "", type=str)
            self.mRepositories[key]["authcfg"] = settings.value(key + "/authcfg", "", type=str)
            self.mRepositories[key]["enabled"] = settings.value(key + "/enabled", True, type=bool)
            self.mRepositories[key]["valid"] = settings.value(key + "/valid", True, type=bool)
            self.mRepositories[key]["Relay"] = Relay(key)
            self.mRepositories[key]["xmlData"] = None
            self.mRepositories[key]["state"] = 0
            self.mRepositories[key]["error"] = ""
        settings.endGroup()
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:27,代码来源:installer_data.py

示例11: reject

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def reject(self):
        self.param = None

        settings = QgsSettings()
        settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())

        QDialog.reject(self)
开发者ID:pigreco,项目名称:QGIS,代码行数:9,代码来源:ModelerParameterDefinitionDialog.py

示例12: execute

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
 def execute(self):
     settings = QgsSettings()
     lastDir = settings.value('Processing/lastScriptsDir', '')
     filenames, selected_filter = QFileDialog.getOpenFileNames(self.toolbox,
                                                               self.tr('Script files', 'AddScriptFromFileAction'), lastDir,
                                                               self.tr('Script files (*.py *.PY)', 'AddScriptFromFileAction'))
     if filenames:
         validAlgs = 0
         wrongAlgs = []
         for filename in filenames:
             try:
                 settings.setValue('Processing/lastScriptsDir',
                                   QFileInfo(filename).absoluteDir().absolutePath())
                 script = ScriptAlgorithm(filename)
                 destFilename = os.path.join(ScriptUtils.scriptsFolders()[0], os.path.basename(filename))
                 with open(destFilename, 'w') as f:
                     f.write(script.script)
                 validAlgs += 1
             except WrongScriptException:
                 wrongAlgs.append(os.path.basename(filename))
         if validAlgs:
             QgsApplication.processingRegistry().providerById('script').refreshAlgorithms()
         if wrongAlgs:
             QMessageBox.warning(self.toolbox,
                                 self.tr('Error reading scripts', 'AddScriptFromFileAction'),
                                 self.tr('The following files do not contain a valid script:\n-', 'AddScriptFromFileAction') +
                                 "\n-".join(wrongAlgs))
开发者ID:nirvn,项目名称:QGIS,代码行数:29,代码来源:AddScriptFromFileAction.py

示例13: saveToGeopackage

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def saveToGeopackage(self):
        file_filter = self.tr('GeoPackage files (*.gpkg);;All files (*.*)', 'OutputFile')

        settings = QgsSettings()
        if settings.contains('/Processing/LastOutputPath'):
            path = settings.value('/Processing/LastOutputPath')
        else:
            path = ProcessingConfig.getSetting(ProcessingConfig.OUTPUT_FOLDER)

        filename, filter = QFileDialog.getSaveFileName(self, self.tr("Save to GeoPackage"), path,
                                                       file_filter, options=QFileDialog.DontConfirmOverwrite)

        if not filename:
            return

        layer_name, ok = QInputDialog.getText(self, self.tr('Save to GeoPackage'), self.tr('Layer name'), text=self.parameter.name().lower())
        if ok:
            self.use_temporary = False
            if not filename.lower().endswith('.gpkg'):
                filename += '.gpkg'
            settings.setValue('/Processing/LastOutputPath',
                              os.path.dirname(filename))

            uri = QgsDataSourceUri()
            uri.setDatabase(filename)
            uri.setDataSource('', layer_name,
                              'geom' if isinstance(self.parameter, QgsProcessingParameterFeatureSink) and self.parameter.hasGeometry() else None)
            self.leText.setText("ogr:" + uri.uri())

            self.skipOutputChanged.emit(False)
            self.destinationChanged.emit()
开发者ID:lbartoletti,项目名称:QGIS,代码行数:33,代码来源:DestinationSelectionPanel.py

示例14: showFileSelectionDialog

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def showFileSelectionDialog(self):
        settings = QgsSettings()
        text = str(self.text.text())
        if os.path.isdir(text):
            path = text
        elif os.path.isdir(os.path.dirname(text)):
            path = os.path.dirname(text)
        elif settings.contains('/Processing/LastInputPath'):
            path = str(settings.value('/Processing/LastInputPath'))
        else:
            path = ''

        ret, selected_filter = QFileDialog.getOpenFileNames(self, self.tr('Select Files'), path,
                                                            getFileFilter(self.param))
        if ret:
            files = list(ret)
            settings.setValue('/Processing/LastInputPath',
                              os.path.dirname(str(files[0])))
            for i, filename in enumerate(files):
                files[i] = dataobjects.getRasterSublayer(filename, self.param)
            if len(files) == 1:
                self.text.setText(files[0])
                self.textEditingFinished()
            else:
                if isinstance(self.param, QgsProcessingParameterMultipleLayers):
                    self.text.setText(';'.join(str(f) for f in files))
                else:
                    rowdif = len(files) - (self._table().rowCount() - self.row)
                    for i in range(rowdif):
                        self._panel().addRow()
                    for i, f in enumerate(files):
                        self._table().cellWidget(i + self.row,
                                                 self.col).setValue(f)
开发者ID:mbernasocchi,项目名称:QGIS,代码行数:35,代码来源:BatchInputSelectionPanel.py

示例15: saveToSpatialite

# 需要导入模块: from qgis.core import QgsSettings [as 别名]
# 或者: from qgis.core.QgsSettings import setValue [as 别名]
    def saveToSpatialite(self):
        fileFilter = self.tr('SpatiaLite files (*.sqlite)', 'OutputFile')

        settings = QgsSettings()
        if settings.contains('/Processing/LastOutputPath'):
            path = settings.value('/Processing/LastOutputPath')
        else:
            path = ProcessingConfig.getSetting(ProcessingConfig.OUTPUT_FOLDER)

        fileDialog = QgsEncodingFileDialog(
            self, self.tr('Save SpatiaLite'), path, fileFilter, self.encoding)
        fileDialog.setFileMode(QFileDialog.AnyFile)
        fileDialog.setAcceptMode(QFileDialog.AcceptSave)
        fileDialog.setOption(QFileDialog.DontConfirmOverwrite, True)

        if fileDialog.exec_() == QDialog.Accepted:
            self.use_temporary = False
            files = fileDialog.selectedFiles()
            self.encoding = str(fileDialog.encoding())
            fileName = str(files[0])
            selectedFileFilter = str(fileDialog.selectedNameFilter())
            if not fileName.lower().endswith(
                    tuple(re.findall("\\*(\\.[a-z]{1,10})", fileFilter))):
                ext = re.search("\\*(\\.[a-z]{1,10})", selectedFileFilter)
                if ext:
                    fileName += ext.group(1)
            settings.setValue('/Processing/LastOutputPath',
                              os.path.dirname(fileName))
            settings.setValue('/Processing/encoding', self.encoding)

            uri = QgsDataSourceUri()
            uri.setDatabase(fileName)
            uri.setDataSource('', self.parameter.name().lower(),
                              'the_geom' if isinstance(self.parameter, QgsProcessingParameterFeatureSink) and self.parameter.hasGeometry() else None)
            self.leText.setText("spatialite:" + uri.uri())
开发者ID:timlinux,项目名称:QGIS,代码行数:37,代码来源:DestinationSelectionPanel.py


注:本文中的qgis.core.QgsSettings.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。