#include "clientsettings.h"
#include "networkmodel.h"
-DesktopNotificationBackend::DesktopNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
- _configWidget = new ConfigWidget();
-
+DesktopNotificationBackend::DesktopNotificationBackend(QObject *parent)
+ : AbstractNotificationBackend(parent)
+{
_dbusInterface = new org::freedesktop::Notifications(
"org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
notificationSettings.notify("DesktopNotification/QueueNotifications", this, SLOT(queueNotificationsChanged(const QVariant &)));
}
-DesktopNotificationBackend::~DesktopNotificationBackend() {
- delete _configWidget;
-}
-
void DesktopNotificationBackend::enabledChanged(const QVariant &v) {
_enabled = v.toBool();
}
Q_UNUSED(id); Q_UNUSED(action);
}
-SettingsPage *DesktopNotificationBackend::configWidget() const {
- return _configWidget;
+SettingsPage *DesktopNotificationBackend::createConfigWidget() const {
+ return new ConfigWidget();
}
/***************************************************************************/
public:
DesktopNotificationBackend(QObject *parent = 0);
- ~DesktopNotificationBackend();
void notify(const Notification &);
void close(uint notificationId);
- SettingsPage *configWidget() const;
+ virtual SettingsPage *createConfigWidget() const;
private slots:
void desktopNotificationClosed(uint id, uint reason);
private:
class ConfigWidget;
- SettingsPage *_configWidget;
org::freedesktop::Notifications *_dbusInterface;
bool _daemonSupportsMarkup;
class DesktopNotificationBackend::ConfigWidget : public SettingsPage {
Q_OBJECT
- public:
- ConfigWidget(QWidget *parent = 0);
- void save();
- void load();
- bool hasDefaults() const;
- void defaults();
-
- private slots:
- void widgetChanged();
-
- private:
- Ui::DesktopNotificationConfigWidget ui;
- int xHint, yHint;
- bool useHints, queueNotifications;
- int timeout;
- bool useTimeout;
- bool enabled;
+public:
+ ConfigWidget(QWidget *parent = 0);
+ void save();
+ void load();
+ bool hasDefaults() const;
+ void defaults();
+
+private slots:
+ void widgetChanged();
+
+private:
+ Ui::DesktopNotificationConfigWidget ui;
+ int xHint, yHint;
+ bool useHints, queueNotifications;
+ int timeout;
+ bool useTimeout;
+ bool enabled;
};
#endif
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _SETTINGSDLG_H_
-#define _SETTINGSDLG_H_
+#ifndef SETTINGSDLG_H
+#define SETTINGSDLG_H
#include <QtGui>
#include "ui_settingsdlg.h"
QVBoxLayout *layout = new QVBoxLayout(this);
foreach(AbstractNotificationBackend *backend, QtUi::notificationBackends()) {
- SettingsPage *cw = backend->configWidget();
+ SettingsPage *cw = backend->createConfigWidget();
if(cw) {
+ cw->setParent(this);
_configWidgets.append(cw);
layout->addWidget(cw);
connect(cw, SIGNAL(changed(bool)), SLOT(widgetHasChanged()));
#include "networkmodel.h"
#include "qtui.h"
-SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) {
+SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent)
+ : AbstractNotificationBackend(parent)
+{
NotificationSettings notificationSettings;
_showBubble = notificationSettings.value("Systray/ShowBubble", true).toBool();
_animate = notificationSettings.value("Systray/Animate", true).toBool();
notificationSettings.notify("Systray/ShowBubble", this, SLOT(showBubbleChanged(const QVariant &)));
notificationSettings.notify("Systray/Animate", this, SLOT(animateChanged(const QVariant &)));
- _configWidget = new ConfigWidget();
_iconActive = false;
connect(&_animationTimer, SIGNAL(timeout()), SLOT(blink()));
}
-SystrayNotificationBackend::~SystrayNotificationBackend() {
- delete _configWidget;
-}
-
void SystrayNotificationBackend::notify(const Notification ¬ification) {
/* fancy stuff to be implemented later: show notifications in order
_notifications.append(notification);
_animate = v.toBool();
}
-SettingsPage *SystrayNotificationBackend::configWidget() const {
- return _configWidget;
+SettingsPage *SystrayNotificationBackend::createConfigWidget() const {
+ return new ConfigWidget();
}
/***************************************************************************/
public:
SystrayNotificationBackend(QObject *parent = 0);
- ~SystrayNotificationBackend();
void notify(const Notification &);
void close(uint notificationId);
- SettingsPage *configWidget() const;
+ virtual SettingsPage *createConfigWidget() const;
private slots:
void showBubble();
private:
class ConfigWidget;
- SettingsPage *_configWidget;
bool _showBubble;
bool _animate;
bool _iconActive;
#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();
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 ¬ification) {
_timeout = v.toInt();
}
-SettingsPage *TaskbarNotificationBackend::configWidget() const {
- return _configWidget;
+SettingsPage *TaskbarNotificationBackend::createConfigWidget() const {
+ return new ConfigWidget();
}
/***************************************************************************/
public:
TaskbarNotificationBackend(QObject *parent = 0);
- ~TaskbarNotificationBackend();
void notify(const Notification &);
void close(uint notificationId);
- SettingsPage *configWidget() const;
+ virtual SettingsPage *createConfigWidget() const;
private slots:
void enabledChanged(const QVariant &);
private:
class ConfigWidget;
- SettingsPage *_configWidget;
bool _enabled;
int _timeout;
};
class AbstractNotificationBackend : public QObject {
Q_OBJECT
- public:
- struct Notification {
- uint notificationId;
- BufferId bufferId;
- QString sender;
- QString message;
-
- Notification(uint id_, BufferId buf_, const QString &sender_, const QString &msg_)
+public:
+ struct Notification {
+ uint notificationId;
+ BufferId bufferId;
+ QString sender;
+ QString message;
+
+ Notification(uint id_, BufferId buf_, const QString &sender_, const QString &msg_)
: notificationId(id_), bufferId(buf_), sender(sender_), message(msg_) {};
- };
+ };
- inline AbstractNotificationBackend(QObject *parent) : QObject(parent) {};
- virtual ~AbstractNotificationBackend() {};
+ inline AbstractNotificationBackend(QObject *parent) : QObject(parent) {};
+ virtual ~AbstractNotificationBackend() {};
- virtual void notify(const Notification &) = 0;
- virtual void close(uint notificationId) { Q_UNUSED(notificationId); }
- virtual SettingsPage *configWidget() const = 0;
+ virtual void notify(const Notification &) = 0;
+ virtual void close(uint notificationId) { Q_UNUSED(notificationId); }
+ //! factory to create a configuration widget suitable for a specific notification backend
+ /**
+ * AbstractNotification will not take owner ship of that configWidget!
+ * in case you need to communicate with the configWidget directly, make your connections here
+ */
+ virtual SettingsPage *createConfigWidget() const = 0;
};
#endif