Skip to content

Commit

Permalink
Merge pull request #1230 from dakcarto/issue_9704_gdal-qsettings
Browse files Browse the repository at this point in the history
Fix #9704, GdalTools file dialogs return QPyNullVariant due to QSettings undefined return type
  • Loading branch information
dakcarto committed Mar 10, 2014
2 parents 60e1a9b + 073dbf1 commit 9c139c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/GdalTools.py
Expand Up @@ -76,7 +76,7 @@ def __init__( self, iface ):
if not overrideLocale:
localeFullName = QLocale.system().name()
else:
localeFullName = QSettings().value( "locale/userLocale", "" )
localeFullName = QSettings().value( "locale/userLocale", "", type=str )

if QFileInfo( userPluginPath ).exists():
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
Expand Down
18 changes: 9 additions & 9 deletions python/plugins/GdalTools/tools/GdalTools_utils.py
Expand Up @@ -59,8 +59,8 @@ def escapeAndJoin(strList):
# Retrieves last used dir from persistent settings
def getLastUsedDir():
settings = QSettings()
lastProjectDir = settings.value( "/UI/lastProjectDir", ".", type=str )
return settings.value( "/GdalTools/lastUsedDir", lastProjectDir, type=str )
lastProjectDir = settings.value( "/UI/lastProjectDir", u".", type=unicode )
return settings.value( "/GdalTools/lastUsedDir", lastProjectDir, type=unicode )

# Stores last used dir in persistent settings
def setLastUsedDir(filePath):
Expand All @@ -75,7 +75,7 @@ def setLastUsedDir(filePath):
# Retrieves GDAL binaries location
def getGdalBinPath():
settings = QSettings()
return settings.value( "/GdalTools/gdalPath", u"" )
return settings.value( "/GdalTools/gdalPath", u"", type=unicode )

# Stores GDAL binaries location
def setGdalBinPath( path ):
Expand All @@ -85,7 +85,7 @@ def setGdalBinPath( path ):
# Retrieves GDAL python modules location
def getGdalPymodPath():
settings = QSettings()
return settings.value( "/GdalTools/gdalPymodPath", u"" )
return settings.value( "/GdalTools/gdalPymodPath", u"", type=unicode )

# Stores GDAL python modules location
def setGdalPymodPath( path ):
Expand All @@ -95,7 +95,7 @@ def setGdalPymodPath( path ):
# Retrieves GDAL help files location
def getHelpPath():
settings = QSettings()
return settings.value( "/GdalTools/helpPath", u"" )
return settings.value( "/GdalTools/helpPath", u"", type=unicode )

# Stores GDAL help files location
def setHelpPath( path ):
Expand All @@ -105,7 +105,7 @@ def setHelpPath( path ):
# Retrieves last used encoding from persistent settings
def getLastUsedEncoding():
settings = QSettings()
return settings.value( "/UI/encoding", u"System" )
return settings.value( "/UI/encoding", u"System", type=unicode )

# Stores last used encoding in persistent settings
def setLastUsedEncoding(encoding):
Expand Down Expand Up @@ -347,7 +347,7 @@ def getDialog(self, parent = None, caption = '', acceptMode = QFileDialog.Accept
dialog.setFileMode(fileMode)
dialog.setAcceptMode(acceptMode)

if selectedFilter != None:
if selectedFilter is not None:
dialog.selectNameFilter(selectedFilter[0])

if not dialog.exec_():
Expand All @@ -356,7 +356,7 @@ def getDialog(self, parent = None, caption = '', acceptMode = QFileDialog.Accept
return ''

# change the selected filter value
if selectedFilter != None:
if selectedFilter is not None:
selectedFilter[0] = dialog.selectedNameFilter()

# save the last used dir and return the selected files
Expand Down Expand Up @@ -409,7 +409,7 @@ class FileFilter:
@classmethod
def getFilter(self, typeName):
settings = QSettings()
return settings.value( "/GdalTools/" + typeName + "FileFilter", u"" )
return settings.value( "/GdalTools/" + typeName + "FileFilter", u"", type=unicode )

@classmethod
def setFilter(self, typeName, aFilter):
Expand Down

0 comments on commit 9c139c2

Please sign in to comment.