* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <QVBoxLayout>
+
#include "notificationssettingspage.h"
#include "qtui.h"
-#include "uisettings.h"
-#include "buffersettings.h"
NotificationsSettingsPage::NotificationsSettingsPage(QWidget *parent)
: SettingsPage(tr("Behaviour"), tr("Notifications"), parent) {
- ui.setupUi(this);
-
- connect(ui.animateTrayIcon, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
- connect(ui.showBubble, SIGNAL(toggled(bool)), this, SLOT(widgetHasChanged()));
- connect(ui.desktopBox, SIGNAL(toggled(bool)), this, SLOT(widgetHasChanged()));
- connect(ui.timeout_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
- connect(ui.x_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
- connect(ui.y_value, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
-#ifndef HAVE_DBUS
- ui.desktopBox->setVisible(false);
-#endif
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ foreach(AbstractNotificationBackend *backend, QtUi::notificationBackends()) {
+ SettingsPage *cw = backend->configWidget();
+ if(cw) {
+ _configWidgets.append(cw);
+ layout->addWidget(cw);
+ connect(cw, SIGNAL(changed(bool)), SLOT(widgetHasChanged()));
+ }
+ }
+ layout->addStretch(1);
}
bool NotificationsSettingsPage::hasDefaults() const {
}
void NotificationsSettingsPage::defaults() {
- ui.animateTrayIcon->setChecked(true);
- ui.showBubble->setChecked(true);
- ui.desktopBox->setChecked(false);
- ui.timeout_value->setValue(5000);
- ui.x_value->setValue(0);
- ui.y_value->setValue(0);
-
+ foreach(SettingsPage *cw, _configWidgets)
+ cw->defaults();
widgetHasChanged();
}
void NotificationsSettingsPage::load() {
- // uiSettings:
- UiSettings uiSettings;
-
- settings["AnimateTrayIcon"] = uiSettings.value("AnimateTrayIcon", QVariant(true));
- ui.animateTrayIcon->setChecked(settings["AnimateTrayIcon"].toBool());
-
- settings["NotificationBubble"] = uiSettings.value("NotificationBubble", QVariant(true));
- ui.showBubble->setChecked(settings["NotificationBubble"].toBool());
-
- settings["NotificationDesktop"] = uiSettings.value("NotificationDesktop", QVariant(false));
- ui.desktopBox->setChecked(settings["NotificationDesktop"].toBool());
- settings["NotificationDesktopTimeout"] = uiSettings.value("NotificationDesktopTimeout", QVariant(5000));
- ui.timeout_value->setValue(settings["NotificationDesktopTimeout"].toInt());
- settings["NotificationDesktopHintX"] = uiSettings.value("NotificationDesktopHintX", QVariant(0));
- ui.x_value->setValue(settings["NotificationDesktopHintX"].toInt());
- settings["NotificationDesktopHintY"] = uiSettings.value("NotificationDesktopHintY", QVariant(0));
- ui.y_value->setValue(settings["NotificationDesktopHintY"].toInt());
-
+ foreach(SettingsPage *cw, _configWidgets)
+ cw->load();
setChangedState(false);
}
void NotificationsSettingsPage::save() {
- UiSettings uiSettings;
-
- uiSettings.setValue("AnimateTrayIcon", ui.animateTrayIcon->isChecked());
-
- uiSettings.setValue("NotificationBubble", ui.showBubble->isChecked());
- uiSettings.setValue("NotificationDesktop", ui.desktopBox->isChecked());
- uiSettings.setValue("NotificationDesktopTimeout", ui.timeout_value->value());
- uiSettings.setValue("NotificationDesktopHintX", ui.x_value->value());
- uiSettings.setValue("NotificationDesktopHintY", ui.y_value->value());
-
- load();
+ foreach(SettingsPage *cw, _configWidgets)
+ cw->save();
setChangedState(false);
}
void NotificationsSettingsPage::widgetHasChanged() {
- bool changed = testHasChanged();
+ bool changed = false;
+ foreach(SettingsPage *cw, _configWidgets) {
+ if(cw->hasChanged()) {
+ changed = true;
+ break;
+ }
+ }
if(changed != hasChanged()) setChangedState(changed);
}
-
-bool NotificationsSettingsPage::testHasChanged() {
- if(settings["AnimateTrayIcon"].toBool() != ui.animateTrayIcon->isChecked()) return true;
- if(settings["NotificationBubble"].toBool() != ui.showBubble->isChecked()) return true;
- if(settings["NotificationDesktop"].toBool() != ui.desktopBox->isChecked()) return true;
- if(settings["NotificationDesktopTimeout"].toInt() != ui.timeout_value->value()) return true;
- if(settings["NotificationDesktopHintX"].toInt() != ui.x_value->value()) return true;
- if(settings["NotificationDesktopHintY"].toInt() != ui.y_value->value()) return true;
-
- return false;
-}
+++ /dev/null
-<ui version="4.0" >
- <class>NotificationsSettingsPage</class>
- <widget class="QWidget" name="NotificationsSettingsPage" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>422</width>
- <height>386</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Form</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="QGroupBox" name="groupBox_3" >
- <property name="title" >
- <string>System Tray</string>
- </property>
- <layout class="QGridLayout" >
- <item row="1" column="0" >
- <widget class="QCheckBox" name="animateTrayIcon" >
- <property name="text" >
- <string>Animate tray icon</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QCheckBox" name="showBubble" >
- <property name="text" >
- <string>Show Bubble</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="desktopBox" >
- <property name="toolTip" >
- <string>Sends Quassel's notifications to a notification daemon compliant to Freedesktop's Notification specification (org.freedesktop.Notification).</string>
- </property>
- <property name="title" >
- <string>Desktop Notification (via DBus)</string>
- </property>
- <property name="checkable" >
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <layout class="QGridLayout">
- <item row="0" column="0" >
- <widget class="QLabel" name="timeout_label" >
- <property name="text" >
- <string>Timeout</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QSpinBox" name="timeout_value" >
- <property name="minimum" >
- <number>-1</number>
- </property>
- <property name="maximum" >
- <number>100000</number>
- </property>
- <property name="value" >
- <number>5000</number>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="x_label" >
- <property name="text" >
- <string>X</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QSpinBox" name="x_value" >
- <property name="maximum" >
- <number>10000</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="y_label" >
- <property name="text" >
- <string>Y</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QSpinBox" name="y_value" >
- <property name="maximum" >
- <number>10000</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>261</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>143</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>