Skip to content
Permalink
Browse files

gdal tools: use native file dialogs (fixes #5500)

  • Loading branch information
jef-n committed Jun 20, 2016
1 parent ab98858 commit 2c112f96cab55eed2f3922dbf2dd14522eac5aee
Showing with 24 additions and 4 deletions.
  1. +24 −4 python/plugins/GdalTools/tools/GdalTools_utils.py
@@ -445,19 +445,39 @@ def getDialog(self, parent=None, caption='', acceptMode=QFileDialog.AcceptOpen,

@classmethod
def getOpenFileNames(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFiles, filter, selectedFilter, useEncoding)
res = QFileDialog.getOpenFileNames(parent, caption, getLastUsedDir(), filter)
if len(res) > 0:
setLastUsedDir(res[-1])
return res

@classmethod
def getOpenFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.ExistingFile, filter, selectedFilter, useEncoding)
res = QFileDialog.getOpenFileName(parent, caption, getLastUsedDir(), filter)
if res:
setLastUsedDir(res)
return res

@classmethod
def getSaveFileName(self, parent=None, caption='', filter='', selectedFilter=None, useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptSave, QFileDialog.AnyFile, filter, selectedFilter, useEncoding)
res = QFileDialog.getSaveFileName(parent, caption, getLastUsedDir(), filter)
if res:
setLastUsedDir(res)
return res

@classmethod
def getExistingDirectory(self, parent=None, caption='', useEncoding=False):
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding)
if useEncoding:
return self.getDialog(parent, caption, QFileDialog.AcceptOpen, QFileDialog.DirectoryOnly, '', None, useEncoding)
res = QFileDialog.getExistingDirectory(parent, caption, getLastUsedDir(), QFileDialog.ShowDirsOnly)
if res:
setLastUsedDir(res)
return res


class FileFilter:

0 comments on commit 2c112f9

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