AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Private Slots | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
AlarmNotifications::DesktopAlarmWidgetKde4 Class Reference

Desktop widget featuring an item in the KDE4 notification area. More...

#include <desktopalarmwidgetkde4.h>

Inheritance diagram for AlarmNotifications::DesktopAlarmWidgetKde4:
Inheritance graph
[legend]
Collaboration diagram for AlarmNotifications::DesktopAlarmWidgetKde4:
Collaboration graph
[legend]

Public Types

enum  DesktopAlarmWidgetStatus { ActiveOK = 0, ActiveAlarm = 1, Disabled = 2 }
 Status of the desktop widget. More...
 

Signals

void alarmStatusChanged ()
 Alarm has been triggered or acknowledged. More...
 
void notificationSwitchChanged (bool enabled)
 Widget has been enabled or disabled. More...
 

Public Member Functions

 DesktopAlarmWidgetKde4 ()
 Constructor. More...
 
 ~DesktopAlarmWidgetKde4 ()
 Destructor. More...
 
 DesktopAlarmWidgetKde4 (const DesktopAlarmWidgetKde4 &other)=delete
 Copy constructor (deleted) More...
 
 DesktopAlarmWidgetKde4 (DesktopAlarmWidgetKde4 &&other)=delete
 Move constructor (C++11, deleted) More...
 
DesktopAlarmWidgetKde4operator= (const DesktopAlarmWidgetKde4 &other)=delete
 Copy assignment (deleted) More...
 
DesktopAlarmWidgetKde4operator= (DesktopAlarmWidgetKde4 &&other)=delete
 Move assignment (deleted) More...
 

Protected Slots

void toggleNotifications ()
 Toggles the "main switch". More...
 
void exitApplication ()
 Close the desktop widget. More...
 
void configureNotificationTimeout ()
 Change timespan between alarm trigger and notification display. More...
 

Protected Member Functions

bool getAlarmActive () const noexcept
 Show alarm active flag to derived class. More...
 
DesktopAlarmWidgetStatus getStatus () const noexcept
 Query alarm status. More...
 
void showStatusMessage ()
 Show status dialog box. More...
 

Private Slots

void notificationSwitchChange (bool enabled)
 React on widget enable/disable. More...
 
void changeTrayIcon ()
 Change the tray icon due to status change. More...
 
void activated (bool active, const QPoint &pos)
 React on click on tray icon. More...
 

Private Member Functions

virtual void createContextMenu ()
 Create context menu objects. More...
 
void setStatusIconAndTooltip (DesktopAlarmWidgetStatus status)
 Adjust tray icon and tooltip message. More...
 

Static Private Member Functions

static bool getBeedoActivated () noexcept
 Return compile-time Beedo activation flag. More...
 

Private Attributes

KStatusNotifierItem _trayicon
 Tray icon object. More...
 
KMenu * _contextmenu
 Tray icon context menu. More...
 
QAction * _toggleAction
 Context menu entry to toggle the desktop widget. More...
 
QAction * _configureAction
 Context menu entry to configure notification timeout. More...
 
QAction * _exitAction
 Context menu entry to close the application. More...
 

Detailed Description

Desktop widget featuring an item in the KDE4 notification area.

This version of the desktop widget provides a KDE4 status notifier item which has extended capabilities in comparision to the pure QSystemTrayIcon provided by the class DesktopAlarmWidgetQt.

The KDE project has defined a new protocol for using the notification area: Application cannot draw their icon themselves anymore but they have to use inter-process communication via D-Bus to ask the desktop environment to do so. The advantage is that the applications cannot only draw an icon, but also provide a status. According to the status and the user's configuration the desktop enviroment can automatically show and hide icons to prevent overpopulation of the notification are.

This class uses this status system as follows: If everything is fine, the status is set to Passive what usually hides the icon. If the widget is disabled the status is set to Active an in case of an alarm the status is set to NeedsAttention what makes the icon not only visible but in addition blink.

Definition at line 57 of file desktopalarmwidgetkde4.h.

Member Enumeration Documentation

Status of the desktop widget.

The current status can be queried from the derived class by calling getStatus(). This status is used e.g. to display the correct icon in the notification area.

Enumerator
ActiveOK 

Widget active, status OK.

The desktop widget is active and no alarm is present

ActiveAlarm 

Widget active, status alarm.

The desktop widget is active and alarms are currently reported.

