X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftaskbarnotificationbackend.cpp;h=a782b3160c63181fab83e7702cb9cb23bce9e17a;hp=ef9736fd9c46d0ae817a8559bfa7fee9ccbb238e;hb=cc6e7c08709c4e761e2fd9c2e322751015497003;hpb=b7447afe8e836376776dac26704e227a678d2913 diff --git a/src/qtui/taskbarnotificationbackend.cpp b/src/qtui/taskbarnotificationbackend.cpp index ef9736fd..a782b316 100644 --- a/src/qtui/taskbarnotificationbackend.cpp +++ b/src/qtui/taskbarnotificationbackend.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -30,55 +30,50 @@ #include "mainwin.h" #include "qtui.h" -TaskbarNotificationBackend::TaskbarNotificationBackend(QObject *parent) +TaskbarNotificationBackend::TaskbarNotificationBackend(QObject* parent) : AbstractNotificationBackend(parent) { NotificationSettings notificationSettings; _enabled = notificationSettings.value("Taskbar/Enabled", true).toBool(); _timeout = notificationSettings.value("Taskbar/Timeout", 0).toInt(); - notificationSettings.notify("Taskbar/Enabled", this, SLOT(enabledChanged(const QVariant &))); - notificationSettings.notify("Taskbar/Timeout", this, SLOT(timeoutChanged(const QVariant &))); + notificationSettings.notify("Taskbar/Enabled", this, &TaskbarNotificationBackend::enabledChanged); + notificationSettings.notify("Taskbar/Timeout", this, &TaskbarNotificationBackend::timeoutChanged); } - -void TaskbarNotificationBackend::notify(const Notification ¬ification) +void TaskbarNotificationBackend::notify(const Notification& notification) { if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { QApplication::alert(QtUi::mainWindow(), _timeout); } } - void TaskbarNotificationBackend::close(uint notificationId) { Q_UNUSED(notificationId); } - -void TaskbarNotificationBackend::enabledChanged(const QVariant &v) +void TaskbarNotificationBackend::enabledChanged(const QVariant& v) { _enabled = v.toBool(); } - -void TaskbarNotificationBackend::timeoutChanged(const QVariant &v) +void TaskbarNotificationBackend::timeoutChanged(const QVariant& v) { _timeout = v.toInt(); } - -SettingsPage *TaskbarNotificationBackend::createConfigWidget() const +SettingsPage* TaskbarNotificationBackend::createConfigWidget() const { return new ConfigWidget(); } - /***************************************************************************/ -TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "TaskbarNotification", parent) +TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget* parent) + : SettingsPage("Internal", "TaskbarNotification", parent) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto* layout = new QHBoxLayout(this); #ifdef Q_OS_MAC layout->addWidget(enabledBox = new QCheckBox(tr("Activate dock entry, timeout:"), this)); #else @@ -95,25 +90,23 @@ TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : Settin layout->addWidget(timeoutBox); layout->addStretch(20); - connect(enabledBox, SIGNAL(toggled(bool)), SLOT(widgetChanged())); - connect(enabledBox, SIGNAL(toggled(bool)), timeoutBox, SLOT(setEnabled(bool))); - connect(timeoutBox, SIGNAL(valueChanged(int)), SLOT(widgetChanged())); + connect(enabledBox, &QAbstractButton::toggled, this, &ConfigWidget::widgetChanged); + connect(enabledBox, &QAbstractButton::toggled, timeoutBox, &QWidget::setEnabled); + connect(timeoutBox, selectOverload(&QSpinBox::valueChanged), this, &ConfigWidget::widgetChanged); } - void TaskbarNotificationBackend::ConfigWidget::widgetChanged() { - bool changed = (enabled != enabledBox->isChecked() || timeout/1000 != timeoutBox->value()); - if (changed != hasChanged()) setChangedState(changed); + bool changed = (enabled != enabledBox->isChecked() || timeout / 1000 != timeoutBox->value()); + if (changed != hasChanged()) + setChangedState(changed); } - bool TaskbarNotificationBackend::ConfigWidget::hasDefaults() const { return true; } - void TaskbarNotificationBackend::ConfigWidget::defaults() { enabledBox->setChecked(true); @@ -121,7 +114,6 @@ void TaskbarNotificationBackend::ConfigWidget::defaults() widgetChanged(); } - void TaskbarNotificationBackend::ConfigWidget::load() { NotificationSettings s; @@ -129,12 +121,11 @@ void TaskbarNotificationBackend::ConfigWidget::load() timeout = s.value("Taskbar/Timeout", 0).toInt(); enabledBox->setChecked(enabled); - timeoutBox->setValue(timeout/1000); + timeoutBox->setValue(timeout / 1000); setChangedState(false); } - void TaskbarNotificationBackend::ConfigWidget::save() { NotificationSettings s;