Home · All Namespaces · All Classes

WidgetNotificationSink Class Reference

#include <widgetnotificationsink.h>

Inheritance diagram for WidgetNotificationSink:
Inheritance graph
[legend]
Collaboration diagram for WidgetNotificationSink:
Collaboration graph
[legend]

List of all members.

Signals

void privacySettingChanged (bool privacyEnabled)

Public Member Functions

 WidgetNotificationSink ()
void setHonorPrivacySetting (bool honor)
void setNotificationsClickable (bool clickable)

Static Public Attributes

static const char * NOTIFICATION_ID_PROPERTY = "notificationId"
 MBanner property to store the notification ID into.
static const char * GROUP_ID_PROPERTY = "groupId"
 MBanner property to store the group ID into.
static const char * USER_REMOVABLE_PROPERTY = "userRemovable"
 MBanner property to store the user removability into.
static const char * TITLE_TEXT_PROPERTY = "titleText"
 MBanner property to store the title text.
static const char * SUBTITLE_TEXT_PROPERTY = "subtitleText"
 MBanner property to store the subtitle text.
static const char * GENERIC_TEXT_PROPERTY = "genericText"
 MBanner property to store the generic text.

Protected Member Functions

MBanner * createInfoBanner (const Notification &notification)
MBanner * createInfoBanner (Notification::NotificationType type, uint groupId, const NotificationParameters &parameters)
void updateTitles (MBanner *infoBanner)
void updateActions (MBanner *infoBanner, const NotificationParameters &parameters)

Static Protected Member Functions

static QString determineIconId (const NotificationParameters &parameters)
static bool determineUserRemovability (const NotificationParameters &parameters)
static QString infoBannerTitleText (const NotificationParameters &parameters)
static QString infoBannerSubtitleText (const NotificationParameters &parameters)
static QString infoBannerGenericText (const NotificationParameters &parameters)

Detailed Description

WidgetNotificationSink is a common base class for all notification sinks that trigger visual feedback using a graphics widget.

WidgetNotificationSink creates MBanner widgets for notifications. When MBanner is clicked the action bound to the notification is triggered and notification is removed from the notification system signaling notificationRemovalRequested().

The sink can be configured to always show the given notification text in the banners (the default mode) or to only show a generic text instead of the given notification text if the privacy mode is enabled by setting the value of the /desktop/meego/privacy/private_lockscreen_notifications GConf key to true. This can be accomplished with the setHonorPrivacySetting() call.

Definition at line 42 of file widgetnotificationsink.h.


Constructor & Destructor Documentation

WidgetNotificationSink::WidgetNotificationSink (  ) 

Constructs a widget notification sink.

Definition at line 33 of file widgetnotificationsink.cpp.

00033                                                :
00034     NotificationSink(),
00035     privacySetting(NULL),
00036     clickableNotifications(true)
00037 {
00038 }


Member Function Documentation

MBanner * WidgetNotificationSink::createInfoBanner ( Notification::NotificationType  type,
uint  groupId,
const NotificationParameters parameters 
) [protected]

Creates a MBanner widget from the given notification parameters. Ownership of the constructed object is passed to the caller.

Parameters:
type Notification type on the basis of which info banner type is to be constructed.
groupId The group ID to be associated with the info banner.
params NotificationParameters according to which configure the MBanner.

Definition at line 62 of file widgetnotificationsink.cpp.

00063 {
00064     // Create a banner on the basis of notification type
00065     MBanner *infoBanner = new MBanner;
00066     infoBanner->setObjectName(type == Notification::ApplicationEvent ? "EventBanner" : "SystemBanner");
00067     infoBanner->setProperty(TITLE_TEXT_PROPERTY, infoBannerTitleText(parameters));
00068     infoBanner->setProperty(SUBTITLE_TEXT_PROPERTY, infoBannerSubtitleText(parameters));
00069     infoBanner->setProperty(GENERIC_TEXT_PROPERTY, infoBannerGenericText(parameters));
00070     infoBanner->setProperty(GROUP_ID_PROPERTY, groupId);
00071     infoBanner->setProperty(USER_REMOVABLE_PROPERTY, determineUserRemovability(parameters));
00072     infoBanner->setIconID(determineIconId(parameters));
00073     updateTitles(infoBanner);
00074     updateActions(infoBanner, parameters);
00075 
00076     // Catch clicks from the info banner
00077     if(clickableNotifications) {
00078         connect(infoBanner, SIGNAL(clicked()), this, SLOT(infoBannerClicked()), Qt::QueuedConnection);
00079     }
00080     return infoBanner;
00081 }

