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))
|
||||
);
|
||||
QUrl destCheck = mDestination;
|
||||
if (QFile::exists(destCheck.path())) {
|
||||
QFileInfo destInfo(destCheck.path());
|
||||
if (QFile::exists(destCheck.toLocalFile())) {
|
||||
QFileInfo destInfo(destCheck.toLocalFile());
|
||||
KIO::RenameDialog *dialog = new KIO::RenameDialog(Q_NULLPTR,
|
||||
i18n("Incoming file exists"),
|
||||
QUrl(mDeviceName + ":/" + destCheck.fileName()),
|
||||
|
@ -102,7 +102,7 @@ void FileTransferJob::renameDone(int result)
|
|||
case KIO::R_OVERWRITE:
|
||||
{
|
||||
// Delete the old file if exists
|
||||
QFile oldFile(mDestination.path());
|
||||
QFile oldFile(mDestination.toLocalFile());
|
||||
if (oldFile.exists()) {
|
||||
oldFile.remove();
|
||||
}
|
||||
|
@ -125,10 +125,10 @@ void FileTransferJob::startTransfer()
|
|||
description(this, i18n("Receiving file over KDE-Connect"),
|
||||
QPair<QString, QString>(i18nc("File transfer origin", "From"),
|
||||
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);
|
||||
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(result(KJob*)), this, SLOT(openFinished(KJob*)));
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ QUrl SharePlugin::destinationDir() const
|
|||
const QString downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
QUrl dir = QUrl::fromLocalFile(config->group("receive").readEntry("path", downloadPath));
|
||||
|
||||
if (!dir.path().endsWith('/')) {
|
||||
dir.setPath(dir.path() + '/');
|
||||
if (!dir.toLocalFile().endsWith('/')) {
|
||||
dir.setPath(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()));
|
||||
QUrl destination = destinationDir();
|
||||
destination = destination.adjusted(QUrl::StripTrailingSlash);
|
||||
destination.setPath(destination.path() + '/' + filename);
|
||||
destination.setPath(destination.toLocalFile() + '/' + filename);
|
||||
FileTransferJob* job = np.createPayloadTransferJob(destination);
|
||||
job->setDeviceName(device()->name());
|
||||
connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
|
||||
|
|
Loading…
Reference in a new issue