From daa6f7fc1423119eda7f38310746f1051e7137c8 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sun, 31 Jan 2021 22:22:36 +0100 Subject: [PATCH] Clean up FileTransferJob description * Set magic `destUrl` property to let it know the job destination in case of multiple files being transferred * Set a normal "Receiving File(s)" title like we do with "Copying" title * Set device name and destination path as details --- core/compositefiletransferjob.cpp | 27 ++++++--------------------- core/compositefiletransferjob.h | 2 -- plugins/share/shareplugin.cpp | 1 + 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/core/compositefiletransferjob.cpp b/core/compositefiletransferjob.cpp index 5dfacf7ca..9a921e1b0 100644 --- a/core/compositefiletransferjob.cpp +++ b/core/compositefiletransferjob.cpp @@ -41,7 +41,12 @@ void CompositeFileTransferJob::startNextSubJob() { m_currentJob = qobject_cast(subjobs().at(0)); m_currentJobSendPayloadSize = 0; - emitDescription(m_currentJob->destination().toString()); + + Q_EMIT description(this, i18ncp("@title job", "Receiving file", "Receiving files", m_totalJobs), + {i18nc("The source of a file operation", "Source"), Daemon::instance()->getDevice(this->m_deviceId)->name()}, + {i18nc("The destination of a file operation", "Destination"), m_currentJob->destination().toDisplayString(QUrl::PreferLocalFile)} + ); + m_currentJob->start(); #ifdef SAILFISHOS connect(m_currentJob, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong)), this, SLOT(slotProcessedAmount(KJob*,KJob::Unit,qulonglong))); @@ -66,9 +71,6 @@ bool CompositeFileTransferJob::addSubjob(KJob* job) setTotalAmount(Files, m_totalJobs); } - QString filename = np->get(QStringLiteral("filename")); - emitDescription(filename); - if (!hasSubjobs()) { QMetaObject::invokeMethod(this, "startNextSubJob", Qt::QueuedConnection); } @@ -130,20 +132,3 @@ void CompositeFileTransferJob::slotResult(KJob *job) } } -void CompositeFileTransferJob::emitDescription(const QString& currentFileName) -{ - QPair field2; - - const QUrl fileUrl(currentFileName); - const QString fileName = fileUrl.toDisplayString(QUrl::PreferLocalFile); - - if (m_totalJobs > 1) { - field2.first = i18n("Progress"); - field2.second = i18n("Receiving file %1 of %2", m_currentJobNum, m_totalJobs); - } - - Q_EMIT description(this, i18np("Receiving file from %2", "Receiving %1 files from %2", m_totalJobs, Daemon::instance()->getDevice(this->m_deviceId)->name()), - { i18n("File"), fileName }, field2 - ); -} - diff --git a/core/compositefiletransferjob.h b/core/compositefiletransferjob.h index 60e03ec0c..5e185b88b 100644 --- a/core/compositefiletransferjob.h +++ b/core/compositefiletransferjob.h @@ -34,8 +34,6 @@ private Q_SLOTS: void startNextSubJob(); private: - void emitDescription(const QString& currentFileName); - QString m_deviceId; bool m_running; int m_currentJobNum; diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index ff922d648..0b45561a4 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -112,6 +112,7 @@ bool SharePlugin::receivePacket(const NetworkPacket& np) if (!m_compositeJob) { m_compositeJob = new CompositeFileTransferJob(device()->id()); + m_compositeJob->setProperty("destUrl", destinationDir().toString()); KIO::getJobTracker()->registerJob(m_compositeJob); }