QFileDialog: make QFileDialog::selectFile resolve remote dirs correctly
The code was assuming local files, and broke with remote dirs. Testcase: `kwrite sftp://localhost/tmp/file.txt` and then Ctrl+O, the initial directory was $PWD instead of the remote dir. Change-Id: Ie24d4c1b2b3278dce44274af0066105bd1bf9b34 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
9be1256e0c
commit
5a1861399b
@ -1047,10 +1047,15 @@ void QFileDialog::selectFile(const QString &filename)
|
||||
return;
|
||||
|
||||
if (!d->usingWidgets()) {
|
||||
QUrl url = QUrl::fromLocalFile(filename);
|
||||
QUrl url;
|
||||
if (QFileInfo(filename).isRelative()) {
|
||||
QDir dir(d->options->initialDirectory().toLocalFile());
|
||||
url = QUrl::fromLocalFile(dir.absoluteFilePath(filename));
|
||||
url = d->options->initialDirectory();
|
||||
QString path = url.path();
|
||||
if (!path.endsWith(QLatin1Char('/')))
|
||||
path += QLatin1Char('/');
|
||||
url.setPath(path + filename);
|
||||
} else {
|
||||
url = QUrl::fromLocalFile(filename);
|
||||
}
|
||||
d->selectFile_sys(url);
|
||||
d->options->setInitiallySelectedFiles(QList<QUrl>() << url);
|
||||
|
Loading…
Reference in New Issue
Block a user