Commit 403b7348 authored by Xuetian Weng's avatar Xuetian Weng

notifications: Correctly display the file in jobs

Summary:
For url with parameter like audiocd:/1.wav?device=/dev/sr0, the filename
displayed in notifications applet is not correct ("sr0") instead of 1.wav.
This commit try to remove the query string before extract the last path
component.

Test Plan: Manually with audiocd-kio

Reviewers: mart, davidedmundson

Reviewed By: davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D4879
parent 3f5f9d09
......@@ -37,6 +37,7 @@ Column {
readonly property string infoMessage: getData(jobsSource.data, "infoMessage", '')
readonly property string labelName0: getData(jobsSource.data, "labelName0", '')
readonly property string labelName1: getData(jobsSource.data, "labelName1", '')
readonly property string labelFileName0: getData(jobsSource.data, "labelFileName0", '')
readonly property string label0: getData(jobsSource.data, "label0", '')
readonly property string label1: getData(jobsSource.data, "label1", '')
readonly property bool isSuspended: getData(jobsSource.data, "state", '') === "suspended"
......@@ -65,7 +66,7 @@ Column {
Layout.fillWidth: true
elide: Text.ElideMiddle
text: {
var label = label0;
var label = labelFileName0;
var lastSlashIdx = label.lastIndexOf("/");
return label.slice(lastSlashIdx + 1);
}
......
......@@ -22,6 +22,7 @@
#include "jobcontrol.h"
#include <QDBusConnection>
#include <QUrl>
#include <KJob>
#include <KFormat>
......@@ -256,10 +257,13 @@ bool JobView::setDescriptionField(uint number, const QString &name, const QStrin
{
const QString labelString = QStringLiteral("label%1").arg(number);
const QString labelNameString = QStringLiteral("labelName%1").arg(number);
const QString labelFileNameString = QStringLiteral("labelFileName%1").arg(number);
if (!data().contains(labelNameString) || data().value(labelString) != value) {
setData(labelNameString, name);
setData(labelString, value);
QUrl url = QUrl::fromUserInput(value, QString(), QUrl::AssumeLocalFile);
setData(labelFileNameString, url.toString(QUrl::PreferLocalFile | QUrl::RemoveFragment | QUrl::RemoveQuery));
scheduleUpdate();
}
return true;
......@@ -269,9 +273,11 @@ void JobView::clearDescriptionField(uint number)
{
const QString labelString = QStringLiteral("label%1").arg(number);
const QString labelNameString = QStringLiteral("labelName%1").arg(number);
const QString labelFileNameString = QStringLiteral("labelFileName%1").arg(number);
setData(labelNameString, QVariant());
setData(labelString, QVariant());
setData(labelFileNameString, QVariant());
scheduleUpdate();
}
......
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