Applets
notification.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 * notification.cpp * 00003 * * 00004 * Copyright (C) 2008 Jason Stubbs <jasonbstubbs@gmail.com> * 00005 * * 00006 * This program is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 2 of the License, or * 00009 * (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 00020 ***************************************************************************/ 00021 00022 #include "notification.h" 00023 00024 #include <QtCore/QTimer> 00025 00026 #include <KDebug> 00027 00028 00029 namespace SystemTray 00030 { 00031 00032 00033 class Notification::Private 00034 { 00035 public: 00036 Private() 00037 : timeout(0) 00038 { 00039 } 00040 00041 QString applicationName; 00042 QIcon applicationIcon; 00043 QString eventId; 00044 QString message; 00045 QString summary; 00046 int timeout; 00047 00048 QHash<QString, QString> actions; 00049 QStringList actionOrder; 00050 }; 00051 00052 00053 Notification::Notification(QObject *parent) 00054 : QObject(parent), 00055 d(new Private) 00056 { 00057 } 00058 00059 00060 Notification::~Notification() 00061 { 00062 emit destroyed(this); 00063 delete d; 00064 } 00065 00066 00067 QString Notification::applicationName() const 00068 { 00069 return d->applicationName; 00070 } 00071 00072 00073 void Notification::setApplicationName(const QString &applicationName) 00074 { 00075 d->applicationName = applicationName; 00076 } 00077 00078 00079 QIcon Notification::applicationIcon() const 00080 { 00081 return d->applicationIcon; 00082 } 00083 00084 00085 void Notification::setApplicationIcon(const QIcon &applicationIcon) 00086 { 00087 d->applicationIcon = applicationIcon; 00088 } 00089 00090 00091 QString Notification::eventId() const 00092 { 00093 return d->eventId; 00094 } 00095 00096 00097 void Notification::setEventId(const QString &eventId) 00098 { 00099 d->eventId = eventId; 00100 } 00101 00102 00103 QString Notification::message() const 00104 { 00105 return d->message; 00106 } 00107 00108 00109 void Notification::setMessage(const QString &message) 00110 { 00111 d->message = message; 00112 } 00113 00114 00115 QString Notification::summary() const 00116 { 00117 return d->summary; 00118 } 00119 00120 00121 void Notification::setSummary(const QString &summary) 00122 { 00123 d->summary = summary; 00124 } 00125 00126 00127 int Notification::timeout() const 00128 { 00129 return d->timeout; 00130 } 00131 00132 00133 void Notification::setTimeout(int timeout) 00134 { 00135 d->timeout = timeout; 00136 if (timeout) { 00137 QTimer::singleShot(timeout, this, SLOT(deleteLater())); 00138 } 00139 } 00140 00141 00142 QHash<QString, QString> Notification::actions() const 00143 { 00144 return d->actions; 00145 } 00146 00147 00148 void Notification::setActions(const QHash<QString, QString> &actions) 00149 { 00150 d->actions = actions; 00151 } 00152 00153 00154 QStringList Notification::actionOrder() const 00155 { 00156 return d->actionOrder; 00157 } 00158 00159 00160 void Notification::setActionOrder(const QStringList &actionOrder) 00161 { 00162 d->actionOrder = actionOrder; 00163 } 00164 00165 00166 void Notification::triggerAction(const QString &actionId) 00167 { 00168 Q_UNUSED(actionId); 00169 kDebug() << "action triggered but no handler implemented"; 00170 } 00171 00172 00173 } 00174 00175 00176 #include "notification.moc"