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, &SystrayAnimationNotificationBackend::alertChanged, true);
36 void SystrayAnimationNotificationBackend::notify(const Notification& n)
38 if (n.type != Highlight && n.type != PrivMsg)
42 QtUi::mainWindow()->systemTray()->setAlert(true);
45 void SystrayAnimationNotificationBackend::close(uint notificationId)
47 Q_UNUSED(notificationId)
48 QtUi::mainWindow()->systemTray()->setAlert(false);
51 void SystrayAnimationNotificationBackend::alertChanged(const QVariant& v)
56 SettingsPage* SystrayAnimationNotificationBackend::createConfigWidget() const
58 return new ConfigWidget();
61 /***************************************************************************/
63 SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget* parent)
64 : SettingsPage("Internal", "SystrayAnimation", parent)
67 ui.enableAlert->setIcon(icon::get("dialog-information"));
69 ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked());
74 QString SystrayAnimationNotificationBackend::ConfigWidget::settingsKey() const
76 return "Notification";
79 QVariant SystrayAnimationNotificationBackend::ConfigWidget::loadAutoWidgetValue(const QString& widgetName)
81 if (widgetName == "attentionBehavior") {
82 NotificationSettings s;
83 if (s.value("Systray/Animate", false).toBool()) {
86 if (s.value("Systray/ChangeColor", true).toBool()) {
92 return SettingsPage::loadAutoWidgetValue(widgetName);
95 void SystrayAnimationNotificationBackend::ConfigWidget::saveAutoWidgetValue(const QString& widgetName, const QVariant& value)
97 if (widgetName == "attentionBehavior") {
98 NotificationSettings s;
99 s.setValue("Systray/ChangeColor", false);
100 s.setValue("Systray/Animate", false);
101 switch (value.toInt()) {
103 s.setValue("Systray/ChangeColor", true);
106 s.setValue("Systray/Animate", true);
113 SettingsPage::saveAutoWidgetValue(widgetName, value);