AlarmNotifications::DesktopAlarmWidgetQt Class Reference

Desktop widget featuring a Qt system tray icon. More...

#include <desktopalarmwidgetqt.h>

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

List of all members.

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.
void notificationSwitchChanged (bool enabled)
 Widget has been enabled or disabled.

Public Member Functions

 DesktopAlarmWidgetQt ()
 Constructor.
 ~DesktopAlarmWidgetQt ()
 Destructor.
 DesktopAlarmWidgetQt (const DesktopAlarmWidgetQt &other)
 Copy constructor (deleted).
 DesktopAlarmWidgetQt (DesktopAlarmWidgetQt &&other)
 Move constructor (C++11, deleted).
DesktopAlarmWidgetQtoperator= (const DesktopAlarmWidgetQt &other)
 Copy assignment (deleted).
DesktopAlarmWidgetQtoperator= (DesktopAlarmWidgetQt &&other)
 Move assignment (deleted).

Protected Slots

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

Protected Member Functions

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

Private Slots

void activated (const QSystemTrayIcon::ActivationReason reason)
 React on click on tray icon.
virtual void notificationSwitchChange (bool enabled)
 React on widget enable/disable.
virtual void changeTrayIcon ()
 Change the tray icon due to status change.

Private Member Functions

virtual void createContextMenu ()
 Create context menu objects.
void setStatusIcon (DesktopAlarmWidgetStatus status)
 Adjust tray icon.

Static Private Member Functions

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

Private Attributes

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

Detailed Description

Desktop widget featuring a Qt system tray icon.

This class implements the DesktopAlarmWidget interface by using a QSystemTrayIcon. This implementation should work on almost any desktop operating system supported by Qt. The main work is done in the base class, this class does only the interaction with the GUI.

Users of a recent version of KDE4 may prefer the status notifier item provided by DesktopAlarmWidgetKde4.

Definition at line 53 of file desktopalarmwidgetqt.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

DesktopAlarmWidgetQt::DesktopAlarmWidgetQt (  ) 

Constructor.

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

Definition at line 41 of file desktopalarmwidgetqt.cpp.

DesktopAlarmWidgetQt::~DesktopAlarmWidgetQt (  ) 

Destructor.

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

Definition at line 54 of file desktopalarmwidgetqt.cpp.

AlarmNotifications::DesktopAlarmWidgetQt::DesktopAlarmWidgetQt ( const DesktopAlarmWidgetQt other  ) 

Copy constructor (deleted).

This class cannot be copied.

Parameters:
other Another instance of DesktopAlarmWidgetQt
AlarmNotifications::DesktopAlarmWidgetQt::DesktopAlarmWidgetQt ( DesktopAlarmWidgetQt &&  other  ) 

Move constructor (C++11, deleted).

This class cannot be moved.

Parameters:
other Another instance of DesktopAlarmWidgetQt

Member Function Documentation

void DesktopAlarmWidgetQt::activated ( const QSystemTrayIcon::ActivationReason  reason  )  [private, slot]

React on click on tray icon.

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

Parameters:
reason Type of interaction as defined within Qt
Returns:
Nothing

Definition at line 101 of file desktopalarmwidgetqt.cpp.

void AlarmNotifications::DesktopAlarmWidget::alarmStatusChanged (  )  [signal, inherited]

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 DesktopAlarmWidgetQt::changeTrayIcon (  )  [private, virtual, slot]

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

Implements AlarmNotifications::DesktopAlarmWidget.

Definition at line 124 of file desktopalarmwidgetqt.cpp.

void DesktopAlarmWidget::configureNotificationTimeout (  )  [protected, slot, inherited]

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 DesktopAlarmWidgetQt::createContextMenu (  )  [private, virtual]

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 76 of file desktopalarmwidgetqt.cpp.

void DesktopAlarmWidget::exitApplication (  )  [protected, slot, inherited]

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 [inline, protected, inherited]

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 DesktopAlarmWidgetQt::getBeedoActivated (  )  [static, private]

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 132 of file desktopalarmwidgetqt.cpp.

DesktopAlarmWidget::DesktopAlarmWidgetStatus DesktopAlarmWidget::getStatus (  )  const [protected, inherited]

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 DesktopAlarmWidgetQt::notificationSwitchChange ( bool  enabled  )  [private, virtual, slot]

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:
enabled New status of the desktop alarm widget
Returns:
Nothing

Implements AlarmNotifications::DesktopAlarmWidget.

Definition at line 108 of file desktopalarmwidgetqt.cpp.

void AlarmNotifications::DesktopAlarmWidget::notificationSwitchChanged ( bool  enabled  )  [signal, inherited]

Widget has been enabled or disabled.

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

Parameters:
enabled New status of the desktop widget.
Returns:
Nothing
DesktopAlarmWidgetQt& AlarmNotifications::DesktopAlarmWidgetQt::operator= ( DesktopAlarmWidgetQt &&  other  ) 

Move assignment (deleted).

This class cannot be moved.

Parameters:
other Another instance of DesktopAlarmWidgetQt
Returns:
Nothing (deleted)

Reimplemented from AlarmNotifications::DesktopAlarmWidget.

DesktopAlarmWidgetQt& AlarmNotifications::DesktopAlarmWidgetQt::operator= ( const DesktopAlarmWidgetQt other  ) 

Copy assignment (deleted).

This class cannot be copied.

Parameters:
other Another instance of DesktopAlarmWidgetQt
Returns:
Nothing (deleted)

Reimplemented from AlarmNotifications::DesktopAlarmWidget.

void DesktopAlarmWidgetQt::setStatusIcon ( DesktopAlarmWidget::DesktopAlarmWidgetStatus  status  )  [private]

Adjust tray icon.

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.

Parameters:
status New status of the alarm widget
Returns:
Nothing

Definition at line 59 of file desktopalarmwidgetqt.cpp.

void DesktopAlarmWidget::showStatusMessage (  )  [protected, inherited]

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 (  )  [protected, slot, inherited]

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

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 80 of file desktopalarmwidgetqt.h.

Tray icon context menu.

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

Definition at line 68 of file desktopalarmwidgetqt.h.

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 86 of file desktopalarmwidgetqt.h.

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 74 of file desktopalarmwidgetqt.h.

Tray icon object.

Creates an icon in the sytem tray or notification area.

Definition at line 62 of file desktopalarmwidgetqt.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 2 Dec 2014 for AlarmNotifications by  doxygen 1.6.1