Split systray notification backend
[quassel.git] / src / qtui / systrayanimationnotificationbackend.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2016 by the Quassel Project                        *
3  *   devel@quassel-irc.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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include <QApplication>
22 #include <QCheckBox>
23 #include <QGroupBox>
24 #include <QIcon>
25 #include <QHBoxLayout>
26
27 #include "systrayanimationnotificationbackend.h"
28
29 #include "client.h"
30 #include "clientsettings.h"
31 #include "mainwin.h"
32 #include "networkmodel.h"
33 #include "qtui.h"
34 #include "systemtray.h"
35
36 SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject *parent)
37     : AbstractNotificationBackend(parent)
38 {
39     NotificationSettings notificationSettings;
40     notificationSettings.initAndNotify("Systray/Animate", this, SLOT(animateChanged(QVariant)), true);
41 }
42
43
44 void SystrayAnimationNotificationBackend::notify(const Notification &n)
45 {
46     if (n.type != Highlight && n.type != PrivMsg)
47         return;
48
49     if (_animate)
50         QtUi::mainWindow()->systemTray()->setAlert(true);
51 }
52
53
54 void SystrayAnimationNotificationBackend::close(uint notificationId)
55 {
56     QtUi::mainWindow()->systemTray()->setAlert(false);
57 }
58
59
60 void SystrayAnimationNotificationBackend::animateChanged(const QVariant &v)
61 {
62     _animate = v.toBool();
63 }
64
65
66 SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
67 {
68     return nullptr;
69 }