AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
desktopalarmwidgetkde4.cpp
Go to the documentation of this file.
1 
34 #include "desktopalarmwidgetkde4.h"
35 
36 using namespace AlarmNotifications;
37 
39  : DesktopAlarmWidget ( getBeedoActivated() ),
40  _trayicon ( QString::fromUtf8 ( "AlarmNotificationsStatus" ), this ),
41  _contextmenu ( nullptr )
42 {
43  _trayicon.setStandardActionsEnabled ( false );
44  _trayicon.setAssociatedWidget ( nullptr );
45  _trayicon.setCategory ( KStatusNotifierItem::SystemServices );
46  _trayicon.setTitle ( QString::fromUtf8 ( "AlarmNotifications Desktop Widget" ) );
49 
50  connect ( &_trayicon, SIGNAL ( activateRequested ( bool,QPoint ) ), this, SLOT ( activated ( bool,QPoint ) ) );
51 }
52 
54 {
55 
56 }
57 
59 {
60  _contextmenu = new KMenu ( QString::fromUtf8 ( "Desktop Alarm Notifications" ), nullptr );
61  _toggleAction = _contextmenu->addAction (
62  QIcon::fromTheme ( QString::fromUtf8 ( "dialog-cancel" ) ),
63  QString::fromUtf8 ( "Disable &notifications" ),
64  this,
65  SLOT ( toggleNotifications() )
66  );
67  _configureAction = _contextmenu->addAction (
68  QIcon::fromTheme ( QString::fromUtf8 ( "configure" ) ),
69  QString::fromUtf8 ( "&Configure notification timeout" ),
70  this,
72  );
73  _exitAction = _contextmenu->addAction (
74  QIcon::fromTheme ( QString::fromUtf8 ( "application-exit" ) ),
75  QString::fromUtf8 ( "&Exit desktop alarm widget" ),
76  this,
77  SLOT ( exitApplication() )
78  );
79  _trayicon.setContextMenu ( _contextmenu );
80 }
81 
83 {
84  switch ( status )
85  {
86  case ActiveOK:
87  _trayicon.setIconByName ( QString::fromUtf8 ( "help-feedback" ) );
88  _trayicon.setStatus ( KStatusNotifierItem::Passive );
89  _trayicon.setToolTip ( QString::fromUtf8 ( "help-feedback" ), QString::fromUtf8 ( "AlarmNotifications Desktop Widget" ), QString::fromUtf8 ( "No active alarm in the Detector Control System." ) );
90  break;
91  case ActiveAlarm:
92  _trayicon.setIconByName ( QString::fromUtf8 ( "dialog-warning" ) );
93  _trayicon.setStatus ( KStatusNotifierItem::NeedsAttention );
94  _trayicon.setToolTip ( QString::fromUtf8 ( "dialog-warning" ), QString::fromUtf8 ( "AlarmNotifications Desktop Widget" ), QString::fromUtf8 ( "ATTENTION! There are active alarms in the Detector Control System!" ) );
95  break;
96  case Disabled:
97  default:
98  _trayicon.setIconByName ( QString::fromUtf8 ( "face-plain" ) );
99  _trayicon.setStatus ( KStatusNotifierItem::Active );
100  _trayicon.setToolTip ( QString::fromUtf8 ( "face-plain" ), QString::fromUtf8 ( "AlarmNotifications Desktop Widget" ), QString::fromUtf8 ( "Alarm notifications disabled!" ) );
101  break;
102  }
103 }
104 
106 {
107  if ( enabled )
108  {
109  _toggleAction->setIcon ( QIcon::fromTheme ( QString::fromUtf8 ( "dialog-cancel" ) ) );
110  _toggleAction->setText ( QString::fromUtf8 ( "Disable &notifications" ) );
111  setStatusIconAndTooltip ( ActiveOK ); // The newly generated AlarmServerConnector will have zero alarms...
112  }
113  else
114  {
115  _toggleAction->setIcon ( QIcon::fromTheme ( QString::fromUtf8 ( "dialog-ok-apply" ) ) );
116  _toggleAction->setText ( QString::fromUtf8 ( "Enable &notifications" ) );
118  }
119 }
120 
122 {
123  if ( getAlarmActive() )
125  else
127 }
128 
129 void DesktopAlarmWidgetKde4::activated ( bool active, const QPoint& posparameter )
130 {
131  Q_UNUSED ( active )
132  Q_UNUSED ( posparameter )
134 }
135 
137 {
138 #ifndef BEEDO
139  return false;
140 #else
141  return true;
142 #endif
143 }
144 
145 #include "desktopalarmwidgetkde4.moc"
void exitApplication()
Close the desktop widget.
KStatusNotifierItem _trayicon
Tray icon object.
void configureNotificationTimeout()
Change timespan between alarm trigger and notification display.
void setStatusIconAndTooltip(DesktopAlarmWidgetStatus status)
Adjust tray icon and tooltip message.
DesktopAlarmWidgetStatus
Status of the desktop widget.
void toggleNotifications()
Toggles the "main switch".
#define nullptr
Allow using the nullptr keyword with GCC < 4.6.
Definition: oldgcccompat.h:56
QAction * _toggleAction
Context menu entry to toggle the desktop widget.
Abstract base class for desktop alarm widgets.
QAction * _exitAction
Context menu entry to close the application.
KMenu * _contextmenu
Tray icon context menu.
void activated(bool active, const QPoint &pos)
React on click on tray icon.
bool getAlarmActive() const noexcept
Show alarm active flag to derived class.
void showStatusMessage()
Show status dialog box.
Implementation if DesktopAlarmWidget for KStatusNotifierItem (KDE4 Plasma Workspaces) ...
QAction * _configureAction
Context menu entry to configure notification timeout.
Namespace for Alarm Notifications application.
static bool getBeedoActivated() noexcept
Return compile-time Beedo activation flag.
virtual void createContextMenu()
Create context menu objects.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
Definition: oldgcccompat.h:52
void changeTrayIcon()
Change the tray icon due to status change.
void notificationSwitchChange(bool enabled)
React on widget enable/disable.