summaryrefslogtreecommitdiff
path: root/core/launcher/inputmethods.cpp
Unidiff
Diffstat (limited to 'core/launcher/inputmethods.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/inputmethods.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp
index 8f3e812..62e316c 100644
--- a/core/launcher/inputmethods.cpp
+++ b/core/launcher/inputmethods.cpp
@@ -134,193 +134,197 @@ InputMethods::InputMethods( QWidget *parent ) :
134 134
135 imButton = new QWidgetStack( this ); // later a widget stack 135 imButton = new QWidgetStack( this ); // later a widget stack
136 imButton->setFocusPolicy(NoFocus); 136 imButton->setFocusPolicy(NoFocus);
137 if (parent->sizeHint().height() > 0) 137 if (parent->sizeHint().height() > 0)
138 imButton->setFixedHeight( parent->sizeHint().height() ); 138 imButton->setFixedHeight( parent->sizeHint().height() );
139 hbox->addWidget(imButton); 139 hbox->addWidget(imButton);
140 140
141 imChoice = new QToolButton( this ); 141 imChoice = new QToolButton( this );
142 imChoice->setFocusPolicy(NoFocus); 142 imChoice->setFocusPolicy(NoFocus);
143 imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); 143 imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) );
144 if (parent->sizeHint().height() > 0) 144 if (parent->sizeHint().height() > 0)
145 imChoice->setFixedHeight( parent->sizeHint().height() ); 145 imChoice->setFixedHeight( parent->sizeHint().height() );
146 imChoice->setFixedWidth( 13 ); 146 imChoice->setFixedWidth( 13 );
147 imChoice->setAutoRaise( TRUE ); 147 imChoice->setAutoRaise( TRUE );
148 hbox->addWidget( imChoice ); 148 hbox->addWidget( imChoice );
149 connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); 149 connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) );
150 150
151 loadInputMethods(); 151 loadInputMethods();
152 152
153 QCopChannel *channel = new QCopChannel( "QPE/IME", this ); 153 QCopChannel *channel = new QCopChannel( "QPE/IME", this );
154 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 154 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
155 this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); 155 this, SLOT(qcopReceive(const QCString&, const QByteArray&)) );
156} 156}
157 157
158InputMethods::~InputMethods() 158InputMethods::~InputMethods()
159{ 159{
160 Config cfg("qpe"); 160 Config cfg("qpe");
161 cfg.setGroup("InputMethod"); 161 cfg.setGroup("InputMethod");
162 if (imethod) 162 if (imethod)
163 cfg.writeEntry("im", imethod->name() ); 163 cfg.writeEntry("im", imethod->name() );
164 if (mkeyboard) 164 if (mkeyboard)
165 cfg.writeEntry("current", mkeyboard->name() ); 165 cfg.writeEntry("current", mkeyboard->name() );
166 166
167 unloadInputMethods(); 167 unloadInputMethods();
168} 168}
169 169
170void InputMethods::hideInputMethod() 170void InputMethods::hideInputMethod()
171{ 171{
172 kbdButton->setOn( FALSE ); 172 kbdButton->setOn( FALSE );
173} 173}
174 174
175void InputMethods::showInputMethod() 175void InputMethods::showInputMethod()
176{ 176{
177 kbdButton->setOn( TRUE ); 177 kbdButton->setOn( TRUE );
178} 178}
179 179
180void InputMethods::showInputMethod(const QString& name) 180void InputMethods::showInputMethod(const QString& name)
181{ 181{
182 int i = 0; 182 int i = 0;
183 QValueList<InputMethod>::Iterator it; 183 QValueList<InputMethod>::Iterator it;
184 InputMethod *im = 0; 184 InputMethod *im = 0;
185 for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { 185 for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) {
186 QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); 186 QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1);
187 if ( (*it).name() == name || lname == name ) { 187 if ( (*it).name() == name || lname == name ) {
188 im = &(*it); 188 im = &(*it);
189 break; 189 break;
190 } 190 }
191 } 191 }
192 if ( im ) 192 if ( im )
193 chooseKeyboard(im); 193 chooseKeyboard(im);
194} 194}
195 195
196void InputMethods::resetStates() 196void InputMethods::resetStates()
197{ 197{
198 if ( mkeyboard && !mkeyboard->newIM ) 198 if ( mkeyboard && !mkeyboard->newIM )
199 mkeyboard->interface->resetState(); 199 mkeyboard->interface->resetState();
200} 200}
201 201
202QRect InputMethods::inputRect() const 202QRect InputMethods::inputRect() const
203{ 203{
204 if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) 204 if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() )
205 return QRect(); 205 return QRect();
206 else 206 else
207 return mkeyboard->widget->geometry(); 207 return mkeyboard->widget->geometry();
208} 208}
209 209
210void InputMethods::unloadInputMethods() 210void InputMethods::unloadInputMethods()
211{ 211{
212 unloadMethod( inputMethodList ); 212 unloadMethod( inputMethodList );
213 unloadMethod( inputModifierList ); 213 unloadMethod( inputModifierList );
214 inputMethodList.clear(); 214 inputMethodList.clear();
215 inputModifierList.clear(); 215 inputModifierList.clear();
216 216
217} 217}
218 218
219void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { 219void InputMethods::unloadMethod( QValueList<InputMethod>& list ) {
220 QValueList<InputMethod>::Iterator it; 220 QValueList<InputMethod>::Iterator it;
221 221
222 for (it = list.begin(); it != list.end(); ++it ) 222 for (it = list.begin(); it != list.end(); ++it )
223 (*it).releaseInterface(); 223 (*it).releaseInterface();
224 224
225} 225}
226 226
227 227
228QStringList InputMethods::plugins()const { 228QStringList InputMethods::plugins()const {
229 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; 229 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods";
230#ifdef Q_OS_MACX
231 QDir dir( path, "lib*.dylib" );
232#else
230 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
234#endif /* Q_OS_MACX */
231 return dir.entryList(); 235 return dir.entryList();
232} 236}
233 237
234void InputMethods::installTranslator( const QString& type ) { 238void InputMethods::installTranslator( const QString& type ) {
235 QStringList langs = Global::languageList(); 239 QStringList langs = Global::languageList();
236 QStringList::ConstIterator lit; 240 QStringList::ConstIterator lit;
237 for ( lit= langs.begin(); lit!=langs.end(); ++lit) { 241 for ( lit= langs.begin(); lit!=langs.end(); ++lit) {
238 QString lang = *lit; 242 QString lang = *lit;
239 QTranslator * trans = new QTranslator(qApp); 243 QTranslator * trans = new QTranslator(qApp);
240 244
241 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 245 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
242 246
243 if ( trans->load( tfn )) 247 if ( trans->load( tfn ))
244 qApp->installTranslator( trans ); 248 qApp->installTranslator( trans );
245 else 249 else
246 delete trans; 250 delete trans;
247 } 251 }
248} 252}
249 253
250void InputMethods::setPreferedHandlers() { 254void InputMethods::setPreferedHandlers() {
251 Config cfg("qpe"); 255 Config cfg("qpe");
252 cfg.setGroup("InputMethod"); 256 cfg.setGroup("InputMethod");
253 QString current = cfg.readEntry("current"); 257 QString current = cfg.readEntry("current");
254 QString im = cfg.readEntry("im"); 258 QString im = cfg.readEntry("im");
255 259
256 QValueList<InputMethod>::Iterator it; 260 QValueList<InputMethod>::Iterator it;
257 if (!inputModifierList.isEmpty() && !im.isEmpty() ) { 261 if (!inputModifierList.isEmpty() && !im.isEmpty() ) {
258 for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) 262 for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it )
259 if ( (*it).name() == im ) { 263 if ( (*it).name() == im ) {
260 imethod = &(*it); break; 264 imethod = &(*it); break;
261 } 265 }
262 266
263 } 267 }
264 if (!inputMethodList.isEmpty() && !current.isEmpty() ) { 268 if (!inputMethodList.isEmpty() && !current.isEmpty() ) {
265 for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) 269 for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it )
266 if ( (*it).name() == current ) { 270 if ( (*it).name() == current ) {
267 qWarning("preferred keyboard is %s", current.latin1() ); 271 qWarning("preferred keyboard is %s", current.latin1() );
268 mkeyboard = &(*it); 272 mkeyboard = &(*it);
269 kbdButton->setPixmap( *mkeyboard->icon() ); 273 kbdButton->setPixmap( *mkeyboard->icon() );
270 break; 274 break;
271 } 275 }
272 } 276 }
273 277
274} 278}
275 279
276void InputMethods::loadInputMethods() 280void InputMethods::loadInputMethods()
277{ 281{
278#ifndef QT_NO_COMPONENT 282#ifndef QT_NO_COMPONENT
279 hideInputMethod(); 283 hideInputMethod();
280 mkeyboard = 0; 284 mkeyboard = 0;
281 285
282 unloadInputMethods(); 286 unloadInputMethods();
283 287
284 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; 288 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods";
285 QStringList list = plugins(); 289 QStringList list = plugins();
286 QStringList::Iterator it; 290 QStringList::Iterator it;
287 for ( it = list.begin(); it != list.end(); ++it ) { 291 for ( it = list.begin(); it != list.end(); ++it ) {
288 InputMethodInterface *iface = 0; 292 InputMethodInterface *iface = 0;
289 ExtInputMethodInterface *eface = 0; 293 ExtInputMethodInterface *eface = 0;
290 QLibrary *lib = new QLibrary( path + "/" + *it ); 294 QLibrary *lib = new QLibrary( path + "/" + *it );
291 295
292 if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { 296 if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) {
293 InputMethod input; 297 InputMethod input;
294 input.newIM = FALSE; 298 input.newIM = FALSE;
295 input.library = lib; 299 input.library = lib;
296 input.libName = *it; 300 input.libName = *it;
297 input.interface = iface; 301 input.interface = iface;
298 input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); 302 input.widget = input.interface->inputMethod( 0, inputWidgetStyle );
299 input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); 303 input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) );
300 inputMethodList.append( input ); 304 inputMethodList.append( input );
301 } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { 305 } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) {
302 InputMethod input; 306 InputMethod input;
303 input.newIM = TRUE; 307 input.newIM = TRUE;
304 input.library = lib; 308 input.library = lib;
305 input.libName = *it; 309 input.libName = *it;
306 input.extInterface = eface; 310 input.extInterface = eface;
307 input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); 311 input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle );
308 // may be either a simple, or advanced. 312 // may be either a simple, or advanced.
309 if (input.widget) { 313 if (input.widget) {
310 //qDebug("its a keyboard"); 314 //qDebug("its a keyboard");
311 inputMethodList.append( input ); 315 inputMethodList.append( input );
312 } else { 316 } else {
313 //qDebug("its a real im"); 317 //qDebug("its a real im");
314 input.widget = input.extInterface->statusWidget( 0, 0 ); 318 input.widget = input.extInterface->statusWidget( 0, 0 );
315 if (input.widget) { 319 if (input.widget) {
316 //qDebug("blah"); 320 //qDebug("blah");
317 inputModifierList.append( input ); 321 inputModifierList.append( input );
318 imButton->addWidget(input.widget, inputModifierList.count()); 322 imButton->addWidget(input.widget, inputModifierList.count());
319 } 323 }
320 } 324 }
321 }else{ 325 }else{
322 delete lib; 326 delete lib;
323 lib = 0l; 327 lib = 0l;
324 } 328 }
325 installTranslator( (*it).left( (*it).find(".") ) ); 329 installTranslator( (*it).left( (*it).find(".") ) );
326 } 330 }