Disabled 

Widget inactive.

The desktop widet is inactive, the connection to the alarm server has been closed.

Definition at line 68 of file desktopalarmwidget.h.

Constructor & Destructor Documentation

DesktopAlarmWidgetKde4::DesktopAlarmWidgetKde4 ( )

Constructor.

Queries the Beedo activation, initializes the base class and sets up the KStatusNotifierItem.

Definition at line 38 of file desktopalarmwidgetkde4.cpp.

DesktopAlarmWidgetKde4::~DesktopAlarmWidgetKde4 ( )

Destructor.

Has nothing to do here, all work in done in the base class.

Definition at line 53 of file desktopalarmwidgetkde4.cpp.

AlarmNotifications::DesktopAlarmWidgetKde4::DesktopAlarmWidgetKde4 ( const DesktopAlarmWidgetKde4 other)
delete

Copy constructor (deleted)

This class cannot be copied.

Parameters
otherAnother instance of DesktopAlarmWidgetKde4
AlarmNotifications::DesktopAlarmWidgetKde4::DesktopAlarmWidgetKde4 ( DesktopAlarmWidgetKde4 &&  other)
delete

Move constructor (C++11, deleted)

This class cannot be moved.

Parameters
otherAnother instance of DesktopAlarmWidgetKde4

Member Function Documentation

void DesktopAlarmWidgetKde4::activated ( bool  active,
const QPoint &  pos 
)
privateslot

React on click on tray icon.

This method is connected to the activateRequest signal of the KStatusNotifierItem and reacts on a click on the icon by invoking showStatusMessage() to display a message to the user.

Parameters
activeActiviation flag of the status item
posPosition of the mouse pointer at the time of the click
Returns
Nothing

Definition at line 129 of file desktopalarmwidgetkde4.cpp.

void AlarmNotifications::DesktopAlarmWidget::alarmStatusChanged ( )
signalinherited

Alarm has been triggered or acknowledged.

This signal is fired by the observeAlarmStatus() method/thread to notify derived classes about a status change.

Returns
Nothing
void DesktopAlarmWidgetKde4::changeTrayIcon ( )
privateslot

Change the tray icon due to status change.

This slot is connected to the alarmStatusChanged() signal in the constructor of this abstract base class. This method reacts on a status change by exchanging the alarm icon.

Returns
Nothing

Definition at line 121 of file desktopalarmwidgetkde4.cpp.

void DesktopAlarmWidget::configureNotificationTimeout ( )
protectedslotinherited

Change timespan between alarm trigger and notification display.

Shows a window where the user can adjust the DesktopNotificationTimeout setting (see AlarmConfiguration). Derived classes should connect this slot to the appropriate item in their context menu.

Returns
Nothing

Definition at line 107 of file desktopalarmwidget.cpp.

void DesktopAlarmWidgetKde4::createContextMenu ( )
privatevirtual

Create context menu objects.

This method is called by the constructor and creates the _contextmenu and its entries.

Returns
Nothing

Implements AlarmNotifications::DesktopAlarmWidget.

Definition at line 58 of file desktopalarmwidgetkde4.cpp.

void DesktopAlarmWidget::exitApplication ( )
protectedslotinherited

Close the desktop widget.

This tells QApplication to stop the event loop which will cause QApplication::exec() to return in the main method. It will then exit and cause the destruction of all objects, including the derived desktop widget class. Derived classes should connect this slot to the appropriate item in their context menu.

Returns
Nothing

Definition at line 182 of file desktopalarmwidget.cpp.

bool AlarmNotifications::DesktopAlarmWidget::getAlarmActive ( ) const
inlineprotectednoexceptinherited

Show alarm active flag to derived class.

Derived classes can access _alarmActive through this method. As this flag should only be changed by observeAlarmStatus(), the derived classes have read-only access.

Returns
bool

Definition at line 204 of file desktopalarmwidget.h.

bool DesktopAlarmWidgetKde4::getBeedoActivated ( )
staticprivatenoexcept

Return compile-time Beedo activation flag.

The desktop widgets can be compiled in two flavours: The standard one just using desktop notifications and the "beamtime" flavour that uses the Beedo engine to provide an opto-acoustic notification, e.g. in a control room.

This static function makes the compile-time switch "-DBEEDO" accessible.

Returns
True if Beedo engine shall be activated.

