1 /***************************************************************************
2 * Copyright (C) 2005-2016 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include <QApplication>
25 #include <QHBoxLayout>
27 #include "systrayanimationnotificationbackend.h"
30 #include "clientsettings.h"
32 #include "networkmodel.h"
34 #include "systemtray.h"
36 SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject *parent)
37 : AbstractNotificationBackend(parent)
39 NotificationSettings notificationSettings;
40 notificationSettings.initAndNotify("Systray/Animate", this, SLOT(animateChanged(QVariant)), true);
44 void SystrayAnimationNotificationBackend::notify(const Notification &n)
46 if (n.type != Highlight && n.type != PrivMsg)
50 QtUi::mainWindow()->systemTray()->setAlert(true);
54 void SystrayAnimationNotificationBackend::close(uint notificationId)
56 QtUi::mainWindow()->systemTray()->setAlert(false);
60 void SystrayAnimationNotificationBackend::animateChanged(const QVariant &v)
62 _animate = v.toBool();
66 SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
68 return new ConfigWidget();
72 /***************************************************************************/
74 SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayNotification", parent)
76 _animateBox = new QCheckBox(tr("Animate system tray icon"));
77 _animateBox->setIcon(QIcon::fromTheme("dialog-information"));
78 connect(_animateBox, SIGNAL(toggled(bool)), this, SLOT(widgetChanged()));
79 QHBoxLayout *layout = new QHBoxLayout(this);
80 layout->addWidget(_animateBox);
84 void SystrayAnimationNotificationBackend::ConfigWidget::widgetChanged()
86 bool changed = (_animate != _animateBox->isChecked());
87 if (changed != hasChanged())
88 setChangedState(changed);
92 bool SystrayAnimationNotificationBackend::ConfigWidget::hasDefaults() const
98 void SystrayAnimationNotificationBackend::ConfigWidget::defaults()
100 _animateBox->setChecked(false);
105 void SystrayAnimationNotificationBackend::ConfigWidget::load()
107 NotificationSettings s;
108 _animate = s.value("Systray/Animate", true).toBool();
109 _animateBox->setChecked(_animate);
110 setChangedState(false);
114 void SystrayAnimationNotificationBackend::ConfigWidget::save()
116 NotificationSettings s;
117 s.setValue("Systray/Animate", _animateBox->isChecked());