|
31 | 31 |
|
32 | 32 | from qgis.PyQt import uic
|
33 | 33 | from qgis.PyQt.QtWidgets import QTableWidgetItem, QComboBox, QHeaderView, QFileDialog, QMessageBox
|
34 |
| - |
| 34 | +from qgis.PyQt.QtCore import QDir, QFileInfo |
35 | 35 | from qgis.core import (QgsApplication,
|
| 36 | + QgsSettings, |
36 | 37 | QgsProcessingParameterDefinition)
|
37 | 38 | from qgis.gui import QgsMessageBar
|
38 | 39 | from processing.gui.wrappers import WidgetWrapperFactory
|
@@ -142,10 +143,14 @@ def initWidgets(self):
|
142 | 143 | self.tblParameters.horizontalHeader().setStretchLastSection(True)
|
143 | 144 |
|
144 | 145 | def load(self):
|
| 146 | + settings = QgsSettings() |
| 147 | + last_path = settings.value("/Processing/LastBatchPath", QDir.homePath()) |
145 | 148 | filename, selected_filter = QFileDialog.getOpenFileName(self,
|
146 |
| - self.tr('Open Batch'), None, |
| 149 | + self.tr('Open Batch'), last_path, |
147 | 150 | self.tr('JSON files (*.json)'))
|
148 | 151 | if filename:
|
| 152 | + last_path = QFileInfo(filename).path() |
| 153 | + settings.setValue('/Processing/LastBatchPath', last_path) |
149 | 154 | with open(filename) as f:
|
150 | 155 | values = json.load(f)
|
151 | 156 | else:
|
@@ -216,13 +221,17 @@ def save(self):
|
216 | 221 | return
|
217 | 222 | toSave.append({self.PARAMETERS: algParams, self.OUTPUTS: algOutputs})
|
218 | 223 |
|
| 224 | + settings = QgsSettings() |
| 225 | + last_path = settings.value("/Processing/LastBatchPath", QDir.homePath()) |
219 | 226 | filename, __ = QFileDialog.getSaveFileName(self,
|
220 | 227 | self.tr('Save Batch'),
|
221 |
| - None, |
| 228 | + last_path, |
222 | 229 | self.tr('JSON files (*.json)'))
|
223 | 230 | if filename:
|
224 | 231 | if not filename.endswith('.json'):
|
225 | 232 | filename += '.json'
|
| 233 | + last_path = QFileInfo(filename).path() |
| 234 | + settings.setValue('/Processing/LastBatchPath', last_path) |
226 | 235 | with open(filename, 'w') as f:
|
227 | 236 | json.dump(toSave, f)
|
228 | 237 |
|
|
0 commit comments