X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsystrayanimationnotificationbackend.cpp;h=086dd2ef41ae00ad7ec5caa6d7cea15e341a8ed6;hp=2cb05507d77c260375a8d531dd3b4ec10097c641;hb=cc6e7c08709c4e761e2fd9c2e322751015497003;hpb=ba8a7d67ff9815f480531acab4a16cfa133929a5 diff --git a/src/qtui/systrayanimationnotificationbackend.cpp b/src/qtui/systrayanimationnotificationbackend.cpp index 2cb05507..086dd2ef 100644 --- a/src/qtui/systrayanimationnotificationbackend.cpp +++ b/src/qtui/systrayanimationnotificationbackend.cpp @@ -18,52 +18,97 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include -#include -#include -#include -#include - #include "systrayanimationnotificationbackend.h" -#include "client.h" #include "clientsettings.h" +#include "icon.h" #include "mainwin.h" -#include "networkmodel.h" #include "qtui.h" #include "systemtray.h" -SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject *parent) +SystrayAnimationNotificationBackend::SystrayAnimationNotificationBackend(QObject* parent) : AbstractNotificationBackend(parent) { NotificationSettings notificationSettings; - notificationSettings.initAndNotify("Systray/Animate", this, SLOT(animateChanged(QVariant)), true); + notificationSettings.initAndNotify("Systray/Alert", this, &SystrayAnimationNotificationBackend::alertChanged, true); } - -void SystrayAnimationNotificationBackend::notify(const Notification &n) +void SystrayAnimationNotificationBackend::notify(const Notification& n) { if (n.type != Highlight && n.type != PrivMsg) return; - if (_animate) + if (_alert) QtUi::mainWindow()->systemTray()->setAlert(true); } - void SystrayAnimationNotificationBackend::close(uint notificationId) { + Q_UNUSED(notificationId) QtUi::mainWindow()->systemTray()->setAlert(false); } +void SystrayAnimationNotificationBackend::alertChanged(const QVariant& v) +{ + _alert = v.toBool(); +} -void SystrayAnimationNotificationBackend::animateChanged(const QVariant &v) +SettingsPage* SystrayAnimationNotificationBackend::createConfigWidget() const { - _animate = v.toBool(); + return new ConfigWidget(); } +/***************************************************************************/ + +SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget* parent) + : SettingsPage("Internal", "SystrayAnimation", parent) +{ + ui.setupUi(this); + ui.enableAlert->setIcon(icon::get("dialog-information")); + + ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked()); + + initAutoWidgets(); +} -SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const +QString SystrayAnimationNotificationBackend::ConfigWidget::settingsKey() const { - return nullptr; -} \ No newline at end of file + return "Notification"; +} + +QVariant SystrayAnimationNotificationBackend::ConfigWidget::loadAutoWidgetValue(const QString& widgetName) +{ + if (widgetName == "attentionBehavior") { + NotificationSettings s; + if (s.value("Systray/Animate", false).toBool()) { + return 2; + } + if (s.value("Systray/ChangeColor", true).toBool()) { + return 1; + } + return 0; + } + + return SettingsPage::loadAutoWidgetValue(widgetName); +} + +void SystrayAnimationNotificationBackend::ConfigWidget::saveAutoWidgetValue(const QString& widgetName, const QVariant& value) +{ + if (widgetName == "attentionBehavior") { + NotificationSettings s; + s.setValue("Systray/ChangeColor", false); + s.setValue("Systray/Animate", false); + switch (value.toInt()) { + case 1: + s.setValue("Systray/ChangeColor", true); + return; + case 2: + s.setValue("Systray/Animate", true); + return; + default: + return; + } + } + + SettingsPage::saveAutoWidgetValue(widgetName, value); +}