Commit daa6f7fc authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

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
parent ae6ab696
Pipeline #49265 passed with stage
in 5 minutes and 37 seconds
...@@ -41,7 +41,12 @@ void CompositeFileTransferJob::startNextSubJob() ...@@ -41,7 +41,12 @@ void CompositeFileTransferJob::startNextSubJob()
{ {
m_currentJob = qobject_cast<FileTransferJob*>(subjobs().at(0)); m_currentJob = qobject_cast<FileTransferJob*>(subjobs().at(0));
m_currentJobSendPayloadSize = 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(); m_currentJob->start();
#ifdef SAILFISHOS #ifdef SAILFISHOS
connect(m_currentJob, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong)), this, SLOT(slotProcessedAmount(KJob*,KJob::Unit,qulonglong))); 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) ...@@ -66,9 +71,6 @@ bool CompositeFileTransferJob::addSubjob(KJob* job)
setTotalAmount(Files, m_totalJobs); setTotalAmount(Files, m_totalJobs);
} }
QString filename = np->get<QString>(QStringLiteral("filename"));
emitDescription(filename);
if (!hasSubjobs()) { if (!hasSubjobs()) {
QMetaObject::invokeMethod(this, "startNextSubJob", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "startNextSubJob", Qt::QueuedConnection);
} }
...@@ -130,20 +132,3 @@ void CompositeFileTransferJob::slotResult(KJob *job) ...@@ -130,20 +132,3 @@ void CompositeFileTransferJob::slotResult(KJob *job)
} }
} }
void CompositeFileTransferJob::emitDescription(const QString& currentFileName)
{
QPair<QString, QString> 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
);
}
...@@ -34,8 +34,6 @@ private Q_SLOTS: ...@@ -34,8 +34,6 @@ private Q_SLOTS:
void startNextSubJob(); void startNextSubJob();
private: private:
void emitDescription(const QString& currentFileName);
QString m_deviceId; QString m_deviceId;
bool m_running; bool m_running;
int m_currentJobNum; int m_currentJobNum;
......
...@@ -112,6 +112,7 @@ bool SharePlugin::receivePacket(const NetworkPacket& np) ...@@ -112,6 +112,7 @@ bool SharePlugin::receivePacket(const NetworkPacket& np)
if (!m_compositeJob) { if (!m_compositeJob) {
m_compositeJob = new CompositeFileTransferJob(device()->id()); m_compositeJob = new CompositeFileTransferJob(device()->id());
m_compositeJob->setProperty("destUrl", destinationDir().toString());
KIO::getJobTracker()->registerJob(m_compositeJob); KIO::getJobTracker()->registerJob(m_compositeJob);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment