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

[Notifications] Make job destination a clickable link

Provides a handy shortcut. Since notifications are already rich text imho
it's fine API-wise for job text to suddenly contain markup, too.
parent 5ba3ad8b
......@@ -78,14 +78,19 @@ QUrl JobPrivate::localFileOrUrl(const QString &urlString)
return url;
}
// Tries to return a more user-friendly displayed destination
QString JobPrivate::prettyDestUrl() const
QUrl JobPrivate::destUrl() const
{
QUrl url = m_destUrl;
// In case of a single file and no destUrl, try using the second label (most likely "Destination")...
if (!url.isValid() && m_totalFiles == 1) {
url = localFileOrUrl(m_descriptionValue2).adjusted(QUrl::RemoveFilename);
}
return url;
}
QString JobPrivate::prettyUrl(const QUrl &_url) const
{
QUrl url(_url);
if (!url.isValid()) {
return QString();
......@@ -159,7 +164,14 @@ QString JobPrivate::text() const
return m_infoMessage;
}
const QString destUrlString = prettyDestUrl();
const QUrl destUrl = this->destUrl();
const QString prettyDestUrl = prettyUrl(destUrl);
QString destUrlString;
if (!prettyDestUrl.isEmpty()) {
// Turn destination into a clickable hyperlink
destUrlString = QStringLiteral("<a href=\"%1\">%2</a>").arg(destUrl.toString(QUrl::PrettyDecoded), prettyDestUrl);
}
if (m_totalFiles == 0) {
if (!destUrlString.isEmpty()) {
......@@ -204,7 +216,7 @@ QString JobPrivate::text() const
qCInfo(NOTIFICATIONMANAGER) << "Failed to generate job text for job with following properties:";
qCInfo(NOTIFICATIONMANAGER) << " processedFiles =" << m_processedFiles << ", totalFiles =" << m_totalFiles << ", current file name =" << descriptionUrl().fileName()
<< ", destination url string =" << destUrlString;
<< ", destination url string =" << this->destUrl();
qCInfo(NOTIFICATIONMANAGER) << "label1 =" << m_descriptionLabel1 << ", value1 =" << m_descriptionValue1 << ", label2 =" << m_descriptionLabel2
<< ", value2 =" << m_descriptionValue2;
......
......@@ -109,7 +109,8 @@ private:
static QUrl localFileOrUrl(const QString &stringUrl);
QString prettyDestUrl() const;
QUrl destUrl() const;
QString prettyUrl(const QUrl &url) const;
void updateHasDetails();
void finish();
......
Supports Markdown
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