From 1f1bbbaeb6a5651ceb3674eaf86654fe0c5d25cd Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 5 Dec 2018 10:31:03 +1000 Subject: [PATCH] [console] Fix saving scripts sometimes defaults to QGIS bin folder --- python/console/console_editor.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/console/console_editor.py b/python/console/console_editor.py index c2c6c9cde36..c985c7e9da2 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -18,7 +18,7 @@ email : lrssvtml (at) gmail (dot) com ***************************************************************************/ Some portions of code were taken from https://code.google.com/p/pydee/ """ -from qgis.PyQt.QtCore import Qt, QObject, QEvent, QCoreApplication, QFileInfo, QSize +from qgis.PyQt.QtCore import Qt, QObject, QEvent, QCoreApplication, QFileInfo, QSize, QDir from qgis.PyQt.QtGui import QFont, QFontMetrics, QColor, QKeySequence, QCursor, QFontDatabase from qgis.PyQt.QtWidgets import QShortcut, QMenu, QApplication, QWidget, QGridLayout, QSpacerItem, QSizePolicy, QFileDialog, QTabWidget, QTreeWidgetItem, QFrame, QLabel, QToolButton, QMessageBox from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs, QsciStyle @@ -831,9 +831,10 @@ class EditorTab(QWidget): if self.path is None: saveTr = QCoreApplication.translate('PythonConsole', 'Python Console: Save file') + folder = self.pc.settings.value("pythonConsole/lastDirPath", QDir.homePath()) self.path, filter = QFileDialog().getSaveFileName(self, saveTr, - self.tw.tabText(index) + '.py', + os.path.join(folder, self.tw.tabText(index) + '.py'), "Script file (*.py)") # If the user didn't select a file, abort the save operation if len(self.path) == 0: