summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp
index 9fac51b..8a8647e 100644
--- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp
+++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp
@@ -105,385 +105,385 @@ void KeyHelperWidget::receiveMessage(
105 version(); 105 version();
106 } else if(msg == "repeater(int)"){ 106 } else if(msg == "repeater(int)"){
107 int mode; 107 int mode;
108 stream >> mode; 108 stream >> mode;
109 m_pHelper->m_oRepeater.setMode(mode); 109 m_pHelper->m_oRepeater.setMode(mode);
110 } else if(msg == "hook(QString)"){ 110 } else if(msg == "hook(QString)"){
111 QString s; 111 QString s;
112 stream >> s; 112 stream >> s;
113 m_pHelper->m_oAction.setHook(s.local8Bit()); 113 m_pHelper->m_oAction.setHook(s.local8Bit());
114 } else if(msg == "unhook()"){ 114 } else if(msg == "unhook()"){
115 m_pHelper->m_oAction.setHook(""); 115 m_pHelper->m_oAction.setHook("");
116 } else if(msg == "config()"){ 116 } else if(msg == "config()"){
117 ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); 117 ConfigEx::getInstance("keyhelper").setConfig("keyhelper");
118 } else if(msg == "config(QString)"){ 118 } else if(msg == "config(QString)"){
119 QString name; 119 QString name;
120 stream >> name; 120 stream >> name;
121 if(name == QString::null){ 121 if(name == QString::null){
122 ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); 122 ConfigEx::getInstance("keyhelper").setConfig("keyhelper");
123 } else { 123 } else {
124 ConfigEx::getInstance("keyhelper").setConfig(name); 124 ConfigEx::getInstance("keyhelper").setConfig(name);
125 } 125 }
126 } else if(msg == "capture(int)"){ 126 } else if(msg == "capture(int)"){
127 int enable; 127 int enable;
128 stream >> enable; 128 stream >> enable;
129 m_pHelper->m_oAction.setCapture(enable); 129 m_pHelper->m_oAction.setCapture(enable);
130 } else if(msg == "statistics()"){ 130 } else if(msg == "statistics()"){
131 int level = g_level; 131 int level = g_level;
132 if(level == 0){ 132 if(level == 0){
133 setDebugLevel(1); 133 setDebugLevel(1);
134 } 134 }
135 m_pHelper->statistics(); 135 m_pHelper->statistics();
136 if(level == 0){ 136 if(level == 0){
137 setDebugLevel(0); 137 setDebugLevel(0);
138 } 138 }
139 } else if(msg == "dumpkeymap()"){ 139 } else if(msg == "dumpkeymap()"){
140 int level = g_level; 140 int level = g_level;
141 if(level == 0){ 141 if(level == 0){
142 setDebugLevel(1); 142 setDebugLevel(1);
143 } 143 }
144 m_pHelper->dumpkeymap(); 144 m_pHelper->dumpkeymap();
145 if(level == 0){ 145 if(level == 0){
146 setDebugLevel(0); 146 setDebugLevel(0);
147 } 147 }
148 } else if(msg == "debug(int)"){ 148 } else if(msg == "debug(int)"){
149 int level; 149 int level;
150 stream >> level; 150 stream >> level;
151 setDebugLevel(level); 151 setDebugLevel(level);
152 } 152 }
153} 153}
154 154
155void KeyHelperWidget::doReload(bool showstatus) 155void KeyHelperWidget::doReload(bool showstatus)
156{ 156{
157 ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); 157 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
158 QString oldgroup = cfg.getGroup(); 158 QString oldgroup = cfg.getGroup();
159 cfg.setGroup("Global"); 159 cfg.setGroup("Global");
160 m_status = false; 160 m_status = false;
161 if(showstatus && (cfg.readNumEntry("ShowStatusOnReload", 1) == 1)){ 161 if(showstatus && (cfg.readNumEntry("ShowStatusOnReload", 1) == 1)){
162 m_status = true; 162 m_status = true;
163 version(); 163 version();
164 QCopEnvelope("QPE/System", "busy()"); 164 QCopEnvelope("QPE/System", "busy()");
165 } 165 }
166 cfg.setGroup(oldgroup); 166 cfg.setGroup(oldgroup);
167 QTimer::singleShot(0, this, SLOT(reload())); 167 QTimer::singleShot(0, this, SLOT(reload()));
168} 168}
169 169
170void KeyHelperWidget::doEvent(int unicode, int keycode, int modifiers, int isPress, int autoRepeat) 170void KeyHelperWidget::doEvent(int unicode, int keycode, int modifiers, int isPress, int autoRepeat)
171{ 171{
172 if(isPress == 0 || isPress == 1){ 172 if(isPress == 0 || isPress == 1){
173 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, isPress, autoRepeat); 173 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, isPress, autoRepeat);
174 m_pHelper->m_oAction.doAction(); 174 m_pHelper->m_oAction.doAction();
175 } else { 175 } else {
176 /* press & release */ 176 /* press & release */
177 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 1, autoRepeat); 177 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 1, autoRepeat);
178 m_pHelper->m_oAction.doAction(); 178 m_pHelper->m_oAction.doAction();
179 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 0, autoRepeat); 179 m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 0, autoRepeat);
180 m_pHelper->m_oAction.doAction(); 180 m_pHelper->m_oAction.doAction();
181 } 181 }
182} 182}
183 183
184void KeyHelperWidget::doEvent(const QString& key, int isPress) 184void KeyHelperWidget::doEvent(const QString& key, int isPress)
185{ 185{
186 int unicode,keycode; 186 int unicode,keycode;
187 int modifiers = 0; 187 int modifiers = 0;
188 int pos; 188 int pos;
189 QString keyname = key; 189 QString keyname = key;
190 pos = keyname.find("+SHIFT", 0, FALSE); 190 pos = keyname.find("+SHIFT", 0, FALSE);
191 if(pos > 0){ 191 if(pos > 0){
192 modifiers |= Qt::ShiftButton; 192 modifiers |= Qt::ShiftButton;
193 keyname.remove(pos, 6); 193 keyname.remove(pos, 6);
194 } 194 }
195 pos = keyname.find("+CTRL", 0, FALSE); 195 pos = keyname.find("+CTRL", 0, FALSE);
196 if(pos > 0){ 196 if(pos > 0){
197 modifiers |= Qt::ControlButton; 197 modifiers |= Qt::ControlButton;
198 keyname.remove(pos, 5); 198 keyname.remove(pos, 5);
199 } 199 }
200 pos = keyname.find("+ALT", 0, FALSE); 200 pos = keyname.find("+ALT", 0, FALSE);
201 if(pos > 0){ 201 if(pos > 0){
202 modifiers |= Qt::AltButton; 202 modifiers |= Qt::AltButton;
203 keyname.remove(pos, 4); 203 keyname.remove(pos, 4);
204 } 204 }
205 if(keyname.length() > 1){ 205 if(keyname.length() > 1){
206 unicode = 0xffff; 206 unicode = 0xffff;
207 keycode = KeyNames::getCode(keyname); 207 keycode = KeyNames::getCode(keyname);
208 /* get unicode */ 208 /* get unicode */
209 const QWSServer::KeyMap* m; 209 const QWSServer::KeyMap* m;
210 for(m=QWSServer::keyMap(); m->key_code != 0; m++){ 210 for(m=QWSServer::keyMap(); m->key_code != 0; m++){
211 if(m->key_code == keycode){ 211 if(m->key_code == keycode){
212 if(modifiers & Qt::ControlButton){ 212 if(modifiers & Qt::ControlButton){
213 unicode = m->ctrl_unicode; 213 unicode = m->ctrl_unicode;
214 } else if(modifiers & Qt::ShiftButton){ 214 } else if(modifiers & Qt::ShiftButton){
215 unicode = m->shift_unicode; 215 unicode = m->shift_unicode;
216 } else { 216 } else {
217 unicode = m->unicode; 217 unicode = m->unicode;
218 } 218 }
219 break; 219 break;
220 } 220 }
221 } 221 }
222 } else { 222 } else {
223 const QWSServer::KeyMap* m; 223 const QWSServer::KeyMap* m;
224 keycode = 0; 224 keycode = 0;
225 unicode = keyname[0].unicode(); 225 unicode = keyname[0].unicode();
226 /* check unicode */ 226 /* check unicode */
227 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ 227 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){
228 if(m->unicode == unicode){ 228 if(m->unicode == unicode){
229 keycode = m->key_code; 229 keycode = m->key_code;
230 break; 230 break;
231 } 231 }
232 } 232 }
233 /* check shift_unicode */ 233 /* check shift_unicode */
234 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ 234 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){
235 if(m->shift_unicode == unicode){ 235 if(m->shift_unicode == unicode){
236 keycode = m->key_code; 236 keycode = m->key_code;
237 modifiers |= Qt::ShiftButton; 237 modifiers |= Qt::ShiftButton;
238 break; 238 break;
239 } 239 }
240 } 240 }
241 /* check ctrl_unicode */ 241 /* check ctrl_unicode */
242 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ 242 for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){
243 if(m->ctrl_unicode == unicode){ 243 if(m->ctrl_unicode == unicode){
244 keycode = m->key_code; 244 keycode = m->key_code;
245 modifiers |= Qt::ControlButton; 245 modifiers |= Qt::ControlButton;
246 break; 246 break;
247 } 247 }
248 } 248 }
249 } 249 }
250 doEvent(unicode, keycode, modifiers, isPress, 0); 250 doEvent(unicode, keycode, modifiers, isPress, 0);
251} 251}
252 252
253void KeyHelperWidget::sysMessage( 253void KeyHelperWidget::sysMessage(
254 const QCString& msg, const QByteArray& data) 254 const QCString& msg, const QByteArray& data)
255{ 255{
256 QSafeDataStream stream(data, IO_ReadOnly); 256 QSafeDataStream stream(data, IO_ReadOnly);
257 if(msg == "linkChanged(QString)"){ 257 if(msg == "linkChanged(QString)"){
258 ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); 258 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
259 QString oldgroup = cfg.getGroup(); 259 QString oldgroup = cfg.getGroup();
260 if(cfg.readNumEntry("DetectLinkChange", 1) == 1){ 260 if(cfg.readNumEntry("DetectLinkChange", 1) == 1){
261 AppLnkManager::init(true); 261 AppLnkManager::init(true);
262 reload(); 262 reload();
263 } 263 }
264 cfg.setGroup(oldgroup); 264 cfg.setGroup(oldgroup);
265 } 265 }
266} 266}
267 267
268void MsgHandler(QtMsgType type, const char* msg) 268void MsgHandler(QtMsgType type, const char* msg)
269{ 269{
270 switch(type){ 270 switch(type){
271 case QtDebugMsg: 271 case QtDebugMsg:
272 if(g_level >= 2){ 272 if(g_level >= 2){
273 syslog(LOG_LOCAL5|LOG_DEBUG, 273 syslog(LOG_LOCAL5|LOG_DEBUG,
274 "<2>%s", msg); 274 "<2>%s", msg);
275 } 275 }
276 break; 276 break;
277 case QtWarningMsg: 277 case QtWarningMsg:
278 if(g_level >= 1){ 278 if(g_level >= 1){
279 syslog(LOG_LOCAL5|LOG_DEBUG, 279 syslog(LOG_LOCAL5|LOG_DEBUG,
280 "<1>%s", msg); 280 "<1>%s", msg);
281 } 281 }
282 break; 282 break;
283 default: 283 default:
284 break; 284 break;
285 } 285 }
286} 286}
287 287
288void KeyHelperWidget::initDebugLevel() 288void KeyHelperWidget::initDebugLevel()
289{ 289{
290 ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); 290 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
291 cfg.setGroup("Global"); 291 cfg.setGroup("Global");
292 292
293 int level = cfg.readNumEntry("DebugLevel", 0); 293 int level = cfg.readNumEntry("DebugLevel", 0);
294 setDebugLevel(level); 294 setDebugLevel(level);
295} 295}
296 296
297void KeyHelperWidget::setDebugLevel(int /*level*/) 297void KeyHelperWidget::setDebugLevel(int level)
298{ 298{
299#ifdef QT_QWS_EBX 299#ifdef QT_QWS_EBX
300 static bool noDebug = true; 300 static bool noDebug = true;
301 g_level = level; 301 g_level = level;
302 if(g_level > 0){ 302 if(g_level > 0){
303 if(noDebug){ 303 if(noDebug){
304 m_defHandler = qInstallMsgHandler(MsgHandler); 304 m_defHandler = qInstallMsgHandler(MsgHandler);
305 noDebug = false; 305 noDebug = false;
306 } 306 }
307 } else { 307 } else {
308 qInstallMsgHandler(m_defHandler); 308 qInstallMsgHandler(m_defHandler);
309 noDebug = true; 309 noDebug = true;
310 } 310 }
311#endif 311#endif
312} 312}
313 313
314void KeyHelperWidget::enable() 314void KeyHelperWidget::enable()
315{ 315{
316 m_enable = true; 316 m_enable = true;
317 m_pHelper->enable(); 317 m_pHelper->enable();
318 //set(); 318 //set();
319 QTimer::singleShot(0, this, SLOT(set())); 319 QTimer::singleShot(0, this, SLOT(set()));
320} 320}
321 321
322void KeyHelperWidget::disable() 322void KeyHelperWidget::disable()
323{ 323{
324 m_enable = false; 324 m_enable = false;
325 m_pHelper->disable(); 325 m_pHelper->disable();
326 unset(); 326 unset();
327} 327}
328 328
329void KeyHelperWidget::pause() 329void KeyHelperWidget::pause()
330{ 330{
331 m_saved = m_enable; 331 m_saved = m_enable;
332 disable(); 332 disable();
333} 333}
334 334
335void KeyHelperWidget::restart() 335void KeyHelperWidget::restart()
336{ 336{
337 if(m_saved){ 337 if(m_saved){
338 enable(); 338 enable();
339 } 339 }
340} 340}
341 341
342void KeyHelperWidget::reload() 342void KeyHelperWidget::reload()
343{ 343{
344 disable(); 344 disable();
345 ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); 345 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
346 cfg.reload(); 346 cfg.reload();
347 if(m_pHelper->reload(m_xmlfile) == false){ 347 if(m_pHelper->reload(m_xmlfile) == false){
348 if(m_status){ 348 if(m_status){
349 Global::statusMessage("KeyHelper: Load Error"); 349 Global::statusMessage("KeyHelper: Load Error");
350 } 350 }
351 } 351 }
352 init(); 352 init();
353 if(m_status){ 353 if(m_status){
354 QCopEnvelope e("QPE/System", "notBusy(QString)"); 354 QCopEnvelope e("QPE/System", "notBusy(QString)");
355 const QString app = KHUtil::currentApp(); 355 const QString app = KHUtil::currentApp();
356 e << app; 356 e << app;
357 m_status = false; 357 m_status = false;
358 } 358 }
359} 359}
360 360
361void KeyHelperWidget::version() 361void KeyHelperWidget::version()
362{ 362{
363 QString ver = "KeyHelper "; 363 QString ver = "KeyHelper ";
364 ver.append(_version_); 364 ver.append(_version_);
365 Global::statusMessage(ver); 365 Global::statusMessage(ver);
366} 366}
367 367
368void KeyHelperWidget::init() 368void KeyHelperWidget::init()
369{ 369{
370 AppLnkManager::init(); 370 AppLnkManager::init();
371#if 0 371#if 0
372 if(m_pHelper == NULL){ 372 if(m_pHelper == NULL){
373 m_pHelper = new KeyHelper(); 373 m_pHelper = new KeyHelper();
374 } 374 }
375#endif 375#endif
376 loadUseFilterApps(); 376 loadUseFilterApps();
377 enable(); 377 enable();
378} 378}
379 379
380void KeyHelperWidget::set() 380void KeyHelperWidget::set()
381{ 381{
382 if(m_pHelper != NULL && m_enable == true && m_useFilter == false){ 382 if(m_pHelper != NULL && m_enable == true && m_useFilter == false){
383 qWarning("KeyHelperWidget::set()"); 383 qWarning("KeyHelperWidget::set()");
384 m_pHelper->set(); 384 m_pHelper->set();
385 } 385 }
386} 386}
387 387
388void KeyHelperWidget::unset() 388void KeyHelperWidget::unset()
389{ 389{
390 m_pHelper->unset(); 390 m_pHelper->unset();
391} 391}
392 392
393void KeyHelperWidget::loadUseFilterApps() 393void KeyHelperWidget::loadUseFilterApps()
394{ 394{
395 ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); 395 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
396 396
397 cfg.setGroup("Global"); 397 cfg.setGroup("Global");
398 m_apps = cfg.readListEntry("UseFilterApps", ','); 398 m_apps = cfg.readListEntry("UseFilterApps", ',');
399 399
400 if(m_apps.isEmpty()){ 400 if(m_apps.isEmpty()){
401 /* default */ 401 /* default */
402 m_apps.append("CRIM"); 402 m_apps.append("CRIM");
403 m_apps.append("Jpn50Pad"); 403 m_apps.append("Jpn50Pad");
404 m_apps.append("JpnKtnPad"); 404 m_apps.append("JpnKtnPad");
405 m_apps.append("JpnNumPad"); 405 m_apps.append("JpnNumPad");
406 m_apps.append("JpnSymPad"); 406 m_apps.append("JpnSymPad");
407 m_apps.append("Keyboard"); 407 m_apps.append("Keyboard");
408 m_apps.append("IMWidget"); /* IMKit */ 408 m_apps.append("IMWidget"); /* IMKit */
409 m_apps.append("POBox"); /* QPOBox */ 409 m_apps.append("POBox"); /* QPOBox */
410 } 410 }
411} 411}
412 412
413#if 0 413#if 0
414void KeyHelperWidget::windowEvent(QWSWindow* w, QWSServer::WindowEvent e) 414void KeyHelperWidget::windowEvent(QWSWindow* w, QWSServer::WindowEvent e)
415{ 415{
416 if(m_apps.contains(w->name())){ 416 if(m_apps.contains(w->name())){
417 switch(e){ 417 switch(e){
418 case QWSServer::Hide: 418 case QWSServer::Hide:
419 case QWSServer::Destroy: 419 case QWSServer::Destroy:
420 m_useFilter = false; 420 m_useFilter = false;
421 //m_reset = true; 421 //m_reset = true;
422 QTimer::singleShot(0, this, SLOT(set())); 422 QTimer::singleShot(0, this, SLOT(set()));
423 break; 423 break;
424 case QWSServer::Create: 424 case QWSServer::Create:
425 case QWSServer::Raise: 425 case QWSServer::Raise:
426 case QWSServer::Show: 426 case QWSServer::Show:
427 m_useFilter = true; 427 m_useFilter = true;
428 //m_reset = false; 428 //m_reset = false;
429 m_reset = true; 429 m_reset = true;
430 break; 430 break;
431 default: 431 default:
432 break; 432 break;
433 } 433 }
434 } else if(w->client()->identity() != NULL && w->name() != NULL){ 434 } else if(w->client()->identity() != NULL && w->name() != NULL){
435 switch(e){ 435 switch(e){
436#if 0 436#if 0
437 case QWSServer::Create: 437 case QWSServer::Create:
438 case QWSServer::Hide: 438 case QWSServer::Hide:
439 if(m_useFilter == false && m_reset){ 439 if(m_useFilter == false && m_reset){
440 m_reset = false; 440 m_reset = false;
441 set(); 441 set();
442 //QTimer::singleShot(0, this, SLOT(set())); 442 //QTimer::singleShot(0, this, SLOT(set()));
443 } 443 }
444 break; 444 break;
445#else 445#else
446 case QWSServer::Hide: 446 case QWSServer::Hide:
447 case QWSServer::Destroy: 447 case QWSServer::Destroy:
448 //if(m_useFilter == false && m_reset){ 448 //if(m_useFilter == false && m_reset){
449 if(m_reset){ 449 if(m_reset){
450 m_reset = false; 450 m_reset = false;
451 set(); 451 set();
452 //QTimer::singleShot(0, this, SLOT(set())); 452 //QTimer::singleShot(0, this, SLOT(set()));
453 } 453 }
454 break; 454 break;
455 case QWSServer::Create: 455 case QWSServer::Create:
456 case QWSServer::Raise: 456 case QWSServer::Raise:
457 case QWSServer::Show: 457 case QWSServer::Show:
458 m_reset = true; 458 m_reset = true;
459 break; 459 break;
460#endif 460#endif
461 default: 461 default:
462#if 0 462#if 0
463 if(m_reset == true){ 463 if(m_reset == true){
464 m_reset = false; 464 m_reset = false;
465 set(); 465 set();
466 } 466 }
467#endif 467#endif
468 break; 468 break;
469 } 469 }
470 } 470 }
471 if(w->name() != NULL){ 471 if(w->name() != NULL){
472 qWarning("[%s][%s][%x][%s]", 472 qWarning("[%s][%s][%x][%s]",
473 w->name().latin1(), 473 w->name().latin1(),
474 w->caption().latin1(), 474 w->caption().latin1(),
475 e, 475 e,
476 w->client()->identity().latin1()); 476 w->client()->identity().latin1());
477 } 477 }
478} 478}
479 479
480#endif 480#endif
481 481
482bool KeyHelperWidget::eventFilter(QObject* o, QEvent* e) 482bool KeyHelperWidget::eventFilter(QObject* o, QEvent* e)
483{ 483{
484 return QWidget::eventFilter(o, e); 484 return QWidget::eventFilter(o, e);
485} 485}
486 486
487int KeyHelperWidget::position() 487int KeyHelperWidget::position()
488{ 488{
489 return 3; 489 return 3;