1
/***************************************************************************
2
* completedjobnotification.h *
3
* Copyright (C) 2010 Marco Martin <notmart@gmail.com> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19
***************************************************************************/
21
#include "completedjobnotification.h"
31
static const int completedJobExpireDelay = 60 * 1000;
32
static const int completedShortJobExpireDelay = 8 * 1000;
33
static const uint shortJobsLength = 30 * 1000;
35
CompletedJobNotification::CompletedJobNotification(QObject *parent)
36
: Notification(parent)
40
CompletedJobNotification::~CompletedJobNotification()
44
void CompletedJobNotification::setJob(Job *job)
46
setApplicationName(job->applicationName());
47
setApplicationIcon(KIcon(job->applicationIconName()));
48
setSummary(i18n("%1 [Finished]", job->message()));
50
if (job->error().isEmpty()) {
51
setMessage(job->completedMessage());
53
setMessage(job->error());
56
if (job->elapsed() < shortJobsLength) {
57
setTimeout(completedShortJobExpireDelay);
59
setTimeout(completedJobExpireDelay);
62
if (job->destination().isValid()) {
63
QHash<QString, QString> actions;
64
actions.insert("open", i18n("Open"));
66
setActionOrder(QStringList()<<"open");
67
m_destinationPrettyUrl = job->destination().prettyUrl();
73
void CompletedJobNotification::linkActivated(const QString &url)
75
kDebug() << "open " << url;
76
QProcess::startDetached("kde-open", QStringList() << url);
79
Job *CompletedJobNotification::job() const
84
void CompletedJobNotification::triggerAction(const QString &actionId)
86
if (actionId == "open" && !m_destinationPrettyUrl.isNull()) {
87
linkActivated(m_destinationPrettyUrl);
92
#include "completedjobnotification.moc"