Here is the call graph for this function:

MBanner * WidgetNotificationSink::createInfoBanner ( const Notification notification  )  [protected]

Creates a MBanner widget to represent a notification object. Ownership of the constructed object is passed to the caller.

Parameters:
notification The notification object to represent with the MBanner.
Returns:
Constructed MBanner that represents the notification.

Definition at line 54 of file widgetnotificationsink.cpp.

00055 {
00056     MBanner *infoBanner = createInfoBanner(notification.type(), notification.groupId(), notification.parameters());
00057     infoBanner->setProperty(NOTIFICATION_ID_PROPERTY, notification.notificationId());
00058 
00059     return infoBanner;
00060 }

Here is the call graph for this function:

QString WidgetNotificationSink::determineIconId ( const NotificationParameters parameters  )  [static, protected]

Determines icon id of a notification based on the given notification parameters.

Parameters:
parameters Notification parameters to determine the icon id from.
Returns:
Logical icon id as a string

Definition at line 40 of file widgetnotificationsink.cpp.

00041 {
00042     return parameters.value(NotificationWidgetParameterFactory::iconIdKey()).toString();
00043 }

Here is the call graph for this function:

bool WidgetNotificationSink::determineUserRemovability ( const NotificationParameters parameters  )  [static, protected]

Determines user removability of a notification based on the given notification parameters.

Parameters:
parameters Notification parameters to determine removability from.
Returns:
true if the notification should be user removable, false otherwise

Definition at line 45 of file widgetnotificationsink.cpp.

00046 {
00047     QVariant value = parameters.value(NotificationWidgetParameterFactory::userRemovableKey());
00048     if(value.isValid()) {
00049         return value.toBool();
00050     }
00051     return true;
00052 }

Here is the call graph for this function:

QString WidgetNotificationSink::infoBannerGenericText ( const NotificationParameters parameters  )  [static, protected]

Creates a generic text string from notification parameters.

Parameters:
parameters the NotificationParameters to get the generic text from
Returns:
the generic text

Definition at line 123 of file widgetnotificationsink.cpp.

00124 {
00125     QString genericText;
00126     QString genericTextId = parameters.value(NotificationWidgetParameterFactory::genericTextIdKey()).toString();
00127 
00128     if(!genericTextId.isEmpty()) {
00129         QString genericTextCatalogue = parameters.value(NotificationWidgetParameterFactory::genericTextCatalogueKey()).toString();
00130 
00131         if(!genericTextCatalogue.isEmpty()) {
00132             // Load the catalog from disk if it's not yet loaded
00133             MLocale locale;
00134             locale.installTrCatalog(genericTextCatalogue);
00135             MLocale::setDefault(locale);
00136 
00137             int eventCount = parameters.value(GenericNotificationParameterFactory::countKey()).toInt();
00138             genericText = qtTrId(genericTextId.toUtf8(), eventCount).arg(eventCount);
00139         }
00140     }
00141 
00142     return genericText;
00143 }

Here is the call graph for this function:

QString WidgetNotificationSink::infoBannerSubtitleText ( const NotificationParameters parameters  )  [static, protected]

Creates a subtitle text string from notification parameters.

Parameters:
parameters the NotificationParameters to get the subtitle text from
Returns:
the subtitle text

Definition at line 118 of file widgetnotificationsink.cpp.

00119 {
00120     return parameters.value(NotificationWidgetParameterFactory::bodyKey()).toString();
00121 }

Here is the call graph for this function:

QString WidgetNotificationSink::infoBannerTitleText ( const NotificationParameters parameters  )  [static, protected]

Creates a title text string from notification parameters.

Parameters:
parameters the NotificationParameters to get the title text from
Returns:
the title text

Definition at line 113 of file widgetnotificationsink.cpp.

00114 {
00115     return parameters.value(NotificationWidgetParameterFactory::summaryKey()).toString();
00116 }

Here is the call graph for this function:

void WidgetNotificationSink::privacySettingChanged ( bool  privacyEnabled  )  [signal]

Informs about a change in the privacy setting.

Parameters:
privacyEnabled true if the privacy was enabled, false if disabled
void WidgetNotificationSink::setHonorPrivacySetting ( bool  honor  ) 

Controls whether the notification banners should only show a generic text instead of the full notification text if the /desktop/meego/privacy/private_lockscreen_notifications GConf key is set to true. If the GConf key is not honored the private mode is never used.

