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 "systrayanimationnotificationbackend.h"
23 #include "clientsettings.h"
27 #include "systemtray.h"
29 SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject *parent)
30 : AbstractNotificationBackend(parent)
32 NotificationSettings notificationSettings;
33 notificationSettings.initAndNotify("Systray/Alert", this, SLOT(alertChanged(QVariant)), true);
37 void SystrayAnimationNotificationBackend::notify(const Notification &n)
39 if (n.type != Highlight && n.type != PrivMsg)
43 QtUi::mainWindow()->systemTray()->setAlert(true);
47 void SystrayAnimationNotificationBackend::close(uint notificationId)
49 Q_UNUSED(notificationId)
50 QtUi::mainWindow()->systemTray()->setAlert(false);
54 void SystrayAnimationNotificationBackend::alertChanged(const QVariant &v)
60 SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
62 return new ConfigWidget();
66 /***************************************************************************/
68 SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayAnimation", parent)
71 ui.enableAlert->setIcon(icon::get("dialog-information"));
73 ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked());
79 QString SystrayAnimationNotificationBackend::ConfigWidget::settingsKey() const
81 return "Notification";
85 QVariant SystrayAnimationNotificationBackend::ConfigWidget::loadAutoWidgetValue(const QString &widgetName)
87 if (widgetName == "attentionBehavior") {
88 NotificationSettings s;
89 if (s.value("Systray/Animate", false).toBool()) {
92 if (s.value("Systray/ChangeColor", true).toBool()) {
98 return SettingsPage::loadAutoWidgetValue(widgetName);
102 void SystrayAnimationNotificationBackend::ConfigWidget::saveAutoWidgetValue(const QString &widgetName, const QVariant &value)
104 if (widgetName == "attentionBehavior") {
105 NotificationSettings s;
106 s.setValue("Systray/ChangeColor", false);
107 s.setValue("Systray/Animate", false);
108 switch (value.toInt()) {
110 s.setValue("Systray/ChangeColor", true);
113 s.setValue("Systray/Animate", true);
120 SettingsPage::saveAutoWidgetValue(widgetName, value);