Support canceling file transfer from pseudo job
Allows to click cancel on the job popup rather than only from within NeoChat.
This commit is contained in:
@@ -12,6 +12,7 @@ FileTransferPseudoJob::FileTransferPseudoJob(Operation operation, const QString
|
|||||||
, m_eventId(eventId)
|
, m_eventId(eventId)
|
||||||
, m_operation(operation)
|
, m_operation(operation)
|
||||||
{
|
{
|
||||||
|
setCapabilities(KJob::Killable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTransferPseudoJob::fileTransferProgress(const QString &id, qint64 progress, qint64 total)
|
void FileTransferPseudoJob::fileTransferProgress(const QString &id, qint64 progress, qint64 total)
|
||||||
@@ -58,3 +59,9 @@ void FileTransferPseudoJob::start()
|
|||||||
{i18nc("The URL being downloaded/uploaded", "Source"), m_path},
|
{i18nc("The URL being downloaded/uploaded", "Source"), m_path},
|
||||||
{i18nc("The location being downloaded to", "Destination"), m_path});
|
{i18nc("The location being downloaded to", "Destination"), m_path});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileTransferPseudoJob::doKill()
|
||||||
|
{
|
||||||
|
Q_EMIT cancelRequested(m_eventId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
class FileTransferPseudoJob : public KJob
|
class FileTransferPseudoJob : public KJob
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Operation {
|
enum Operation {
|
||||||
Download,
|
Download,
|
||||||
@@ -48,6 +49,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void start() override;
|
void start() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool doKill() override;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void cancelRequested(const QString &id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_path;
|
QString m_path;
|
||||||
QString m_eventId;
|
QString m_eventId;
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
|||||||
job->fileTransferFailed(txnId);
|
job->fileTransferFailed(txnId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(job, &FileTransferPseudoJob::cancelRequested, this, &Room::cancelFileTransfer);
|
||||||
KIO::getJobTracker()->registerJob(job);
|
KIO::getJobTracker()->registerJob(job);
|
||||||
job->start();
|
job->start();
|
||||||
#endif
|
#endif
|
||||||
@@ -1526,6 +1527,7 @@ void NeoChatRoom::download(const QString &eventId, const QUrl &localFilename)
|
|||||||
job->fileTransferFailed(eventId);
|
job->fileTransferFailed(eventId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
connect(job, &FileTransferPseudoJob::cancelRequested, this, &Room::cancelFileTransfer);
|
||||||
KIO::getJobTracker()->registerJob(job);
|
KIO::getJobTracker()->registerJob(job);
|
||||||
job->start();
|
job->start();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user