Skip to content

Commit 8526a2d

Browse files
committedNov 10, 2017
Remember last used folder for processing batch save/load
Fixes #16310
1 parent 9bac962 commit 8526a2d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎python/plugins/processing/gui/BatchPanel.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131

3232
from qgis.PyQt import uic
3333
from qgis.PyQt.QtWidgets import QTableWidgetItem, QComboBox, QHeaderView, QFileDialog, QMessageBox
34-
34+
from qgis.PyQt.QtCore import QDir, QFileInfo
3535
from qgis.core import (QgsApplication,
36+
QgsSettings,
3637
QgsProcessingParameterDefinition)
3738
from qgis.gui import QgsMessageBar
3839
from processing.gui.wrappers import WidgetWrapperFactory
@@ -142,10 +143,14 @@ def initWidgets(self):
142143
self.tblParameters.horizontalHeader().setStretchLastSection(True)
143144

144145
def load(self):
146+
settings = QgsSettings()
147+
last_path = settings.value("/Processing/LastBatchPath", QDir.homePath())
145148
filename, selected_filter = QFileDialog.getOpenFileName(self,
146-
self.tr('Open Batch'), None,
149+
self.tr('Open Batch'), last_path,
147150
self.tr('JSON files (*.json)'))
148151
if filename:
152+
last_path = QFileInfo(filename).path()
153+
settings.setValue('/Processing/LastBatchPath', last_path)
149154
with open(filename) as f:
150155
values = json.load(f)
151156
else:
@@ -216,13 +221,17 @@ def save(self):
216221
return
217222
toSave.append({self.PARAMETERS: algParams, self.OUTPUTS: algOutputs})
218223

224+
settings = QgsSettings()
225+
last_path = settings.value("/Processing/LastBatchPath", QDir.homePath())
219226
filename, __ = QFileDialog.getSaveFileName(self,
220227
self.tr('Save Batch'),
221-
None,
228+
last_path,
222229
self.tr('JSON files (*.json)'))
223230
if filename:
224231
if not filename.endswith('.json'):
225232
filename += '.json'
233+
last_path = QFileInfo(filename).path()
234+
settings.setValue('/Processing/LastBatchPath', last_path)
226235
with open(filename, 'w') as f:
227236
json.dump(toSave, f)
228237

0 commit comments

Comments
 (0)
Please sign in to comment.