1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/****************************************************************************
KHotKeys
Copyright (C) 1999-2001 Lubos Lunak <[email protected]>
Distributed under the terms of the GNU General Public License version 2.
****************************************************************************/
#ifndef _TRIGGERS_H_
#define _TRIGGERS_H_
#include <tqptrlist.h>
#include <tqtimer.h>
#include <tqmap.h>
#include <kdemacros.h>
#include "khotkeysglobal.h"
#include "voicesignature.h"
#include "input.h"
class TDEConfig;
namespace KHotKeys
{
class Windowdef_list;
class Action_data;
class TDE_EXPORT Trigger
{
public:
Trigger( Action_data* data_P );
Trigger( TDEConfig& cfg_P, Action_data* data_P );
virtual ~Trigger();
virtual void cfg_write( TDEConfig& cfg_P ) const = 0;
virtual Trigger* copy( Action_data* data_P ) const = 0;
virtual const TQString description() const = 0;
static Trigger* create_cfg_read( TDEConfig& cfg_P, Action_data* data_P );
virtual void activate( bool activate_P ) = 0;
protected:
Action_data* const data;
KHOTKEYS_DISABLE_COPY( Trigger );
};
class TDE_EXPORT Trigger_list
: public TQPtrList< Trigger >
{
public:
Trigger_list( const TQString& comment_P ); // CHECKME nebo i data ?
Trigger_list( TDEConfig& cfg_P, Action_data* data_P );
void activate( bool activate_P );
void cfg_write( TDEConfig& cfg_P ) const;
typedef TQPtrListIterator< Trigger > Iterator;
const TQString& comment() const;
Trigger_list* copy( Action_data* data_P ) const;
private:
TQString _comment;
KHOTKEYS_DISABLE_COPY( Trigger_list );
};
class TDE_EXPORT Shortcut_trigger
: public Trigger, public Kbd_receiver
{
typedef Trigger base;
public:
Shortcut_trigger( Action_data* data_P, const TDEShortcut& shortcut_P );
Shortcut_trigger( TDEConfig& cfg_P, Action_data* data_P );
virtual ~Shortcut_trigger();
virtual void cfg_write( TDEConfig& cfg_P ) const;
virtual Shortcut_trigger* copy( Action_data* data_P ) const;
virtual const TQString description() const;
const TDEShortcut& shortcut() const;
virtual bool handle_key( const TDEShortcut& shortcut_P );
virtual void activate( bool activate_P );
private:
TDEShortcut _shortcut;
};
class TDE_EXPORT Window_trigger
: public TQObject, public Trigger
{
TQ_OBJECT
typedef Trigger base;
public:
enum window_action_t
{
WINDOW_APPEARS = ( 1 << 0 ),
WINDOW_DISAPPEARS = ( 1 << 1 ),
WINDOW_ACTIVATES = ( 1 << 2 ),
WINDOW_DEACTIVATES = ( 1 << 3 )
};
Window_trigger( Action_data* data_P, Windowdef_list* windows_P, int window_actions_P );
Window_trigger( TDEConfig& cfg_P, Action_data* data_P );
virtual ~Window_trigger();
virtual void cfg_write( TDEConfig& cfg_P ) const;
#ifndef COVARIANT_RETURN_BROKEN // stupid gcc, it doesn't even warn it can't do this
virtual Window_trigger* copy( Action_data* data_P ) const;
#else
virtual Trigger* copy( Action_data* data_P ) const;
#endif
virtual const TQString description() const;
const Windowdef_list* windows() const;
bool triggers_on( window_action_t w_action_P ) const;
virtual void activate( bool activate_P );
protected: // CHECKME neco private ?
Windowdef_list* _windows;
int window_actions;
void init();
typedef TQMap< WId, bool > Windows_map;
Windows_map existing_windows;
WId last_active_window;
protected slots:
void window_added( WId window_P );
void window_removed( WId window_P );
void active_window_changed( WId window_P );
void window_changed( WId window_P, unsigned int dirty_P );
protected:
bool active;
};
class TDE_EXPORT Gesture_trigger
: public TQObject, public Trigger
{
TQ_OBJECT
typedef Trigger base;
public:
Gesture_trigger( Action_data* data_P, const TQString& gesture_P );
Gesture_trigger( TDEConfig& cfg_P, Action_data* data_P );
virtual ~Gesture_trigger();
virtual void cfg_write( TDEConfig& cfg_P ) const;
virtual Trigger* copy( Action_data* data_P ) const;
virtual const TQString description() const;
const TQString& gesturecode() const;
virtual void activate( bool activate_P );
protected slots:
void handle_gesture( const TQString& gesture_P, WId window_P );
private:
TQString _gesturecode;
};
class TDE_EXPORT Voice_trigger
: public TQObject, public Trigger
{
TQ_OBJECT
typedef Trigger base;
public:
Voice_trigger( Action_data* data_P, const TQString& Voice_P, const VoiceSignature & signature1_P, const VoiceSignature & signature2_P );
Voice_trigger( TDEConfig& cfg_P, Action_data* data_P );
virtual ~Voice_trigger();
virtual void cfg_write( TDEConfig& cfg_P ) const;
virtual Trigger* copy( Action_data* data_P ) const;
virtual const TQString description() const;
const TQString& voicecode() const;
virtual void activate( bool activate_P );
VoiceSignature voicesignature( int ech ) const;
public slots:
void handle_Voice( );
private:
TQString _voicecode;
VoiceSignature _voicesignature[2];
};
//***************************************************************************
// Inline
//***************************************************************************
// Trigger
inline
Trigger::Trigger( Action_data* data_P )
: data( data_P )
{
}
inline
Trigger::Trigger( TDEConfig&, Action_data* data_P )
: data( data_P )
{
}
inline
Trigger::~Trigger()
{
}
// Trigger_list
inline
Trigger_list::Trigger_list( const TQString& comment_P )
: TQPtrList< Trigger >(), _comment( comment_P )
{
setAutoDelete( true );
}
inline
const TQString& Trigger_list::comment() const
{
return _comment;
}
// Shortcut_trigger
inline
const TDEShortcut& Shortcut_trigger::shortcut() const
{
return _shortcut;
}
// Window_trigger
inline
Window_trigger::Window_trigger( Action_data* data_P, Windowdef_list* windows_P,
int window_actions_P )
: Trigger( data_P ), _windows( windows_P ), window_actions( window_actions_P ),
last_active_window( None ), active( false )
{
init();
}
inline
const Windowdef_list* Window_trigger::windows() const
{
return _windows;
}
inline
bool Window_trigger::triggers_on( window_action_t w_action_P ) const
{
return window_actions & w_action_P;
}
// Gesture_trigger
inline
const TQString& Gesture_trigger::gesturecode() const
{
return _gesturecode;
}
// Voice_trigger
inline
const TQString& Voice_trigger::voicecode() const
{
return _voicecode;
}
inline
VoiceSignature Voice_trigger::voicesignature(int ech) const
{
return _voicesignature[ech-1];
}
} // namespace KHotKeys
#endif
|