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
22 #include <QtGui/QWidget>
23 #include <QtGui/QPixmap>
24 #include <QtGui/QMouseEvent>
27 #include <ksystemtray.h>
31 #include <khelpmenu.h>
32 #include <kiconloader.h>
34 // forward declarations
40 class KSayItSystemTray
: public KSystemTray
{
46 KSayItSystemTray(QWidget
*parent
=0, const char *name
=0);
50 /** Signal emitted if configuration has been changed
52 void signalCallPreferences();
54 /** Signal emitted if the Tray icon was clicked.
56 void signalSayClipboard();
58 /** Signal emitted by the control actions
60 void signalSayActivated();
62 void signalShutUpActivated();
64 void signalPauseActivated();
66 void signalNextActivated();
68 void signalPrevActivated();
71 /** opens the Preferences-Dialog
73 void slotPreferences();
75 /** activated if "say" was clicked
77 void slotSayActivated();
79 /** activated if "shut up" was clicked
81 void slotStopActivated();
83 /** activated if "pause" was clicked
85 void slotPauseActivated();
87 /** activated if "next sentence" was clicked
89 void slotNextSentenceActivated();
91 /** activated if "previous sentence" was clicked
93 void slotPrevSentenceActivated();
96 /** Changes the state of the statemachine
98 void changeState(State
*state
);
100 /** Enables/Diasabled the actions in the menu
102 void setActions(bool sayEnabled
, bool pauseEnabled
, bool shutupEnabled
,
103 bool nextEnabled
, bool prevEnabled
);
105 protected: // Methods
106 /** Reimplementation from base class
108 void mousePressEvent(QMouseEvent
*);
110 /** Reimplementation from base class
112 void mouseReleaseEvent(QMouseEvent
*);
114 /** KSystemTray default mouse handling
116 void normalMousePressEvent(QMouseEvent
*e
);
118 /** KSystemTray default mouse handling
120 void normalMouseReleaseEvent(QMouseEvent
*e
);
122 /** Called if the Tray icon was clicked.
127 /** initializes the KActions of the application */
134 KAction
*next_sentence
;
135 KAction
*prev_sentence
;
150 class State
: public KSystemTray
{
156 virtual void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
157 virtual void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
158 virtual void setContext(KSayItSystemTray
*caller
);
161 void changeState(KSayItSystemTray
*caller
, State
*state
);
162 void say(KSayItSystemTray
*caller
);
163 void mousePressEventCall(KSayItSystemTray
*caller
, QMouseEvent
*e
);
164 void mouseReleaseEventCall(KSayItSystemTray
*caller
, QMouseEvent
*e
);
170 class StateWAIT
: public State
{
173 static StateWAIT
* Instance();
178 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
179 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
180 void setContext(KSayItSystemTray
*caller
);
183 static StateWAIT
*_instance
;
184 QPixmap m_traypixmap
;
190 class StateSAY
: public State
{
193 static StateSAY
* Instance();
198 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
199 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
200 void setContext(KSayItSystemTray
*caller
);
203 static StateSAY
*_instance
;
204 QPixmap m_traypixmap
;
210 class StateCLIPEMPTY
: public State
{
213 static StateCLIPEMPTY
* Instance();
218 void mousePressEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
219 void mouseReleaseEvent(KSayItSystemTray
*caller
, QMouseEvent
*e
);
220 void setContext(KSayItSystemTray
*caller
);
223 static StateCLIPEMPTY
*_instance
;
224 QPixmap m_traypixmap
;