Skip to content
Permalink
Browse files

Remember last used folder for processing batch save/load

Fixes #16310
  • Loading branch information
nyalldawson committed Nov 10, 2017
1 parent 9bac962 commit 8526a2dd3f6e03d4b8cde7964fa42ed9f5df62cf
Showing with 12 additions and 3 deletions.
  1. +12 −3 python/plugins/processing/gui/BatchPanel.py
@@ -31,8 +31,9 @@

from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QTableWidgetItem, QComboBox, QHeaderView, QFileDialog, QMessageBox

from qgis.PyQt.QtCore import QDir, QFileInfo
from qgis.core import (QgsApplication,
QgsSettings,
QgsProcessingParameterDefinition)
from qgis.gui import QgsMessageBar
from processing.gui.wrappers import WidgetWrapperFactory
@@ -142,10 +143,14 @@ def initWidgets(self):
self.tblParameters.horizontalHeader().setStretchLastSection(True)

def load(self):
settings = QgsSettings()
last_path = settings.value("/Processing/LastBatchPath", QDir.homePath())
filename, selected_filter = QFileDialog.getOpenFileName(self,
self.tr('Open Batch'), None,
self.tr('Open Batch'), last_path,
self.tr('JSON files (*.json)'))
if filename:
last_path = QFileInfo(filename).path()
settings.setValue('/Processing/LastBatchPath', last_path)
with open(filename) as f:
values = json.load(f)
else:
@@ -216,13 +221,17 @@ def save(self):
return
toSave.append({self.PARAMETERS: algParams, self.OUTPUTS: algOutputs})

settings = QgsSettings()
last_path = settings.value("/Processing/LastBatchPath", QDir.homePath())
filename, __ = QFileDialog.getSaveFileName(self,
self.tr('Save Batch'),
None,
last_path,
self.tr('JSON files (*.json)'))
if filename:
if not filename.endswith('.json'):
filename += '.json'
last_path = QFileInfo(filename).path()
settings.setValue('/Processing/LastBatchPath', last_path)
with open(filename, 'w') as f:
json.dump(toSave, f)

0 comments on commit 8526a2d

Please sign in to comment.
You can’t perform that action at this time.