Definition at line 136 of file desktopalarmwidgetkde4.cpp.

DesktopAlarmWidget::DesktopAlarmWidgetStatus DesktopAlarmWidget::getStatus ( ) const
protectednoexceptinherited

Query alarm status.

Returns the current status so derived classes can display the correct icon.

Returns
Item of the status enum

Definition at line 74 of file desktopalarmwidget.cpp.

void DesktopAlarmWidgetKde4::notificationSwitchChange ( bool  enabled)
privateslot

React on widget enable/disable.

The constructor of this abstract base class connects this slot to the notificationSwitchChanged() signal. This method reacts on such a change by switching the icon.

Parameters
enabledNew status of the desktop alarm widget
Returns
Nothing

Definition at line 105 of file desktopalarmwidgetkde4.cpp.

void AlarmNotifications::DesktopAlarmWidget::notificationSwitchChanged ( bool  enabled)
signalinherited

Widget has been enabled or disabled.

This signal is fired by the toggleNotifications() method to inform the base classes about a switch change.

Parameters
enabledNew status of the desktop widget.
Returns
Nothing
DesktopAlarmWidgetKde4& AlarmNotifications::DesktopAlarmWidgetKde4::operator= ( const DesktopAlarmWidgetKde4 other)
delete

Copy assignment (deleted)

This class cannot be copied.

Parameters
otherAnother instance of DesktopAlarmWidgetKde4
Returns
Nothing (deleted)
DesktopAlarmWidgetKde4& AlarmNotifications::DesktopAlarmWidgetKde4::operator= ( DesktopAlarmWidgetKde4 &&  other)
delete

Move assignment (deleted)

This class cannot be moved.

Parameters
otherAnother instance of DesktopAlarmWidgetKde4
Returns
Nothing (deleted)
void DesktopAlarmWidgetKde4::setStatusIconAndTooltip ( DesktopAlarmWidget::DesktopAlarmWidgetStatus  status)
private

Adjust tray icon and tooltip message.

This method is called internally when this derived class is notified by the base class of a status change. It will load and display the proper icon for the new status and also adjust the tooltip message to tell the user about the alarm status.

Parameters
statusNew status of the alarm widget
Returns
Nothing

Definition at line 82 of file desktopalarmwidgetkde4.cpp.

void DesktopAlarmWidget::showStatusMessage ( )
protectedinherited

Show status dialog box.

Shows a message box explaining the current status of the desktop alarm widget to the user.

Returns
Nothing

Definition at line 130 of file desktopalarmwidget.cpp.

void DesktopAlarmWidget::toggleNotifications ( )
protectedslotinherited

Toggles the "main switch".

If the widget is currently active, it will disabled, and vice versa. When it is disabled, the instance of AlarmServerConnector will be destroyed and _asc set to nullptr. When it is enabled, a new instance of AlarmServerConnector will be created. Derived classes should connect this slot to the appropriate item in their context menu.

Returns
Nothing

Definition at line 91 of file desktopalarmwidget.cpp.

Member Data Documentation

QAction* AlarmNotifications::DesktopAlarmWidgetKde4::_configureAction
private

Context menu entry to configure notification timeout.

Using this action in the context menu, the user can configure the timespan between the occurence of an alarm and the display of a notification.

Definition at line 84 of file desktopalarmwidgetkde4.h.

KMenu* AlarmNotifications::DesktopAlarmWidgetKde4::_contextmenu
private

Tray icon context menu.

The menu opened by a right click on the tray icon.

Definition at line 72 of file desktopalarmwidgetkde4.h.

QAction* AlarmNotifications::DesktopAlarmWidgetKde4::_exitAction
private

Context menu entry to close the application.

Using this action in the context menu, the user can close the AlarmNotifications desktop widget.

Definition at line 90 of file desktopalarmwidgetkde4.h.

QAction* AlarmNotifications::DesktopAlarmWidgetKde4::_toggleAction
private

Context menu entry to toggle the desktop widget.

Using this action in the context menu, the user can switch notifications on and off.

Definition at line 78 of file desktopalarmwidgetkde4.h.

KStatusNotifierItem AlarmNotifications::DesktopAlarmWidgetKde4::_trayicon
private

Tray icon object.

Creates an icon in the notification area by using the new DBus-based protocotol defined by KDE.

Definition at line 66 of file desktopalarmwidgetkde4.h.


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