code style
[quassel.git] / src / qtui / snorenotificationbackend.h
1 /***************************************************************************
2 *   Copyright (C) 2011-2013 by Patrick von Reth                           *
3 *   vonreth@kde.org                                                       *
4 *                                                                         *
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.                                           *
9 *                                                                         *
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.                          *
14 *                                                                         *
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 ***************************************************************************/
20
21 #ifndef SNORENOTIFICATIONBACKEND_H_
22 #define SNORENOTIFICATIONBACKEND_H_
23
24 #include "abstractnotificationbackend.h"
25
26 #include "settingspage.h"
27
28 #include "ui_snorentificationconfigwidget.h"
29
30 namespace Snore{
31 class SnoreCore;
32 class Icon;
33 }
34 class SystrayNotificationBackend;
35
36 #include <snore/core/notification/notification.h>
37
38 class SnoreNotificationBackend : public AbstractNotificationBackend {
39     Q_OBJECT
40 public:
41     SnoreNotificationBackend (QObject *parent);
42     ~SnoreNotificationBackend();
43
44     void notify(const Notification &);
45     void close(uint notificationId);
46
47     virtual SettingsPage *createConfigWidget()const;
48
49 signals:
50     void activated(uint notificationId = 0);
51
52 public slots:
53     void actionInvoked(Snore::Notification);
54 private slots:
55     void backendChanged(const QVariant &);
56     void timeoutChanged(const QVariant &);
57
58 private:
59     void setTraybackend();
60     bool setSnoreBackend(const QString &backend);
61
62     class ConfigWidget;
63     SystrayNotificationBackend * m_systrayBackend;
64     Snore::SnoreCore *m_snore;
65     QHash<uint, uint> m_notificationIds;
66     Snore::Icon m_icon;
67     int m_timeout;
68 };
69
70 class SnoreNotificationBackend::ConfigWidget : public SettingsPage {
71     Q_OBJECT
72
73 public:
74     ConfigWidget(Snore::SnoreCore *snore, QWidget *parent = 0);
75     void save();
76     void load();
77     bool hasDefaults() const;
78     void defaults();
79
80 private slots:
81     void backendChanged(const QString&);
82     void timeoutChanged(int);
83
84 private:
85     Ui::SnoreNotificationConfigWidget ui;
86     Snore::SnoreCore *m_snore;
87
88     //  QSpinBox *timeoutBox;
89
90     //  bool enabled;
91     //  int timeout;
92 };
93
94 #endif