-rw-r--r-- | core/launcher/inputmethods.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index cef16bf..a0e8939 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,411 +1,412 @@ | |||
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 */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <qtopia/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qtopia/qpeapplication.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/qpeapplication.h> | ||
28 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
29 | 30 | ||
30 | /* QT */ | 31 | /* QT */ |
31 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
32 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
33 | #include <qwidgetstack.h> | 34 | #include <qwidgetstack.h> |
34 | #include <qlayout.h> | 35 | #include <qlayout.h> |
35 | #include <qdir.h> | 36 | #include <qdir.h> |
36 | #include <qtl.h> | 37 | #include <qtl.h> |
37 | #ifdef Q_WS_QWS | 38 | #ifdef Q_WS_QWS |
38 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
39 | #include <qwsevent_qws.h> | 40 | #include <qwsevent_qws.h> |
40 | #include <qcopchannel_qws.h> | 41 | #include <qcopchannel_qws.h> |
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | /* STD */ | 44 | /* STD */ |
44 | #include <stdlib.h> | 45 | #include <stdlib.h> |
45 | 46 | ||
46 | /* XPM */ | 47 | /* XPM */ |
47 | static const char * tri_xpm[]={ | 48 | static const char * tri_xpm[]={ |
48 | "9 9 2 1", | 49 | "9 9 2 1", |
49 | "a c #000000", | 50 | "a c #000000", |
50 | ". c None", | 51 | ". c None", |
51 | ".........", | 52 | ".........", |
52 | ".........", | 53 | ".........", |
53 | ".........", | 54 | ".........", |
54 | "....a....", | 55 | "....a....", |
55 | "...aaa...", | 56 | "...aaa...", |
56 | "..aaaaa..", | 57 | "..aaaaa..", |
57 | ".aaaaaaa.", | 58 | ".aaaaaaa.", |
58 | ".........", | 59 | ".........", |
59 | "........."}; | 60 | "........."}; |
60 | 61 | ||
61 | int InputMethod::operator <(const InputMethod& o) const | 62 | int InputMethod::operator <(const InputMethod& o) const |
62 | { | 63 | { |
63 | return name() < o.name(); | 64 | return name() < o.name(); |
64 | } | 65 | } |
65 | int InputMethod::operator >(const InputMethod& o) const | 66 | int InputMethod::operator >(const InputMethod& o) const |
66 | { | 67 | { |
67 | return name() > o.name(); | 68 | return name() > o.name(); |
68 | } | 69 | } |
69 | int InputMethod::operator <=(const InputMethod& o) const | 70 | int InputMethod::operator <=(const InputMethod& o) const |
70 | { | 71 | { |
71 | return name() <= o.name(); | 72 | return name() <= o.name(); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
75 | /* | 76 | /* |
76 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget | 77 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget |
77 | belongs to the IM system, so clicking it should not cause a reset". | 78 | belongs to the IM system, so clicking it should not cause a reset". |
78 | */ | 79 | */ |
79 | class IMToolButton : public QToolButton | 80 | class IMToolButton : public QToolButton |
80 | { | 81 | { |
81 | public: | 82 | public: |
82 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) | 83 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) |
83 | { setWFlags( WStyle_Tool ); } | 84 | { setWFlags( WStyle_Tool ); } |
84 | }; | 85 | }; |
85 | 86 | ||
86 | 87 | ||
87 | InputMethods::InputMethods( QWidget *parent ) : | 88 | InputMethods::InputMethods( QWidget *parent ) : |
88 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 89 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
89 | mkeyboard(0), imethod(0) | 90 | mkeyboard(0), imethod(0) |
90 | { | 91 | { |
91 | Config cfg( "Launcher" ); | 92 | Config cfg( "Launcher" ); |
92 | cfg.setGroup( "InputMethods" ); | 93 | cfg.setGroup( "InputMethods" ); |
93 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; | 94 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; |
94 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; | 95 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; |
95 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | 96 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); |
96 | 97 | ||
97 | setBackgroundMode( PaletteBackground ); | 98 | setBackgroundMode( PaletteBackground ); |
98 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 99 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
99 | 100 | ||
100 | kbdButton = new IMToolButton( this); | 101 | kbdButton = new IMToolButton( this); |
101 | kbdButton->setFocusPolicy(NoFocus); | 102 | kbdButton->setFocusPolicy(NoFocus); |
102 | kbdButton->setToggleButton( TRUE ); | 103 | kbdButton->setToggleButton( TRUE ); |
103 | if (parent->sizeHint().height() > 0) | 104 | if (parent->sizeHint().height() > 0) |
104 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 105 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
105 | kbdButton->setFixedWidth( 32 ); | 106 | kbdButton->setFixedWidth( 32 ); |
106 | kbdButton->setAutoRaise( TRUE ); | 107 | kbdButton->setAutoRaise( TRUE ); |
107 | kbdButton->setUsesBigPixmap( TRUE ); | 108 | kbdButton->setUsesBigPixmap( TRUE ); |
108 | hbox->addWidget( kbdButton ); | 109 | hbox->addWidget( kbdButton ); |
109 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 110 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
110 | 111 | ||
111 | kbdChoice = new IMToolButton( this ); | 112 | kbdChoice = new IMToolButton( this ); |
112 | kbdChoice->setFocusPolicy(NoFocus); | 113 | kbdChoice->setFocusPolicy(NoFocus); |
113 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 114 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
114 | if (parent->sizeHint().height() > 0) | 115 | if (parent->sizeHint().height() > 0) |
115 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 116 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
116 | kbdChoice->setFixedWidth( 13 ); | 117 | kbdChoice->setFixedWidth( 13 ); |
117 | kbdChoice->setAutoRaise( TRUE ); | 118 | kbdChoice->setAutoRaise( TRUE ); |
118 | hbox->addWidget( kbdChoice ); | 119 | hbox->addWidget( kbdChoice ); |
119 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 120 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
120 | 121 | ||
121 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 122 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
122 | this, SLOT(resetStates()) ); | 123 | this, SLOT(resetStates()) ); |
123 | 124 | ||
124 | 125 | ||
125 | imButton = new QWidgetStack( this ); // later a widget stack | 126 | imButton = new QWidgetStack( this ); // later a widget stack |
126 | imButton->setFocusPolicy(NoFocus); | 127 | imButton->setFocusPolicy(NoFocus); |
127 | if (parent->sizeHint().height() > 0) | 128 | if (parent->sizeHint().height() > 0) |
128 | imButton->setFixedHeight( parent->sizeHint().height() ); | 129 | imButton->setFixedHeight( parent->sizeHint().height() ); |
129 | hbox->addWidget(imButton); | 130 | hbox->addWidget(imButton); |
130 | 131 | ||
131 | imChoice = new QToolButton( this ); | 132 | imChoice = new QToolButton( this ); |
132 | imChoice->setFocusPolicy(NoFocus); | 133 | imChoice->setFocusPolicy(NoFocus); |
133 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
134 | if (parent->sizeHint().height() > 0) | 135 | if (parent->sizeHint().height() > 0) |
135 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 136 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
136 | imChoice->setFixedWidth( 13 ); | 137 | imChoice->setFixedWidth( 13 ); |
137 | imChoice->setAutoRaise( TRUE ); | 138 | imChoice->setAutoRaise( TRUE ); |
138 | hbox->addWidget( imChoice ); | 139 | hbox->addWidget( imChoice ); |
139 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
140 | 141 | ||
141 | loadInputMethods(); | 142 | loadInputMethods(); |
142 | 143 | ||
143 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
144 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
145 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); | 146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
146 | } | 147 | } |
147 | 148 | ||
148 | InputMethods::~InputMethods() | 149 | InputMethods::~InputMethods() |
149 | { | 150 | { |
150 | Config cfg("qpe"); | 151 | Config cfg("qpe"); |
151 | cfg.setGroup("InputMethod"); | 152 | cfg.setGroup("InputMethod"); |
152 | if (imethod) | 153 | if (imethod) |
153 | cfg.writeEntry("im", imethod->name() ); | 154 | cfg.writeEntry("im", imethod->name() ); |
154 | if (mkeyboard) | 155 | if (mkeyboard) |
155 | cfg.writeEntry("current", mkeyboard->name() ); | 156 | cfg.writeEntry("current", mkeyboard->name() ); |
156 | 157 | ||
157 | unloadInputMethods(); | 158 | unloadInputMethods(); |
158 | } | 159 | } |
159 | 160 | ||
160 | void InputMethods::hideInputMethod() | 161 | void InputMethods::hideInputMethod() |
161 | { | 162 | { |
162 | kbdButton->setOn( FALSE ); | 163 | kbdButton->setOn( FALSE ); |
163 | } | 164 | } |
164 | 165 | ||
165 | void InputMethods::showInputMethod() | 166 | void InputMethods::showInputMethod() |
166 | { | 167 | { |
167 | kbdButton->setOn( TRUE ); | 168 | kbdButton->setOn( TRUE ); |
168 | } | 169 | } |
169 | 170 | ||
170 | void InputMethods::showInputMethod(const QString& name) | 171 | void InputMethods::showInputMethod(const QString& name) |
171 | { | 172 | { |
172 | int i = 0; | 173 | int i = 0; |
173 | QValueList<InputMethod>::Iterator it; | 174 | QValueList<InputMethod>::Iterator it; |
174 | InputMethod *im = 0; | 175 | InputMethod *im = 0; |
175 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
176 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
177 | if ( (*it).name() == name || lname == name ) { | 178 | if ( (*it).name() == name || lname == name ) { |
178 | im = &(*it); | 179 | im = &(*it); |
179 | break; | 180 | break; |
180 | } | 181 | } |
181 | } | 182 | } |
182 | if ( im ) | 183 | if ( im ) |
183 | chooseKeyboard(im); | 184 | chooseKeyboard(im); |
184 | } | 185 | } |
185 | 186 | ||
186 | void InputMethods::resetStates() | 187 | void InputMethods::resetStates() |
187 | { | 188 | { |
188 | if ( mkeyboard && !mkeyboard->newIM ) | 189 | if ( mkeyboard && !mkeyboard->newIM ) |
189 | mkeyboard->interface->resetState(); | 190 | mkeyboard->interface->resetState(); |
190 | } | 191 | } |
191 | 192 | ||
192 | QRect InputMethods::inputRect() const | 193 | QRect InputMethods::inputRect() const |
193 | { | 194 | { |
194 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 195 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
195 | return QRect(); | 196 | return QRect(); |
196 | else | 197 | else |
197 | return mkeyboard->widget->geometry(); | 198 | return mkeyboard->widget->geometry(); |
198 | } | 199 | } |
199 | 200 | ||
200 | void InputMethods::unloadInputMethods() | 201 | void InputMethods::unloadInputMethods() |
201 | { | 202 | { |
202 | unloadMethod( inputMethodList ); | 203 | unloadMethod( inputMethodList ); |
203 | unloadMethod( inputModifierList ); | 204 | unloadMethod( inputModifierList ); |
204 | inputMethodList.clear(); | 205 | inputMethodList.clear(); |
205 | inputModifierList.clear(); | 206 | inputModifierList.clear(); |
206 | 207 | ||
207 | } | 208 | } |
208 | 209 | ||
209 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 210 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
210 | QValueList<InputMethod>::Iterator it; | 211 | QValueList<InputMethod>::Iterator it; |
211 | 212 | ||
212 | for (it = list.begin(); it != list.end(); ++it ) | 213 | for (it = list.begin(); it != list.end(); ++it ) |
213 | (*it).releaseInterface(); | 214 | (*it).releaseInterface(); |
214 | 215 | ||
215 | } | 216 | } |
216 | 217 | ||
217 | 218 | ||
218 | QStringList InputMethods::plugins()const { | 219 | QStringList InputMethods::plugins()const { |
219 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 220 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
220 | #ifdef Q_OS_MACX | 221 | #ifdef Q_OS_MACX |
221 | QDir dir( path, "lib*.dylib" ); | 222 | QDir dir( path, "lib*.dylib" ); |
222 | #else | 223 | #else |
223 | QDir dir( path, "lib*.so" ); | 224 | QDir dir( path, "lib*.so" ); |
224 | #endif /* Q_OS_MACX */ | 225 | #endif /* Q_OS_MACX */ |
225 | return dir.entryList(); | 226 | return dir.entryList(); |
226 | } | 227 | } |
227 | 228 | ||
228 | void InputMethods::installTranslator( const QString& type ) { | 229 | void InputMethods::installTranslator( const QString& type ) { |
229 | QStringList langs = Global::languageList(); | 230 | QStringList langs = Global::languageList(); |
230 | QStringList::ConstIterator lit; | 231 | QStringList::ConstIterator lit; |
231 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { | 232 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { |
232 | QString lang = *lit; | 233 | QString lang = *lit; |
233 | QTranslator * trans = new QTranslator(qApp); | 234 | QTranslator * trans = new QTranslator(qApp); |
234 | 235 | ||
235 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 236 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
236 | 237 | ||
237 | if ( trans->load( tfn )) | 238 | if ( trans->load( tfn )) |
238 | qApp->installTranslator( trans ); | 239 | qApp->installTranslator( trans ); |
239 | else | 240 | else |
240 | delete trans; | 241 | delete trans; |
241 | } | 242 | } |
242 | } | 243 | } |
243 | 244 | ||
244 | void InputMethods::setPreferedHandlers() { | 245 | void InputMethods::setPreferedHandlers() { |
245 | Config cfg("qpe"); | 246 | Config cfg("qpe"); |
246 | cfg.setGroup("InputMethod"); | 247 | cfg.setGroup("InputMethod"); |
247 | QString current = cfg.readEntry("current"); | 248 | QString current = cfg.readEntry("current"); |
248 | QString im = cfg.readEntry("im"); | 249 | QString im = cfg.readEntry("im"); |
249 | 250 | ||
250 | QValueList<InputMethod>::Iterator it; | 251 | QValueList<InputMethod>::Iterator it; |
251 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 252 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
252 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 253 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
253 | if ( (*it).name() == im ) { | 254 | if ( (*it).name() == im ) { |
254 | imethod = &(*it); break; | 255 | imethod = &(*it); break; |
255 | } | 256 | } |
256 | 257 | ||
257 | } | 258 | } |
258 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 259 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
259 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 260 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
260 | if ( (*it).name() == current ) { | 261 | if ( (*it).name() == current ) { |
261 | owarn << "preferred keyboard is " << current << "" << oendl; | 262 | owarn << "preferred keyboard is " << current << "" << oendl; |
262 | mkeyboard = &(*it); | 263 | mkeyboard = &(*it); |
263 | kbdButton->setPixmap( *mkeyboard->icon() ); | 264 | kbdButton->setPixmap( *mkeyboard->icon() ); |
264 | break; | 265 | break; |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
268 | } | 269 | } |
269 | 270 | ||
270 | void InputMethods::loadInputMethods() | 271 | void InputMethods::loadInputMethods() |
271 | { | 272 | { |
272 | #ifndef QT_NO_COMPONENT | 273 | #ifndef QT_NO_COMPONENT |
273 | hideInputMethod(); | 274 | hideInputMethod(); |
274 | mkeyboard = 0; | 275 | mkeyboard = 0; |
275 | 276 | ||
276 | unloadInputMethods(); | 277 | unloadInputMethods(); |
277 | 278 | ||
278 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 279 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
279 | QStringList list = plugins(); | 280 | QStringList list = plugins(); |
280 | QStringList::Iterator it; | 281 | QStringList::Iterator it; |
281 | for ( it = list.begin(); it != list.end(); ++it ) { | 282 | for ( it = list.begin(); it != list.end(); ++it ) { |
282 | InputMethodInterface *iface = 0; | 283 | InputMethodInterface *iface = 0; |
283 | ExtInputMethodInterface *eface = 0; | 284 | ExtInputMethodInterface *eface = 0; |
284 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 285 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
285 | 286 | ||
286 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 287 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
287 | InputMethod input; | 288 | InputMethod input; |
288 | input.newIM = FALSE; | 289 | input.newIM = FALSE; |
289 | input.library = lib; | 290 | input.library = lib; |
290 | input.libName = *it; | 291 | input.libName = *it; |
291 | input.interface = iface; | 292 | input.interface = iface; |
292 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 293 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
293 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 294 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
294 | inputMethodList.append( input ); | 295 | inputMethodList.append( input ); |
295 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 296 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
296 | InputMethod input; | 297 | InputMethod input; |
297 | input.newIM = TRUE; | 298 | input.newIM = TRUE; |
298 | input.library = lib; | 299 | input.library = lib; |
299 | input.libName = *it; | 300 | input.libName = *it; |
300 | input.extInterface = eface; | 301 | input.extInterface = eface; |
301 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 302 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
302 | // may be either a simple, or advanced. | 303 | // may be either a simple, or advanced. |
303 | if (input.widget) { | 304 | if (input.widget) { |
304 | //odebug << "its a keyboard" << oendl; | 305 | //odebug << "its a keyboard" << oendl; |
305 | inputMethodList.append( input ); | 306 | inputMethodList.append( input ); |
306 | } else { | 307 | } else { |
307 | //odebug << "its a real im" << oendl; | 308 | //odebug << "its a real im" << oendl; |
308 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 309 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
309 | if (input.widget) { | 310 | if (input.widget) { |
310 | //odebug << "blah" << oendl; | 311 | //odebug << "blah" << oendl; |
311 | inputModifierList.append( input ); | 312 | inputModifierList.append( input ); |
312 | imButton->addWidget(input.widget, inputModifierList.count()); | 313 | imButton->addWidget(input.widget, inputModifierList.count()); |
313 | } | 314 | } |
314 | } | 315 | } |
315 | }else{ | 316 | }else{ |
316 | delete lib; | 317 | delete lib; |
317 | lib = 0l; | 318 | lib = 0l; |
318 | } | 319 | } |
319 | installTranslator( (*it).left( (*it).find(".") ) ); | 320 | installTranslator( (*it).left( (*it).find(".") ) ); |
320 | } | 321 | } |
321 | qHeapSort( inputMethodList ); | 322 | qHeapSort( inputMethodList ); |
322 | #endif /* killed BUILT in cause they would not compile */ | 323 | #endif /* killed BUILT in cause they would not compile */ |
323 | 324 | ||
324 | QWSServer::setCurrentInputMethod( 0 ); | 325 | QWSServer::setCurrentInputMethod( 0 ); |
325 | 326 | ||
326 | /* set the prefered IM + handler */ | 327 | /* set the prefered IM + handler */ |
327 | setPreferedHandlers(); | 328 | setPreferedHandlers(); |
328 | if ( !inputModifierList.isEmpty() ) { | 329 | if ( !inputModifierList.isEmpty() ) { |
329 | if (!imethod) | 330 | if (!imethod) |
330 | imethod = &inputModifierList[0]; | 331 | imethod = &inputModifierList[0]; |
331 | imButton->raiseWidget(imethod->widget); | 332 | imButton->raiseWidget(imethod->widget); |
332 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 333 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
333 | } else { | 334 | } else { |
334 | imethod = 0; | 335 | imethod = 0; |
335 | } | 336 | } |
336 | 337 | ||
337 | // we need to update keyboards afterwards, as some of them may not be compatible with | 338 | // we need to update keyboards afterwards, as some of them may not be compatible with |
338 | // the current input method | 339 | // the current input method |
339 | updateKeyboards(imethod); | 340 | updateKeyboards(imethod); |
340 | 341 | ||
341 | if ( !inputModifierList.isEmpty() ) | 342 | if ( !inputModifierList.isEmpty() ) |
342 | imButton->show(); | 343 | imButton->show(); |
343 | else | 344 | else |
344 | imButton->hide(); | 345 | imButton->hide(); |
345 | 346 | ||
346 | if ( inputModifierList.count() > 1 ) | 347 | if ( inputModifierList.count() > 1 ) |
347 | imChoice->show(); | 348 | imChoice->show(); |
348 | else | 349 | else |
349 | imChoice->hide(); | 350 | imChoice->hide(); |
350 | } | 351 | } |
351 | 352 | ||
352 | void InputMethods::chooseKbd() | 353 | void InputMethods::chooseKbd() |
353 | { | 354 | { |
354 | QPopupMenu pop( this ); | 355 | QPopupMenu pop( this ); |
355 | pop.setFocusPolicy( NoFocus ); //don't reset IM | 356 | pop.setFocusPolicy( NoFocus ); //don't reset IM |
356 | 357 | ||
357 | QString imname; | 358 | QString imname; |
358 | if (imethod) | 359 | if (imethod) |
359 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); | 360 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); |
360 | 361 | ||
361 | int i = 0; | 362 | int i = 0; |
362 | int firstDepKbd = 0; | 363 | int firstDepKbd = 0; |
363 | 364 | ||
364 | QValueList<InputMethod>::Iterator it; | 365 | QValueList<InputMethod>::Iterator it; |
365 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 366 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
366 | // add empty new items, all old items. | 367 | // add empty new items, all old items. |
367 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { | 368 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { |
368 | pop.insertItem( (*it).name(), i, firstDepKbd); | 369 | pop.insertItem( (*it).name(), i, firstDepKbd); |
369 | if ( mkeyboard == &(*it) ) | 370 | if ( mkeyboard == &(*it) ) |
370 | pop.setItemChecked( i, TRUE ); | 371 | pop.setItemChecked( i, TRUE ); |
371 | 372 | ||
372 | firstDepKbd++; | 373 | firstDepKbd++; |
373 | } else if ( (*it).extInterface->compatible().contains(imname)) { | 374 | } else if ( (*it).extInterface->compatible().contains(imname)) { |
374 | // check if we need to insert a sep. | 375 | // check if we need to insert a sep. |
375 | if (firstDepKbd == i) | 376 | if (firstDepKbd == i) |
376 | pop.insertSeparator(); | 377 | pop.insertSeparator(); |
377 | pop.insertItem( (*it).name(), i, -1); | 378 | pop.insertItem( (*it).name(), i, -1); |
378 | if ( mkeyboard == &(*it) ) | 379 | if ( mkeyboard == &(*it) ) |
379 | pop.setItemChecked( i, TRUE ); | 380 | pop.setItemChecked( i, TRUE ); |
380 | } | 381 | } |
381 | } | 382 | } |
382 | 383 | ||
383 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); | 384 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); |
384 | QSize s = pop.sizeHint(); | 385 | QSize s = pop.sizeHint(); |
385 | pt.ry() -= s.height(); | 386 | pt.ry() -= s.height(); |
386 | pt.rx() -= s.width(); | 387 | pt.rx() -= s.width(); |
387 | i = pop.exec( pt ); | 388 | i = pop.exec( pt ); |
388 | if ( i == -1 ) | 389 | if ( i == -1 ) |
389 | return; | 390 | return; |
390 | InputMethod *im = &inputMethodList[i]; | 391 | InputMethod *im = &inputMethodList[i]; |
391 | chooseKeyboard(im); | 392 | chooseKeyboard(im); |
392 | } | 393 | } |
393 | 394 | ||
394 | void InputMethods::chooseIm() | 395 | void InputMethods::chooseIm() |
395 | { | 396 | { |
396 | QPopupMenu pop( this ); | 397 | QPopupMenu pop( this ); |
397 | 398 | ||
398 | int i = 0; | 399 | int i = 0; |
399 | QValueList<InputMethod>::Iterator it; | 400 | QValueList<InputMethod>::Iterator it; |
400 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { | 401 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { |
401 | pop.insertItem( (*it).name(), i ); | 402 | pop.insertItem( (*it).name(), i ); |
402 | if ( imethod == &(*it) ) | 403 | if ( imethod == &(*it) ) |
403 | pop.setItemChecked( i, TRUE ); | 404 | pop.setItemChecked( i, TRUE ); |
404 | } | 405 | } |
405 | 406 | ||
406 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); | 407 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); |
407 | QSize s = pop.sizeHint(); | 408 | QSize s = pop.sizeHint(); |
408 | pt.ry() -= s.height(); | 409 | pt.ry() -= s.height(); |
409 | pt.rx() -= s.width(); | 410 | pt.rx() -= s.width(); |
410 | i = pop.exec( pt ); | 411 | i = pop.exec( pt ); |
411 | if ( i == -1 ) | 412 | if ( i == -1 ) |