forked from Raffarti/Touchegg-gce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists.cpp
418 lines (394 loc) · 12.3 KB
/
lists.cpp
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/**
*This work is licensed under the
*Creative Commons Attribuzione 3.0
*Unported License. To view a copy
*of this license, visit
*http://creativecommons.org/licenses/by/3.0/
*
*Please note that this is not Touchégg nor Touchégg-gui,
*which author is José Expósito <[email protected]>.
*This is a gui interface to edit
*Touchégg configuration file alternative to Touchégg-gui.
*
*@author Raffaele Pertile <[email protected]>
*/
#include "lists.h"
Lists::Lists(QObject *parent) :
QObject(parent){}
//this class is an extremly boring one, just don't look at it.
QString* Lists::toString(ActionType t){
switch(t){
case (NO_ACTION):
return new QString(tr("No Action"));
case (MOUSE_CLICK):
return new QString(tr("Mouse Click"));
case (SCROLL):
return new QString(tr("Scroll"));
case (MINIMIZE_WINDOW):
return new QString(tr("Minimize"));
case (MAXIMIZE_RESTORE_WINDOW):
return new QString(tr("Maximize"));
case (CLOSE_WINDOW):
return new QString(tr("Close"));
case (RESIZE_WINDOW):
return new QString(tr("Resize"));
case (SHOW_DESKTOP):
return new QString(tr("Show Desktop"));
case (CHANGE_DESKTOP):
return new QString(tr("Change Desktop"));
case (CHANGE_VIEWPORT):
return new QString(tr("Change Viewport"));
case (SEND_KEYS):
return new QString(tr("Send Keys"));
case (MOVE_WINDOW):
return new QString(tr("Move Window"));
case (RUN_COMMAND):
return new QString(tr("Run Command"));
case (DRAG_AND_DROP):
return new QString(tr("Drag&Drop"));
}
return NULL;
}
QString* Lists::toString(GestureType t){
switch(t){
case (TAP):
return new QString(tr("Tap"));
case (DRAG):
return new QString(tr("Drag"));
case (PINCH):
return new QString(tr("Pinch"));
case (ROTATE):
return new QString(tr("Rotate"));
case (TAP_AND_HOLD):
return new QString(tr("Tap&Hold"));
case (DOUBLE_TAP):
return new QString(tr("DoubleTap"));
}
return NULL;
}
QString* Lists::toString(GestureDirection t){
switch(t){
case (NO_DIRECTION):
return new QString("");
case (ALL):
return new QString(tr("All"));
case (UP):
return new QString(tr("Up"));
case (DOWN):
return new QString(tr("Down"));
case (LEFT):
return new QString(tr("Left"));
case (RIGHT):
return new QString(tr("Right"));
case (IN):
return new QString(tr("Inward"));
case (OUT):
return new QString(tr("Outward"));
}
return NULL;
}
QStringList* Lists::actionList(){
QStringList *ret = new QStringList();
for (int i = 0; toString((ActionType)i);i++)
ret->append(*toString((ActionType)i));
return ret;
}
QStringList* Lists::gestureTypes(){
QStringList *ret = new QStringList();
for (int i = 0; toString((GestureType)i);i++)
ret->append(*toString((GestureType)i));
return ret;
}
QStringList* Lists::gestureDirections(GestureType type){
QStringList *ret = new QStringList();
for (int i = 0; toString((GestureDirection)i);i++)
if(got(type,(GestureDirection)i))ret->append(*toString((GestureDirection)i));
return ret;
}
Lists::ActionType Lists::toAT(QString s){
if (s == tr("No Action"))
return NO_ACTION;
else if (s == tr("Mouse Click"))
return MOUSE_CLICK;
else if (s == tr("Scroll"))
return SCROLL;
else if (s == tr("Minimize"))
return MINIMIZE_WINDOW;
else if (s == tr("Maximize"))
return MAXIMIZE_RESTORE_WINDOW;
else if (s == tr("Close"))
return CLOSE_WINDOW;
else if (s == tr("Resize"))
return RESIZE_WINDOW;
else if (s == tr("Show Desktop"))
return SHOW_DESKTOP;
else if (s == tr("Change Desktop"))
return CHANGE_DESKTOP;
else if (s == tr("Change Viewport"))
return CHANGE_VIEWPORT;
else if (s == tr("Send Keys"))
return SEND_KEYS;
else if (s == tr("Move Window"))
return MOVE_WINDOW;
else if (s == tr("Run Command"))
return RUN_COMMAND;
else if (s == tr("Drag&Drop"))
return DRAG_AND_DROP;
qDebug(QString("toAT: String \"").append(s).append("\" not reconized.").toAscii());
return NO_ACTION;
}
Lists::GestureType Lists::gT(QString s){
if (s == "TAP")
return TAP;
else if (s == "DRAG")
return DRAG;
else if (s == "PINCH")
return PINCH;
else if (s == "ROTATE")
return ROTATE;
else if (s == "TAP_AND_HOLD")
return TAP_AND_HOLD;
else if (s == "DOUBLE_TAP")
return DOUBLE_TAP;
qDebug(QString("gT: TAG \"").append(s).append("\" not reconized.").toAscii());
return (GestureType)-1;
}
Lists::GestureDirection Lists::toGD(QString s){
if (s == "")
return NO_DIRECTION;
else if (s == tr("All"))
return ALL;
else if (s == tr("Up"))
return UP;
else if (s == tr("Down"))
return DOWN;
else if (s == tr("Left"))
return LEFT;
else if (s == tr("Right"))
return RIGHT;
else if (s == tr("Inward"))
return IN;
else if (s == tr("Outward"))
return OUT;
qDebug(QString("toGD: String \"").append(s).append("\" not reconized.").toAscii());
return (GestureDirection)-1;
}
Lists::GestureDirection Lists::gD(QString s){
if (s == "")
return NO_DIRECTION;
else if (s == "ALL")
return ALL;
else if (s == "UP")
return UP;
else if (s == "DOWN")
return DOWN;
else if (s == "LEFT")
return LEFT;
else if (s == "RIGHT")
return RIGHT;
else if (s == "IN")
return IN;
else if (s == "OUT")
return (OUT);
qDebug(QString("gD: String \"").append(s).append("\" not reconized.").toAscii());
return (GestureDirection)-1;
}
Lists::GestureType Lists::toGT(QString s){
if (s == tr("Tap"))
return TAP;
else if (s == tr("Drag"))
return DRAG;
else if (s == tr("Pinch"))
return PINCH;
else if (s == tr("Rotate"))
return ROTATE;
else if (s == tr("Tap&Hold"))
return TAP_AND_HOLD;
else if (s == tr("DoubleTap"))
return DOUBLE_TAP;
qDebug(QString("toGT: String \"").append(s).append("\" not reconized.").toAscii());
return (GestureType)-1;
}
Lists::ActionType Lists::aT(QString s){
if (s == "NO_ACTION")
return NO_ACTION;
else if (s == "MOUSE_CLICK")
return MOUSE_CLICK;
else if (s == "SCROLL")
return SCROLL;
else if (s == "MINIMIZE_WINDOW")
return MINIMIZE_WINDOW;
else if (s == "MAXIMIZE_RESTORE_WINDOW")
return MAXIMIZE_RESTORE_WINDOW;
else if (s == "CLOSE_WINDOW")
return CLOSE_WINDOW;
else if (s == "RESIZE_WINDOW")
return RESIZE_WINDOW;
else if (s == "SHOW_DESKTOP")
return SHOW_DESKTOP;
else if (s == "CHANGE_DESKTOP")
return CHANGE_DESKTOP;
else if (s == "CHANGE_VIEWPORT")
return CHANGE_VIEWPORT;
else if (s == "SEND_KEYS")
return SEND_KEYS;
else if (s == "MOVE_WINDOW")
return MOVE_WINDOW;
else if (s == "RUN_COMMAND")
return RUN_COMMAND;
else if (s == "DRAG_AND_DROP")
return DRAG_AND_DROP;
qDebug(QString("aT: TAG \"").append(s).append("\" not reconized.").toAscii());
return (ActionType)-1;
}
QString Lists::trnAT(QString s){
if (s == "NO_ACTION")
return *toString(NO_ACTION);
else if (s == "MOUSE_CLICK")
return *toString(MOUSE_CLICK);
else if (s == "SCROLL")
return *toString(SCROLL);
else if (s == "MINIMIZE_WINDOW")
return *toString(MINIMIZE_WINDOW);
else if (s == "MAXIMIZE_RESTORE_WINDOW")
return *toString(MAXIMIZE_RESTORE_WINDOW);
else if (s == "CLOSE_WINDOW")
return *toString(CLOSE_WINDOW);
else if (s == "RESIZE_WINDOW")
return *toString(RESIZE_WINDOW);
else if (s == "SHOW_DESKTOP")
return *toString(SHOW_DESKTOP);
else if (s == "CHANGE_DESKTOP")
return *toString(CHANGE_DESKTOP);
else if (s == "CHANGE_VIEWPORT")
return *toString(CHANGE_VIEWPORT);
else if (s == "SEND_KEYS")
return *toString(SEND_KEYS);
else if (s == "MOVE_WINDOW")
return *toString(MOVE_WINDOW);
else if (s == "RUN_COMMAND")
return *toString(RUN_COMMAND);
else if (s == "DRAG_AND_DROP")
return *toString(DRAG_AND_DROP);
qDebug(QString("trnAT: TAG \"").append(s).append("\" not reconized.").toAscii());
return *toString(NO_ACTION);
}
QString Lists::trnGT(QString s){
if (s == "TAP")
return *toString(TAP);
else if (s == "DRAG")
return *toString(DRAG);
else if (s == "PINCH")
return *toString(PINCH);
else if (s == "ROTATE")
return *toString(ROTATE);
else if (s == "TAP_AND_HOLD")
return *toString(TAP_AND_HOLD);
else if (s == "DOUBLE_TAP")
return *toString(DOUBLE_TAP);
qDebug(QString("trnGT: TAG \"").append(s).append("\" not reconized.").toAscii());
return NULL;
}
QString Lists::trnGD(QString s){
if (s == "")
return *toString(NO_DIRECTION);
else if (s == "ALL")
return *toString(ALL);
else if (s == "DOWN")
return *toString(DOWN);
else if (s == "UP")
return *toString(UP);
else if (s == "LEFT")
return *toString(LEFT);
else if (s == "RIGHT")
return *toString(RIGHT);
else if (s == "IN")
return *toString(IN);
else if (s == "OUT")
return *toString(OUT);
qDebug(QString("trnGD: TAG \"").append(s).append("\" not reconized.").toAscii());
return NULL;
}
bool Lists::got(GestureType type, GestureDirection dir){
switch(type){
case TAP:;
case DOUBLE_TAP: return dir == NO_DIRECTION;
case PINCH: return dir == ALL || dir == IN || dir == OUT;
case ROTATE: return dir == ALL || dir == LEFT || dir == RIGHT;
case TAP_AND_HOLD:;
case DRAG: return dir == ALL || dir == LEFT || dir == RIGHT || dir == UP || dir == DOWN;
default: return false;
}
return false;
}
QString* Lists::printTag(ActionType t){
switch(t){
case (NO_ACTION):
return new QString("NO_ACTION");
case (MOUSE_CLICK):
return new QString("MOUSE_CLICK");
case (SCROLL):
return new QString("SCROLL");
case (MINIMIZE_WINDOW):
return new QString("MINIMIZE_WINDOW");
case (MAXIMIZE_RESTORE_WINDOW):
return new QString("MAXIMIZE_RESTORE_WINDOW");
case (CLOSE_WINDOW):
return new QString("CLOSE_WINDOW");
case (RESIZE_WINDOW):
return new QString("RESIZE_WINDOW");
case (SHOW_DESKTOP):
return new QString("SHOW_DESKTOP");
case (CHANGE_DESKTOP):
return new QString("CHANGE_DESKTOP");
case (CHANGE_VIEWPORT):
return new QString("CHANGE_VIEWPORT");
case (SEND_KEYS):
return new QString("SEND_KEYS");
case (MOVE_WINDOW):
return new QString("MOVE_WINDOW");
case (RUN_COMMAND):
return new QString("RUN_COMMAND");
case (DRAG_AND_DROP):
return new QString("DRAG_AND_DROP");
}
return NULL;
}
QString* Lists::printTag(GestureType t){
switch(t){
case (TAP):
return new QString("TAP");
case (DRAG):
return new QString("DRAG");
case (PINCH):
return new QString("PINCH");
case (ROTATE):
return new QString("ROTATE");
case (TAP_AND_HOLD):
return new QString("TAP_AND_HOLD");
case (DOUBLE_TAP):
return new QString("DOUBLE_TAP");
}
return NULL;
}
QString* Lists::printTag(GestureDirection t){
switch(t){
case (NO_DIRECTION):
return new QString("");
case (ALL):
return new QString("ALL");
case (UP):
return new QString("UP");
case (DOWN):
return new QString("DOWN");
case (LEFT):
return new QString("LEFT");
case (RIGHT):
return new QString("RIGHT");
case (IN):
return new QString("IN");
case (OUT):
return new QString("OUT");
}
return NULL;
}