Diffstat (limited to 'core/launcher/inputmethods.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/launcher/inputmethods.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 19e799a..cef16bf 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,72 +1,68 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | 23 | ||
24 | /* OPIE */ | ||
25 | #include <opie2/odebug.h> | ||
24 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
25 | #include <qtopia/qpeapplication.h> | 27 | #include <qtopia/qpeapplication.h> |
28 | using namespace Opie::Core; | ||
26 | 29 | ||
30 | /* QT */ | ||
27 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
28 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
29 | #include <qwidgetstack.h> | 33 | #include <qwidgetstack.h> |
30 | #include <qlayout.h> | 34 | #include <qlayout.h> |
31 | #include <qdir.h> | 35 | #include <qdir.h> |
32 | #include <stdlib.h> | ||
33 | #include <qtl.h> | 36 | #include <qtl.h> |
34 | |||
35 | #ifdef Q_WS_QWS | 37 | #ifdef Q_WS_QWS |
36 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
37 | #include <qwsevent_qws.h> | 39 | #include <qwsevent_qws.h> |
38 | #include <qcopchannel_qws.h> | 40 | #include <qcopchannel_qws.h> |
39 | #endif | 41 | #endif |
40 | 42 | ||
41 | /* ### SingleFloppy if someone is interested? */ | 43 | /* STD */ |
42 | #if 0 | 44 | #include <stdlib.h> |
43 | #ifdef QT_NO_COMPONENT | ||
44 | #include "../plugins/inputmethods/handwriting/handwritingimpl.h" | ||
45 | #include "../plugins/inputmethods/keyboard/keyboardimpl.h" | ||
46 | #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" | ||
47 | #endif | ||
48 | #endif | ||
49 | 45 | ||
50 | /* XPM */ | 46 | /* XPM */ |
51 | static const char * tri_xpm[]={ | 47 | static const char * tri_xpm[]={ |
52 | "9 9 2 1", | 48 | "9 9 2 1", |
53 | "a c #000000", | 49 | "a c #000000", |
54 | ". c None", | 50 | ". c None", |
55 | ".........", | 51 | ".........", |
56 | ".........", | 52 | ".........", |
57 | ".........", | 53 | ".........", |
58 | "....a....", | 54 | "....a....", |
59 | "...aaa...", | 55 | "...aaa...", |
60 | "..aaaaa..", | 56 | "..aaaaa..", |
61 | ".aaaaaaa.", | 57 | ".aaaaaaa.", |
62 | ".........", | 58 | ".........", |
63 | "........."}; | 59 | "........."}; |
64 | 60 | ||
65 | int InputMethod::operator <(const InputMethod& o) const | 61 | int InputMethod::operator <(const InputMethod& o) const |
66 | { | 62 | { |
67 | return name() < o.name(); | 63 | return name() < o.name(); |
68 | } | 64 | } |
69 | int InputMethod::operator >(const InputMethod& o) const | 65 | int InputMethod::operator >(const InputMethod& o) const |
70 | { | 66 | { |
71 | return name() > o.name(); | 67 | return name() > o.name(); |
72 | } | 68 | } |
@@ -241,98 +237,98 @@ void InputMethods::installTranslator( const QString& type ) { | |||
241 | if ( trans->load( tfn )) | 237 | if ( trans->load( tfn )) |
242 | qApp->installTranslator( trans ); | 238 | qApp->installTranslator( trans ); |
243 | else | 239 | else |
244 | delete trans; | 240 | delete trans; |
245 | } | 241 | } |
246 | } | 242 | } |
247 | 243 | ||
248 | void InputMethods::setPreferedHandlers() { | 244 | void InputMethods::setPreferedHandlers() { |
249 | Config cfg("qpe"); | 245 | Config cfg("qpe"); |
250 | cfg.setGroup("InputMethod"); | 246 | cfg.setGroup("InputMethod"); |
251 | QString current = cfg.readEntry("current"); | 247 | QString current = cfg.readEntry("current"); |
252 | QString im = cfg.readEntry("im"); | 248 | QString im = cfg.readEntry("im"); |
253 | 249 | ||
254 | QValueList<InputMethod>::Iterator it; | 250 | QValueList<InputMethod>::Iterator it; |
255 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 251 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
256 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 252 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
257 | if ( (*it).name() == im ) { | 253 | if ( (*it).name() == im ) { |
258 | imethod = &(*it); break; | 254 | imethod = &(*it); break; |
259 | } | 255 | } |
260 | 256 | ||
261 | } | 257 | } |
262 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 258 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
263 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 259 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
264 | if ( (*it).name() == current ) { | 260 | if ( (*it).name() == current ) { |
265 | qWarning("preferred keyboard is %s", current.latin1() ); | 261 | owarn << "preferred keyboard is " << current << "" << oendl; |
266 | mkeyboard = &(*it); | 262 | mkeyboard = &(*it); |
267 | kbdButton->setPixmap( *mkeyboard->icon() ); | 263 | kbdButton->setPixmap( *mkeyboard->icon() ); |
268 | break; | 264 | break; |
269 | } | 265 | } |
270 | } | 266 | } |
271 | 267 | ||
272 | } | 268 | } |
273 | 269 | ||
274 | void InputMethods::loadInputMethods() | 270 | void InputMethods::loadInputMethods() |
275 | { | 271 | { |
276 | #ifndef QT_NO_COMPONENT | 272 | #ifndef QT_NO_COMPONENT |
277 | hideInputMethod(); | 273 | hideInputMethod(); |
278 | mkeyboard = 0; | 274 | mkeyboard = 0; |
279 | 275 | ||
280 | unloadInputMethods(); | 276 | unloadInputMethods(); |
281 | 277 | ||
282 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 278 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
283 | QStringList list = plugins(); | 279 | QStringList list = plugins(); |
284 | QStringList::Iterator it; | 280 | QStringList::Iterator it; |
285 | for ( it = list.begin(); it != list.end(); ++it ) { | 281 | for ( it = list.begin(); it != list.end(); ++it ) { |
286 | InputMethodInterface *iface = 0; | 282 | InputMethodInterface *iface = 0; |
287 | ExtInputMethodInterface *eface = 0; | 283 | ExtInputMethodInterface *eface = 0; |
288 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 284 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
289 | 285 | ||
290 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 286 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
291 | InputMethod input; | 287 | InputMethod input; |
292 | input.newIM = FALSE; | 288 | input.newIM = FALSE; |
293 | input.library = lib; | 289 | input.library = lib; |
294 | input.libName = *it; | 290 | input.libName = *it; |
295 | input.interface = iface; | 291 | input.interface = iface; |
296 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 292 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
297 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 293 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
298 | inputMethodList.append( input ); | 294 | inputMethodList.append( input ); |
299 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 295 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
300 | InputMethod input; | 296 | InputMethod input; |
301 | input.newIM = TRUE; | 297 | input.newIM = TRUE; |
302 | input.library = lib; | 298 | input.library = lib; |
303 | input.libName = *it; | 299 | input.libName = *it; |
304 | input.extInterface = eface; | 300 | input.extInterface = eface; |
305 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 301 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
306 | // may be either a simple, or advanced. | 302 | // may be either a simple, or advanced. |
307 | if (input.widget) { | 303 | if (input.widget) { |
308 | //qDebug("its a keyboard"); | 304 | //odebug << "its a keyboard" << oendl; |
309 | inputMethodList.append( input ); | 305 | inputMethodList.append( input ); |
310 | } else { | 306 | } else { |
311 | //qDebug("its a real im"); | 307 | //odebug << "its a real im" << oendl; |
312 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 308 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
313 | if (input.widget) { | 309 | if (input.widget) { |
314 | //qDebug("blah"); | 310 | //odebug << "blah" << oendl; |
315 | inputModifierList.append( input ); | 311 | inputModifierList.append( input ); |
316 | imButton->addWidget(input.widget, inputModifierList.count()); | 312 | imButton->addWidget(input.widget, inputModifierList.count()); |
317 | } | 313 | } |
318 | } | 314 | } |
319 | }else{ | 315 | }else{ |
320 | delete lib; | 316 | delete lib; |
321 | lib = 0l; | 317 | lib = 0l; |
322 | } | 318 | } |
323 | installTranslator( (*it).left( (*it).find(".") ) ); | 319 | installTranslator( (*it).left( (*it).find(".") ) ); |
324 | } | 320 | } |
325 | qHeapSort( inputMethodList ); | 321 | qHeapSort( inputMethodList ); |
326 | #endif /* killed BUILT in cause they would not compile */ | 322 | #endif /* killed BUILT in cause they would not compile */ |
327 | 323 | ||
328 | QWSServer::setCurrentInputMethod( 0 ); | 324 | QWSServer::setCurrentInputMethod( 0 ); |
329 | 325 | ||
330 | /* set the prefered IM + handler */ | 326 | /* set the prefered IM + handler */ |
331 | setPreferedHandlers(); | 327 | setPreferedHandlers(); |
332 | if ( !inputModifierList.isEmpty() ) { | 328 | if ( !inputModifierList.isEmpty() ) { |
333 | if (!imethod) | 329 | if (!imethod) |
334 | imethod = &inputModifierList[0]; | 330 | imethod = &inputModifierList[0]; |
335 | imButton->raiseWidget(imethod->widget); | 331 | imButton->raiseWidget(imethod->widget); |
336 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 332 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
337 | } else { | 333 | } else { |
338 | imethod = 0; | 334 | imethod = 0; |
@@ -520,85 +516,85 @@ void InputMethods::chooseMethod(InputMethod* im) | |||
520 | 516 | ||
521 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) | 517 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) |
522 | { | 518 | { |
523 | if ( imethod && imethod->newIM ) | 519 | if ( imethod && imethod->newIM ) |
524 | imethod->extInterface->qcopReceive( msg, data ); | 520 | imethod->extInterface->qcopReceive( msg, data ); |
525 | } | 521 | } |
526 | 522 | ||
527 | 523 | ||
528 | void InputMethods::showKbd( bool on ) | 524 | void InputMethods::showKbd( bool on ) |
529 | { | 525 | { |
530 | if ( !mkeyboard ) | 526 | if ( !mkeyboard ) |
531 | return; | 527 | return; |
532 | 528 | ||
533 | if ( on ) | 529 | if ( on ) |
534 | { | 530 | { |
535 | mkeyboard->resetState(); | 531 | mkeyboard->resetState(); |
536 | 532 | ||
537 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); | 533 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); |
538 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); | 534 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); |
539 | int left = 0; | 535 | int left = 0; |
540 | int top = mapToGlobal( QPoint() ).y() - height; | 536 | int top = mapToGlobal( QPoint() ).y() - height; |
541 | 537 | ||
542 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 538 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
543 | { | 539 | { |
544 | qDebug( "InputMethods: reading geometry." ); | 540 | odebug << "InputMethods: reading geometry." << oendl; |
545 | Config cfg( "Launcher" ); | 541 | Config cfg( "Launcher" ); |
546 | cfg.setGroup( "InputMethods" ); | 542 | cfg.setGroup( "InputMethods" ); |
547 | int l = cfg.readNumEntry( "absX", -1 ); | 543 | int l = cfg.readNumEntry( "absX", -1 ); |
548 | int t = cfg.readNumEntry( "absY", -1 ); | 544 | int t = cfg.readNumEntry( "absY", -1 ); |
549 | int w = cfg.readNumEntry( "absWidth", -1 ); | 545 | int w = cfg.readNumEntry( "absWidth", -1 ); |
550 | int h = cfg.readNumEntry( "absHeight", -1 ); | 546 | int h = cfg.readNumEntry( "absHeight", -1 ); |
551 | 547 | ||
552 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) | 548 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) |
553 | { | 549 | { |
554 | qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); | 550 | odebug << "InputMethods: config values ( " << l << ", " << t << ", " << w << ", " << h << " ) are ok." << oendl; |
555 | left = l; | 551 | left = l; |
556 | top = t; | 552 | top = t; |
557 | width = w; | 553 | width = w; |
558 | height = h; | 554 | height = h; |
559 | } | 555 | } |
560 | else | 556 | else |
561 | { | 557 | { |
562 | qDebug( "InputMethods: config values are new or not ok." ); | 558 | odebug << "InputMethods: config values are new or not ok." << oendl; |
563 | } | 559 | } |
564 | } | 560 | } |
565 | else | 561 | else |
566 | { | 562 | { |
567 | qDebug( "InputMethods: no floating selected." ); | 563 | odebug << "InputMethods: no floating selected." << oendl; |
568 | } | 564 | } |
569 | mkeyboard->widget->resize( width, height ); | 565 | mkeyboard->widget->resize( width, height ); |
570 | mkeyboard->widget->move( left, top ); | 566 | mkeyboard->widget->move( left, top ); |
571 | mkeyboard->widget->show(); | 567 | mkeyboard->widget->show(); |
572 | mkeyboard->widget->installEventFilter( this ); | 568 | mkeyboard->widget->installEventFilter( this ); |
573 | } | 569 | } |
574 | else | 570 | else |
575 | { | 571 | { |
576 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 572 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
577 | { | 573 | { |
578 | QPoint pos = mkeyboard->widget->pos(); | 574 | QPoint pos = mkeyboard->widget->pos(); |
579 | QSize siz = mkeyboard->widget->size(); | 575 | QSize siz = mkeyboard->widget->size(); |
580 | qDebug( "InputMethods: saving geometry." ); | 576 | odebug << "InputMethods: saving geometry." << oendl; |
581 | Config cfg( "Launcher" ); | 577 | Config cfg( "Launcher" ); |
582 | cfg.setGroup( "InputMethods" ); | 578 | cfg.setGroup( "InputMethods" ); |
583 | cfg.writeEntry( "absX", pos.x() ); | 579 | cfg.writeEntry( "absX", pos.x() ); |
584 | cfg.writeEntry( "absY", pos.y() ); | 580 | cfg.writeEntry( "absY", pos.y() ); |
585 | cfg.writeEntry( "absWidth", siz.width() ); | 581 | cfg.writeEntry( "absWidth", siz.width() ); |
586 | cfg.writeEntry( "absHeight", siz.height() ); | 582 | cfg.writeEntry( "absHeight", siz.height() ); |
587 | cfg.write(); | 583 | cfg.write(); |
588 | mkeyboard->widget->removeEventFilter( this ); | 584 | mkeyboard->widget->removeEventFilter( this ); |
589 | } | 585 | } |
590 | mkeyboard->widget->hide(); | 586 | mkeyboard->widget->hide(); |
591 | } | 587 | } |
592 | 588 | ||
593 | emit inputToggled( on ); | 589 | emit inputToggled( on ); |
594 | } | 590 | } |
595 | 591 | ||
596 | bool InputMethods::shown() const | 592 | bool InputMethods::shown() const |
597 | { | 593 | { |
598 | return mkeyboard && mkeyboard->widget->isVisible(); | 594 | return mkeyboard && mkeyboard->widget->isVisible(); |
599 | } | 595 | } |
600 | 596 | ||
601 | QString InputMethods::currentShown() const | 597 | QString InputMethods::currentShown() const |
602 | { | 598 | { |
603 | return mkeyboard && mkeyboard->widget->isVisible() | 599 | return mkeyboard && mkeyboard->widget->isVisible() |
604 | ? mkeyboard->name() : QString::null; | 600 | ? mkeyboard->name() : QString::null; |