From ee3677da2b3fb0e9ed6b17a220b5295fe64151c5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 11 Jun 2012 21:24:55 +0000 Subject: [PATCH] Added and modified patch from AsamK - Fixed bug in Qt for Windows Vista and higher. Convert path from native separators of filenames from QFileDialog::getOpenFileName(s) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5213 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/util/misc.cpp | 47 ++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index aeaba029d..a5c1cbd9b 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -288,12 +288,19 @@ bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, co file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks); - if (file.isEmpty() == false) { - lastDir = QFileInfo(file).absoluteDir().absolutePath(); - Settings->setLastDir(type, lastDir); - } + if (file.isEmpty()) + return false; - return !file.isEmpty(); + lastDir = QFileInfo(file).absoluteDir().absolutePath(); + Settings->setLastDir(type, lastDir); + +#ifdef WINDOWS_SYS + // fix bug in Qt for Windows Vista and higher, convert path from native separators + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) + file = QDir::fromNativeSeparators(file); +#endif + + return true; } bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QStringList &files) @@ -302,12 +309,21 @@ bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, c files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks); - if (files.isEmpty() == false) { - lastDir = QFileInfo(*files.begin()).absoluteDir().absolutePath(); - Settings->setLastDir(type, lastDir); - } + if (files.isEmpty()) + return false; - return !files.isEmpty(); + lastDir = QFileInfo(*files.begin()).absoluteDir().absolutePath(); + Settings->setLastDir(type, lastDir); + +#ifdef WINDOWS_SYS + // fix bug in Qt for Windows Vista and higher, convert path from native separators + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) + for (QStringList::iterator file = files.begin(); file != files.end(); file++) { + (*file) = QDir::fromNativeSeparators(*file); + } +#endif + + return true; } bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file) @@ -316,10 +332,11 @@ bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, co file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter); - if (file.isEmpty() == false) { - lastDir = QFileInfo(file).absoluteDir().absolutePath(); - Settings->setLastDir(type, lastDir); - } + if (file.isEmpty()) + return false; - return !file.isEmpty(); + lastDir = QFileInfo(file).absoluteDir().absolutePath(); + Settings->setLastDir(type, lastDir); + + return true; }