Commit ed53dd42 authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Show a message on status bar if saving the blob takes less than 500ms

The job tracker doesn't show a notification if the job takes less than
500ms, so in that case give the user some feedback manually.
parent 995144c6
......@@ -739,6 +739,12 @@ void WebEnginePage::slotAuthenticationRequired(const QUrl &requestUrl, QAuthenti
}
}
void WebEnginePage::setStatusBarText(const QString& text)
{
if (m_part) {
emit m_part->setStatusBarText(text);
}
}
/************************************* Begin NewWindowPage ******************************************/
......
......@@ -66,6 +66,8 @@ public:
void requestOpenFileAsTemporary(const QUrl &url, const QString &mimeType = "", bool newWindow = false);
void setStatusBarText(const QString &text);
WebEngineWallet* wallet() const {return m_wallet;}
/**
......
......@@ -280,6 +280,7 @@ QString WebEngineBlobDownloadJob::errorString() const
void WebEngineBlobDownloadJob::startDownloading()
{
if (m_downloadItem) {
m_startTime = QDateTime::currentDateTime();
emit description(this, i18nc("Notification about downloading a file", "Downloading"),
QPair<QString, QString>(i18nc("Source of a file being downloaded", "Source"), m_downloadItem->url().toString()),
QPair<QString, QString>(i18nc("Destination of a file download", "Destination"), m_downloadItem->downloadFileName()));
......@@ -290,6 +291,14 @@ void WebEngineBlobDownloadJob::startDownloading()
void WebEngineBlobDownloadJob::downloadFinished()
{
emitResult();
QDateTime now = QDateTime::currentDateTime();
if (m_startTime.msecsTo(now) < 500) {
if (m_downloadItem && m_downloadItem->page()) {
WebEnginePage *page = qobject_cast<WebEnginePage*>(m_downloadItem->page());
QString filePath = QDir(m_downloadItem->downloadDirectory()).filePath(m_downloadItem->downloadFileName());
emit page->setStatusBarText(i18nc("Finished saving BLOB URL", "Finished saving %1 as %2", m_downloadItem->url().toString(), filePath));
}
}
delete m_downloadItem;
m_downloadItem = nullptr;
}
......@@ -26,6 +26,7 @@
#include <QVector>
#include <QWebEngineDownloadItem>
#include <QTemporaryDir>
#include <QDateTime>
#include <KJob>
......@@ -98,6 +99,7 @@ private slots:
private:
QWebEngineDownloadItem *m_downloadItem;
QDateTime m_startTime;
};
#endif // WEBENGINEPARTDOWNLOADMANAGER_H
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