Parameters:
honor if true, privacy setting is honored. If false, the privacy setting is ignored.

Definition at line 177 of file widgetnotificationsink.cpp.

00178 {
00179     if (honor) {
00180         if (privacySetting == NULL) {
00181             privacySetting = new MGConfItem("/desktop/meego/privacy/private_lockscreen_notifications", this);
00182             emitPrivacySettingValue();
00183 
00184             connect(privacySetting, SIGNAL(valueChanged()), this, SLOT(emitPrivacySettingValue()));
00185         }
00186     } else {
00187         if (privacySetting != NULL) {
00188             delete privacySetting;
00189             privacySetting = NULL;
00190 
00191             emitPrivacySettingValue();
00192         }
00193     }
00194 }

void WidgetNotificationSink::setNotificationsClickable ( bool  clickable  ) 

Sets if notifications are clickable

Parameters:
clickable true if notifications are clickable. false if notifications are not clickable

Definition at line 201 of file widgetnotificationsink.cpp.

00202 {
00203     clickableNotifications = clickable;
00204 }

void WidgetNotificationSink::updateActions ( MBanner *  infoBanner,
const NotificationParameters parameters 
) [protected]

Removes old actions from the given info banner and adds the action specified in the notification (if any)

Parameters:
infoBanner the MBanner to update
parameters the NotificationParameters to get the action from

Definition at line 96 of file widgetnotificationsink.cpp.

00097 {
00098     // Remove the old actions
00099     foreach(QAction * qAction, infoBanner->actions()) {
00100         infoBanner->removeAction(qAction);
00101         delete qAction;
00102     }
00103 
00104     // Add the action if it exists
00105     QString action = parameters.value(NotificationWidgetParameterFactory::actionKey()).toString();
00106     if (!action.isEmpty()) {
00107         MRemoteAction *remoteAction = new MRemoteAction(action, infoBanner);
00108         remoteAction->setVisible(false);
00109         infoBanner->addAction(remoteAction);
00110     }
00111 }

Here is the call graph for this function:

void WidgetNotificationSink::updateTitles ( MBanner *  infoBanner  )  [protected]

Updates the titles in a banner based on the current privacy mode.

Parameters:
infoBanner the MBanner to update

Definition at line 83 of file widgetnotificationsink.cpp.

00084 {
00085     if (privacySetting != NULL && privacySetting->value().toBool()) {
00086         // Privacy is honored and privacy mode is enabled: use a generic text in the banner
00087         infoBanner->setTitle(infoBanner->property(GENERIC_TEXT_PROPERTY).toString());
00088         infoBanner->setSubtitle(QString());
00089     } else {
00090         // Privacy is not honored or privacy mode is disabled: use the given text in the banner
00091         infoBanner->setTitle(infoBanner->objectName() == "EventBanner" ? infoBanner->property(TITLE_TEXT_PROPERTY).toString() : QString());
00092         infoBanner->setSubtitle(infoBanner->property(SUBTITLE_TEXT_PROPERTY).toString());
00093     }
00094 }


Member Data Documentation

const char * WidgetNotificationSink::GENERIC_TEXT_PROPERTY = "genericText" [static]

MBanner property to store the generic text.

Definition at line 80 of file widgetnotificationsink.h.

const char * WidgetNotificationSink::GROUP_ID_PROPERTY = "groupId" [static]

MBanner property to store the group ID into.

Definition at line 72 of file widgetnotificationsink.h.

const char * WidgetNotificationSink::NOTIFICATION_ID_PROPERTY = "notificationId" [static]

MBanner property to store the notification ID into.

Definition at line 70 of file widgetnotificationsink.h.

const char * WidgetNotificationSink::SUBTITLE_TEXT_PROPERTY = "subtitleText" [static]

MBanner property to store the subtitle text.

Definition at line 78 of file widgetnotificationsink.h.

const char * WidgetNotificationSink::TITLE_TEXT_PROPERTY = "titleText" [static]

MBanner property to store the title text.

Definition at line 76 of file widgetnotificationsink.h.

const char * WidgetNotificationSink::USER_REMOVABLE_PROPERTY = "userRemovable" [static]

MBanner property to store the user removability into.

Definition at line 74 of file widgetnotificationsink.h.


The documentation for this class was generated from the following files:

Copyright © 2010 Nokia Corporation Generated on Wed Nov 10 16:05:15 2010
Doxygen 1.6.1
MeeGo Touch