Ref T489, overlay message support for download progress

This commit is contained in:
Klaus Basan
2018-12-28 00:59:17 +01:00
committed by Mat Sutcliffe
parent d71e5f289a
commit fefeeac33b
3 changed files with 46 additions and 2 deletions

View File

@@ -333,6 +333,13 @@ namespace BlackGui
{
if (message.isEmpty()) { return; }
if (!sGui || sGui->isShuttingDown()) { return; }
this->showHTMLMessage(message.toHtml(true, true), timeOutMs);
}
void COverlayMessages::showHTMLMessage(const QString &htmlMessage, int timeOutMs)
{
if (htmlMessage.isEmpty()) { return; }
if (!sGui || sGui->isShuttingDown()) { return; }
if (this->hasPendingConfirmation())
{
@@ -341,16 +348,30 @@ namespace BlackGui
m_pendingMessageCalls.push_back([ = ]()
{
if (!myself) { return; }
myself->showHTMLMessage(message, timeOutMs);
myself->showHTMLMessage(htmlMessage, timeOutMs);
});
return;
}
this->setModeToHTMLMessage();
ui->te_HTMLMessage->setText(message.toHtml(true, true));
ui->te_HTMLMessage->setText(htmlMessage);
this->display(timeOutMs);
}
void COverlayMessages::showDownloadProgress(int progress, qint64 current, qint64 max, const QUrl &url, int timeOutMs)
{
if (progress >= 0 && max >= 0)
{
static const QString m("%1 of %2 from %3");
this->showProgressBar(progress, m.arg(current).arg(max).arg(url.toString()), timeOutMs);
}
else
{
static const QString m("%1 from %2");
this->showHTMLMessage(m.arg(current).arg(url.toString()), timeOutMs);
}
}
void COverlayMessages::showProgressBar(int percentage, const QString &message, int timeOutMs)
{
if (message.isEmpty()) { return; }