X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsystrayanimationnotificationbackend.cpp;h=086dd2ef41ae00ad7ec5caa6d7cea15e341a8ed6;hp=65cc38b543182a402fa2066a21362c9082e73f8e;hb=edc55b1f86cf613a332eeeb5d85537a54120dfa5;hpb=408250f819b35ecf43271a9bbe4455b891e302c8 diff --git a/src/qtui/systrayanimationnotificationbackend.cpp b/src/qtui/systrayanimationnotificationbackend.cpp index 65cc38b5..086dd2ef 100644 --- a/src/qtui/systrayanimationnotificationbackend.cpp +++ b/src/qtui/systrayanimationnotificationbackend.cpp @@ -18,102 +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::animateChanged(const QVariant &v) +void SystrayAnimationNotificationBackend::alertChanged(const QVariant& v) { - _animate = v.toBool(); + _alert = v.toBool(); } - -SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const +SettingsPage* SystrayAnimationNotificationBackend::createConfigWidget() const { return new ConfigWidget(); } - /***************************************************************************/ -SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayNotification", parent) +SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget* parent) + : SettingsPage("Internal", "SystrayAnimation", parent) { - _animateBox = new QCheckBox(tr("Animate system tray icon")); - _animateBox->setIcon(QIcon::fromTheme("dialog-information")); - connect(_animateBox, SIGNAL(toggled(bool)), this, SLOT(widgetChanged())); - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(_animateBox); -} + ui.setupUi(this); + ui.enableAlert->setIcon(icon::get("dialog-information")); + ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked()); -void SystrayAnimationNotificationBackend::ConfigWidget::widgetChanged() -{ - bool changed = (_animate != _animateBox->isChecked()); - if (changed != hasChanged()) - setChangedState(changed); + initAutoWidgets(); } - -bool SystrayAnimationNotificationBackend::ConfigWidget::hasDefaults() const +QString SystrayAnimationNotificationBackend::ConfigWidget::settingsKey() const { - return true; + return "Notification"; } - -void SystrayAnimationNotificationBackend::ConfigWidget::defaults() +QVariant SystrayAnimationNotificationBackend::ConfigWidget::loadAutoWidgetValue(const QString& widgetName) { - _animateBox->setChecked(false); - widgetChanged(); + 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::load() +void SystrayAnimationNotificationBackend::ConfigWidget::saveAutoWidgetValue(const QString& widgetName, const QVariant& value) { - NotificationSettings s; - _animate = s.value("Systray/Animate", true).toBool(); - _animateBox->setChecked(_animate); - setChangedState(false); + 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); } - - -void SystrayAnimationNotificationBackend::ConfigWidget::save() -{ - NotificationSettings s; - s.setValue("Systray/Animate", _animateBox->isChecked()); - load(); -} \ No newline at end of file