1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
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) version 3. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include <QVBoxLayout>
23 #include <KNotification>
24 #include <KNotifyConfigWidget>
26 #include "knotificationbackend.h"
30 #include "iconloader.h"
31 #include "networkmodel.h"
33 #include "systemtray.h"
35 KNotificationBackend::KNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
39 void KNotificationBackend::notify(const Notification &n) {
40 //QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId);
41 QString message = QString("<b><%1></b> %2").arg(n.sender, n.message);
42 KNotification *notification = KNotification::event("Highlight", message, DesktopIcon("dialog-information"), QtUi::mainWindow(),
43 KNotification::Persistent|KNotification::RaiseWidgetOnActivation|KNotification::CloseWhenWidgetActivated);
44 connect(notification, SIGNAL(activated()), SLOT(notificationActivated()));
45 QtUi::mainWindow()->systemTray()->setAlert(true);
48 void KNotificationBackend::close(uint notificationId) {
49 Q_UNUSED(notificationId);
50 QtUi::mainWindow()->systemTray()->setAlert(false);
53 void KNotificationBackend::notificationActivated() {
57 SettingsPage *KNotificationBackend::createConfigWidget() const {
58 return new ConfigWidget();
61 /***************************************************************************/
63 KNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "KNotification", parent) {
64 _widget = new KNotifyConfigWidget(this);
65 _widget->setApplication("quassel");
67 QVBoxLayout *layout = new QVBoxLayout(this);
68 layout->addWidget(_widget);
70 connect(_widget, SIGNAL(changed(bool)), SLOT(widgetChanged(bool)));
73 void KNotificationBackend::ConfigWidget::widgetChanged(bool changed) {
74 setChangedState(changed);
77 void KNotificationBackend::ConfigWidget::load() {
78 setChangedState(false);
81 void KNotificationBackend::ConfigWidget::save() {