summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index c6d9cfd..ca90427 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -184,840 +184,856 @@ public:
184 if (!qcopQok ) 184 if (!qcopQok )
185 return; 185 return;
186 186
187 QCopRec * r; 187 QCopRec * r;
188 188
189 while((r=qcopq.dequeue())) { 189 while((r=qcopq.dequeue())) {
190 // remove from queue before sending... 190 // remove from queue before sending...
191 // event loop can come around again before getting 191 // event loop can come around again before getting
192 // back from sendLocally 192 // back from sendLocally
193#ifndef QT_NO_COP 193#ifndef QT_NO_COP
194 QCopChannel::sendLocally( r->channel, r->message, r->data ); 194 QCopChannel::sendLocally( r->channel, r->message, r->data );
195#endif 195#endif
196 196
197 delete r; 197 delete r;
198 } 198 }
199 } 199 }
200 200
201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
202 { 202 {
203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
204 { 204 {
205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
206 } 206 }
207 QPoint p; 207 QPoint p;
208 QSize s; 208 QSize s;
209 bool max; 209 bool max;
210 if ( mw->isVisible() ) { 210 if ( mw->isVisible() ) {
211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
212 mw->resize(s); 212 mw->resize(s);
213 mw->move(p); 213 mw->move(p);
214 } 214 }
215 mw->raise(); 215 mw->raise();
216 } else { 216 } else {
217 217
218 if ( mw->layout() && mw->inherits("QDialog") ) { 218 if ( mw->layout() && mw->inherits("QDialog") ) {
219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
220 mw->resize(s); 220 mw->resize(s);
221 mw->move(p); 221 mw->move(p);
222 222
223 if ( max && !nomaximize ) { 223 if ( max && !nomaximize ) {
224 mw->showMaximized(); 224 mw->showMaximized();
225 } else { 225 } else {
226 mw->show(); 226 mw->show();
227 } 227 }
228 } else { 228 } else {
229 qpe_show_dialog((QDialog*)mw,nomaximize); 229 qpe_show_dialog((QDialog*)mw,nomaximize);
230 } 230 }
231 } else { 231 } else {
232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
233 mw->resize(s); 233 mw->resize(s);
234 mw->move(p); 234 mw->move(p);
235 } else { //no stored rectangle, make an estimation 235 } else { //no stored rectangle, make an estimation
236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
238 mw->move( QMAX(x,0), QMAX(y,0) ); 238 mw->move( QMAX(x,0), QMAX(y,0) );
239#ifdef Q_WS_QWS 239#ifdef Q_WS_QWS
240 if ( !nomaximize ) 240 if ( !nomaximize )
241 mw->showMaximized(); 241 mw->showMaximized();
242#endif 242#endif
243 } 243 }
244 if ( max && !nomaximize ) 244 if ( max && !nomaximize )
245 mw->showMaximized(); 245 mw->showMaximized();
246 else 246 else
247 mw->show(); 247 mw->show();
248 } 248 }
249 } 249 }
250 } 250 }
251 251
252static void qpe_show_dialog( QDialog* d, bool nomax ) 252static void qpe_show_dialog( QDialog* d, bool nomax )
253{ 253{
254 QSize sh = d->sizeHint(); 254 QSize sh = d->sizeHint();
255 int w = QMAX(sh.width(),d->width()); 255 int w = QMAX(sh.width(),d->width());
256 int h = QMAX(sh.height(),d->height()); 256 int h = QMAX(sh.height(),d->height());
257 257
258 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 258 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
259 nomax = TRUE; 259 nomax = TRUE;
260 260
261#ifndef Q_WS_QWS 261#ifndef Q_WS_QWS
262 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 262 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
263#else 263#else
264 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 264 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
265#endif 265#endif
266 266
267 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 267 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
268 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 268 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
269 269
270 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { 270 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) {
271 d->showMaximized(); 271 d->showMaximized();
272 } else { 272 } else {
273 // try centering the dialog around its parent 273 // try centering the dialog around its parent
274 QPoint p(0,0); 274 QPoint p(0,0);
275 if ( d->parentWidget() ) { 275 if ( d->parentWidget() ) {
276 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); 276 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) );
277 p = QPoint( pp.x() + d->parentWidget()->width()/2, 277 p = QPoint( pp.x() + d->parentWidget()->width()/2,
278 pp.y() + d->parentWidget()->height()/ 2 ); 278 pp.y() + d->parentWidget()->height()/ 2 );
279 } else { 279 } else {
280 p = QPoint( maxX/2, maxY/2 ); 280 p = QPoint( maxX/2, maxY/2 );
281 } 281 }
282 282
283 p = QPoint( p.x() - w/2, p.y() - h/2 ); 283 p = QPoint( p.x() - w/2, p.y() - h/2 );
284// qDebug("p(x,y) is %d %d", p.x(), p.y() ); 284// qDebug("p(x,y) is %d %d", p.x(), p.y() );
285 285
286 if ( w >= maxX ) { 286 if ( w >= maxX ) {
287 if ( p.y() < 0 ) 287 if ( p.y() < 0 )
288 p.setY(0); 288 p.setY(0);
289 if ( p.y() + h > maxY ) 289 if ( p.y() + h > maxY )
290 p.setY( maxY - h); 290 p.setY( maxY - h);
291 291
292 d->resize(maxX, h); 292 d->resize(maxX, h);
293 d->move(0, p.y() ); 293 d->move(0, p.y() );
294 } else if ( h >= maxY ) { 294 } else if ( h >= maxY ) {
295 if ( p.x() < 0 ) 295 if ( p.x() < 0 )
296 p.setX(0); 296 p.setX(0);
297 if ( p.x() + w > maxX ) 297 if ( p.x() + w > maxX )
298 p.setX( maxX - w); 298 p.setX( maxX - w);
299 299
300 d->resize(w, maxY); 300 d->resize(w, maxY);
301 d->move(p.x(),0); 301 d->move(p.x(),0);
302 } else { 302 } else {
303 d->resize(w, h); 303 d->resize(w, h);
304 } 304 }
305 305
306 d->show(); 306 d->show();
307 } 307 }
308} 308}
309 309
310 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 310 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
311 { 311 {
312 maximized = TRUE; 312 maximized = TRUE;
313 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 313 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
314 if ( qApp->desktop()->width() <= 350 ) 314 if ( qApp->desktop()->width() <= 350 )
315 return FALSE; 315 return FALSE;
316 316
317 Config cfg( "qpe" ); 317 Config cfg( "qpe" );
318 cfg.setGroup("ApplicationPositions"); 318 cfg.setGroup("ApplicationPositions");
319 QString str = cfg.readEntry( app, QString::null ); 319 QString str = cfg.readEntry( app, QString::null );
320 QStringList l = QStringList::split(",", str); 320 QStringList l = QStringList::split(",", str);
321 321
322 if ( l.count() == 5) { 322 if ( l.count() == 5) {
323 p.setX( l[0].toInt() ); 323 p.setX( l[0].toInt() );
324 p.setY( l[1].toInt() ); 324 p.setY( l[1].toInt() );
325 325
326 s.setWidth( l[2].toInt() ); 326 s.setWidth( l[2].toInt() );
327 s.setHeight( l[3].toInt() ); 327 s.setHeight( l[3].toInt() );
328 328
329 maximized = l[4].toInt(); 329 maximized = l[4].toInt();
330 330
331 return TRUE; 331 return TRUE;
332 } 332 }
333 333
334 return FALSE; 334 return FALSE;
335 } 335 }
336 336
337 337
338 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 338 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
339 { 339 {
340#ifndef Q_WS_QWS 340#ifndef Q_WS_QWS
341 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 341 QRect qt_maxWindowRect = qApp->desktop()->geometry();
342#endif 342#endif
343 int maxX = qt_maxWindowRect.width(); 343 int maxX = qt_maxWindowRect.width();
344 int maxY = qt_maxWindowRect.height(); 344 int maxY = qt_maxWindowRect.height();
345 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 345 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
346 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 346 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
347 347
348 // total window size is not allowed to be larger than desktop window size 348 // total window size is not allowed to be larger than desktop window size
349 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 349 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
350 return FALSE; 350 return FALSE;
351 351
352 if ( wWidth > maxX ) { 352 if ( wWidth > maxX ) {
353 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 353 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
354 wWidth = maxX; 354 wWidth = maxX;
355 } 355 }
356 356
357 if ( wHeight > maxY ) { 357 if ( wHeight > maxY ) {
358 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 358 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
359 wHeight = maxY; 359 wHeight = maxY;
360 } 360 }
361 361
362 // any smaller than this and the maximize/close/help buttons will be overlapping 362 // any smaller than this and the maximize/close/help buttons will be overlapping
363 if ( wWidth < 80 || wHeight < 60 ) 363 if ( wWidth < 80 || wHeight < 60 )
364 return FALSE; 364 return FALSE;
365 365
366 if ( p.x() < 0 ) 366 if ( p.x() < 0 )
367 p.setX(0); 367 p.setX(0);
368 if ( p.y() < 0 ) 368 if ( p.y() < 0 )
369 p.setY(0); 369 p.setY(0);
370 370
371 if ( p.x() + wWidth > maxX ) 371 if ( p.x() + wWidth > maxX )
372 p.setX( maxX - wWidth ); 372 p.setX( maxX - wWidth );
373 if ( p.y() + wHeight > maxY ) 373 if ( p.y() + wHeight > maxY )
374 p.setY( maxY - wHeight ); 374 p.setY( maxY - wHeight );
375 375
376 return TRUE; 376 return TRUE;
377 } 377 }
378 378
379 static void store_widget_rect(QWidget *w, QString &app) 379 static void store_widget_rect(QWidget *w, QString &app)
380 { 380 {
381 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 381 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
382 if ( qApp->desktop()->width() <= 350 ) 382 if ( qApp->desktop()->width() <= 350 )
383 return; 383 return;
384 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 384 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
385 // get the non-maximized version, so we have to do it the hard way ) 385 // get the non-maximized version, so we have to do it the hard way )
386 int offsetX = w->x() - w->geometry().left(); 386 int offsetX = w->x() - w->geometry().left();
387 int offsetY = w->y() - w->geometry().top(); 387 int offsetY = w->y() - w->geometry().top();
388 388
389 QRect r; 389 QRect r;
390 if ( w->isMaximized() ) 390 if ( w->isMaximized() )
391 r = ( (HackWidget *) w)->normalGeometry(); 391 r = ( (HackWidget *) w)->normalGeometry();
392 else 392 else
393 r = w->geometry(); 393 r = w->geometry();
394 394
395 // Stores the window placement as pos(), size() (due to the offset mapping) 395 // Stores the window placement as pos(), size() (due to the offset mapping)
396 Config cfg( "qpe" ); 396 Config cfg( "qpe" );
397 cfg.setGroup("ApplicationPositions"); 397 cfg.setGroup("ApplicationPositions");
398 QString s; 398 QString s;
399 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 399 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
400 cfg.writeEntry( app, s ); 400 cfg.writeEntry( app, s );
401 } 401 }
402 402
403 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 403 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
404 { 404 {
405 /* 405 /*
406 // This works but disable it for now until it is safe to apply 406 // This works but disable it for now until it is safe to apply
407 // What is does is scan the .desktop files of all the apps for 407 // What is does is scan the .desktop files of all the apps for
408 // the applnk that has the corresponding argv[0] as this program 408 // the applnk that has the corresponding argv[0] as this program
409 // then it uses the name stored in the .desktop file as the caption 409 // then it uses the name stored in the .desktop file as the caption
410 // for the main widget. This saves duplicating translations for 410 // for the main widget. This saves duplicating translations for
411 // the app name in the program and in the .desktop files. 411 // the app name in the program and in the .desktop files.
412 412
413 AppLnkSet apps( appsPath ); 413 AppLnkSet apps( appsPath );
414 414
415 QList<AppLnk> appsList = apps.children(); 415 QList<AppLnk> appsList = apps.children();
416 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 416 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
417 if ( (*it)->exec() == appName ) { 417 if ( (*it)->exec() == appName ) {
418 mw->setCaption( (*it)->name() ); 418 mw->setCaption( (*it)->name() );
419 return TRUE; 419 return TRUE;
420 } 420 }
421 } 421 }
422 */ 422 */
423 return FALSE; 423 return FALSE;
424 } 424 }
425 425
426 426
427 void show(QWidget* mw, bool nomax) 427 void show(QWidget* mw, bool nomax)
428 { 428 {
429 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 429 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
430 nomaximize = nomax; 430 nomaximize = nomax;
431 qpe_main_widget = mw; 431 qpe_main_widget = mw;
432 qcopQok = TRUE; 432 qcopQok = TRUE;
433#ifndef QT_NO_COP 433#ifndef QT_NO_COP
434 434
435 sendQCopQ(); 435 sendQCopQ();
436#endif 436#endif
437 437
438 if ( preloaded ) { 438 if ( preloaded ) {
439 if (forceshow) 439 if (forceshow)
440 show_mx(mw, nomax, appName); 440 show_mx(mw, nomax, appName);
441 } 441 }
442 else if ( keep_running ) { 442 else if ( keep_running ) {
443 show_mx(mw, nomax, appName); 443 show_mx(mw, nomax, appName);
444 } 444 }
445 } 445 }
446 446
447 void loadTextCodecs() 447 void loadTextCodecs()
448 { 448 {
449 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 449 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
450#ifdef Q_OS_MACX 450#ifdef Q_OS_MACX
451 QDir dir( path, "lib*.dylib" ); 451 QDir dir( path, "lib*.dylib" );
452#else 452#else
453 QDir dir( path, "lib*.so" ); 453 QDir dir( path, "lib*.so" );
454#endif 454#endif
455 QStringList list; 455 QStringList list;
456 if ( dir. exists ( )) 456 if ( dir. exists ( ))
457 list = dir.entryList(); 457 list = dir.entryList();
458 QStringList::Iterator it; 458 QStringList::Iterator it;
459 for ( it = list.begin(); it != list.end(); ++it ) { 459 for ( it = list.begin(); it != list.end(); ++it ) {
460 TextCodecInterface *iface = 0; 460 TextCodecInterface *iface = 0;
461 QLibrary *lib = new QLibrary( path + "/" + *it ); 461 QLibrary *lib = new QLibrary( path + "/" + *it );
462 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 462 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
463 QValueList<int> mibs = iface->mibEnums(); 463 QValueList<int> mibs = iface->mibEnums();
464 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 464 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
465 (void)iface->createForMib(*i); 465 (void)iface->createForMib(*i);
466 // ### it exists now; need to remember if we can delete it 466 // ### it exists now; need to remember if we can delete it
467 } 467 }
468 } 468 }
469 else { 469 else {
470 lib->unload(); 470 lib->unload();
471 delete lib; 471 delete lib;
472 } 472 }
473 } 473 }
474 } 474 }
475 475
476 void loadImageCodecs() 476 void loadImageCodecs()
477 { 477 {
478 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 478 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
479#ifdef Q_OS_MACX 479#ifdef Q_OS_MACX
480 QDir dir( path, "lib*.dylib" ); 480 QDir dir( path, "lib*.dylib" );
481#else 481#else
482 QDir dir( path, "lib*.so" ); 482 QDir dir( path, "lib*.so" );
483#endif 483#endif
484 QStringList list; 484 QStringList list;
485 if ( dir. exists ( )) 485 if ( dir. exists ( ))
486 list = dir.entryList(); 486 list = dir.entryList();
487 QStringList::Iterator it; 487 QStringList::Iterator it;
488 for ( it = list.begin(); it != list.end(); ++it ) { 488 for ( it = list.begin(); it != list.end(); ++it ) {
489 ImageCodecInterface *iface = 0; 489 ImageCodecInterface *iface = 0;
490 QLibrary *lib = new QLibrary( path + "/" + *it ); 490 QLibrary *lib = new QLibrary( path + "/" + *it );
491 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 491 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
492 QStringList formats = iface->keys(); 492 QStringList formats = iface->keys();
493 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 493 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
494 (void)iface->installIOHandler(*i); 494 (void)iface->installIOHandler(*i);
495 // ### it exists now; need to remember if we can delete it 495 // ### it exists now; need to remember if we can delete it
496 } 496 }
497 } 497 }
498 else { 498 else {
499 lib->unload(); 499 lib->unload();
500 delete lib; 500 delete lib;
501 } 501 }
502 } 502 }
503 } 503 }
504 504
505}; 505};
506 506
507class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
508{ 508{
509public: 509public:
510 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
511 { 511 {
512 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
513 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
514 } 514 }
515 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
516 delete resImage; 516 delete resImage;
517 } 517 }
518 518
519 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
520 { 520 {
521 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
522 if ( !r ) { 522 if ( !r ) {
523 int sl = abs_name.length(); 523 int sl = abs_name.length();
524 do { 524 do {
525 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
527 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
528 if ( dot >= 0 ) 528 if ( dot >= 0 )
529 name = name.left( dot ); 529 name = name.left( dot );
530 QImage img = Resource::loadImage( name ); 530 QImage img = Resource::loadImage( name );
531 if ( !img.isNull() ) { 531 if ( !img.isNull() ) {
532 delete resImage; 532 delete resImage;
533 resImage = new QImageDrag( img ); 533 resImage = new QImageDrag( img );
534 r = resImage; 534 r = resImage;
535 } 535 }
536 } 536 }
537 while ( !r && sl > 0 ); 537 while ( !r && sl > 0 );
538 } 538 }
539 return r; 539 return r;
540 } 540 }
541private: 541private:
542 mutable QImageDrag *resImage; 542 mutable QImageDrag *resImage;
543}; 543};
544 544
545static int& hack(int& i) 545static int& hack(int& i)
546{ 546{
547#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 547#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
548 // These should be created, but aren't in Qt 2.3.0 548 // These should be created, but aren't in Qt 2.3.0
549 (void)new QUtf8Codec; 549 (void)new QUtf8Codec;
550 (void)new QUtf16Codec; 550 (void)new QUtf16Codec;
551#endif 551#endif
552 return i; 552 return i;
553} 553}
554 554
555static int muted = 0; 555static int muted = 0;
556static int micMuted = 0; 556static int micMuted = 0;
557 557
558static void setVolume( int t = 0, int percent = -1 ) 558static void setVolume( int t = 0, int percent = -1 )
559{ 559{
560 switch ( t ) { 560 switch ( t ) {
561 case 0: { 561 case 0: {
562 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
563 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
564 if ( percent < 0 ) 564 if ( percent < 0 )
565 percent = cfg.readNumEntry( "VolumePercent", 50 ); 565 percent = cfg.readNumEntry( "VolumePercent", 50 );
566#ifndef QT_NO_SOUND 566#ifndef QT_NO_SOUND
567 int fd = 0; 567 int fd = 0;
568#ifdef QT_QWS_DEVFS
569 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
570#else
568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 571 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
572#endif
569 int vol = muted ? 0 : percent; 573 int vol = muted ? 0 : percent;
570 // set both channels to same volume 574 // set both channels to same volume
571 vol |= vol << 8; 575 vol |= vol << 8;
572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 576 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
573 ::close( fd ); 577 ::close( fd );
574 } 578 }
575#endif 579#endif
576 } 580 }
577 break; 581 break;
578 } 582 }
579} 583}
580 584
581static void setMic( int t = 0, int percent = -1 ) 585static void setMic( int t = 0, int percent = -1 )
582{ 586{
583 switch ( t ) { 587 switch ( t ) {
584 case 0: { 588 case 0: {
585 Config cfg( "qpe" ); 589 Config cfg( "qpe" );
586 cfg.setGroup( "Volume" ); 590 cfg.setGroup( "Volume" );
587 if ( percent < 0 ) 591 if ( percent < 0 )
588 percent = cfg.readNumEntry( "Mic", 50 ); 592 percent = cfg.readNumEntry( "Mic", 50 );
589 593
590#ifndef QT_NO_SOUND 594#ifndef QT_NO_SOUND
591 int fd = 0; 595 int fd = 0;
592 int mic = micMuted ? 0 : percent; 596 int mic = micMuted ? 0 : percent;
597#ifdef QT_QWS_DEVFS
598 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
599#else
593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 600 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
601#endif
594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 602 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
595 ::close( fd ); 603 ::close( fd );
596 } 604 }
597#endif 605#endif
598 } 606 }
599 break; 607 break;
600 } 608 }
601} 609}
602 610
603 611
604static void setBass( int t = 0, int percent = -1 ) 612static void setBass( int t = 0, int percent = -1 )
605{ 613{
606 switch ( t ) { 614 switch ( t ) {
607 case 0: { 615 case 0: {
608 Config cfg( "qpe" ); 616 Config cfg( "qpe" );
609 cfg.setGroup( "Volume" ); 617 cfg.setGroup( "Volume" );
610 if ( percent < 0 ) 618 if ( percent < 0 )
611 percent = cfg.readNumEntry( "BassPercent", 50 ); 619 percent = cfg.readNumEntry( "BassPercent", 50 );
612 620
613#ifndef QT_NO_SOUND 621#ifndef QT_NO_SOUND
614 int fd = 0; 622 int fd = 0;
615 int bass = percent; 623 int bass = percent;
624#ifdef QT_QWS_DEVFS
625 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
626#else
616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 627 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
628#endif
617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 629 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
618 ::close( fd ); 630 ::close( fd );
619 } 631 }
620#endif 632#endif
621 } 633 }
622 break; 634 break;
623 } 635 }
624} 636}
625 637
626 638
627static void setTreble( int t = 0, int percent = -1 ) 639static void setTreble( int t = 0, int percent = -1 )
628{ 640{
629 switch ( t ) { 641 switch ( t ) {
630 case 0: { 642 case 0: {
631 Config cfg( "qpe" ); 643 Config cfg( "qpe" );
632 cfg.setGroup( "Volume" ); 644 cfg.setGroup( "Volume" );
633 if ( percent < 0 ) 645 if ( percent < 0 )
634 percent = cfg.readNumEntry( "TreblePercent", 50 ); 646 percent = cfg.readNumEntry( "TreblePercent", 50 );
635 647
636#ifndef QT_NO_SOUND 648#ifndef QT_NO_SOUND
637 int fd = 0; 649 int fd = 0;
638 int treble = percent; 650 int treble = percent;
651#ifdef QT_QWS_DEVFS
652 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
653#else
639 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 654 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
655#endif
640 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 656 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
641 ::close( fd ); 657 ::close( fd );
642 } 658 }
643#endif 659#endif
644 } 660 }
645 break; 661 break;
646 } 662 }
647} 663}
648 664
649 665
650/** 666/**
651 \class QPEApplication 667 \class QPEApplication
652 \brief The QPEApplication class implements various system services 668 \brief The QPEApplication class implements various system services
653 that are available to all Qtopia applications. 669 that are available to all Qtopia applications.
654 670
655 Simply by using QPEApplication instead of QApplication, a standard Qt 671 Simply by using QPEApplication instead of QApplication, a standard Qt
656 application becomes a Qtopia application. It automatically follows 672 application becomes a Qtopia application. It automatically follows
657 style changes, quits and raises, and in the 673 style changes, quits and raises, and in the
658 case of \link docwidget.html document-oriented\endlink applications, 674 case of \link docwidget.html document-oriented\endlink applications,
659 changes the currently displayed document in response to the environment. 675 changes the currently displayed document in response to the environment.
660 676
661 To create a \link docwidget.html document-oriented\endlink 677 To create a \link docwidget.html document-oriented\endlink
662 application use showMainDocumentWidget(); to create a 678 application use showMainDocumentWidget(); to create a
663 non-document-oriented application use showMainWidget(). The 679 non-document-oriented application use showMainWidget(). The
664 keepRunning() function indicates whether the application will 680 keepRunning() function indicates whether the application will
665 continue running after it's processed the last \link qcop.html 681 continue running after it's processed the last \link qcop.html
666 QCop\endlink message. This can be changed using setKeepRunning(). 682 QCop\endlink message. This can be changed using setKeepRunning().
667 683
668 A variety of signals are emitted when certain events occur, for 684 A variety of signals are emitted when certain events occur, for
669 example, timeChanged(), clockChanged(), weekChanged(), 685 example, timeChanged(), clockChanged(), weekChanged(),
670 dateFormatChanged() and volumeChanged(). If the application receives 686 dateFormatChanged() and volumeChanged(). If the application receives
671 a \link qcop.html QCop\endlink message on the application's 687 a \link qcop.html QCop\endlink message on the application's
672 QPE/Application/\e{appname} channel, the appMessage() signal is 688 QPE/Application/\e{appname} channel, the appMessage() signal is
673 emitted. There are also flush() and reload() signals, which 689 emitted. There are also flush() and reload() signals, which
674 are emitted when synching begins and ends respectively - upon these 690 are emitted when synching begins and ends respectively - upon these
675 signals, the application should save and reload any data 691 signals, the application should save and reload any data
676 files that are involved in synching. Most of these signals will initially 692 files that are involved in synching. Most of these signals will initially
677 be received and unfiltered through the appMessage() signal. 693 be received and unfiltered through the appMessage() signal.
678 694
679 This class also provides a set of useful static functions. The 695 This class also provides a set of useful static functions. The
680 qpeDir() and documentDir() functions return the respective paths. 696 qpeDir() and documentDir() functions return the respective paths.
681 The grabKeyboard() and ungrabKeyboard() functions are used to 697 The grabKeyboard() and ungrabKeyboard() functions are used to
682 control whether the application takes control of the device's 698 control whether the application takes control of the device's
683 physical buttons (e.g. application launch keys). The stylus' mode of 699 physical buttons (e.g. application launch keys). The stylus' mode of
684 operation is set with setStylusOperation() and retrieved with 700 operation is set with setStylusOperation() and retrieved with
685 stylusOperation(). There are also setInputMethodHint() and 701 stylusOperation(). There are also setInputMethodHint() and
686 inputMethodHint() functions. 702 inputMethodHint() functions.
687 703
688 \ingroup qtopiaemb 704 \ingroup qtopiaemb
689*/ 705*/
690 706
691/*! 707/*!
692 \fn void QPEApplication::clientMoused() 708 \fn void QPEApplication::clientMoused()
693 709
694 \internal 710 \internal
695*/ 711*/
696 712
697/*! 713/*!
698 \fn void QPEApplication::timeChanged(); 714 \fn void QPEApplication::timeChanged();
699 This signal is emitted when the time changes outside the normal 715 This signal is emitted when the time changes outside the normal
700 passage of time, i.e. if the time is set backwards or forwards. 716 passage of time, i.e. if the time is set backwards or forwards.
701*/ 717*/
702 718
703/*! 719/*!
704 \fn void QPEApplication::clockChanged( bool ampm ); 720 \fn void QPEApplication::clockChanged( bool ampm );
705 721
706 This signal is emitted when the user changes the clock's style. If 722 This signal is emitted when the user changes the clock's style. If
707 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 723 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
708 they want a 24-hour clock. 724 they want a 24-hour clock.
709*/ 725*/
710 726
711/*! 727/*!
712 \fn void QPEApplication::volumeChanged( bool muted ) 728 \fn void QPEApplication::volumeChanged( bool muted )
713 729
714 This signal is emitted whenever the mute state is changed. If \a 730 This signal is emitted whenever the mute state is changed. If \a
715 muted is TRUE, then sound output has been muted. 731 muted is TRUE, then sound output has been muted.
716*/ 732*/
717 733
718/*! 734/*!
719 \fn void QPEApplication::weekChanged( bool startOnMonday ) 735 \fn void QPEApplication::weekChanged( bool startOnMonday )
720 736
721 This signal is emitted if the week start day is changed. If \a 737 This signal is emitted if the week start day is changed. If \a
722 startOnMonday is TRUE then the first day of the week is Monday; if 738 startOnMonday is TRUE then the first day of the week is Monday; if
723 \a startOnMonday is FALSE then the first day of the week is 739 \a startOnMonday is FALSE then the first day of the week is
724 Sunday. 740 Sunday.
725*/ 741*/
726 742
727/*! 743/*!
728 \fn void QPEApplication::dateFormatChanged(DateFormat) 744 \fn void QPEApplication::dateFormatChanged(DateFormat)
729 745
730 This signal is emitted whenever the date format is changed. 746 This signal is emitted whenever the date format is changed.
731*/ 747*/
732 748
733/*! 749/*!
734 \fn void QPEApplication::flush() 750 \fn void QPEApplication::flush()
735 751
736 ### 752 ###
737*/ 753*/
738 754
739/*! 755/*!
740 \fn void QPEApplication::reload() 756 \fn void QPEApplication::reload()
741 757
742*/ 758*/
743 759
744 760
745 761
746void QPEApplication::processQCopFile() 762void QPEApplication::processQCopFile()
747{ 763{
748 QString qcopfn("/tmp/qcop-msg-"); 764 QString qcopfn("/tmp/qcop-msg-");
749 qcopfn += d->appName; // append command name 765 qcopfn += d->appName; // append command name
750 766
751 QFile f(qcopfn); 767 QFile f(qcopfn);
752 if ( f.open(IO_ReadWrite) ) { 768 if ( f.open(IO_ReadWrite) ) {
753#ifndef Q_OS_WIN32 769#ifndef Q_OS_WIN32
754 flock(f.handle(), LOCK_EX); 770 flock(f.handle(), LOCK_EX);
755#endif 771#endif
756 QDataStream ds(&f); 772 QDataStream ds(&f);
757 QCString channel, message; 773 QCString channel, message;
758 QByteArray data; 774 QByteArray data;
759 while(!ds.atEnd()) { 775 while(!ds.atEnd()) {
760 ds >> channel >> message >> data; 776 ds >> channel >> message >> data;
761 d->enqueueQCop(channel,message,data); 777 d->enqueueQCop(channel,message,data);
762 } 778 }
763 ::ftruncate(f.handle(), 0); 779 ::ftruncate(f.handle(), 0);
764#ifndef Q_OS_WIN32 780#ifndef Q_OS_WIN32
765 f.flush(); 781 f.flush();
766 flock(f.handle(), LOCK_UN); 782 flock(f.handle(), LOCK_UN);
767#endif 783#endif
768 } 784 }
769#endif 785#endif
770} 786}
771 787
772 788
773/*! 789/*!
774 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 790 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
775 791
776 This signal is emitted when a message is received on this 792 This signal is emitted when a message is received on this
777 application's QPE/Application/<i>appname</i> \link qcop.html 793 application's QPE/Application/<i>appname</i> \link qcop.html
778 QCop\endlink channel. 794 QCop\endlink channel.
779 795
780 The slot to which you connect this signal uses \a msg and \a data 796 The slot to which you connect this signal uses \a msg and \a data
781 in the following way: 797 in the following way:
782 798
783\code 799\code
784 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 800 void MyWidget::receive( const QCString& msg, const QByteArray& data )
785 { 801 {
786 QDataStream stream( data, IO_ReadOnly ); 802 QDataStream stream( data, IO_ReadOnly );
787 if ( msg == "someMessage(int,int,int)" ) { 803 if ( msg == "someMessage(int,int,int)" ) {
788 int a,b,c; 804 int a,b,c;
789 stream >> a >> b >> c; 805 stream >> a >> b >> c;
790 ... 806 ...
791 } else if ( msg == "otherMessage(QString)" ) { 807 } else if ( msg == "otherMessage(QString)" ) {
792 ... 808 ...
793 } 809 }
794 } 810 }
795\endcode 811\endcode
796 812
797 \sa qcop.html 813 \sa qcop.html
798 Note that messages received here may be processed by qpe application 814 Note that messages received here may be processed by qpe application
799 and emitted as signals, such as flush() and reload(). 815 and emitted as signals, such as flush() and reload().
800*/ 816*/
801 817
802/*! 818/*!
803 Constructs a QPEApplication just as you would construct 819 Constructs a QPEApplication just as you would construct
804 a QApplication, passing \a argc, \a argv, and \a t. 820 a QApplication, passing \a argc, \a argv, and \a t.
805 821
806 For applications, \a t should be the default, GuiClient. Only 822 For applications, \a t should be the default, GuiClient. Only
807 the Qtopia server passes GuiServer. 823 the Qtopia server passes GuiServer.
808*/ 824*/
809QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 825QPEApplication::QPEApplication( int & argc, char **argv, Type t )
810 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 826 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
811{ 827{
812 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 828 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
813 829
814 d = new QPEApplicationData; 830 d = new QPEApplicationData;
815 d->loadTextCodecs(); 831 d->loadTextCodecs();
816 d->loadImageCodecs(); 832 d->loadImageCodecs();
817 833
818 setFont( QFont( d->fontFamily, d->fontSize ) ); 834 setFont( QFont( d->fontFamily, d->fontSize ) );
819 AppLnk::setSmallIconSize( d->smallIconSize ); 835 AppLnk::setSmallIconSize( d->smallIconSize );
820 AppLnk::setBigIconSize( d->bigIconSize ); 836 AppLnk::setBigIconSize( d->bigIconSize );
821 837
822 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 838 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
823 839
824 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 840 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
825 841
826 842
827 sysChannel = new QCopChannel( "QPE/System", this ); 843 sysChannel = new QCopChannel( "QPE/System", this );
828 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 844 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
829 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 845 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
830 846
831/* COde now in initapp */ 847/* COde now in initapp */
832#if 0 848#if 0
833#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 849#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
834 850
835 QString qcopfn( "/tmp/qcop-msg-" ); 851 QString qcopfn( "/tmp/qcop-msg-" );
836 qcopfn += QString( argv[ 0 ] ); // append command name 852 qcopfn += QString( argv[ 0 ] ); // append command name
837 853
838 QFile f( qcopfn ); 854 QFile f( qcopfn );
839 if ( f.open( IO_ReadOnly ) ) { 855 if ( f.open( IO_ReadOnly ) ) {
840 flock( f.handle(), LOCK_EX ); 856 flock( f.handle(), LOCK_EX );
841 } 857 }
842 858
843 859
844 860
845 QCString channel = QCString( argv[ 0 ] ); 861 QCString channel = QCString( argv[ 0 ] );
846 channel.replace( QRegExp( ".*/" ), "" ); 862 channel.replace( QRegExp( ".*/" ), "" );
847 d->appName = channel; 863 d->appName = channel;
848 channel = "QPE/Application/" + channel; 864 channel = "QPE/Application/" + channel;
849 pidChannel = new QCopChannel( channel, this ); 865 pidChannel = new QCopChannel( channel, this );
850 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 866 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
851 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 867 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
852 868
853 if ( f.isOpen() ) { 869 if ( f.isOpen() ) {
854 d->keep_running = FALSE; 870 d->keep_running = FALSE;
855 QDataStream ds( &f ); 871 QDataStream ds( &f );
856 QCString channel, message; 872 QCString channel, message;
857 QByteArray data; 873 QByteArray data;
858 while ( !ds.atEnd() ) { 874 while ( !ds.atEnd() ) {
859 ds >> channel >> message >> data; 875 ds >> channel >> message >> data;
860 d->enqueueQCop( channel, message, data ); 876 d->enqueueQCop( channel, message, data );
861 } 877 }
862 878
863 flock( f.handle(), LOCK_UN ); 879 flock( f.handle(), LOCK_UN );
864 f.close(); 880 f.close();
865 f.remove(); 881 f.remove();
866 } 882 }
867 883
868 for ( int a = 0; a < argc; a++ ) { 884 for ( int a = 0; a < argc; a++ ) {
869 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 885 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
870 argv[ a ] = argv[ a + 1 ]; 886 argv[ a ] = argv[ a + 1 ];
871 a++; 887 a++;
872 d->preloaded = TRUE; 888 d->preloaded = TRUE;
873 argc -= 1; 889 argc -= 1;
874 } 890 }
875 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 891 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
876 argv[ a ] = argv[ a + 1 ]; 892 argv[ a ] = argv[ a + 1 ];
877 a++; 893 a++;
878 d->preloaded = TRUE; 894 d->preloaded = TRUE;
879 d->forceshow = TRUE; 895 d->forceshow = TRUE;
880 argc -= 1; 896 argc -= 1;
881 } 897 }
882 } 898 }
883 899
884 /* overide stored arguments */ 900 /* overide stored arguments */
885 setArgs( argc, argv ); 901 setArgs( argc, argv );
886 902
887#endif 903#endif
888#else 904#else
889 initApp( argc, argv ); 905 initApp( argc, argv );
890#endif 906#endif
891#ifdef Q_WS_QWS 907#ifdef Q_WS_QWS
892 /* load the font renderer factories */ 908 /* load the font renderer factories */
893 FontDatabase::loadRenderers(); 909 FontDatabase::loadRenderers();
894#endif 910#endif
895#ifndef QT_NO_TRANSLATION 911#ifndef QT_NO_TRANSLATION
896 912
897 d->langs = Global::languageList(); 913 d->langs = Global::languageList();
898 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 914 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
899 QString lang = *it; 915 QString lang = *it;
900 916
901 installTranslation( lang + "/libopie.qm"); 917 installTranslation( lang + "/libopie.qm");
902 installTranslation( lang + "/libqpe.qm" ); 918 installTranslation( lang + "/libqpe.qm" );
903 installTranslation( lang + "/" + d->appName + ".qm" ); 919 installTranslation( lang + "/" + d->appName + ".qm" );
904 920
905 921
906 //###language/font hack; should look it up somewhere 922 //###language/font hack; should look it up somewhere
907#ifdef QWS 923#ifdef QWS
908 924
909 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 925 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
910 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 926 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
911 setFont( fn ); 927 setFont( fn );
912 } 928 }
913#endif 929#endif
914 } 930 }
915#endif 931#endif
916 932
917 applyStyle(); 933 applyStyle();
918 934
919 if ( type() == GuiServer ) { 935 if ( type() == GuiServer ) {
920 setVolume(); 936 setVolume();
921 } 937 }
922 938
923 installEventFilter( this ); 939 installEventFilter( this );
924 940
925 QPEMenuToolFocusManager::initialize(); 941 QPEMenuToolFocusManager::initialize();
926 942
927#ifdef QT_NO_QWS_CURSOR 943#ifdef QT_NO_QWS_CURSOR
928 // if we have no cursor, probably don't want tooltips 944 // if we have no cursor, probably don't want tooltips
929 QToolTip::setEnabled( FALSE ); 945 QToolTip::setEnabled( FALSE );
930#endif 946#endif
931} 947}
932 948
933 949
934#ifdef QTOPIA_INTERNAL_INITAPP 950#ifdef QTOPIA_INTERNAL_INITAPP
935void QPEApplication::initApp( int argc, char **argv ) 951void QPEApplication::initApp( int argc, char **argv )
936{ 952{
937 delete pidChannel; 953 delete pidChannel;
938 d->keep_running = TRUE; 954 d->keep_running = TRUE;
939 d->preloaded = FALSE; 955 d->preloaded = FALSE;
940 d->forceshow = FALSE; 956 d->forceshow = FALSE;
941 957
942 QCString channel = QCString(argv[0]); 958 QCString channel = QCString(argv[0]);
943 959
944 channel.replace(QRegExp(".*/"),""); 960 channel.replace(QRegExp(".*/"),"");
945 d->appName = channel; 961 d->appName = channel;
946 962
947 #if QT_VERSION > 235 963 #if QT_VERSION > 235
948 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 964 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
949 #endif 965 #endif
950 966
951 channel = "QPE/Application/" + channel; 967 channel = "QPE/Application/" + channel;
952 pidChannel = new QCopChannel( channel, this); 968 pidChannel = new QCopChannel( channel, this);
953 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 969 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
954 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 970 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
955 971
956 972
957 973
958 processQCopFile(); 974 processQCopFile();
959 d->keep_running = d->qcopq.isEmpty(); 975 d->keep_running = d->qcopq.isEmpty();
960 976
961 for (int a=0; a<argc; a++) { 977 for (int a=0; a<argc; a++) {
962 if ( qstrcmp(argv[a],"-preload")==0 ) { 978 if ( qstrcmp(argv[a],"-preload")==0 ) {
963 argv[a] = argv[a+1]; 979 argv[a] = argv[a+1];
964 a++; 980 a++;
965 d->preloaded = TRUE; 981 d->preloaded = TRUE;
966 argc-=1; 982 argc-=1;
967 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 983 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
968 argv[a] = argv[a+1]; 984 argv[a] = argv[a+1];
969 a++; 985 a++;
970 d->preloaded = TRUE; 986 d->preloaded = TRUE;
971 d->forceshow = TRUE; 987 d->forceshow = TRUE;
972 argc-=1; 988 argc-=1;
973 } 989 }
974 } 990 }
975 991
976 /* overide stored arguments */ 992 /* overide stored arguments */
977 setArgs(argc, argv); 993 setArgs(argc, argv);
978 994
979 /* install translation here */ 995 /* install translation here */
980 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 996 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
981 installTranslation( (*it) + "/" + d->appName + ".qm" ); 997 installTranslation( (*it) + "/" + d->appName + ".qm" );
982} 998}
983#endif 999#endif
984 1000
985 1001
986static QPtrDict<void>* inputMethodDict = 0; 1002static QPtrDict<void>* inputMethodDict = 0;
987static void createInputMethodDict() 1003static void createInputMethodDict()
988{ 1004{
989 if ( !inputMethodDict ) 1005 if ( !inputMethodDict )
990 inputMethodDict = new QPtrDict<void>; 1006 inputMethodDict = new QPtrDict<void>;
991} 1007}
992 1008
993/*! 1009/*!
994 Returns the currently set hint to the system as to whether 1010 Returns the currently set hint to the system as to whether
995 widget \a w has any use for text input methods. 1011 widget \a w has any use for text input methods.
996 1012
997 1013
998 \sa setInputMethodHint() InputMethodHint 1014 \sa setInputMethodHint() InputMethodHint
999*/ 1015*/
1000QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 1016QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
1001{ 1017{
1002 if ( inputMethodDict && w ) 1018 if ( inputMethodDict && w )
1003 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 1019 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
1004 return Normal; 1020 return Normal;
1005} 1021}
1006 1022
1007/*! 1023/*!
1008 \enum QPEApplication::InputMethodHint 1024 \enum QPEApplication::InputMethodHint
1009 1025
1010 \value Normal the application sometimes needs text input (the default). 1026 \value Normal the application sometimes needs text input (the default).
1011 \value AlwaysOff the application never needs text input. 1027 \value AlwaysOff the application never needs text input.
1012 \value AlwaysOn the application always needs text input. 1028 \value AlwaysOn the application always needs text input.
1013*/ 1029*/
1014 1030
1015/*! 1031/*!
1016 Hints to the system that widget \a w has use for text input methods 1032 Hints to the system that widget \a w has use for text input methods
1017 as specified by \a mode. 1033 as specified by \a mode.
1018 1034
1019 \sa inputMethodHint() InputMethodHint 1035 \sa inputMethodHint() InputMethodHint
1020*/ 1036*/
1021void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1037void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1022{ 1038{
1023 createInputMethodDict(); 1039 createInputMethodDict();