def __init__(self, parent, alg): super(BatchPanel, self).__init__(None) self.setupUi(self) self.wrappers = [] self.btnAdvanced.hide() # Set icons self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnOpen.setIcon(QgsApplication.getThemeIcon('/mActionFileOpen.svg')) self.btnSave.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.btnAdvanced.setIcon(QgsApplication.getThemeIcon("/processingAlgorithm.svg")) self.alg = alg self.parent = parent self.btnAdd.clicked.connect(self.addRow) self.btnRemove.clicked.connect(self.removeRows) self.btnOpen.clicked.connect(self.load) self.btnSave.clicked.connect(self.save) self.btnAdvanced.toggled.connect(self.toggleAdvancedMode) self.tblParameters.horizontalHeader().sectionDoubleClicked.connect( self.fillParameterValues) self.tblParameters.horizontalHeader().resizeSections(QHeaderView.ResizeToContents) self.tblParameters.horizontalHeader().setDefaultSectionSize(250) self.tblParameters.horizontalHeader().setMinimumSectionSize(150) self.initWidgets()
def __init__(self, resourceType): super(GetScriptsAndModelsDialog, self).__init__(iface.mainWindow()) self.setupUi(self) if hasattr(self.leFilter, 'setPlaceholderText'): self.leFilter.setPlaceholderText(self.tr('Search...')) self.manager = QgsNetworkAccessManager.instance() repoUrl = ProcessingConfig.getSetting(ProcessingConfig.MODELS_SCRIPTS_REPO) self.resourceType = resourceType if self.resourceType == self.MODELS: self.folder = ModelerUtils.modelsFolders()[0] self.urlBase = '{}/models/'.format(repoUrl) self.icon = QgsApplication.getThemeIcon("/processingModel.svg") elif self.resourceType == self.SCRIPTS: self.folder = ScriptUtils.scriptsFolders()[0] self.urlBase = '{}/scripts/'.format(repoUrl) self.icon = QgsApplication.getThemeIcon("/processingScript.svg") self.lastSelectedItem = None self.updateProvider = False self.data = None self.populateTree() self.buttonBox.accepted.connect(self.okPressed) self.buttonBox.rejected.connect(self.cancelPressed) self.tree.currentItemChanged.connect(self.currentItemChanged) self.leFilter.textChanged.connect(self.fillTree)
def getGroupIcon(group): if group == ProcessingConfig.tr('General'): return QgsApplication.getThemeIcon("/processingAlgorithm.svg") if group in ProcessingConfig.settingIcons: return ProcessingConfig.settingIcons[group] else: return QgsApplication.getThemeIcon("/processingAlgorithm.svg")
def __init__(self, parent, alg): super(BatchPanel, self).__init__(None) self.setupUi(self) self.wrappers = [] self.btnAdvanced.hide() # Set icons self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnOpen.setIcon(QgsApplication.getThemeIcon('/mActionFileOpen.svg')) self.btnSave.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.btnAdvanced.setIcon(QIcon(os.path.join(pluginPath, 'images', 'alg.png'))) self.alg = alg self.parent = parent self.btnAdd.clicked.connect(self.addRow) self.btnRemove.clicked.connect(self.removeRows) self.btnOpen.clicked.connect(self.load) self.btnSave.clicked.connect(self.save) self.btnAdvanced.toggled.connect(self.toggleAdvancedMode) self.tblParameters.horizontalHeader().sectionDoubleClicked.connect( self.fillParameterValues) self.initWidgets()
def __init__(self): super(InterpolationDataWidget, self).__init__(None) self.setupUi(self) self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.cmbLayers.setFilters(QgsMapLayerProxyModel.VectorLayer) self.cmbFields.setFilters(QgsFieldProxyModel.Numeric) self.cmbFields.setLayer(self.cmbLayers.currentLayer())
def initGui(self): self.toolbox = ProcessingToolbox() self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox) self.toolbox.hide() self.resultsDock = ResultsDock() self.iface.addDockWidget(Qt.RightDockWidgetArea, self.resultsDock) self.resultsDock.hide() resultsList.resultAdded.connect(self.resultsDock.fillTree) self.menu = QMenu(self.iface.mainWindow().menuBar()) self.menu.setObjectName('processing') self.menu.setTitle(self.tr('Pro&cessing')) self.toolboxAction = self.toolbox.toggleViewAction() self.toolboxAction.setObjectName('toolboxAction') self.toolboxAction.setIcon( QgsApplication.getThemeIcon("/processingAlgorithm.svg")) self.toolboxAction.setText(self.tr('&Toolbox')) self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T') self.menu.addAction(self.toolboxAction) self.modelerAction = QAction( QgsApplication.getThemeIcon("/processingModel.svg"), self.tr('Graphical &Modeler...'), self.iface.mainWindow()) self.modelerAction.setObjectName('modelerAction') self.modelerAction.triggered.connect(self.openModeler) self.iface.registerMainWindowAction(self.modelerAction, 'Ctrl+Alt+M') self.menu.addAction(self.modelerAction) self.historyAction = QAction( QIcon(os.path.join(cmd_folder, 'images', 'history.svg')), self.tr('&History...'), self.iface.mainWindow()) self.historyAction.setObjectName('historyAction') self.historyAction.triggered.connect(self.openHistory) self.iface.registerMainWindowAction(self.historyAction, 'Ctrl+Alt+H') self.menu.addAction(self.historyAction) self.resultsAction = self.resultsDock.toggleViewAction() self.resultsAction.setObjectName('resultsAction') self.resultsAction.setIcon( QgsApplication.getThemeIcon("/processingResult.svg")) self.resultsAction.setText(self.tr('&Results Viewer')) self.iface.registerMainWindowAction(self.resultsAction, 'Ctrl+Alt+R') self.menu.addAction(self.resultsAction) menuBar = self.iface.mainWindow().menuBar() menuBar.insertMenu( self.iface.firstRightStandardMenu().menuAction(), self.menu) self.menu.addSeparator() initializeMenus() createMenus()
def contextMenuEvent(self, e): menu = QMenu(self) iconRun = QgsApplication.getThemeIcon("console/iconRunConsole.png") iconClear = QgsApplication.getThemeIcon("console/iconClearConsole.png") iconHideTool = QgsApplication.getThemeIcon("console/iconHideToolConsole.png") iconSettings = QgsApplication.getThemeIcon("console/iconSettingsConsole.png") hideToolBar = menu.addAction(iconHideTool, QCoreApplication.translate("PythonConsole", "Hide/Show Toolbar"), self.hideToolBar) menu.addSeparator() showEditorAction = menu.addAction(QCoreApplication.translate("PythonConsole", "Show Editor"), self.showEditor) menu.addSeparator() runAction = menu.addAction(iconRun, QCoreApplication.translate("PythonConsole", "Enter Selected"), self.enteredSelected, QKeySequence(Qt.CTRL + Qt.Key_E)) clearAction = menu.addAction(iconClear, QCoreApplication.translate("PythonConsole", "Clear console"), self.clearConsole) menu.addSeparator() copyAction = menu.addAction(QCoreApplication.translate("PythonConsole", "Copy"), self.copy, QKeySequence.Copy) menu.addSeparator() selectAllAction = menu.addAction(QCoreApplication.translate("PythonConsole", "Select All"), self.selectAll, QKeySequence.SelectAll) menu.addSeparator() settingsDialog = menu.addAction(iconSettings, QCoreApplication.translate("PythonConsole", "Settings"), self.parent.openSettings) runAction.setEnabled(False) clearAction.setEnabled(False) copyAction.setEnabled(False) selectAllAction.setEnabled(False) showEditorAction.setEnabled(True) if self.hasSelectedText(): runAction.setEnabled(True) copyAction.setEnabled(True) if not self.text(3) == '': selectAllAction.setEnabled(True) clearAction.setEnabled(True) if self.parent.tabEditorWidget.isVisible(): showEditorAction.setEnabled(False) action = menu.exec_(self.mapToGlobal(e.pos()))
def __init__(self, parent=None): super(EnumModelerWidget, self).__init__(parent) self.setupUi(self) self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnClear.setIcon(QgsApplication.getThemeIcon('console/iconClearConsole.svg')) self.btnAdd.clicked.connect(self.addItem) self.btnRemove.clicked.connect(lambda: self.removeItems()) self.btnClear.clicked.connect(lambda: self.removeItems(True)) self.lstItems.setModel(QStandardItemModel()) self.lstItems.model().itemChanged.connect(self.onItemChanged)
def __init__(self, report): super(ReportDialog, self).__init__() self.setupUi(self) self.actionSaveAll.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.actionSaveSelected.setIcon(QgsApplication.getThemeIcon('/mActionFileSaveAs.svg')) self.actionOpenTracker.setIcon(QgsApplication.getThemeIcon('/mActionHelpAPI.png')) self.actionSaveAll.triggered.connect(lambda: self.saveResults(True)) self.actionSaveSelected.triggered.connect(lambda: self.saveResults(False)) self.resultsTree.clear() results = report.results self.saveFailed(results) self.reopen = False allResults = defaultdict(list) for result in results: test = result.test allResults[test.group].append(result) for group, groupResults in list(allResults.items()): groupItem = QTreeWidgetItem() groupItem.setText(0, group) for result in groupResults: resultItem = QTreeWidgetItem() resultItem.result = result resultItem.setText(0, result.test.name) resultItem.setForeground(0, self.resultColor[result.status]) groupItem.addChild(resultItem) self.resultsTree.addTopLevelItem(groupItem) self.resultsTree.expandAll() self.resultsTree.itemClicked.connect(self.itemClicked) self.resultsTree.customContextMenuRequested.connect(self.showPopupMenu) button = QPushButton("Re-open test selector"); def _reopen(): self.reopen = True self.close() button.clicked.connect(_reopen) self.buttonBox.addButton(button, QDialogButtonBox.ActionRole); self.buttonBox.rejected.connect(self.close)
def __init__(self, table, parent): TreeItem.__init__(self, table, parent) table.changed.connect(self.itemChanged) table.deleted.connect(self.itemDeleted) self.populate() # load (shared) icon with first instance of table item if not hasattr(TableItem, 'tableIcon'): TableItem.tableIcon = QgsApplication.getThemeIcon("/mIconTableLayer.svg") TableItem.viewIcon = QIcon(":/db_manager/icons/view.png") TableItem.viewMaterializedIcon = QIcon(":/db_manager/icons/view_materialized.png") TableItem.layerPointIcon = QgsApplication.getThemeIcon("/mIconPointLayer.svg") TableItem.layerLineIcon = QgsApplication.getThemeIcon("/mIconLineLayer.svg") TableItem.layerPolygonIcon = QgsApplication.getThemeIcon("/mIconPolygonLayer.svg") TableItem.layerRasterIcon = QgsApplication.getThemeIcon("/mIconRasterLayer.svg") TableItem.layerUnknownIcon = QIcon(":/db_manager/icons/layer_unknown.png")
def __init__(self): super(HistoryDialog, self).__init__(None) self.setupUi(self) QgsGui.instance().enableAutoGeometryRestore(self) self.groupIcon = QgsApplication.getThemeIcon('mIconFolder.svg') self.keyIcon = self.style().standardIcon(QStyle.SP_FileIcon) self.clearButton = QPushButton(self.tr('Clear')) self.clearButton.setToolTip(self.tr('Clear history')) self.buttonBox.addButton(self.clearButton, QDialogButtonBox.ActionRole) self.saveButton = QPushButton(QCoreApplication.translate('HistoryDialog', 'Save As…')) self.saveButton.setToolTip(self.tr('Save history')) self.buttonBox.addButton(self.saveButton, QDialogButtonBox.ActionRole) self.tree.doubleClicked.connect(self.executeAlgorithm) self.tree.currentItemChanged.connect(self.changeText) self.clearButton.clicked.connect(self.clearLog) self.saveButton.clicked.connect(self.saveLog) self.tree.setContextMenuPolicy(Qt.CustomContextMenu) self.tree.customContextMenuRequested.connect(self.showPopupMenu) self.fillTree()
def __init__(self, param): super().__init__(param) self.label = QLabel('') self.units_combo = QComboBox() self.base_units = QgsUnitTypes.DistanceUnknownUnit for u in (QgsUnitTypes.DistanceMeters, QgsUnitTypes.DistanceKilometers, QgsUnitTypes.DistanceFeet, QgsUnitTypes.DistanceMiles, QgsUnitTypes.DistanceYards): self.units_combo.addItem(QgsUnitTypes.toString(u), u) label_margin = self.fontMetrics().width('X') self.layout().insertSpacing(1, label_margin / 2) self.layout().insertWidget(2, self.label) self.layout().insertWidget(3, self.units_combo) self.layout().insertSpacing(4, label_margin / 2) self.warning_label = QLabel() icon = QgsApplication.getThemeIcon('mIconWarning.svg') size = max(24, self.spnValue.height() * 0.5) self.warning_label.setPixmap(icon.pixmap(icon.actualSize(QSize(size, size)))) self.warning_label.setToolTip(self.tr('Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results.')) self.layout().insertWidget(4, self.warning_label) self.layout().insertSpacing(5, label_margin) self.setUnits(QgsUnitTypes.DistanceUnknownUnit)
def initGui(self): """startup""" # run run_icon = QIcon('%s/%s' % (self.context.ppath, 'images/MetaSearch.png')) self.action_run = QAction(run_icon, 'MetaSearch', self.iface.mainWindow()) self.action_run.setWhatsThis(QCoreApplication.translate('MetaSearch', 'MetaSearch plugin')) self.action_run.setStatusTip(QCoreApplication.translate('MetaSearch', 'Search Metadata Catalogs')) self.action_run.triggered.connect(self.run) self.iface.addWebToolBarIcon(self.action_run) self.iface.addPluginToWebMenu(self.web_menu, self.action_run) # help help_icon = QgsApplication.getThemeIcon('/mActionHelpContents.svg') self.action_help = QAction(help_icon, 'Help', self.iface.mainWindow()) self.action_help.setWhatsThis(QCoreApplication.translate('MetaSearch', 'MetaSearch plugin help')) self.action_help.setStatusTip(QCoreApplication.translate('MetaSearch', 'Get Help on MetaSearch')) self.action_help.triggered.connect(self.help) self.iface.addPluginToWebMenu(self.web_menu, self.action_help) # prefab the dialog but not open it yet self.dialog = MetaSearchDialog(self.iface)
def createMenu(self): self.menu.clear() self.menu.setMinimumWidth(self.width()) fill_down_action = QAction(self.tr('Fill Down'), self.menu) fill_down_action.triggered.connect(self.fillDown) fill_down_action.setToolTip(self.tr('Copy the first value down to all other rows')) self.menu.addAction(fill_down_action) calculate_by_expression = QAction(QCoreApplication.translate('BatchPanel', 'Calculate by Expression…'), self.menu) calculate_by_expression.setIcon(QgsApplication.getThemeIcon('/mActionCalculateField.svg')) calculate_by_expression.triggered.connect(self.calculateByExpression) calculate_by_expression.setToolTip(self.tr('Calculates parameter values by evaluating an expression')) self.menu.addAction(calculate_by_expression) add_by_expression = QAction(QCoreApplication.translate('BatchPanel', 'Add Values by Expression…'), self.menu) add_by_expression.triggered.connect(self.addByExpression) add_by_expression.setToolTip(self.tr('Adds new parameter values by evaluating an expression')) self.menu.addAction(add_by_expression) if isinstance(self.parameterDefinition, (QgsProcessingParameterFile, QgsProcessingParameterMapLayer, QgsProcessingParameterRasterLayer, QgsProcessingParameterMeshLayer, QgsProcessingParameterVectorLayer, QgsProcessingParameterFeatureSource)): self.menu.addSeparator() find_by_pattern_action = QAction(QCoreApplication.translate('BatchPanel', 'Add Files by Pattern…'), self.menu) find_by_pattern_action.triggered.connect(self.addFilesByPattern) find_by_pattern_action.setToolTip(self.tr('Adds files by a file pattern match')) self.menu.addAction(find_by_pattern_action)
def __init__(self, descriptionFile, script=None): """The script parameter can be used to directly pass the code of the script without a file. This is to be used from the script edition dialog, but should not be used in other cases. """ super().__init__() self._icon = QgsApplication.getThemeIcon("/processingScript.svg") self._name = '' self._display_name = '' self._group = '' self._flags = None self.script = script self.allowEdit = True self.noCRSWarning = False self.descriptionFile = descriptionFile if script is not None: self.defineCharacteristicsFromScript() if descriptionFile is not None: self.defineCharacteristicsFromFile() self.ns = {} self.cleaned_script = None self.results = {}
def __init__(self, colormap, vMin, vMax, fnRedraw, parent=None): qtBaseClass.__init__(self) uiDialog.__init__(self, parent) self.setupUi(self) self.buttonBox.hide() # currently not used self.colormap = colormap self.vMin = vMin self.vMax = vMax self.fnRedraw = fnRedraw self.model = ColorMapModel(self.colormap) self.viewColorMap.setModel(self.model) self.viewColorMap.setItemDelegate(ValueDelegate(self.viewColorMap)) initColorRampComboBox(self.cboColorRamp) self.btnAdd.setIcon(QgsApplication.getThemeIcon("/mActionSignPlus.png")) self.btnRemove.setIcon(QgsApplication.getThemeIcon("/mActionSignMinus.png")) self.btnLoad.setIcon(QgsApplication.getThemeIcon("/mActionFileOpen.svg")) self.btnSave.setIcon(QgsApplication.getThemeIcon("/mActionFileSaveAs.svg")) # make sure we accept only doubles for min/max values self.editMin.setValidator(QDoubleValidator(self.editMin)) self.editMax.setValidator(QDoubleValidator(self.editMax)) self.editMin.setText("%.3f" % vMin) self.editMax.setText("%.3f" % vMax) self.updateGUI() self.connect(self.btnAdd, SIGNAL("clicked()"), self.addItem) self.connect(self.btnRemove, SIGNAL("clicked()"), self.removeItem) self.connect(self.btnLoad, SIGNAL("clicked()"), self.loadColorMap) self.connect(self.btnSave, SIGNAL("clicked()"), self.saveColorMap) self.connect(self.btnClassify, SIGNAL("clicked()"), self.classify) self.connect(self.model, SIGNAL("dataChanged(QModelIndex,QModelIndex)"), self.updatePreview) self.connect(self.model, SIGNAL("rowsInserted(QModelIndex,int,int)"), self.updatePreview) self.connect(self.model, SIGNAL("rowsRemoved(QModelIndex,int,int)"), self.updatePreview) #self.connect(self.model, SIGNAL("rowsMoved(QModelIndex,int,int,QModelIndex,int)"), self.updatePreview) self.connect(self.viewColorMap, SIGNAL("doubleClicked(QModelIndex)"), self.viewDoubleClicked) self.connect(self.radIntLinear, SIGNAL("clicked()"), self.setMethod) self.connect(self.radIntDiscrete, SIGNAL("clicked()"), self.setMethod) self.connect(self.chkFillValuesBelow, SIGNAL("clicked()"), self.setClipLow) self.connect(self.chkFillValuesAbove, SIGNAL("clicked()"), self.setClipHigh)
def __init__(self, parent=None): super(FieldsMappingPanel, self).__init__(parent) self.setupUi(self) self.addButton.setIcon(QgsApplication.getThemeIcon("/mActionNewAttribute.svg")) self.deleteButton.setIcon(QgsApplication.getThemeIcon('/mActionDeleteAttribute.svg')) self.upButton.setIcon(QgsApplication.getThemeIcon('/mActionArrowUp.svg')) self.downButton.setIcon(QgsApplication.getThemeIcon('/mActionArrowDown.svg')) self.resetButton.setIcon(QgsApplication.getThemeIcon('/mIconClearText.svg')) self.configure() self.model.modelReset.connect(self.on_model_modelReset) self.model.rowsInserted.connect(self.on_model_rowsInserted) self.layerCombo.setAllowEmptyLayer(True) self.layerCombo.setFilters(QgsMapLayerProxyModel.VectorLayer)
def __init__(self, parent=None): super(FieldsMappingPanel, self).__init__(parent) self.setupUi(self) self.addButton.setIcon(QgsApplication.getThemeIcon("/mActionNewAttribute.svg")) self.deleteButton.setIcon(QgsApplication.getThemeIcon('/mActionDeleteAttribute.svg')) self.upButton.setIcon(QgsApplication.getThemeIcon('/mActionArrowUp.svg')) self.downButton.setIcon(QgsApplication.getThemeIcon('/mActionArrowDown.svg')) self.resetButton.setIcon(QgsApplication.getThemeIcon('/mIconClearText.svg')) self.model = FieldsMappingModel() self.fieldsView.setModel(self.model) self.model.rowsInserted.connect(self.on_model_rowsInserted) self.fieldsView.setItemDelegate(FieldDelegate()) self.updateLayerCombo()
def __init__(self, parent, alg): super(BatchPanel, self).__init__(None) self.setupUi(self) self.wrappers = [] self.btnAdvanced.hide() # Set icons self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnOpen.setIcon(QgsApplication.getThemeIcon('/mActionFileOpen.svg')) self.btnSave.setIcon(QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.btnAdvanced.setIcon(QgsApplication.getThemeIcon("/processingAlgorithm.svg")) self.alg = alg self.parent = parent self.btnAdd.clicked.connect(self.addRow) self.btnRemove.clicked.connect(self.removeRows) self.btnOpen.clicked.connect(self.load) self.btnSave.clicked.connect(self.save) self.btnAdvanced.toggled.connect(self.toggleAdvancedMode) self.tblParameters.horizontalHeader().resizeSections(QHeaderView.ResizeToContents) self.tblParameters.horizontalHeader().setDefaultSectionSize(250) self.tblParameters.horizontalHeader().setMinimumSectionSize(150) self.processing_context = createContext() class ContextGenerator(QgsProcessingContextGenerator): def __init__(self, context): super().__init__() self.processing_context = context def processingContext(self): return self.processing_context self.context_generator = ContextGenerator(self.processing_context) self.column_to_parameter_definition = {} self.parameter_to_column = {} self.initWidgets()
def initGui(self): self.actionAbout = QAction(self.tr("About RasterTransparency…"), self.iface.mainWindow()) self.actionAbout.setIcon(QgsApplication.getThemeIcon("/mActionHelpContents.svg")) self.actionAbout.setObjectName("aboutRasterTransparency") self.actionAbout.triggered.connect(self.about) self.iface.addPluginToRasterMenu(self.tr("Raster transparency"), self.actionAbout) self.iface.registerMapLayerConfigWidgetFactory(self.factory)
def menu(self): menu = QMenu() status = "[Not in sync]" if self.status == self.NOT_IN_SYNC else "" addAction = QAction(icon("reset.png"), "Add to project %s" % status, menu) addAction.triggered.connect(self.add) menu.addAction(addAction) deleteAction = QAction(QgsApplication.getThemeIcon('/mActionDeleteSelected.svg'), "Delete", menu) deleteAction.triggered.connect(self.delete) menu.addAction(deleteAction) return menu
def contextMenuEvent(self, e): menu = QMenu(self) iconRun = QgsApplication.getThemeIcon("console/iconRunConsole.png") iconPastebin = QgsApplication.getThemeIcon("console/iconCodepadConsole.png") iconClear = QgsApplication.getThemeIcon("console/iconClearConsole.png") iconHideTool = QgsApplication.getThemeIcon("console/iconHideToolConsole.png") hideToolBar = menu.addAction(iconHideTool, "Hide/Show Toolbar", self.hideToolBar) menu.addSeparator() runAction = menu.addAction(iconRun, "Enter Selected", self.enteredSelected, QKeySequence(Qt.CTRL + Qt.Key_E)) clearAction = menu.addAction(iconClear, "Clear console", self.clearConsole) menu.addSeparator() copyAction = menu.addAction("Copy", self.copy, QKeySequence.Copy) pastebinAction = menu.addAction(iconPastebin, "Share on codepad", self.pastebin) menu.addSeparator() selectAllAction = menu.addAction("Select All", self.selectAll, QKeySequence.SelectAll) runAction.setEnabled(False) clearAction.setEnabled(False) copyAction.setEnabled(False) pastebinAction.setEnabled(False) selectAllAction.setEnabled(False) if self.hasSelectedText(): runAction.setEnabled(True) copyAction.setEnabled(True) pastebinAction.setEnabled(True) if not self.text(3) == '': selectAllAction.setEnabled(True) clearAction.setEnabled(True) action = menu.exec_(self.mapToGlobal(e.pos()))
def registerDatabaseActions(self, mainWindow): action = QAction(QApplication.translate("DBManagerPlugin", "&Re-connect"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Database"), self.reconnectActionSlot) if self.schemas() is not None: action = QAction(QApplication.translate("DBManagerPlugin", "&Create Schema…"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Schema"), self.createSchemaActionSlot) action = QAction(QApplication.translate("DBManagerPlugin", "&Delete (Empty) Schema"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Schema"), self.deleteSchemaActionSlot) action = QAction(QApplication.translate("DBManagerPlugin", "Delete Selected Item"), self) mainWindow.registerAction(action, None, self.deleteActionSlot) action.setShortcuts(QKeySequence.Delete) action = QAction(QgsApplication.getThemeIcon("/mActionCreateTable.svg"), QApplication.translate("DBManagerPlugin", "&Create Table…"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"), self.createTableActionSlot) action = QAction(QgsApplication.getThemeIcon("/mActionEditTable.svg"), QApplication.translate("DBManagerPlugin", "&Edit Table…"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"), self.editTableActionSlot) action = QAction(QgsApplication.getThemeIcon("/mActionDeleteTable.svg"), QApplication.translate("DBManagerPlugin", "&Delete Table/View…"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"), self.deleteTableActionSlot) action = QAction(QApplication.translate("DBManagerPlugin", "&Empty Table…"), self) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"), self.emptyTableActionSlot) if self.schemas() is not None: action = QAction(QApplication.translate("DBManagerPlugin", "&Move to Schema"), self) action.setMenu(QMenu(mainWindow)) def invoke_callback(): return mainWindow.invokeCallback(self.prepareMenuMoveTableToSchemaActionSlot) action.menu().aboutToShow.connect(invoke_callback) mainWindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"))
def __init__(self, parent, alg): QWidget.__init__(self) self.setupUi(self) self.btnAdvanced.hide() # Set icons self.btnAdd.setIcon(QgsApplication.getThemeIcon('/mActionSignPlus.png')) self.btnRemove.setIcon(QgsApplication.getThemeIcon('/mActionSignMinus.png')) self.btnAdvanced.setIcon(QIcon(':/processing/images/alg.png')) self.alg = alg self.parent = parent self.btnAdd.clicked.connect(self.addRow) self.btnRemove.clicked.connect(self.removeRows) self.btnAdvanced.toggled.connect(self.toggleAdvancedMode) self.tblParameters.horizontalHeader().sectionDoubleClicked.connect( self.fillParameterValues) self.initWidgets()
def addMenuShow(self): menu = self.sender() menu.clear() indexes = self.tvData.selectedIndexes() if not indexes: return item = indexes[0].data(Qt.UserRole) add_text = self.tr('Add layer') if isinstance(item, LayerItem) else self.tr(u'Add all layers from project') add = menu.addAction(QgsApplication.getThemeIcon('/mActionAddMap.svg'), add_text, lambda: self.addLayer(indexes[0])) f = add.font() f.setBold(True) add.setFont(f) if not isinstance(item, VectorItem): return sep = menu.addSeparator() sep.setText(self.tr('Add as...')) sep.setEnabled(False) load_layer_as = partial(self.plugin.loadLayerType, item=item) menu.addAction(QgsApplication.getThemeIcon('/mIconPointLayer.svg'), self.tr('Points'), lambda: load_layer_as(geom_type='MultiPoint')) menu.addAction(QgsApplication.getThemeIcon('/mIconLineLayer.svg'), self.tr('Linestring'), lambda: load_layer_as(geom_type='MultiLineString')) menu.addAction(QgsApplication.getThemeIcon('/mIconPolygonLayer.svg'), self.tr('Polygons'), lambda: load_layer_as(geom_type='MultiPolygon'))
def initGui(self): self.eSearch = QgsFilterLineEdit(self.dockWidgetContents) self.eSearch.setObjectName(u"eSearch") self.eSearch.setPlaceholderText(self.tr("Search...")) self.editLayout.addWidget(self.eSearch) #Toolbar self.btnAddLayer.setIcon( QgsApplication.getThemeIcon('/mActionAddMap.svg') ) menu = QMenu() menu.aboutToShow.connect(self.addMenuShow) self.btnAddLayer.setMenu(menu) self.btnAddLayer.clicked.connect( self.addItems ) self.btnRefresh.clicked.connect(lambda checked: self.refreshItems( self.tvData.selectedIndexes()[0] if self.tvData.selectedIndexes() else None )) self.btnRefresh.setIcon( QgsApplication.getThemeIcon('/mActionReload.svg') ) #Filters settings = QSettings() self.gbFilters.setCollapsed( not settings.value( '{}/filters/filters'.format(CONFIG_NAME), False, bool ) ) self.cbVectors.setChecked( settings.value( '{}/filters/vectors'.format(CONFIG_NAME), True, bool ) ) self.cbTables.setChecked( settings.value( '{}/filters/tables'.format(CONFIG_NAME), True, bool ) ) self.cbRasters.setChecked( settings.value( '{}/filters/rasters'.format(CONFIG_NAME), True, bool ) ) self.cbWms.setChecked( settings.value( '{}/filters/wms'.format(CONFIG_NAME), True, bool ) ) self.cbBasemaps.setChecked( settings.value( '{}/filters/basmeaps'.format(CONFIG_NAME), True, bool ) )
def registerDatabaseActions(self, mainWindow): action = QAction(QApplication.translate( "DBManagerPlugin", "&Re-connect"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Database"), self.reconnectActionSlot) if self.schemas(): action = QAction(QApplication.translate( "DBManagerPlugin", "&Create Schema…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Schema"), self.createSchemaActionSlot) action = QAction(QApplication.translate( "DBManagerPlugin", "&Delete (Empty) Schema…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Schema"), self.deleteSchemaActionSlot) action = QAction(QApplication.translate( "DBManagerPlugin", "Delete Selected Item"), self) mainWindow.registerAction(action, None, self.deleteActionSlot) action.setShortcuts(QKeySequence.Delete) action = QAction(QgsApplication.getThemeIcon("/mActionCreateTable.svg"), QApplication.translate( "DBManagerPlugin", "&Create Table…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Table"), self.createTableActionSlot) action = QAction(QgsApplication.getThemeIcon("/mActionEditTable.svg"), QApplication.translate( "DBManagerPlugin", "&Edit Table…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Table"), self.editTableActionSlot) action = QAction(QgsApplication.getThemeIcon("/mActionDeleteTable.svg"), QApplication.translate( "DBManagerPlugin", "&Delete Table/View…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Table"), self.deleteTableActionSlot) action = QAction(QApplication.translate( "DBManagerPlugin", "&Empty Table…"), self) mainWindow.registerAction(action, QApplication.translate( "DBManagerPlugin", "&Table"), self.emptyTableActionSlot)
def menu(self): menu = QMenu() refreshAction = QAction(icon("refresh.svg"), "Refresh", menu) refreshAction.triggered.connect(self.refreshContent) menu.addAction(refreshAction) createBranchAction = QAction(icon("create_branch.png"), "Create branch", menu) createBranchAction.triggered.connect(self.createBranch) menu.addAction(createBranchAction) deleteAction = QAction(QgsApplication.getThemeIcon('/mActionDeleteSelected.svg'), "Delete", menu) deleteAction.triggered.connect(self.delete) menu.addAction(deleteAction) deleteAction.setEnabled(self.parent().childCount() > 1 and self.branch != "master") return menu
def __init__(self, iface, vlayer): super().__init__(None) self.setupUi(self) self.iface = iface self.layer = vlayer self.setWindowTitle('NavTable - ' + self.layer.name()) self.exprFilterBT.setIcon(QgsApplication.getThemeIcon('mIconExpressionSelect.svg')) self.removeFilterBT.setIcon(QgsApplication.getThemeIcon('mActionDeselectAll.svg')) self.orderByBT.setIcon(QgsApplication.getThemeIcon('sort.svg')) self.previousDialog = self.widget_form self.validator = QIntValidator(1, 1) self.currentFeatLB.setValidator(self.validator) self.nextBT.clicked.connect(self.next) self.previousBT.clicked.connect(self.previous) self.lastBT.clicked.connect(self.last) self.firstBT.clicked.connect(self.first) self.orderByBT.clicked.connect(self.orderBy) self.exprFilterBT.clicked.connect(self.filter_by_expression) self.removeFilterBT.clicked.connect(self.removeFilter) self.deleteBT.clicked.connect(self.deleteFeature) self.currentFeatLB.returnPressed.connect(self.manual) self.layer.editingStarted.connect(self.activateEdit) self.layer.editingStopped.connect(self.deactivateEdit) self.allIds = self.layer.allFeatureIds() self.currentIndexFid = 0 self.currentFid = self.allIds[self.currentIndexFid] self.currentExpression = '' self.update(self.currentFid, self.currentIndexFid) self.removeFilterBT.setEnabled(False) if self.layer.isEditable(): self.activateEdit()
def __init__(self, parent=None): super(MatrixModelerWidget, self).__init__(parent) self.setupUi(self) self.btnAddColumn.setIcon(QgsApplication.getThemeIcon('/mActionNewAttribute.svg')) self.btnRemoveColumn.setIcon(QgsApplication.getThemeIcon('/mActionDeleteAttribute.svg')) self.btnAddRow.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg')) self.btnRemoveRow.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg')) self.btnClear.setIcon(QgsApplication.getThemeIcon('console/iconClearConsole.svg')) self.btnAddColumn.clicked.connect(self.addColumn) self.btnRemoveColumn.clicked.connect(self.removeColumns) self.btnAddRow.clicked.connect(self.addRow) self.btnRemoveRow.clicked.connect(self.removeRows) self.btnClear.clicked.connect(self.clearTable) items = [QStandardItem('0')] model = QStandardItemModel() model.appendColumn(items) self.tblView.setModel(model) self.tblView.horizontalHeader().sectionDoubleClicked.connect(self.changeHeader)
def icon(self): return QgsApplication.getThemeIcon("/mIconOracle.svg")
def icon(self): return QgsApplication.getThemeIcon("/processingScript.svg")
def icon(self): return QgsApplication.getThemeIcon('/processingAlgorithm.svg')
def __init__(self, model=None): super().__init__(None) self.setAttribute(Qt.WA_DeleteOnClose) self.setupUi(self) self.bar = QgsMessageBar() self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.centralWidget().layout().insertWidget(0, self.bar) try: self.setDockOptions(self.dockOptions() | QMainWindow.GroupedDragging) except: pass self.mToolbar.setIconSize(iface.iconSize()) self.mActionOpen.setIcon( QgsApplication.getThemeIcon('/mActionFileOpen.svg')) self.mActionSave.setIcon( QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.mActionSaveAs.setIcon( QgsApplication.getThemeIcon('/mActionFileSaveAs.svg')) self.mActionZoomActual.setIcon( QgsApplication.getThemeIcon('/mActionZoomActual.svg')) self.mActionZoomIn.setIcon( QgsApplication.getThemeIcon('/mActionZoomIn.svg')) self.mActionZoomOut.setIcon( QgsApplication.getThemeIcon('/mActionZoomOut.svg')) self.mActionExportImage.setIcon( QgsApplication.getThemeIcon('/mActionSaveMapAsImage.svg')) self.mActionZoomToItems.setIcon( QgsApplication.getThemeIcon('/mActionZoomFullExtent.svg')) self.mActionExportPdf.setIcon( QgsApplication.getThemeIcon('/mActionSaveAsPDF.svg')) self.mActionExportSvg.setIcon( QgsApplication.getThemeIcon('/mActionSaveAsSVG.svg')) #self.mActionExportPython.setIcon( # QgsApplication.getThemeIcon('/mActionSaveAsPython.svg')) self.mActionEditHelp.setIcon( QgsApplication.getThemeIcon('/mActionEditHelpContent.svg')) self.mActionRun.setIcon( QgsApplication.getThemeIcon('/mActionStart.svg')) self.addDockWidget(Qt.LeftDockWidgetArea, self.propertiesDock) self.addDockWidget(Qt.LeftDockWidgetArea, self.inputsDock) self.addDockWidget(Qt.LeftDockWidgetArea, self.algorithmsDock) self.tabifyDockWidget(self.inputsDock, self.algorithmsDock) self.inputsDock.raise_() self.zoom = 1 self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint) settings = QgsSettings() self.restoreState( settings.value("/Processing/stateModeler", QByteArray())) self.restoreGeometry( settings.value("/Processing/geometryModeler", QByteArray())) self.scene = ModelerScene(self, dialog=self) self.scene.setSceneRect( QRectF(0, 0, self.CANVAS_SIZE, self.CANVAS_SIZE)) self.view.setScene(self.scene) self.view.setAcceptDrops(True) self.view.ensureVisible(0, 0, 10, 10) def _dragEnterEvent(event): if event.mimeData().hasText(): event.acceptProposedAction() else: event.ignore() def _dropEvent(event): if event.mimeData().hasText(): itemId = event.mimeData().text() if itemId in [ param.id() for param in QgsApplication.instance(). processingRegistry().parameterTypes() ]: self.addInputOfType(itemId, event.pos()) else: alg = QgsApplication.processingRegistry( ).createAlgorithmById(itemId) if alg is not None: self._addAlgorithm(alg, event.pos()) event.accept() else: event.ignore() def _dragMoveEvent(event): if event.mimeData().hasText(): event.accept() else: event.ignore() def _wheelEvent(event): self.view.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) settings = QgsSettings() factor = settings.value('/qgis/zoom_favor', 2.0) # "Normal" mouse has an angle delta of 120, precision mouses provide data # faster, in smaller steps factor = 1.0 + (factor - 1.0) / 120.0 * abs(event.angleDelta().y()) if (event.modifiers() == Qt.ControlModifier): factor = 1.0 + (factor - 1.0) / 20.0 if event.angleDelta().y() < 0: factor = 1 / factor self.view.scale(factor, factor) def _enterEvent(e): QGraphicsView.enterEvent(self.view, e) self.view.viewport().setCursor(Qt.ArrowCursor) def _mouseReleaseEvent(e): QGraphicsView.mouseReleaseEvent(self.view, e) self.view.viewport().setCursor(Qt.ArrowCursor) def _mousePressEvent(e): if e.button() == Qt.MidButton: self.previousMousePos = e.pos() else: QGraphicsView.mousePressEvent(self.view, e) def _mouseMoveEvent(e): if e.buttons() == Qt.MidButton: offset = self.previousMousePos - e.pos() self.previousMousePos = e.pos() self.view.verticalScrollBar().setValue( self.view.verticalScrollBar().value() + offset.y()) self.view.horizontalScrollBar().setValue( self.view.horizontalScrollBar().value() + offset.x()) else: QGraphicsView.mouseMoveEvent(self.view, e) self.view.setDragMode(QGraphicsView.ScrollHandDrag) self.view.dragEnterEvent = _dragEnterEvent self.view.dropEvent = _dropEvent self.view.dragMoveEvent = _dragMoveEvent self.view.wheelEvent = _wheelEvent self.view.enterEvent = _enterEvent self.view.mousePressEvent = _mousePressEvent self.view.mouseMoveEvent = _mouseMoveEvent def _mimeDataInput(items): mimeData = QMimeData() text = items[0].data(0, Qt.UserRole) mimeData.setText(text) return mimeData self.inputsTree.mimeData = _mimeDataInput self.inputsTree.setDragDropMode(QTreeWidget.DragOnly) self.inputsTree.setDropIndicatorShown(True) def _mimeDataAlgorithm(items): item = items[0] mimeData = None if isinstance(item, TreeAlgorithmItem): mimeData = QMimeData() mimeData.setText(item.alg.id()) return mimeData self.algorithmTree.mimeData = _mimeDataAlgorithm self.algorithmTree.setDragDropMode(QTreeWidget.DragOnly) self.algorithmTree.setDropIndicatorShown(True) if hasattr(self.searchBox, 'setPlaceholderText'): self.searchBox.setPlaceholderText( QCoreApplication.translate('ModelerDialog', 'Search…')) if hasattr(self.textName, 'setPlaceholderText'): self.textName.setPlaceholderText(self.tr('Enter model name here')) if hasattr(self.textGroup, 'setPlaceholderText'): self.textGroup.setPlaceholderText(self.tr('Enter group name here')) # Connect signals and slots self.inputsTree.doubleClicked.connect(self.addInput) self.searchBox.textChanged.connect(self.textChanged) self.algorithmTree.doubleClicked.connect(self.addAlgorithm) # Ctrl+= should also trigger a zoom in action ctrlEquals = QShortcut(QKeySequence("Ctrl+="), self) ctrlEquals.activated.connect(self.zoomIn) self.mActionOpen.triggered.connect(self.openModel) self.mActionSave.triggered.connect(self.save) self.mActionSaveAs.triggered.connect(self.saveAs) self.mActionZoomIn.triggered.connect(self.zoomIn) self.mActionZoomOut.triggered.connect(self.zoomOut) self.mActionZoomActual.triggered.connect(self.zoomActual) self.mActionZoomToItems.triggered.connect(self.zoomToItems) self.mActionExportImage.triggered.connect(self.exportAsImage) self.mActionExportPdf.triggered.connect(self.exportAsPdf) self.mActionExportSvg.triggered.connect(self.exportAsSvg) #self.mActionExportPython.triggered.connect(self.exportAsPython) self.mActionEditHelp.triggered.connect(self.editHelp) self.mActionRun.triggered.connect(self.runModel) if model is not None: self.model = model.create() self.model.setSourceFilePath(model.sourceFilePath()) self.textGroup.setText(self.model.group()) self.textName.setText(self.model.displayName()) self.repaintModel() else: self.model = QgsProcessingModelAlgorithm() self.model.setProvider( QgsApplication.processingRegistry().providerById('model')) self.fillInputsTree() self.fillTreeUsingProviders() self.view.centerOn(0, 0) self.help = None self.hasChanged = False
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmConcaveHull.svg")
def icon(self): return QgsApplication.getThemeIcon("/providerQgis.svg")
def initialize(): icon = QgsApplication.getThemeIcon("/processingAlgorithm.svg") ProcessingConfig.settingIcons['General'] = icon ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.SHOW_DEBUG_IN_DIALOG, ProcessingConfig.tr('Show extra info in Log panel'), True)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.KEEP_DIALOG_OPEN, ProcessingConfig.tr( 'Keep dialog open after running an algorithm'), False)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.USE_FILENAME_AS_LAYER_NAME, ProcessingConfig.tr('Use filename as layer name'), False)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.SHOW_RECENT_ALGORITHMS, ProcessingConfig.tr('Show recently executed algorithms'), True)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.SHOW_PROVIDERS_TOOLTIP, ProcessingConfig.tr( 'Show tooltip when there are disabled providers'), True)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.OUTPUT_FOLDER, ProcessingConfig.tr('Output folder'), defaultOutputFolder(), valuetype=Setting.FOLDER)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.SHOW_CRS_DEF, ProcessingConfig.tr( 'Show layer CRS definition in selection boxes'), True)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.WARN_UNMATCHING_CRS, ProcessingConfig.tr( "Warn before executing if layer CRS's do not match"), True)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.WARN_UNMATCHING_EXTENT_CRS, ProcessingConfig. tr("Warn before executing if extent CRS might not match layers CRS" ), True)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.RASTER_STYLE, ProcessingConfig.tr('Style for raster layers'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.VECTOR_POINT_STYLE, ProcessingConfig.tr('Style for point layers'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.VECTOR_LINE_STYLE, ProcessingConfig.tr('Style for line layers'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.VECTOR_POLYGON_STYLE, ProcessingConfig.tr('Style for polygon layers'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.PRE_EXECUTION_SCRIPT, ProcessingConfig.tr('Pre-execution script'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.POST_EXECUTION_SCRIPT, ProcessingConfig.tr('Post-execution script'), '', valuetype=Setting.FILE)) ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.RECENT_ALGORITHMS, ProcessingConfig.tr('Recent algorithms'), '', hidden=True)) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.MODELS_SCRIPTS_REPO, ProcessingConfig.tr('Scripts and models repository'), 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master' )) invalidFeaturesOptions = [ ProcessingConfig.tr('Do not filter (better performance)'), ProcessingConfig.tr('Ignore features with invalid geometries'), ProcessingConfig.tr( 'Stop algorithm execution when a geometry is invalid') ] ProcessingConfig.addSetting( Setting(ProcessingConfig.tr('General'), ProcessingConfig.FILTER_INVALID_GEOMETRIES, ProcessingConfig.tr('Invalid features filtering'), invalidFeaturesOptions[2], valuetype=Setting.SELECTION, options=invalidFeaturesOptions)) extensions = QgsVectorFileWriter.supportedFormatExtensions() ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.DEFAULT_OUTPUT_VECTOR_LAYER_EXT, ProcessingConfig.tr('Default output vector layer extension'), extensions[0], valuetype=Setting.SELECTION, options=extensions)) extensions = processing.tools.dataobjects.getSupportedOutputRasterLayerExtensions( ) ProcessingConfig.addSetting( Setting( ProcessingConfig.tr('General'), ProcessingConfig.DEFAULT_OUTPUT_RASTER_LAYER_EXT, ProcessingConfig.tr('Default output raster layer extension'), extensions[0], valuetype=Setting.SELECTION, options=extensions))
def getIcon(self): return QgsApplication.getThemeIcon("/processingModel.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmRandomPointsWithinPolygon.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmExtractLayerExtent.svg")
def __init__(self, filePath=None, parent=None): super(ScriptEditorDialog, self).__init__(parent) self.setupUi(self) QgsGui.instance().enableAutoGeometryRestore(self) self.editor.initLexer() self.searchWidget.setVisible(False) if iface is not None: self.toolBar.setIconSize(iface.iconSize()) self.setStyleSheet(iface.mainWindow().styleSheet()) self.actionOpenScript.setIcon( QgsApplication.getThemeIcon('/mActionScriptOpen.svg')) self.actionSaveScript.setIcon( QgsApplication.getThemeIcon('/mActionFileSave.svg')) self.actionSaveScriptAs.setIcon( QgsApplication.getThemeIcon('/mActionFileSaveAs.svg')) self.actionRunScript.setIcon( QgsApplication.getThemeIcon('/mActionStart.svg')) self.actionCut.setIcon( QgsApplication.getThemeIcon('/mActionEditCut.svg')) self.actionCopy.setIcon( QgsApplication.getThemeIcon('/mActionEditCopy.svg')) self.actionPaste.setIcon( QgsApplication.getThemeIcon('/mActionEditPaste.svg')) self.actionUndo.setIcon( QgsApplication.getThemeIcon('/mActionUndo.svg')) self.actionRedo.setIcon( QgsApplication.getThemeIcon('/mActionRedo.svg')) self.actionFindReplace.setIcon( QgsApplication.getThemeIcon('/mActionFindReplace.svg')) self.actionIncreaseFontSize.setIcon( QgsApplication.getThemeIcon('/mActionIncreaseFont.svg')) self.actionDecreaseFontSize.setIcon( QgsApplication.getThemeIcon('/mActionDecreaseFont.svg')) # Connect signals and slots self.actionOpenScript.triggered.connect(self.openScript) self.actionSaveScript.triggered.connect(self.save) self.actionSaveScriptAs.triggered.connect(self.saveAs) self.actionRunScript.triggered.connect(self.runAlgorithm) self.actionCut.triggered.connect(self.editor.cut) self.actionCopy.triggered.connect(self.editor.copy) self.actionPaste.triggered.connect(self.editor.paste) self.actionUndo.triggered.connect(self.editor.undo) self.actionRedo.triggered.connect(self.editor.redo) self.actionFindReplace.toggled.connect(self.toggleSearchBox) self.actionIncreaseFontSize.triggered.connect(self.editor.zoomIn) self.actionDecreaseFontSize.triggered.connect(self.editor.zoomOut) self.editor.textChanged.connect(lambda: self.setHasChanged(True)) self.leFindText.returnPressed.connect(self.find) self.btnFind.clicked.connect(self.find) self.btnReplace.clicked.connect(self.replace) self.lastSearch = None self.filePath = None if filePath is not None: self._loadFile(filePath) self.setHasChanged(False)
def initGui(self): self.options_factory = ProcessingOptionsFactory() self.options_factory.setTitle(self.tr('Processing')) iface.registerOptionsWidgetFactory(self.options_factory) self.drop_handler = ProcessingDropHandler() iface.registerCustomDropHandler(self.drop_handler) self.item_provider = ProcessingDataItemProvider() QgsApplication.dataItemProviderRegistry().addProvider( self.item_provider) self.locator_filter = AlgorithmLocatorFilter() iface.registerLocatorFilter(self.locator_filter) # Invalidate the locator filter for in-place when active layer changes iface.currentLayerChanged.connect( lambda _: self.iface.invalidateLocatorResults()) self.edit_features_locator_filter = InPlaceAlgorithmLocatorFilter() iface.registerLocatorFilter(self.edit_features_locator_filter) self.toolbox = ProcessingToolbox() self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox) self.toolbox.hide() self.toolbox.visibilityChanged.connect(self.toolboxVisibilityChanged) self.resultsDock = ResultsDock() self.iface.addDockWidget(Qt.RightDockWidgetArea, self.resultsDock) self.resultsDock.hide() self.menu = QMenu(self.iface.mainWindow().menuBar()) self.menu.setObjectName('processing') self.menu.setTitle(self.tr('Pro&cessing')) self.toolboxAction = QAction(self.tr('&Toolbox'), self.iface.mainWindow()) self.toolboxAction.setCheckable(True) self.toolboxAction.setObjectName('toolboxAction') self.toolboxAction.setIcon( QgsApplication.getThemeIcon("/processingAlgorithm.svg")) self.iface.registerMainWindowAction( self.toolboxAction, QKeySequence('Ctrl+Alt+T').toString(QKeySequence.NativeText)) self.toolboxAction.toggled.connect(self.openToolbox) self.iface.attributesToolBar().insertAction( self.iface.actionOpenStatisticalSummary(), self.toolboxAction) self.menu.addAction(self.toolboxAction) self.modelerAction = QAction( QgsApplication.getThemeIcon("/processingModel.svg"), QCoreApplication.translate('ProcessingPlugin', 'Graphical &Modeler…'), self.iface.mainWindow()) self.modelerAction.setObjectName('modelerAction') self.modelerAction.triggered.connect(self.openModeler) self.iface.registerMainWindowAction( self.modelerAction, QKeySequence('Ctrl+Alt+M').toString(QKeySequence.NativeText)) self.menu.addAction(self.modelerAction) self.historyAction = QAction( QgsApplication.getThemeIcon("/mIconHistory.svg"), QCoreApplication.translate('ProcessingPlugin', '&History…'), self.iface.mainWindow()) self.historyAction.setObjectName('historyAction') self.historyAction.triggered.connect(self.openHistory) self.iface.registerMainWindowAction( self.historyAction, QKeySequence('Ctrl+Alt+H').toString(QKeySequence.NativeText)) self.menu.addAction(self.historyAction) self.toolbox.processingToolbar.addAction(self.historyAction) self.resultsAction = QAction( QgsApplication.getThemeIcon("/processingResult.svg"), self.tr('&Results Viewer'), self.iface.mainWindow()) self.resultsAction.setCheckable(True) self.iface.registerMainWindowAction( self.resultsAction, QKeySequence('Ctrl+Alt+R').toString(QKeySequence.NativeText)) self.menu.addAction(self.resultsAction) self.toolbox.processingToolbar.addAction(self.resultsAction) self.resultsDock.visibilityChanged.connect( self.resultsAction.setChecked) self.resultsAction.toggled.connect(self.resultsDock.setUserVisible) self.toolbox.processingToolbar.addSeparator() self.editInPlaceAction = QAction( QgsApplication.getThemeIcon("/mActionProcessSelected.svg"), self.tr('Edit Features In-Place'), self.iface.mainWindow()) self.editInPlaceAction.setObjectName('editInPlaceFeatures') self.editInPlaceAction.setCheckable(True) self.editInPlaceAction.toggled.connect(self.editSelected) self.menu.addAction(self.editInPlaceAction) self.toolbox.processingToolbar.addAction(self.editInPlaceAction) self.toolbox.processingToolbar.addSeparator() self.optionsAction = QAction( QgsApplication.getThemeIcon("/mActionOptions.svg"), self.tr('Options'), self.iface.mainWindow()) self.optionsAction.setObjectName('optionsAction') self.optionsAction.triggered.connect(self.openProcessingOptions) self.toolbox.processingToolbar.addAction(self.optionsAction) menuBar = self.iface.mainWindow().menuBar() menuBar.insertMenu(self.iface.firstRightStandardMenu().menuAction(), self.menu) self.menu.addSeparator() initializeMenus() createMenus() # In-place editing button state sync self.iface.currentLayerChanged.connect(self.sync_in_place_button_state) self.iface.mapCanvas().selectionChanged.connect( self.sync_in_place_button_state) self.iface.actionToggleEditing().triggered.connect( partial(self.sync_in_place_button_state, None)) self.sync_in_place_button_state()
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmDelaunay.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmPolygonToLine.svg")
def icon(self): return QgsApplication.getThemeIcon("/mIconQgsProjectFile.svg")
def getIcon(self): if self._icon is None: self._icon = QgsApplication.getThemeIcon("/providerGrass.svg") return self._icon
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console")) self.settings = QSettings() self.options = optionsDialog(self) self.shell = ShellScintilla(self) self.setFocusProxy(self.shell) self.shellOut = ShellOutputScintilla(self) self.tabEditorWidget = EditorTabWidget(self) ##------------ UI ------------------------------- self.splitterEditor = QSplitter(self) self.splitterEditor.setOrientation(Qt.Horizontal) self.splitterEditor.setHandleWidth(6) self.splitterEditor.setChildrenCollapsible(True) self.splitter = QSplitter(self.splitterEditor) self.splitter.setOrientation(Qt.Vertical) self.splitter.setHandleWidth(3) self.splitter.setChildrenCollapsible(False) self.splitter.addWidget(self.shellOut) self.splitter.addWidget(self.shell) #self.splitterEditor.addWidget(self.tabEditorWidget) self.splitterObj = QSplitter(self.splitterEditor) self.splitterObj.setHandleWidth(3) self.splitterObj.setOrientation(Qt.Horizontal) #self.splitterObj.setSizes([0, 0]) #self.splitterObj.setStretchFactor(0, 1) self.widgetEditor = QWidget(self.splitterObj) self.widgetFind = QWidget(self) self.listClassMethod = QTreeWidget(self.splitterObj) self.listClassMethod.setColumnCount(2) objInspLabel = QCoreApplication.translate("PythonConsole", "Object Inspector") self.listClassMethod.setHeaderLabels([objInspLabel, '']) self.listClassMethod.setColumnHidden(1, True) self.listClassMethod.setAlternatingRowColors(True) #self.splitterEditor.addWidget(self.widgetEditor) #self.splitterObj.addWidget(self.listClassMethod) #self.splitterObj.addWidget(self.widgetEditor) # Hide side editor on start up self.splitterObj.hide() self.listClassMethod.hide() # Hide search widget on start up self.widgetFind.hide() sizes = self.splitter.sizes() self.splitter.setSizes(sizes) ##----------------Restore Settings------------------------------------ self.restoreSettingsConsole() ##------------------Toolbar Editor------------------------------------- ## Action for Open File openFileBt = QCoreApplication.translate("PythonConsole", "Open file") self.openFileButton = QAction(self) self.openFileButton.setCheckable(False) self.openFileButton.setEnabled(True) self.openFileButton.setIcon(QgsApplication.getThemeIcon("console/iconOpenConsole.png")) self.openFileButton.setMenuRole(QAction.PreferencesRole) self.openFileButton.setIconVisibleInMenu(True) self.openFileButton.setToolTip(openFileBt) self.openFileButton.setText(openFileBt) ## Action for Save File saveFileBt = QCoreApplication.translate("PythonConsole", "Save") self.saveFileButton = QAction(self) self.saveFileButton.setCheckable(False) self.saveFileButton.setEnabled(False) self.saveFileButton.setIcon(QgsApplication.getThemeIcon("console/iconSaveConsole.png")) self.saveFileButton.setMenuRole(QAction.PreferencesRole) self.saveFileButton.setIconVisibleInMenu(True) self.saveFileButton.setToolTip(saveFileBt) self.saveFileButton.setText(saveFileBt) ## Action for Save File As saveAsFileBt = QCoreApplication.translate("PythonConsole", "Save As...") self.saveAsFileButton = QAction(self) self.saveAsFileButton.setCheckable(False) self.saveAsFileButton.setEnabled(True) self.saveAsFileButton.setIcon(QgsApplication.getThemeIcon("console/iconSaveAsConsole.png")) self.saveAsFileButton.setMenuRole(QAction.PreferencesRole) self.saveAsFileButton.setIconVisibleInMenu(True) self.saveAsFileButton.setToolTip(saveAsFileBt) self.saveAsFileButton.setText(saveAsFileBt) ## Action Cut cutEditorBt = QCoreApplication.translate("PythonConsole", "Cut") self.cutEditorButton = QAction(self) self.cutEditorButton.setCheckable(False) self.cutEditorButton.setEnabled(True) self.cutEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconCutEditorConsole.png")) self.cutEditorButton.setMenuRole(QAction.PreferencesRole) self.cutEditorButton.setIconVisibleInMenu(True) self.cutEditorButton.setToolTip(cutEditorBt) self.cutEditorButton.setText(cutEditorBt) ## Action Copy copyEditorBt = QCoreApplication.translate("PythonConsole", "Copy") self.copyEditorButton = QAction(self) self.copyEditorButton.setCheckable(False) self.copyEditorButton.setEnabled(True) self.copyEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconCopyEditorConsole.png")) self.copyEditorButton.setMenuRole(QAction.PreferencesRole) self.copyEditorButton.setIconVisibleInMenu(True) self.copyEditorButton.setToolTip(copyEditorBt) self.copyEditorButton.setText(copyEditorBt) ## Action Paste pasteEditorBt = QCoreApplication.translate("PythonConsole", "Paste") self.pasteEditorButton = QAction(self) self.pasteEditorButton.setCheckable(False) self.pasteEditorButton.setEnabled(True) self.pasteEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconPasteEditorConsole.png")) self.pasteEditorButton.setMenuRole(QAction.PreferencesRole) self.pasteEditorButton.setIconVisibleInMenu(True) self.pasteEditorButton.setToolTip(pasteEditorBt) self.pasteEditorButton.setText(pasteEditorBt) ## Action Run Script (subprocess) runScriptEditorBt = QCoreApplication.translate("PythonConsole", "Run script") self.runScriptEditorButton = QAction(self) self.runScriptEditorButton.setCheckable(False) self.runScriptEditorButton.setEnabled(True) self.runScriptEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconRunScriptConsole.png")) self.runScriptEditorButton.setMenuRole(QAction.PreferencesRole) self.runScriptEditorButton.setIconVisibleInMenu(True) self.runScriptEditorButton.setToolTip(runScriptEditorBt) self.runScriptEditorButton.setText(runScriptEditorBt) ## Action Run Script (subprocess) commentEditorBt = QCoreApplication.translate("PythonConsole", "Comment") self.commentEditorButton = QAction(self) self.commentEditorButton.setCheckable(False) self.commentEditorButton.setEnabled(True) self.commentEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconCommentEditorConsole.png")) self.commentEditorButton.setMenuRole(QAction.PreferencesRole) self.commentEditorButton.setIconVisibleInMenu(True) self.commentEditorButton.setToolTip(commentEditorBt) self.commentEditorButton.setText(commentEditorBt) ## Action Run Script (subprocess) uncommentEditorBt = QCoreApplication.translate("PythonConsole", "Uncomment") self.uncommentEditorButton = QAction(self) self.uncommentEditorButton.setCheckable(False) self.uncommentEditorButton.setEnabled(True) self.uncommentEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconUncommentEditorConsole.png")) self.uncommentEditorButton.setMenuRole(QAction.PreferencesRole) self.uncommentEditorButton.setIconVisibleInMenu(True) self.uncommentEditorButton.setToolTip(uncommentEditorBt) self.uncommentEditorButton.setText(uncommentEditorBt) ## Action for Object browser objList = QCoreApplication.translate("PythonConsole", "Object Inspector") self.objectListButton = QAction(self) self.objectListButton.setCheckable(True) self.objectListButton.setEnabled(self.settings.value("pythonConsole/enableObjectInsp", False).toBool()) self.objectListButton.setIcon(QgsApplication.getThemeIcon("console/iconClassBrowserConsole.png")) self.objectListButton.setMenuRole(QAction.PreferencesRole) self.objectListButton.setIconVisibleInMenu(True) self.objectListButton.setToolTip(objList) self.objectListButton.setText(objList) ## Action for Find text findText = QCoreApplication.translate("PythonConsole", "Find Text") self.findTextButton = QAction(self) self.findTextButton.setCheckable(True) self.findTextButton.setEnabled(True) self.findTextButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchEditorConsole.png")) self.findTextButton.setMenuRole(QAction.PreferencesRole) self.findTextButton.setIconVisibleInMenu(True) self.findTextButton.setToolTip(findText) self.findTextButton.setText(findText) ##----------------Toolbar Console------------------------------------- ## Action Show Editor showEditor = QCoreApplication.translate("PythonConsole", "Show editor") self.showEditorButton = QAction(self) self.showEditorButton.setEnabled(True) self.showEditorButton.setCheckable(True) self.showEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconShowEditorConsole.png")) self.showEditorButton.setMenuRole(QAction.PreferencesRole) self.showEditorButton.setIconVisibleInMenu(True) self.showEditorButton.setToolTip(showEditor) self.showEditorButton.setText(showEditor) ## Action for Clear button clearBt = QCoreApplication.translate("PythonConsole", "Clear console") self.clearButton = QAction(self) self.clearButton.setCheckable(False) self.clearButton.setEnabled(True) self.clearButton.setIcon(QgsApplication.getThemeIcon("console/iconClearConsole.png")) self.clearButton.setMenuRole(QAction.PreferencesRole) self.clearButton.setIconVisibleInMenu(True) self.clearButton.setToolTip(clearBt) self.clearButton.setText(clearBt) ## Action for settings optionsBt = QCoreApplication.translate("PythonConsole", "Settings") self.optionsButton = QAction(self) self.optionsButton.setCheckable(False) self.optionsButton.setEnabled(True) self.optionsButton.setIcon(QgsApplication.getThemeIcon("console/iconSettingsConsole.png")) self.optionsButton.setMenuRole(QAction.PreferencesRole) self.optionsButton.setIconVisibleInMenu(True) self.optionsButton.setToolTip(optionsBt) self.optionsButton.setText(optionsBt) ## Action menu for class actionClassBt = QCoreApplication.translate("PythonConsole", "Import Class") self.actionClass = QAction(self) self.actionClass.setCheckable(False) self.actionClass.setEnabled(True) self.actionClass.setIcon(QgsApplication.getThemeIcon("console/iconClassConsole.png")) self.actionClass.setMenuRole(QAction.PreferencesRole) self.actionClass.setIconVisibleInMenu(True) self.actionClass.setToolTip(actionClassBt) self.actionClass.setText(actionClassBt) ## Import Sextante class loadSextanteBt = QCoreApplication.translate("PythonConsole", "Import Sextante class") self.loadSextanteButton = QAction(self) self.loadSextanteButton.setCheckable(False) self.loadSextanteButton.setEnabled(True) self.loadSextanteButton.setIcon(QgsApplication.getThemeIcon("console/iconSextanteConsole.png")) self.loadSextanteButton.setMenuRole(QAction.PreferencesRole) self.loadSextanteButton.setIconVisibleInMenu(True) self.loadSextanteButton.setToolTip(loadSextanteBt) self.loadSextanteButton.setText(loadSextanteBt) ## Import QtCore class loadQtCoreBt = QCoreApplication.translate("PythonConsole", "Import PyQt.QtCore class") self.loadQtCoreButton = QAction(self) self.loadQtCoreButton.setCheckable(False) self.loadQtCoreButton.setEnabled(True) self.loadQtCoreButton.setIcon(QgsApplication.getThemeIcon("console/iconQtCoreConsole.png")) self.loadQtCoreButton.setMenuRole(QAction.PreferencesRole) self.loadQtCoreButton.setIconVisibleInMenu(True) self.loadQtCoreButton.setToolTip(loadQtCoreBt) self.loadQtCoreButton.setText(loadQtCoreBt) ## Import QtGui class loadQtGuiBt = QCoreApplication.translate("PythonConsole", "Import PyQt.QtGui class") self.loadQtGuiButton = QAction(self) self.loadQtGuiButton.setCheckable(False) self.loadQtGuiButton.setEnabled(True) self.loadQtGuiButton.setIcon(QgsApplication.getThemeIcon("console/iconQtGuiConsole.png")) self.loadQtGuiButton.setMenuRole(QAction.PreferencesRole) self.loadQtGuiButton.setIconVisibleInMenu(True) self.loadQtGuiButton.setToolTip(loadQtGuiBt) self.loadQtGuiButton.setText(loadQtGuiBt) ## Action for Run script runBt = QCoreApplication.translate("PythonConsole", "Run command") self.runButton = QAction(self) self.runButton.setCheckable(False) self.runButton.setEnabled(True) self.runButton.setIcon(QgsApplication.getThemeIcon("console/iconRunConsole.png")) self.runButton.setMenuRole(QAction.PreferencesRole) self.runButton.setIconVisibleInMenu(True) self.runButton.setToolTip(runBt) self.runButton.setText(runBt) ## Help action helpBt = QCoreApplication.translate("PythonConsole", "Help") self.helpButton = QAction(self) self.helpButton.setCheckable(False) self.helpButton.setEnabled(True) self.helpButton.setIcon(QgsApplication.getThemeIcon("console/iconHelpConsole.png")) self.helpButton.setMenuRole(QAction.PreferencesRole) self.helpButton.setIconVisibleInMenu(True) self.helpButton.setToolTip(helpBt) self.helpButton.setText(helpBt) self.toolBar = QToolBar() self.toolBar.setEnabled(True) self.toolBar.setFocusPolicy(Qt.NoFocus) self.toolBar.setContextMenuPolicy(Qt.DefaultContextMenu) self.toolBar.setLayoutDirection(Qt.LeftToRight) self.toolBar.setIconSize(QSize(24, 24)) self.toolBar.setOrientation(Qt.Vertical) self.toolBar.setMovable(True) self.toolBar.setFloatable(True) self.toolBar.addAction(self.clearButton) self.toolBar.addAction(self.actionClass) self.toolBar.addAction(self.runButton) self.toolBar.addSeparator() self.toolBar.addAction(self.showEditorButton) self.toolBar.addSeparator() self.toolBar.addAction(self.optionsButton) self.toolBar.addAction(self.helpButton) if sys.platform.startswith('win'): bkgrcolor = ['170', '170', '170'] bordercl = ['125', '125', '125'] else: bkgrcolor = ['200', '200', '200'] bordercl = ['155', '155', '155'] self.toolBarEditor = QToolBar() self.toolBarEditor.setStyleSheet('QToolBar{background-color: rgb(%s, %s, %s' % tuple(bkgrcolor) + ');\ border-right: 1px solid rgb(%s, %s, %s' % tuple(bordercl) + ');}') self.toolBarEditor.setEnabled(False) self.toolBarEditor.setFocusPolicy(Qt.NoFocus) self.toolBarEditor.setContextMenuPolicy(Qt.DefaultContextMenu) self.toolBarEditor.setLayoutDirection(Qt.LeftToRight) self.toolBarEditor.setIconSize(QSize(18, 18)) self.toolBarEditor.setOrientation(Qt.Vertical) self.toolBarEditor.setMovable(True) self.toolBarEditor.setFloatable(True) self.toolBarEditor.addAction(self.openFileButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.saveFileButton) self.toolBarEditor.addAction(self.saveAsFileButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.findTextButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.cutEditorButton) self.toolBarEditor.addAction(self.copyEditorButton) self.toolBarEditor.addAction(self.pasteEditorButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.commentEditorButton) self.toolBarEditor.addAction(self.uncommentEditorButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.objectListButton) self.toolBarEditor.addSeparator() self.toolBarEditor.addAction(self.runScriptEditorButton) ## Menu Import Class self.classMenu = QMenu() self.classMenu.addAction(self.loadSextanteButton) self.classMenu.addAction(self.loadQtCoreButton) self.classMenu.addAction(self.loadQtGuiButton) cM = self.toolBar.widgetForAction(self.actionClass) cM.setMenu(self.classMenu) cM.setPopupMode(QToolButton.InstantPopup) self.widgetButton = QWidget() sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.widgetButton.sizePolicy().hasHeightForWidth()) self.widgetButton.setSizePolicy(sizePolicy) self.widgetButtonEditor = QWidget(self.widgetEditor) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.widgetButtonEditor.sizePolicy().hasHeightForWidth()) self.widgetButtonEditor.setSizePolicy(sizePolicy) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.shellOut.sizePolicy().hasHeightForWidth()) self.shellOut.setSizePolicy(sizePolicy) self.shellOut.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.shell.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) ##------------ Layout ------------------------------- self.mainLayout = QGridLayout(self) self.mainLayout.setMargin(0) self.mainLayout.setSpacing(0) self.mainLayout.addWidget(self.widgetButton, 0, 0, 1, 1) self.mainLayout.addWidget(self.splitterEditor, 0, 1, 1, 1) self.layoutEditor = QGridLayout(self.widgetEditor) self.layoutEditor.setMargin(0) self.layoutEditor.setSpacing(0) self.layoutEditor.addWidget(self.widgetButtonEditor, 0, 0, 2, 1) self.layoutEditor.addWidget(self.tabEditorWidget, 0, 1, 1, 1) self.layoutEditor.addWidget(self.widgetFind, 1, 1, 1, 1) self.toolBarLayout = QGridLayout(self.widgetButton) self.toolBarLayout.setMargin(0) self.toolBarLayout.setSpacing(0) self.toolBarLayout.addWidget(self.toolBar) self.toolBarEditorLayout = QGridLayout(self.widgetButtonEditor) self.toolBarEditorLayout.setMargin(0) self.toolBarEditorLayout.setSpacing(0) self.toolBarEditorLayout.addWidget(self.toolBarEditor) ## Layout for the find widget self.layoutFind = QGridLayout(self.widgetFind) self.layoutFind.setContentsMargins(0, 0, 0, 0) self.lineEditFind = QgsFilterLineEdit() placeHolderTxt = QCoreApplication.translate("PythonConsole", "Enter text to find...") if pyqtconfig.Configuration().qt_version >= 0x40700: self.lineEditFind.setPlaceholderText(placeHolderTxt) else: self.lineEditFind.setToolTip(placeHolderTxt) self.findNextButton = QToolButton() self.findNextButton.setEnabled(False) toolTipfindNext = QCoreApplication.translate("PythonConsole", "Find Next") self.findNextButton.setToolTip(toolTipfindNext) self.findNextButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchNextEditorConsole.png")) self.findNextButton.setIconSize(QSize(24, 24)) self.findNextButton.setAutoRaise(True) self.findPrevButton = QToolButton() self.findPrevButton.setEnabled(False) toolTipfindPrev = QCoreApplication.translate("PythonConsole", "Find Previous") self.findPrevButton.setToolTip(toolTipfindPrev) self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png")) self.findPrevButton.setIconSize(QSize(24, 24)) self.findPrevButton.setAutoRaise(True) self.caseSensitive = QCheckBox() caseSensTr = QCoreApplication.translate("PythonConsole", "Case Sensitive") self.caseSensitive.setText(caseSensTr) self.wholeWord = QCheckBox() wholeWordTr = QCoreApplication.translate("PythonConsole", "Whole Word") self.wholeWord.setText(wholeWordTr) self.wrapAround = QCheckBox() self.wrapAround.setChecked(True) wrapAroundTr = QCoreApplication.translate("PythonConsole", "Wrap Around") self.wrapAround.setText(wrapAroundTr) self.layoutFind.addWidget(self.lineEditFind, 0, 1, 1, 1) self.layoutFind.addWidget(self.findPrevButton, 0, 2, 1, 1) self.layoutFind.addWidget(self.findNextButton, 0, 3, 1, 1) self.layoutFind.addWidget(self.caseSensitive, 0, 4, 1, 1) self.layoutFind.addWidget(self.wholeWord, 0, 5, 1, 1) self.layoutFind.addWidget(self.wrapAround, 0, 6, 1, 1) ##------------ Add first Tab in Editor ------------------------------- #self.tabEditorWidget.newTabEditor(tabName='first', filename=None) ##------------ Signal ------------------------------- self.findTextButton.toggled.connect(self.findTextEditor) self.objectListButton.toggled.connect(self.toggleObjectListWidget) self.commentEditorButton.triggered.connect(self.commentCode) self.uncommentEditorButton.triggered.connect(self.uncommentCode) self.runScriptEditorButton.triggered.connect(self.runScriptEditor) self.cutEditorButton.triggered.connect(self.cutEditor) self.copyEditorButton.triggered.connect(self.copyEditor) self.pasteEditorButton.triggered.connect(self.pasteEditor) self.showEditorButton.toggled.connect(self.toggleEditor) self.clearButton.triggered.connect(self.shellOut.clearConsole) self.optionsButton.triggered.connect(self.openSettings) self.loadSextanteButton.triggered.connect(self.sextante) self.loadQtCoreButton.triggered.connect(self.qtCore) self.loadQtGuiButton.triggered.connect(self.qtGui) self.runButton.triggered.connect(self.shell.entered) self.openFileButton.triggered.connect(self.openScriptFile) self.saveFileButton.triggered.connect(self.saveScriptFile) self.saveAsFileButton.triggered.connect(self.saveAsScriptFile) self.helpButton.triggered.connect(self.openHelp) self.connect(self.options.buttonBox, SIGNAL("accepted()"), self.prefChanged) self.connect(self.listClassMethod, SIGNAL('itemClicked(QTreeWidgetItem*, int)'), self.onClickGoToLine) self.lineEditFind.returnPressed.connect(self._findText) self.findNextButton.clicked.connect(self._findNext) self.findPrevButton.clicked.connect(self._findPrev) self.lineEditFind.textChanged.connect(self._textFindChanged)
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmBasicStatistics.svg")
def icon(self): return QgsApplication.getThemeIcon("/algorithms/mAlgorithmAddGeometryAttributes.svg")
def icon(self): return QgsApplication.getThemeIcon("/algorithms/mAlgorithmUniqueValues.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmSelectRandom.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmDissolve.svg")
def icon(self): return QgsApplication.getThemeIcon("/algorithms/mAlgorithmCentroids.svg")
def getIcon(self): return QgsApplication.getThemeIcon("/processingAlgorithm.svg")
def getIcon(self): if self.scriptType == self.SCRIPT_PYTHON: return QgsApplication.getThemeIcon("/processingScript.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmNearestNeighbour.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmCheckGeometry.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmSplitLayer.svg")
def icon(self): return QgsApplication.getThemeIcon( "/algorithms/mAlgorithmRegularPoints.svg")
def fillTreeUsingProviders(self): self.items = {} self.model.clear() self.model.setHorizontalHeaderLabels( [self.tr('Setting'), self.tr('Value')]) settings = ProcessingConfig.getSettings() rootItem = self.model.invisibleRootItem() """ Filter 'General', 'Models' and 'Scripts' items """ priorityKeys = [ self.tr('General'), self.tr('Models'), self.tr('Scripts') ] for group in priorityKeys: groupItem = QStandardItem(group) icon = ProcessingConfig.getGroupIcon(group) groupItem.setIcon(icon) groupItem.setEditable(False) emptyItem = QStandardItem() emptyItem.setEditable(False) rootItem.insertRow(0, [groupItem, emptyItem]) if not group in settings: continue # add menu item only if it has any search matches for setting in settings[group]: if setting.hidden or setting.name.startswith("MENU_"): continue labelItem = QStandardItem(setting.description) labelItem.setIcon(icon) labelItem.setEditable(False) self.items[setting] = SettingItem(setting) groupItem.insertRow(0, [labelItem, self.items[setting]]) """ Filter 'Providers' items """ providersItem = QStandardItem(self.tr('Providers')) icon = QgsApplication.getThemeIcon("/processingAlgorithm.svg") providersItem.setIcon(icon) providersItem.setEditable(False) emptyItem = QStandardItem() emptyItem.setEditable(False) rootItem.insertRow(0, [providersItem, emptyItem]) for group in list(settings.keys()): if group in priorityKeys or group == menusSettingsGroup: continue groupItem = QStandardItem(group) icon = ProcessingConfig.getGroupIcon(group) groupItem.setIcon(icon) groupItem.setEditable(False) for setting in settings[group]: if setting.hidden: continue labelItem = QStandardItem(setting.description) labelItem.setIcon(icon) labelItem.setEditable(False) self.items[setting] = SettingItem(setting) groupItem.insertRow(0, [labelItem, self.items[setting]]) emptyItem = QStandardItem() emptyItem.setEditable(False) providersItem.appendRow([groupItem, emptyItem]) """ Filter 'Menus' items """ self.menusItem = QStandardItem(self.tr('Menus')) icon = QIcon(os.path.join(pluginPath, 'images', 'menu.png')) self.menusItem.setIcon(icon) self.menusItem.setEditable(False) emptyItem = QStandardItem() emptyItem.setEditable(False) rootItem.insertRow(0, [self.menusItem, emptyItem]) button = QPushButton(self.tr('Reset to defaults')) button.clicked.connect(self.resetMenusToDefaults) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(button) layout.addStretch() widget = QWidget() widget.setLayout(layout) self.tree.setIndexWidget(emptyItem.index(), widget) for provider in QgsApplication.processingRegistry().providers(): providerDescription = provider.name() groupItem = QStandardItem(providerDescription) icon = provider.icon() groupItem.setIcon(icon) groupItem.setEditable(False) for alg in provider.algorithms(): algItem = QStandardItem(alg.displayName()) algItem.setIcon(icon) algItem.setEditable(False) try: settingMenu = ProcessingConfig.settings["MENU_" + alg.id()] settingButton = ProcessingConfig.settings["BUTTON_" + alg.id()] settingIcon = ProcessingConfig.settings["ICON_" + alg.id()] except: continue self.items[settingMenu] = SettingItem(settingMenu) self.items[settingButton] = SettingItem(settingButton) self.items[settingIcon] = SettingItem(settingIcon) menuLabelItem = QStandardItem("Menu path") menuLabelItem.setEditable(False) buttonLabelItem = QStandardItem("Add button in toolbar") buttonLabelItem.setEditable(False) iconLabelItem = QStandardItem("Icon") iconLabelItem.setEditable(False) emptyItem = QStandardItem() emptyItem.setEditable(False) algItem.insertRow(0, [menuLabelItem, self.items[settingMenu]]) algItem.insertRow(0, [buttonLabelItem, self.items[settingButton]]) algItem.insertRow(0, [iconLabelItem, self.items[settingIcon]]) groupItem.insertRow(0, [algItem, emptyItem]) emptyItem = QStandardItem() emptyItem.setEditable(False) self.menusItem.appendRow([groupItem, emptyItem]) self.tree.sortByColumn(0, Qt.AscendingOrder) self.adjustColumns()