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; }

View File

@@ -119,6 +119,12 @@ namespace BlackGui
//! HTML message
void showHTMLMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1);
//! HTML message
void showHTMLMessage(const QString &htmlMessage, int timeOutMs = -1);
//! Download progress
void showDownloadProgress(int progress, qint64 current, qint64 max, const QUrl &url, int timeOutMs = -1);
//! Progress bar
void showProgressBar(int percentage, const QString &message, int timeOutMs = -1);

View File

@@ -27,6 +27,7 @@
#include <QMessageBox>
#include <QObject>
#include <QSize>
#include <QUrl>
#include <QString>
#include <functional>
@@ -163,6 +164,14 @@ namespace BlackGui
WIDGET::repaint();
}
//! \copydoc BlackGui::COverlayMessages::showHTMLMessage
void showOverlayHTMLMessage(const QString &htmlMessage, int timeOutMs = -1)
{
this->initMinimalFrame();
m_overlayMessages->showHTMLMessage(htmlMessage, timeOutMs);
WIDGET::repaint();
}
//! \copydoc BlackGui::COverlayMessages::showHTMLMessage
void showOverlayHTMLMessage(const BlackMisc::CStatusMessage &message, int timeOutMs = -1)
{
@@ -171,6 +180,14 @@ namespace BlackGui
WIDGET::repaint();
}
//! \copydoc BlackGui::COverlayMessages::showDownloadProgress
void showDownloadProgress(int progress, qint64 current, qint64 max, const QUrl &url, int timeOutMs = -1)
{
this->initMinimalFrame();
m_overlayMessages->showDownloadProgress(progress, current, max, url, timeOutMs);
WIDGET::repaint();
}
//! \copydoc BlackGui::COverlayMessages::showOverlayImage
void showOverlayInlineTextMessage(Components::TextMessageTab tab)
{