[Jobs] Support "transient" flag for job

This is for jobs, such as "Loading archive" or "Examining..."
which are purely informational and provide no meaningful
action once finished. When this property is set, a job will
not show a "Finished" notification when finished successfully.
wilder-5.24
Kai Uwe Broulik 4 years ago
parent 5b5e916371
commit 86597ad03b
  1. 10
      libnotificationmanager/job.cpp
  2. 3
      libnotificationmanager/job.h
  3. 4
      libnotificationmanager/job_p.cpp
  4. 1
      libnotificationmanager/job_p.h
  5. 4
      libnotificationmanager/jobsmodel_p.cpp

@ -159,6 +159,16 @@ void Job::setKillable(bool killable)
d->m_killable = killable;
}
bool Job::transient() const
{
return d->m_transient;
}
void Job::setTransient(bool transient)
{
d->m_transient = transient;
}
QUrl Job::destUrl() const
{
return d->m_destUrl;

@ -167,6 +167,9 @@ public:
// TODO remove and let only constructor do it?
void setKillable(bool killable);
bool transient() const;
void setTransient(bool transient);
QUrl destUrl() const;
qulonglong speed() const;

@ -264,8 +264,8 @@ void JobPrivate::finish()
// Unregister the dbus service since the client is done with it
QDBusConnection::sessionBus().unregisterObject(m_objectPath.path());
// When user canceled transfer, remove it without notice
if (m_error == KIO::ERR_USER_CANCELED) {
// When user canceled job or a transient job finished successfully, remove it without notice
if (m_error == KIO::ERR_USER_CANCELED || (!m_error && m_transient)) {
emit closed();
return;
}

@ -141,6 +141,7 @@ private:
QString m_errorText;
bool m_suspendable = false;
bool m_killable = false;
bool m_transient = false;
QUrl m_destUrl;

@ -312,6 +312,10 @@ QDBusObjectPath JobsModelPrivate::requestView(const QString &desktopEntry, int c
job->d->delayedShow(500ms, JobPrivate::ShowCondition::OnTimeout);
}
if (hints.value(QStringLiteral("transient")).toBool()) {
job->setTransient(true);
}
m_jobServices.insert(job, serviceName);
m_serviceWatcher->addWatchedService(serviceName);

Loading…
Cancel
Save