Introduce the concept of an "active" bufferview
[quassel.git] / src / qtui / taskbarnotificationbackend.cpp
index 9b2e2be..f99706b 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
-*   Copyright (C) 2005-08 by the Quassel Project                          *
+*   Copyright (C) 2005-09 by the Quassel Project                          *
 *   devel@quassel-irc.org                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 #include <QtGui>
 
 #include "clientsettings.h"
+#include "iconloader.h"
 #include "mainwin.h"
 #include "qtui.h"
 
-TaskbarNotificationBackend::TaskbarNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
+TaskbarNotificationBackend::TaskbarNotificationBackend(QObject *parent)
+  : AbstractNotificationBackend(parent)
+{
   NotificationSettings notificationSettings;
   _enabled = notificationSettings.value("Taskbar/Enabled", true).toBool();
-  _timeout = notificationSettings.value("Taskbar/Timeout", 0).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 &)));
-
-  _configWidget = new ConfigWidget();
-}
-
-TaskbarNotificationBackend::~TaskbarNotificationBackend() {
-  delete _configWidget;
 }
 
 void TaskbarNotificationBackend::notify(const Notification &notification) {
-  Q_UNUSED(notification)
-  if(_enabled) {
+  if(_enabled && (notification.type == Highlight || notification.type == PrivMsg)) {
     QApplication::alert(QtUi::mainWindow(), _timeout);
   }
 }
@@ -60,8 +56,8 @@ void TaskbarNotificationBackend::timeoutChanged(const QVariant &v) {
   _timeout = v.toInt();
 }
 
-SettingsPage *TaskbarNotificationBackend::configWidget() const {
-  return _configWidget;
+SettingsPage *TaskbarNotificationBackend::createConfigWidget() const {
+  return new ConfigWidget();
 }
 
 /***************************************************************************/
@@ -73,15 +69,19 @@ TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : Settin
 #else
   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(0);
+  timeoutBox->setMinimum(1);
   timeoutBox->setMaximum(99);
   timeoutBox->setSpecialValueText(tr("Unlimited"));
-  timeoutBox->setSuffix(tr(" s"));
+  timeoutBox->setSuffix(tr(" seconds"));
   layout->addWidget(timeoutBox);
-  layout->addStretch(1);
+  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()));
 }