Skip to content
Permalink
Browse files

[processing] save last used models/scripts directory (fix #12536)

  • Loading branch information
alexbruy committed Apr 10, 2015
1 parent 8ffa4ac commit 7f94cf7de851638f1c7386901c2fd889f37cb18b
@@ -28,6 +28,7 @@
import os
import shutil
from PyQt4.QtGui import QIcon, QFileDialog, QMessageBox
from PyQt4.QtCore import QSettings, QFileInfo
from processing.gui.ToolboxAction import ToolboxAction
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
from processing.modeler.WrongModelException import WrongModelException
@@ -43,11 +44,16 @@ def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../images/model.png')

def execute(self):
settings = QSettings()
lastDir = settings.value('Processing/lastModelsDir', '')
filename = QFileDialog.getOpenFileName(self.toolbox,
self.tr('Open model', 'AddModelFromFileAction'), None,
self.tr('Open model', 'AddModelFromFileAction'), lastDir,
self.tr('Processing model files (*.model *.MODEL)', 'AddModelFromFileAction'))
if filename:
try:
settings.setValue('Processing/lastModelsDir',
QFileInfo(fileName).absoluteDir().absolutePath())

ModelerAlgorithm.fromFile(filename)
except WrongModelException:
QMessageBox.warning(
@@ -42,12 +42,16 @@ def getIcon(self):
return QIcon(':/processing/images/script.png')

def execute(self):
settings = QSettings()
lastDir = settings.value('Processing/lastScriptsDir', '')
filename = QFileDialog.getOpenFileName(self.toolbox,
self.tr('Script files', 'AddScriptFromFileAction'), None,
self.tr('Script files (*.py *.PY)', 'AddScriptFromFileAction')
)
self.tr('Script files (*.py *.PY)', 'AddScriptFromFileAction'))
if filename:
try:
settings.setValue('Processing/lastScriptsDir',
QFileInfo(fileName).absoluteDir().absolutePath())

script = ScriptAlgorithm(filename)
except WrongScriptException:
QMessageBox.warning(self.toolbox,

0 comments on commit 7f94cf7

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