X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftaskbarnotificationbackend.cpp;h=81165f23d3662aaeefd3ae51b74b05eb72740c1e;hp=46e562b3372de3e78136cf6135f312a0c8451d9e;hb=f04db2cb802b1296ca739c823495930c71d3b4ab;hpb=4ae8f86c1ce452582d6fe576956c7c1bc1460adf diff --git a/src/qtui/taskbarnotificationbackend.cpp b/src/qtui/taskbarnotificationbackend.cpp index 46e562b3..81165f23 100644 --- a/src/qtui/taskbarnotificationbackend.cpp +++ b/src/qtui/taskbarnotificationbackend.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include @@ -31,92 +31,114 @@ #include "qtui.h" TaskbarNotificationBackend::TaskbarNotificationBackend(QObject *parent) - : AbstractNotificationBackend(parent) + : AbstractNotificationBackend(parent) { - NotificationSettings notificationSettings; - _enabled = notificationSettings.value("Taskbar/Enabled", true).toBool(); - _timeout = notificationSettings.value("Taskbar/Timeout", 0).toInt(); + 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, SLOT(enabledChanged(const QVariant &))); + notificationSettings.notify("Taskbar/Timeout", this, SLOT(timeoutChanged(const QVariant &))); } -void TaskbarNotificationBackend::notify(const Notification ¬ification) { - if(_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { - QApplication::alert(QtUi::mainWindow(), _timeout); - } + +void TaskbarNotificationBackend::notify(const Notification ¬ification) +{ + if (_enabled && (notification.type == Highlight || notification.type == PrivMsg)) { + QApplication::alert(QtUi::mainWindow(), _timeout); + } } -void TaskbarNotificationBackend::close(uint notificationId) { - Q_UNUSED(notificationId); + +void TaskbarNotificationBackend::close(uint notificationId) +{ + Q_UNUSED(notificationId); } -void TaskbarNotificationBackend::enabledChanged(const QVariant &v) { - _enabled = v.toBool(); + +void TaskbarNotificationBackend::enabledChanged(const QVariant &v) +{ + _enabled = v.toBool(); } -void TaskbarNotificationBackend::timeoutChanged(const QVariant &v) { - _timeout = v.toInt(); + +void TaskbarNotificationBackend::timeoutChanged(const QVariant &v) +{ + _timeout = v.toInt(); } -SettingsPage *TaskbarNotificationBackend::createConfigWidget() const { - return new ConfigWidget(); + +SettingsPage *TaskbarNotificationBackend::createConfigWidget() const +{ + return new ConfigWidget(); } + /***************************************************************************/ -TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "TaskbarNotification", parent) { - QHBoxLayout *layout = new QHBoxLayout(this); +TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "TaskbarNotification", parent) +{ + QHBoxLayout *layout = new QHBoxLayout(this); #ifdef Q_WS_MAC - layout->addWidget(enabledBox = new QCheckBox(tr("Activate dock entry, timeout:"), this)); + layout->addWidget(enabledBox = new QCheckBox(tr("Activate dock entry, timeout:"), this)); #else - layout->addWidget(enabledBox = new QCheckBox(tr("Mark taskbar entry, timeout:"), this)); + layout->addWidget(enabledBox = new QCheckBox(tr("Mark taskbar entry, timeout:"), this)); #endif - enabledBox->setIcon(SmallIcon("flag-blue")); - enabledBox->setEnabled(true); - - timeoutBox = new QSpinBox(this); - timeoutBox->setMinimum(1); - timeoutBox->setMaximum(99); - timeoutBox->setSpecialValueText(tr("Unlimited")); - timeoutBox->setSuffix(tr(" seconds")); - 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())); + enabledBox->setIcon(SmallIcon("flag-blue")); + enabledBox->setEnabled(true); + + timeoutBox = new QSpinBox(this); + timeoutBox->setMinimum(0); + timeoutBox->setMaximum(99); + timeoutBox->setSpecialValueText(tr("Unlimited")); + timeoutBox->setSuffix(tr(" seconds")); + 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())); } -void TaskbarNotificationBackend::ConfigWidget::widgetChanged() { - bool changed = (enabled != enabledBox->isChecked() || timeout/1000 != timeoutBox->value()); - if(changed != hasChanged()) setChangedState(changed); + +void TaskbarNotificationBackend::ConfigWidget::widgetChanged() +{ + bool changed = (enabled != enabledBox->isChecked() || timeout/1000 != timeoutBox->value()); + if (changed != hasChanged()) setChangedState(changed); } -bool TaskbarNotificationBackend::ConfigWidget::hasDefaults() const { - return true; + +bool TaskbarNotificationBackend::ConfigWidget::hasDefaults() const +{ + return true; } -void TaskbarNotificationBackend::ConfigWidget::defaults() { - enabledBox->setChecked(true); - timeoutBox->setValue(0); - widgetChanged(); + +void TaskbarNotificationBackend::ConfigWidget::defaults() +{ + enabledBox->setChecked(true); + timeoutBox->setValue(0); + widgetChanged(); } -void TaskbarNotificationBackend::ConfigWidget::load() { - NotificationSettings s; - enabled = s.value("Taskbar/Enabled", true).toBool(); - timeout = s.value("Taskbar/Timeout", 0).toInt(); - enabledBox->setChecked(enabled); - timeoutBox->setValue(timeout/1000); +void TaskbarNotificationBackend::ConfigWidget::load() +{ + NotificationSettings s; + enabled = s.value("Taskbar/Enabled", true).toBool(); + timeout = s.value("Taskbar/Timeout", 0).toInt(); + + enabledBox->setChecked(enabled); + timeoutBox->setValue(timeout/1000); - setChangedState(false); + setChangedState(false); } -void TaskbarNotificationBackend::ConfigWidget::save() { - NotificationSettings s; - s.setValue("Taskbar/Enabled", enabledBox->isChecked()); - s.setValue("Taskbar/Timeout", timeoutBox->value() * 1000); - load(); + +void TaskbarNotificationBackend::ConfigWidget::save() +{ + NotificationSettings s; + s.setValue("Taskbar/Enabled", enabledBox->isChecked()); + s.setValue("Taskbar/Timeout", timeoutBox->value() * 1000); + load(); }