Skip to content
Permalink
Browse files

Fix dest selection panel when used in folder mode

Also fix some UX issues with the panel in folder, such as
correctly remembering/restoring last used folders, defaulting
to home dir, don't clear value when canceling while browsing
  • Loading branch information
nyalldawson committed Jun 22, 2017
1 parent 76a9844 commit 9d8118c995c10cdb9f3a087bae74ae3ecb0d5c11
@@ -121,8 +121,9 @@ def getParamValues(self):
dest_project = QgsProject.instance()

value = self.mainWidget.outputWidgets[param.name()].getValue()
if value:
if value and isinstance(value, QgsProcessingOutputLayerDefinition):
value.destinationProject = dest_project
if value:
parameters[param.name()] = value

return parameters
@@ -30,7 +30,7 @@
import os

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtCore import QCoreApplication, QDir
from qgis.PyQt.QtWidgets import QDialog, QMenu, QAction, QFileDialog
from qgis.PyQt.QtGui import QCursor
from qgis.gui import QgsEncodingFileDialog, QgsExpressionBuilderDialog
@@ -40,10 +40,9 @@
QgsSettings,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputLayerDefinition,
QgsProcessingParameterDefinition)
QgsProcessingParameterDefinition,
QgsProcessingParameterFolderOutput)
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.outputs import OutputVector
from processing.core.outputs import OutputDirectory
from processing.tools.dataobjects import createContext
from processing.gui.PostgisTableSelector import PostgisTableSelector
from processing.gui.ParameterGuiUtils import getFileFilter
@@ -80,7 +79,7 @@ def __init__(self, parameter, alg):
and alg.provider().supportsNonFileBasedOutput():
# use memory layers for temporary files if supported
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_LAYER)
else:
elif not isinstance(self.parameter, QgsProcessingParameterFolderOutput):
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_FILE)

self.btnSelect.clicked.connect(self.selectOutput)
@@ -95,7 +94,7 @@ def skipOutput(self):
self.use_temporary = False

def selectOutput(self):
if isinstance(self.parameter, OutputDirectory):
if isinstance(self.parameter, QgsProcessingParameterFolderOutput):
self.selectDirectory()
else:
popupMenu = QMenu()
@@ -253,10 +252,16 @@ def selectFile(self):
settings.setValue('/Processing/encoding', self.encoding)

def selectDirectory(self):
lastDir = ''
lastDir = self.leText.text()
settings = QgsSettings()
if not lastDir:
lastDir = settings.value("/Processing/LastOutputPath", QDir.homePath())

dirName = QFileDialog.getExistingDirectory(self, self.tr('Select directory'),
lastDir, QFileDialog.ShowDirsOnly)
self.leText.setText(dirName)
if dirName:
self.leText.setText(QDir.toNativeSeparators(dirName))
settings.setValue('/Processing/LastOutputPath', dirName)

def getValue(self):
key = None
@@ -268,6 +273,9 @@ def getValue(self):
if not key and self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
return None

if isinstance(self.parameter, QgsProcessingParameterFolderOutput):
return key

value = QgsProcessingOutputLayerDefinition(key)
value.createOptions = {'fileEncoding': self.encoding}
return value

0 comments on commit 9d8118c

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