1 /***************************************************************************
2 ksayitsystemtray.h - description
5 copyright : (C) 2003 by Robert Vogl
6 email : voglrobe@saphir
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #ifndef KSAYITSYSTEMTRAY_H
19 #define KSAYITSYSTEMTRAY_H
25 #include <QMouseEvent>
28 #include <kapplication.h>
29 #include <ksystemtray.h>
33 #include <khelpmenu.h>
34 #include <kiconloader.h>
36 // forward declarations
42 class KSayItSystemTray
: public KSystemTray
{
48 KSayItSystemTray(QWidget
*parent
=0, const char *name
=0);
52 /** Signal emitted if configuration has been changed
54 void signalCallPreferences();
56 /** Signal emitted if the Tray icon was clicked.
58 void signalSayClipboard();
60 /** Signal emitted by the control actions
62 void signalSayActivated();
64 void signalShutUpActivated();
66 void signalPauseActivated();
68 void signalNextActivated();
70 void signalPrevActivated();
73 /** opens the Preferences-Dialog
75 void slotPreferences();
77 /** activated if "say" was clicked
79 void slotSayActivated();
81 /** activated if "shut up" was clicked
83 void slotStopActivated();
85 /** activated if "pause" was clicked
87 void slotPauseActivated();
89 /** activated if "next sentence" was clicked
91 void slotNextSentenceActivated();
93 /** activated if "previous sentence" was clicked
95 void slotPrevSentenceActivated();
98 /** Changes the state of the statemachine
100 void changeState(State
*state
);
102 /** Enables/Diasabled the actions in the menu
104 void setActions(bool sayEnabled
, bool pauseEnabled
, bool shutupEnabled
,
105 bool nextEnabled
, bool prevEnabled
);
107 protected: // Methods
108 /** Reimplementation from base class
110 void mousePressEvent(QMouseEvent
*);
112 /** Reimplementation from base class
114 void mouseReleaseEvent(QMouseEvent
*);
116 /** KSystemTray default mouse handling
118 void normalMousePressEvent(QMouseEvent
*e
);
120 /** KSystemTray default mouse handling
122 void normalMouseReleaseEvent(QMouseEvent
*e
);
124 /** Called if the Tray icon was clicked.
129 /** initializes the KActions of the application */
136 KAction
*next_sentence
;
137 KAction
*prev_sentence
;
152 class State
: public KSystemTray
{
158 virtual void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
159 virtual void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
160 virtual void setContext(KSayItSystemTray
*caller
);
163 void changeState(KSayItSystemTray
*caller
, State
*state
);
164 void say(KSayItSystemTray
*caller
);
165 void mousePressEventCall(KSayItSystemTray
*caller
, QMouseEvent
*e
);
166 void mouseReleaseEventCall(KSayItSystemTray
*caller
, QMouseEvent
*e
);
172 class StateWAIT
: public State
{
175 static StateWAIT
* Instance();
180 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
181 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
182 void setContext(KSayItSystemTray
*caller
);
185 static StateWAIT
*_instance
;
186 QPixmap m_traypixmap
;
192 class StateSAY
: public State
{
195 static StateSAY
* Instance();
200 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
201 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
202 void setContext(KSayItSystemTray
*caller
);
205 static StateSAY
*_instance
;
206 QPixmap m_traypixmap
;
212 class StateCLIPEMPTY
: public State
{
215 static StateCLIPEMPTY
* Instance();
220 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
221 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
222 void setContext(KSayItSystemTray
*caller
);
225 static StateCLIPEMPTY
*_instance
;
226 QPixmap m_traypixmap
;