Skip to content

Commit

Permalink
gdal tools: use native file dialogs (fixes #5500)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2c112f9)
  • Loading branch information
jef-n committed Jun 26, 2016
1 parent f52d27b commit ca86571
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions python/plugins/GdalTools/tools/GdalTools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,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:
Expand Down

0 comments on commit ca86571

Please sign in to comment.