Prefer the usage of QUrl::toLocalFile to QUrl::path
QUrl::toLocalFile is portable.
This commit is contained in:
parent
463aa0cbf9
commit
b06038e60e
2 changed files with 8 additions and 8 deletions
|
@ -66,8 +66,8 @@ void FileTransferJob::doStart()
|
||||||
QString(mDeviceName))
|
QString(mDeviceName))
|
||||||
);
|
);
|
||||||
QUrl destCheck = mDestination;
|
QUrl destCheck = mDestination;
|
||||||
if (QFile::exists(destCheck.path())) {
|
if (QFile::exists(destCheck.toLocalFile())) {
|
||||||
QFileInfo destInfo(destCheck.path());
|
QFileInfo destInfo(destCheck.toLocalFile());
|
||||||
KIO::RenameDialog *dialog = new KIO::RenameDialog(Q_NULLPTR,
|
KIO::RenameDialog *dialog = new KIO::RenameDialog(Q_NULLPTR,
|
||||||
i18n("Incoming file exists"),
|
i18n("Incoming file exists"),
|
||||||
QUrl(mDeviceName + ":/" + destCheck.fileName()),
|
QUrl(mDeviceName + ":/" + destCheck.fileName()),
|
||||||
|
@ -102,7 +102,7 @@ void FileTransferJob::renameDone(int result)
|
||||||
case KIO::R_OVERWRITE:
|
case KIO::R_OVERWRITE:
|
||||||
{
|
{
|
||||||
// Delete the old file if exists
|
// Delete the old file if exists
|
||||||
QFile oldFile(mDestination.path());
|
QFile oldFile(mDestination.toLocalFile());
|
||||||
if (oldFile.exists()) {
|
if (oldFile.exists()) {
|
||||||
oldFile.remove();
|
oldFile.remove();
|
||||||
}
|
}
|
||||||
|
@ -125,10 +125,10 @@ void FileTransferJob::startTransfer()
|
||||||
description(this, i18n("Receiving file over KDE-Connect"),
|
description(this, i18n("Receiving file over KDE-Connect"),
|
||||||
QPair<QString, QString>(i18nc("File transfer origin", "From"),
|
QPair<QString, QString>(i18nc("File transfer origin", "From"),
|
||||||
QString(mDeviceName)),
|
QString(mDeviceName)),
|
||||||
QPair<QString, QString>(i18nc("File transfer destination", "To"), mDestination.path()));
|
QPair<QString, QString>(i18nc("File transfer destination", "To"), mDestination.toLocalFile()));
|
||||||
|
|
||||||
mDestinationJob = KIO::open(mDestination, QIODevice::WriteOnly);
|
mDestinationJob = KIO::open(mDestination, QIODevice::WriteOnly);
|
||||||
QFile(mDestination.path()).open(QIODevice::WriteOnly | QIODevice::Truncate); //KIO won't create the file if it doesn't exist
|
QFile(mDestination.toLocalFile()).open(QIODevice::WriteOnly | QIODevice::Truncate); //KIO won't create the file if it doesn't exist
|
||||||
connect(mDestinationJob, SIGNAL(open(KIO::Job*)), this, SLOT(open(KIO::Job*)));
|
connect(mDestinationJob, SIGNAL(open(KIO::Job*)), this, SLOT(open(KIO::Job*)));
|
||||||
connect(mDestinationJob, SIGNAL(result(KJob*)), this, SLOT(openFinished(KJob*)));
|
connect(mDestinationJob, SIGNAL(result(KJob*)), this, SLOT(openFinished(KJob*)));
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ QUrl SharePlugin::destinationDir() const
|
||||||
const QString downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
const QString downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||||
QUrl dir = QUrl::fromLocalFile(config->group("receive").readEntry("path", downloadPath));
|
QUrl dir = QUrl::fromLocalFile(config->group("receive").readEntry("path", downloadPath));
|
||||||
|
|
||||||
if (!dir.path().endsWith('/')) {
|
if (!dir.toLocalFile().endsWith('/')) {
|
||||||
dir.setPath(dir.path() + '/');
|
dir.setPath(dir.toLocalFile() + '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
QString url = dir.toLocalFile();
|
QString url = dir.toLocalFile();
|
||||||
|
@ -99,7 +99,7 @@ bool SharePlugin::receivePackage(const NetworkPackage& np)
|
||||||
QString filename = np.get<QString>("filename", QString::number(QDateTime::currentMSecsSinceEpoch()));
|
QString filename = np.get<QString>("filename", QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||||
QUrl destination = destinationDir();
|
QUrl destination = destinationDir();
|
||||||
destination = destination.adjusted(QUrl::StripTrailingSlash);
|
destination = destination.adjusted(QUrl::StripTrailingSlash);
|
||||||
destination.setPath(destination.path() + '/' + filename);
|
destination.setPath(destination.toLocalFile() + '/' + filename);
|
||||||
FileTransferJob* job = np.createPayloadTransferJob(destination);
|
FileTransferJob* job = np.createPayloadTransferJob(destination);
|
||||||
job->setDeviceName(device()->name());
|
job->setDeviceName(device()->name());
|
||||||
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
|
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
|
||||||
|
|
Loading…
Reference in a new issue