diff --git a/images/images.qrc b/images/images.qrc index 918eeaafb43..909d5918e40 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -115,6 +115,8 @@ themes/default/mActionAddBasicCircle.svg themes/default/mActionEditNodesItem.svg themes/default/mActionEditHelpContent.svg + themes/default/mActionIncreaseFont.svg + themes/default/mActionDecreaseFont.svg themes/default/mActionAddNodesItem.svg themes/default/mActionAddPolygon.svg themes/default/mActionAddPolyline.svg diff --git a/images/themes/default/mActionDecreaseFont.svg b/images/themes/default/mActionDecreaseFont.svg new file mode 100644 index 00000000000..322629dd99f --- /dev/null +++ b/images/themes/default/mActionDecreaseFont.svg @@ -0,0 +1,555 @@ + + + + + label + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + label + 2011-03-11 + + + Robert Szczepanek + + + + + Robert Szczepanek + + + + + icon + gis + + + GIS icons 0.2 + + + + + + + + + + + + + + + + A− + + + + + + diff --git a/images/themes/default/mActionIncreaseFont.svg b/images/themes/default/mActionIncreaseFont.svg new file mode 100644 index 00000000000..f1212320014 --- /dev/null +++ b/images/themes/default/mActionIncreaseFont.svg @@ -0,0 +1,555 @@ + + + + + label + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + label + 2011-03-11 + + + Robert Szczepanek + + + + + Robert Szczepanek + + + + + icon + gis + + + GIS icons 0.2 + + + + + + + + + + + + + + + + A+ + + + + + + diff --git a/python/plugins/processing/gui/CreateNewScriptAction.py b/python/plugins/processing/gui/CreateNewScriptAction.py index 141484751d5..e3df462f87a 100644 --- a/python/plugins/processing/gui/CreateNewScriptAction.py +++ b/python/plugins/processing/gui/CreateNewScriptAction.py @@ -60,7 +60,6 @@ class CreateNewScriptAction(ToolboxAction): if self.scriptType == self.SCRIPT_R: dlg = ScriptEditorDialog(ScriptEditorDialog.SCRIPT_R, None) dlg.show() - dlg.exec_() if dlg.update: if self.scriptType == self.SCRIPT_PYTHON: algList.reloadProvider('script') diff --git a/python/plugins/processing/gui/ScriptEditorDialog.py b/python/plugins/processing/gui/ScriptEditorDialog.py index 597cbdac75e..bf2223a588d 100644 --- a/python/plugins/processing/gui/ScriptEditorDialog.py +++ b/python/plugins/processing/gui/ScriptEditorDialog.py @@ -31,9 +31,14 @@ import json import os from qgis.PyQt import uic -from qgis.PyQt.QtCore import Qt +from qgis.PyQt.QtCore import Qt, QSize, QByteArray, QSettings from qgis.PyQt.QtGui import QIcon, QCursor -from qgis.PyQt.QtWidgets import QMenu, QAction, QMessageBox, QFileDialog, QApplication +from qgis.PyQt.QtWidgets import (QMenu, + QAction, + QToolButton, + QMessageBox, + QFileDialog, + QApplication) from qgis.core import QgsApplication from qgis.utils import iface @@ -65,40 +70,52 @@ class ScriptEditorDialog(BASE, WIDGET): self.setWindowFlags(Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint | Qt.WindowCloseButtonHint) - # Set icons - self.btnOpen.setIcon( + + settings = QSettings() + self.restoreState(settings.value("/Processing/stateScriptEditor", QByteArray())) + self.restoreGeometry(settings.value("/Processing/geometryScriptEditor", QByteArray())) + + iconSize = settings.value("iconsize", 24) + self.toolBar.setIconSize(QSize(iconSize, iconSize)) + + self.actionOpenScript.setIcon( QgsApplication.getThemeIcon('/mActionFileOpen.svg')) - self.btnSave.setIcon( + self.actionSaveScript.setIcon( QgsApplication.getThemeIcon('/mActionFileSave.svg')) - self.btnSaveAs.setIcon( + self.actionSaveScriptAs.setIcon( QgsApplication.getThemeIcon('/mActionFileSaveAs.svg')) - self.btnEditHelp.setIcon( - QIcon(os.path.join(pluginPath, 'images', 'edithelp.png'))) - self.btnRun.setIcon( - QIcon(os.path.join(pluginPath, 'images', 'runalgorithm.png'))) - self.btnCut.setIcon(QgsApplication.getThemeIcon('/mActionEditCut.svg')) - self.btnCopy.setIcon( + self.actionEditScriptHelp.setIcon( + QgsApplication.getThemeIcon('/mActionEditHelpContent.svg')) + self.actionRunScript.setIcon( + QgsApplication.getThemeIcon('/mActionStart.svg')) + self.actionCut.setIcon( + QgsApplication.getThemeIcon('/mActionEditCut.svg')) + self.actionCopy.setIcon( QgsApplication.getThemeIcon('/mActionEditCopy.svg')) - self.btnPaste.setIcon( + self.actionPaste.setIcon( QgsApplication.getThemeIcon('/mActionEditPaste.svg')) - self.btnUndo.setIcon(QgsApplication.getThemeIcon('/mActionUndo.svg')) - self.btnRedo.setIcon(QgsApplication.getThemeIcon('/mActionRedo.svg')) - self.btnSnippets.setIcon(QgsApplication.getThemeIcon('/mActionHelpAPI.png')) + self.actionUndo.setIcon( + QgsApplication.getThemeIcon('/mActionUndo.svg')) + self.actionRedo.setIcon( + QgsApplication.getThemeIcon('/mActionRedo.svg')) + self.actionIncreaseFontSize.setIcon( + QgsApplication.getThemeIcon('/mActionIncreaseFont.svg')) + self.actionDecreaseFontSize.setIcon( + QgsApplication.getThemeIcon('/mActionDecreaseFont.svg')) # Connect signals and slots - self.btnOpen.clicked.connect(self.openScript) - self.btnSave.clicked.connect(self.save) - self.btnSaveAs.clicked.connect(self.saveAs) - self.btnEditHelp.clicked.connect(self.editHelp) - self.btnRun.clicked.connect(self.runAlgorithm) - self.btnSnippets.clicked.connect(self.showSnippets) - self.btnCut.clicked.connect(self.editor.cut) - self.btnCopy.clicked.connect(self.editor.copy) - self.btnPaste.clicked.connect(self.editor.paste) - self.btnUndo.clicked.connect(self.editor.undo) - self.btnRedo.clicked.connect(self.editor.redo) - self.btnIncreaseFont.clicked.connect(self.editor.zoomIn) - self.btnDecreaseFont.clicked.connect(self.editor.zoomOut) + self.actionOpenScript.triggered.connect(self.openScript) + self.actionSaveScript.triggered.connect(self.save) + self.actionSaveScriptAs.triggered.connect(self.saveAs) + self.actionEditScriptHelp.triggered.connect(self.editHelp) + 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.actionIncreaseFontSize.triggered.connect(self.editor.zoomIn) + self.actionDecreaseFontSize.triggered.connect(self.editor.zoomOut) self.editor.textChanged.connect(lambda: self.setHasChanged(True)) self.alg = alg @@ -107,7 +124,7 @@ class ScriptEditorDialog(BASE, WIDGET): self.snippets = {} if self.algType == self.SCRIPT_PYTHON: path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "script", "snippets.py") - with open(path) as f: + with codecs.open(path, 'r', encoding='utf-8') as f: lines = f.readlines() snippetlines = [] name = None @@ -122,8 +139,8 @@ class ScriptEditorDialog(BASE, WIDGET): if snippetlines: self.snippets[name] = "".join(snippetlines) - if not self.snippets: - self.btnSnippets.setVisible(False) + #if self.snippets: + # self.btnSnippets.setVisible(False) if self.alg is not None: self.filename = self.alg.descriptionFile @@ -138,13 +155,13 @@ class ScriptEditorDialog(BASE, WIDGET): self.editor.setLexerType(self.algType) - def showSnippets(self, evt): - popupmenu = QMenu() - for name, snippet in list(self.snippets.items()): - action = QAction(self.tr(name), self.btnSnippets) - action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet)) - popupmenu.addAction(action) - popupmenu.exec_(QCursor.pos()) + #def showSnippets(self, evt): + # popupmenu = QMenu() + # for name, snippet in list(self.snippets.items()): + # action = QAction(self.tr(name), self.btnSnippets) + # action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet)) + # popupmenu.addAction(action) + # popupmenu.exec_(QCursor.pos()) def closeEvent(self, evt): if self.hasChanged: @@ -189,7 +206,7 @@ class ScriptEditorDialog(BASE, WIDGET): scriptDir = RUtils.RScriptsFolders()[0] filterName = self.tr('Processing R script (*.rsx)') - self.filename = QFileDialog.getOpenFileName( + self.filename, fileFilter = QFileDialog.getOpenFileName( self, self.tr('Open script'), scriptDir, filterName) if self.filename == '': @@ -220,9 +237,8 @@ class ScriptEditorDialog(BASE, WIDGET): scriptDir = RUtils.RScriptsFolders()[0] filterName = self.tr('Processing R script (*.rsx)') - self.filename = str(QFileDialog.getSaveFileName(self, - self.tr('Save script'), scriptDir, - filterName)) + self.filename, fileFilter = QFileDialog.getSaveFileName( + self, self.tr('Save script'), scriptDir, filterName) if self.filename: if self.algType == self.SCRIPT_PYTHON and \ @@ -239,9 +255,9 @@ class ScriptEditorDialog(BASE, WIDGET): with codecs.open(self.filename, 'w', encoding='utf-8') as fout: fout.write(text) except IOError: - QMessageBox.warning(self, self.tr('I/O error'), - self.tr('Unable to save edits. Reason:\n %s') - % str(sys.exc_info()[1]) + QMessageBox.warning(self, + self.tr('I/O error'), + self.tr('Unable to save edits. Reason:\n{}').format(sys.exc_info()[1]) ) return self.update = True @@ -249,7 +265,7 @@ class ScriptEditorDialog(BASE, WIDGET): # If help strings were defined before saving the script for # the first time, we do it here if self.help: - with open(self.filename + '.help', 'w') as f: + with codecs.open(self.filename + '.help', 'w', encoding='utf-8') as f: json.dump(self.help, f) self.help = None self.setHasChanged(False) @@ -258,7 +274,7 @@ class ScriptEditorDialog(BASE, WIDGET): def setHasChanged(self, hasChanged): self.hasChanged = hasChanged - self.btnSave.setEnabled(hasChanged) + self.actionSaveScript.setEnabled(hasChanged) def runAlgorithm(self): if self.algType == self.SCRIPT_PYTHON: diff --git a/python/plugins/processing/modeler/ModelerDialog.py b/python/plugins/processing/modeler/ModelerDialog.py index f51d0b50589..553320c4f36 100644 --- a/python/plugins/processing/modeler/ModelerDialog.py +++ b/python/plugins/processing/modeler/ModelerDialog.py @@ -279,9 +279,9 @@ class ModelerDialog(BASE, WIDGET): self.saveModel(True) def exportAsImage(self): - filename, filter = QFileDialog.getSaveFileName(self, - self.tr('Save Model As Image'), '', - self.tr('PNG files (*.png *.PNG)')) + filename, fileFilter = QFileDialog.getSaveFileName(self, + self.tr('Save Model As Image'), '', + self.tr('PNG files (*.png *.PNG)')) if not filename: return diff --git a/python/plugins/processing/ui/DlgScriptEditor.ui b/python/plugins/processing/ui/DlgScriptEditor.ui index ad3001c751b..a236a575608 100644 --- a/python/plugins/processing/ui/DlgScriptEditor.ui +++ b/python/plugins/processing/ui/DlgScriptEditor.ui @@ -1,287 +1,177 @@ - DlgScriptEditor - + MainWindow + 0 0 - 720 - 480 + 721 + 578 Script editor - - - 6 + + + + + + + + + + + toolBar - - 9 + + TopToolBarArea + + + false + + + + + + + + + + + + + + + + + + + + + + Open script... - - - - 6 - - - 3 - - - 3 - - - 3 - - - - - Open script - - - ... - - - Ctrl+O, Return - - - true - - - - - - - Save - - - ... - - - Ctrl+S - - - true - - - - - - - Save as... - - - ... - - - Ctrl+Shift+S - - - true - - - - - - - Qt::Vertical - - - - - - - Edit script help - - - ... - - - true - - - - - - - Qt::Vertical - - - - - - - Run algorithm - - - ... - - - F5 - - - true - - - - - - - Qt::Vertical - - - - - - - Cut - - - ... - - - Ctrl+X - - - true - - - - - - - Copy - - - ... - - - Ctrl+C - - - true - - - - - - - Paste - - - ... - - - Ctrl+V - - - true - - - - - - - Qt::Vertical - - - - - - - Undo - - - ... - - - Ctrl+Z - - - true - - - - - - - Redo - - - ... - - - Ctrl+Shift+Z - - - true - - - - - - - Qt::Vertical - - - - - - - ... - - - true - - - - - - - Qt::Vertical - - - - - - - A+ - - - true - - - - - - - A- - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - + + Open script + + + Ctrl+O + + + + + Save script... + + + Save script... + + + Ctrl+S + + + + + Save script as... + + + Save script as... + + + Ctrl+Shift+S + + + + + Edit script help + + + Edit script help + + + + + Run script + + + Run script + + + F5 + + + + + Cut + + + Cut + + + Ctrl+X + + + + + Copy + + + Copy + + + Ctrl+C + + + + + Paste + + + Paste + + + Ctrl+V + + + + + Undo + + + Undo + + + Ctrl+Z + + + + + Redo + + + Redo + + + Ctrl+Shift+Z + + + + + Increase font size + + + Increase font size + + + + + Decrease font size + + + Decrease font size + + @@ -290,12 +180,6 @@
processing.gui.ScriptEdit
- - btnSave - btnSaveAs - btnEditHelp - btnRun -