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
This commit is contained in:
thunder2 2012-06-11 21:24:55 +00:00
parent 63104ceefc
commit ee3677da2b

View File

@ -288,12 +288,19 @@ bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, co
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks); file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
if (file.isEmpty() == false) { if (file.isEmpty())
return false;
lastDir = QFileInfo(file).absoluteDir().absolutePath(); lastDir = QFileInfo(file).absoluteDir().absolutePath();
Settings->setLastDir(type, lastDir); Settings->setLastDir(type, lastDir);
}
return !file.isEmpty(); #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) 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); files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
if (files.isEmpty() == false) { if (files.isEmpty())
return false;
lastDir = QFileInfo(*files.begin()).absoluteDir().absolutePath(); lastDir = QFileInfo(*files.begin()).absoluteDir().absolutePath();
Settings->setLastDir(type, lastDir); Settings->setLastDir(type, lastDir);
}
return !files.isEmpty(); #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) 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); file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter);
if (file.isEmpty() == false) { if (file.isEmpty())
return false;
lastDir = QFileInfo(file).absoluteDir().absolutePath(); lastDir = QFileInfo(file).absoluteDir().absolutePath();
Settings->setLastDir(type, lastDir); Settings->setLastDir(type, lastDir);
}
return !file.isEmpty(); return true;
} }