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 ***************************************************************************/
23 #include "systrayanimationnotificationbackend.h"
25 #include "clientsettings.h"
28 #include "systemtray.h"
30 SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject *parent)
31 : AbstractNotificationBackend(parent)
33 NotificationSettings notificationSettings;
34 notificationSettings.initAndNotify("Systray/Alert", this, SLOT(alertChanged(QVariant)), true);
38 void SystrayAnimationNotificationBackend::notify(const Notification &n)
40 if (n.type != Highlight && n.type != PrivMsg)
44 QtUi::mainWindow()->systemTray()->setAlert(true);
48 void SystrayAnimationNotificationBackend::close(uint notificationId)
50 Q_UNUSED(notificationId)
51 QtUi::mainWindow()->systemTray()->setAlert(false);
55 void SystrayAnimationNotificationBackend::alertChanged(const QVariant &v)
61 SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
63 return new ConfigWidget();
67 /***************************************************************************/
69 SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayAnimation", parent)
72 ui.enableAlert->setIcon(QIcon::fromTheme("dialog-information"));
74 ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked());
80 QString SystrayAnimationNotificationBackend::ConfigWidget::settingsKey() const
82 return "Notification";
86 QVariant SystrayAnimationNotificationBackend::ConfigWidget::loadAutoWidgetValue(const QString &widgetName)
88 if (widgetName == "attentionBehavior") {
89 NotificationSettings s;
90 if (s.value("Systray/Animate", false).toBool()) {
93 if (s.value("Systray/ChangeColor", true).toBool()) {
99 return SettingsPage::loadAutoWidgetValue(widgetName);
103 void SystrayAnimationNotificationBackend::ConfigWidget::saveAutoWidgetValue(const QString &widgetName, const QVariant &value)
105 if (widgetName == "attentionBehavior") {
106 NotificationSettings s;
107 s.setValue("Systray/ChangeColor", false);
108 s.setValue("Systray/Animate", false);
109 switch (value.toInt()) {
111 s.setValue("Systray/ChangeColor", true);
114 s.setValue("Systray/Animate", true);
121 SettingsPage::saveAutoWidgetValue(widgetName, value);