author | zecke <zecke> | 2002-09-10 14:27:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 14:27:11 (UTC) |
commit | a768f061a0e4ea279ab70aa2d3e109fc71cb8737 (patch) (unidiff) | |
tree | e28952f0ee080942bb92bf347d16c21048a8a495 | |
parent | 8b59b498892b0e345d977ccd520087b660a91437 (diff) | |
download | opie-a768f061a0e4ea279ab70aa2d3e109fc71cb8737.zip opie-a768f061a0e4ea279ab70aa2d3e109fc71cb8737.tar.gz opie-a768f061a0e4ea279ab70aa2d3e109fc71cb8737.tar.bz2 |
Icon size update
-rw-r--r-- | library/qpeapplication.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 3ca6d73..c107a08 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -190,521 +190,522 @@ public: | |||
190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
191 | QDir dir( path, "lib*.so" ); | 191 | QDir dir( path, "lib*.so" ); |
192 | QStringList list = dir.entryList(); | 192 | QStringList list = dir.entryList(); |
193 | QStringList::Iterator it; | 193 | QStringList::Iterator it; |
194 | for ( it = list.begin(); it != list.end(); ++it ) { | 194 | for ( it = list.begin(); it != list.end(); ++it ) { |
195 | TextCodecInterface *iface = 0; | 195 | TextCodecInterface *iface = 0; |
196 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 196 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
198 | QValueList<int> mibs = iface->mibEnums(); | 198 | QValueList<int> mibs = iface->mibEnums(); |
199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { | 199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { |
200 | (void)iface->createForMib(*i); | 200 | (void)iface->createForMib(*i); |
201 | // ### it exists now; need to remember if we can delete it | 201 | // ### it exists now; need to remember if we can delete it |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | lib->unload(); | 204 | lib->unload(); |
205 | delete lib; | 205 | delete lib; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void loadImageCodecs() | 210 | void loadImageCodecs() |
211 | { | 211 | { |
212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
213 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
214 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
217 | ImageCodecInterface *iface = 0; | 217 | ImageCodecInterface *iface = 0; |
218 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QStringList formats = iface->keys(); | 220 | QStringList formats = iface->keys(); |
221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { | 221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { |
222 | (void)iface->installIOHandler(*i); | 222 | (void)iface->installIOHandler(*i); |
223 | // ### it exists now; need to remember if we can delete it | 223 | // ### it exists now; need to remember if we can delete it |
224 | } | 224 | } |
225 | } else { | 225 | } else { |
226 | lib->unload(); | 226 | lib->unload(); |
227 | delete lib; | 227 | delete lib; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | QString styleName; | 231 | QString styleName; |
232 | QString decorationName; | 232 | QString decorationName; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 235 | class ResourceMimeFactory : public QMimeSourceFactory { |
236 | public: | 236 | public: |
237 | ResourceMimeFactory() | 237 | ResourceMimeFactory() |
238 | { | 238 | { |
239 | setFilePath( Global::helpPath() ); | 239 | setFilePath( Global::helpPath() ); |
240 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 240 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
241 | } | 241 | } |
242 | 242 | ||
243 | const QMimeSource* data( const QString& abs_name ) const | 243 | const QMimeSource* data( const QString& abs_name ) const |
244 | { | 244 | { |
245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
246 | if ( !r ) { | 246 | if ( !r ) { |
247 | int sl = abs_name.length(); | 247 | int sl = abs_name.length(); |
248 | do { | 248 | do { |
249 | sl = abs_name.findRev( '/', sl - 1 ); | 249 | sl = abs_name.findRev( '/', sl - 1 ); |
250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
251 | int dot = name.findRev( '.' ); | 251 | int dot = name.findRev( '.' ); |
252 | if ( dot >= 0 ) | 252 | if ( dot >= 0 ) |
253 | name = name.left( dot ); | 253 | name = name.left( dot ); |
254 | QImage img = Resource::loadImage( name ); | 254 | QImage img = Resource::loadImage( name ); |
255 | if ( !img.isNull() ) | 255 | if ( !img.isNull() ) |
256 | r = new QImageDrag( img ); | 256 | r = new QImageDrag( img ); |
257 | } | 257 | } |
258 | while ( !r && sl > 0 ); | 258 | while ( !r && sl > 0 ); |
259 | } | 259 | } |
260 | return r; | 260 | return r; |
261 | } | 261 | } |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int muted = 0; | 264 | static int muted = 0; |
265 | static int micMuted = 0; | 265 | static int micMuted = 0; |
266 | 266 | ||
267 | static void setVolume( int t = 0, int percent = -1 ) | 267 | static void setVolume( int t = 0, int percent = -1 ) |
268 | { | 268 | { |
269 | switch ( t ) { | 269 | switch ( t ) { |
270 | case 0: { | 270 | case 0: { |
271 | Config cfg( "qpe" ); | 271 | Config cfg( "qpe" ); |
272 | cfg.setGroup( "Volume" ); | 272 | cfg.setGroup( "Volume" ); |
273 | if ( percent < 0 ) | 273 | if ( percent < 0 ) |
274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
275 | int fd = 0; | 275 | int fd = 0; |
276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
277 | int vol = muted ? 0 : percent; | 277 | int vol = muted ? 0 : percent; |
278 | // set both channels to same volume | 278 | // set both channels to same volume |
279 | vol |= vol << 8; | 279 | vol |= vol << 8; |
280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
281 | ::close( fd ); | 281 | ::close( fd ); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | static void setMic( int t = 0, int percent = -1 ) | 288 | static void setMic( int t = 0, int percent = -1 ) |
289 | { | 289 | { |
290 | switch ( t ) { | 290 | switch ( t ) { |
291 | case 0: { | 291 | case 0: { |
292 | Config cfg( "qpe" ); | 292 | Config cfg( "qpe" ); |
293 | cfg.setGroup( "Volume" ); | 293 | cfg.setGroup( "Volume" ); |
294 | if ( percent < 0 ) | 294 | if ( percent < 0 ) |
295 | percent = cfg.readNumEntry( "Mic", 50 ); | 295 | percent = cfg.readNumEntry( "Mic", 50 ); |
296 | 296 | ||
297 | int fd = 0; | 297 | int fd = 0; |
298 | int mic = micMuted ? 0 : percent; | 298 | int mic = micMuted ? 0 : percent; |
299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
301 | ::close( fd ); | 301 | ::close( fd ); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | /*! | 309 | /*! |
310 | \class QPEApplication qpeapplication.h | 310 | \class QPEApplication qpeapplication.h |
311 | \brief The QPEApplication class implements various system services | 311 | \brief The QPEApplication class implements various system services |
312 | that are available to all Qtopia applications. | 312 | that are available to all Qtopia applications. |
313 | 313 | ||
314 | Simply by using QPEApplication instead of QApplication, a standard Qt | 314 | Simply by using QPEApplication instead of QApplication, a standard Qt |
315 | application becomes a Qtopia application. It automatically follows | 315 | application becomes a Qtopia application. It automatically follows |
316 | style changes, quits and raises, and in the | 316 | style changes, quits and raises, and in the |
317 | case of \link docwidget.html document-oriented\endlink applications, | 317 | case of \link docwidget.html document-oriented\endlink applications, |
318 | changes the currently displayed document in response to the environment. | 318 | changes the currently displayed document in response to the environment. |
319 | 319 | ||
320 | To create a \link docwidget.html document-oriented\endlink | 320 | To create a \link docwidget.html document-oriented\endlink |
321 | application use showMainDocumentWidget(); to create a | 321 | application use showMainDocumentWidget(); to create a |
322 | non-document-oriented application use showMainWidget(). The | 322 | non-document-oriented application use showMainWidget(). The |
323 | keepRunning() function indicates whether the application will | 323 | keepRunning() function indicates whether the application will |
324 | continue running after it's processed the last \link qcop.html | 324 | continue running after it's processed the last \link qcop.html |
325 | QCop\endlink message. This can be changed using setKeepRunning(). | 325 | QCop\endlink message. This can be changed using setKeepRunning(). |
326 | 326 | ||
327 | A variety of signals are emitted when certain events occur, for | 327 | A variety of signals are emitted when certain events occur, for |
328 | example, timeChanged(), clockChanged(), weekChanged(), | 328 | example, timeChanged(), clockChanged(), weekChanged(), |
329 | dateFormatChanged() and volumeChanged(). If the application receives | 329 | dateFormatChanged() and volumeChanged(). If the application receives |
330 | a \link qcop.html QCop\endlink message on the application's | 330 | a \link qcop.html QCop\endlink message on the application's |
331 | QPE/Application/\e{appname} channel, the appMessage() signal is | 331 | QPE/Application/\e{appname} channel, the appMessage() signal is |
332 | emitted. There are also flush() and reload() signals, which | 332 | emitted. There are also flush() and reload() signals, which |
333 | are emitted when synching begins and ends respectively - upon these | 333 | are emitted when synching begins and ends respectively - upon these |
334 | signals, the application should save and reload any data | 334 | signals, the application should save and reload any data |
335 | files that are involved in synching. Most of these signals will initially | 335 | files that are involved in synching. Most of these signals will initially |
336 | be received and unfiltered through the appMessage() signal. | 336 | be received and unfiltered through the appMessage() signal. |
337 | 337 | ||
338 | This class also provides a set of useful static functions. The | 338 | This class also provides a set of useful static functions. The |
339 | qpeDir() and documentDir() functions return the respective paths. | 339 | qpeDir() and documentDir() functions return the respective paths. |
340 | The grabKeyboard() and ungrabKeyboard() functions are used to | 340 | The grabKeyboard() and ungrabKeyboard() functions are used to |
341 | control whether the application takes control of the device's | 341 | control whether the application takes control of the device's |
342 | physical buttons (e.g. application launch keys). The stylus' mode of | 342 | physical buttons (e.g. application launch keys). The stylus' mode of |
343 | operation is set with setStylusOperation() and retrieved with | 343 | operation is set with setStylusOperation() and retrieved with |
344 | stylusOperation(). There are also setInputMethodHint() and | 344 | stylusOperation(). There are also setInputMethodHint() and |
345 | inputMethodHint() functions. | 345 | inputMethodHint() functions. |
346 | 346 | ||
347 | \ingroup qtopiaemb | 347 | \ingroup qtopiaemb |
348 | */ | 348 | */ |
349 | 349 | ||
350 | /*! | 350 | /*! |
351 | \fn void QPEApplication::clientMoused() | 351 | \fn void QPEApplication::clientMoused() |
352 | 352 | ||
353 | \internal | 353 | \internal |
354 | */ | 354 | */ |
355 | 355 | ||
356 | /*! | 356 | /*! |
357 | \fn void QPEApplication::timeChanged(); | 357 | \fn void QPEApplication::timeChanged(); |
358 | This signal is emitted when the time changes outside the normal | 358 | This signal is emitted when the time changes outside the normal |
359 | passage of time, i.e. if the time is set backwards or forwards. | 359 | passage of time, i.e. if the time is set backwards or forwards. |
360 | */ | 360 | */ |
361 | 361 | ||
362 | /*! | 362 | /*! |
363 | \fn void QPEApplication::clockChanged( bool ampm ); | 363 | \fn void QPEApplication::clockChanged( bool ampm ); |
364 | 364 | ||
365 | This signal is emitted when the user changes the clock's style. If | 365 | This signal is emitted when the user changes the clock's style. If |
366 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 366 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
367 | they want a 24-hour clock. | 367 | they want a 24-hour clock. |
368 | */ | 368 | */ |
369 | 369 | ||
370 | /*! | 370 | /*! |
371 | \fn void QPEApplication::volumeChanged( bool muted ) | 371 | \fn void QPEApplication::volumeChanged( bool muted ) |
372 | 372 | ||
373 | This signal is emitted whenever the mute state is changed. If \a | 373 | This signal is emitted whenever the mute state is changed. If \a |
374 | muted is TRUE, then sound output has been muted. | 374 | muted is TRUE, then sound output has been muted. |
375 | */ | 375 | */ |
376 | 376 | ||
377 | /*! | 377 | /*! |
378 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 378 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
379 | 379 | ||
380 | This signal is emitted if the week start day is changed. If \a | 380 | This signal is emitted if the week start day is changed. If \a |
381 | startOnMonday is TRUE then the first day of the week is Monday; if | 381 | startOnMonday is TRUE then the first day of the week is Monday; if |
382 | \a startOnMonday is FALSE then the first day of the week is | 382 | \a startOnMonday is FALSE then the first day of the week is |
383 | Sunday. | 383 | Sunday. |
384 | */ | 384 | */ |
385 | 385 | ||
386 | /*! | 386 | /*! |
387 | \fn void QPEApplication::dateFormatChanged() | 387 | \fn void QPEApplication::dateFormatChanged() |
388 | 388 | ||
389 | This signal is emitted whenever the date format is changed. | 389 | This signal is emitted whenever the date format is changed. |
390 | */ | 390 | */ |
391 | 391 | ||
392 | /*! | 392 | /*! |
393 | \fn void QPEApplication::flush() | 393 | \fn void QPEApplication::flush() |
394 | 394 | ||
395 | ### | 395 | ### |
396 | */ | 396 | */ |
397 | 397 | ||
398 | /*! | 398 | /*! |
399 | \fn void QPEApplication::reload() | 399 | \fn void QPEApplication::reload() |
400 | 400 | ||
401 | */ | 401 | */ |
402 | 402 | ||
403 | /*! | 403 | /*! |
404 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 404 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
405 | 405 | ||
406 | This signal is emitted when a message is received on this | 406 | This signal is emitted when a message is received on this |
407 | application's QPE/Application/<i>appname</i> \link qcop.html | 407 | application's QPE/Application/<i>appname</i> \link qcop.html |
408 | QCop\endlink channel. | 408 | QCop\endlink channel. |
409 | 409 | ||
410 | The slot to which you connect this signal uses \a msg and \a data | 410 | The slot to which you connect this signal uses \a msg and \a data |
411 | in the following way: | 411 | in the following way: |
412 | 412 | ||
413 | \code | 413 | \code |
414 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 414 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
415 | { | 415 | { |
416 | QDataStream stream( data, IO_ReadOnly ); | 416 | QDataStream stream( data, IO_ReadOnly ); |
417 | if ( msg == "someMessage(int,int,int)" ) { | 417 | if ( msg == "someMessage(int,int,int)" ) { |
418 | int a,b,c; | 418 | int a,b,c; |
419 | stream >> a >> b >> c; | 419 | stream >> a >> b >> c; |
420 | ... | 420 | ... |
421 | } else if ( msg == "otherMessage(QString)" ) { | 421 | } else if ( msg == "otherMessage(QString)" ) { |
422 | ... | 422 | ... |
423 | } | 423 | } |
424 | } | 424 | } |
425 | \endcode | 425 | \endcode |
426 | 426 | ||
427 | \sa qcop.html | 427 | \sa qcop.html |
428 | Note that messages received here may be processed by qpe application | 428 | Note that messages received here may be processed by qpe application |
429 | and emitted as signals, such as flush() and reload(). | 429 | and emitted as signals, such as flush() and reload(). |
430 | */ | 430 | */ |
431 | 431 | ||
432 | /*! | 432 | /*! |
433 | Constructs a QPEApplication just as you would construct | 433 | Constructs a QPEApplication just as you would construct |
434 | a QApplication, passing \a argc, \a argv, and \a t. | 434 | a QApplication, passing \a argc, \a argv, and \a t. |
435 | 435 | ||
436 | For applications, \a t should be the default, GuiClient. Only | 436 | For applications, \a t should be the default, GuiClient. Only |
437 | the Qtopia server passes GuiServer. | 437 | the Qtopia server passes GuiServer. |
438 | */ | 438 | */ |
439 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 439 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
440 | : QApplication( argc, argv, t ) | 440 | : QApplication( argc, argv, t ) |
441 | { | 441 | { |
442 | d = new QPEApplicationData; | 442 | d = new QPEApplicationData; |
443 | d->loadTextCodecs(); | 443 | d->loadTextCodecs(); |
444 | d->loadImageCodecs(); | 444 | d->loadImageCodecs(); |
445 | int dw = desktop() ->width(); | 445 | int dw = desktop() ->width(); |
446 | qWarning( "Width %d", dw ); | ||
446 | if ( dw < 200 ) { | 447 | if ( dw < 200 ) { |
447 | setFont( QFont( "helvetica", 8 ) ); | 448 | setFont( QFont( "helvetica", 8 ) ); |
448 | AppLnk::setSmallIconSize( 10 ); | 449 | AppLnk::setSmallIconSize( 10 ); |
449 | AppLnk::setBigIconSize( 28 ); | 450 | AppLnk::setBigIconSize( 28 ); |
450 | }else if ( dw > 600 ) { | 451 | }else if ( dw > 600 ) { |
451 | setFont( QFont( "helvetica", 12 ) ); | 452 | setFont( QFont( "helvetica", 12 ) ); |
452 | AppLnk::setSmallIconSize( 24 ); | 453 | AppLnk::setSmallIconSize( 24 ); |
453 | AppLnk::setBigIconSize( 48 ); | 454 | AppLnk::setBigIconSize( 48 ); |
454 | }else if ( dw > 400 ) { | 455 | }else if ( dw > 200 ) { |
455 | setFont( QFont( "helvetica", 12 ) ); | 456 | setFont( QFont( "helvetica", 12 ) ); |
456 | AppLnk::setSmallIconSize( 16 ); | 457 | AppLnk::setSmallIconSize( 16 ); |
457 | AppLnk::setBigIconSize( 32 ); | 458 | AppLnk::setBigIconSize( 32 ); |
458 | } | 459 | } |
459 | 460 | ||
460 | 461 | ||
461 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 462 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
462 | 463 | ||
463 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 464 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
464 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 465 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
465 | 466 | ||
466 | QString qcopfn( "/tmp/qcop-msg-" ); | 467 | QString qcopfn( "/tmp/qcop-msg-" ); |
467 | qcopfn += QString( argv[ 0 ] ); // append command name | 468 | qcopfn += QString( argv[ 0 ] ); // append command name |
468 | 469 | ||
469 | QFile f( qcopfn ); | 470 | QFile f( qcopfn ); |
470 | if ( f.open( IO_ReadOnly ) ) { | 471 | if ( f.open( IO_ReadOnly ) ) { |
471 | flock( f.handle(), LOCK_EX ); | 472 | flock( f.handle(), LOCK_EX ); |
472 | } | 473 | } |
473 | 474 | ||
474 | sysChannel = new QCopChannel( "QPE/System", this ); | 475 | sysChannel = new QCopChannel( "QPE/System", this ); |
475 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 476 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
476 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 477 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
477 | 478 | ||
478 | QCString channel = QCString( argv[ 0 ] ); | 479 | QCString channel = QCString( argv[ 0 ] ); |
479 | channel.replace( QRegExp( ".*/" ), "" ); | 480 | channel.replace( QRegExp( ".*/" ), "" ); |
480 | d->appName = channel; | 481 | d->appName = channel; |
481 | channel = "QPE/Application/" + channel; | 482 | channel = "QPE/Application/" + channel; |
482 | pidChannel = new QCopChannel( channel, this ); | 483 | pidChannel = new QCopChannel( channel, this ); |
483 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 484 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
484 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 485 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
485 | 486 | ||
486 | if ( f.isOpen() ) { | 487 | if ( f.isOpen() ) { |
487 | d->keep_running = FALSE; | 488 | d->keep_running = FALSE; |
488 | QDataStream ds( &f ); | 489 | QDataStream ds( &f ); |
489 | QCString channel, message; | 490 | QCString channel, message; |
490 | QByteArray data; | 491 | QByteArray data; |
491 | while ( !ds.atEnd() ) { | 492 | while ( !ds.atEnd() ) { |
492 | ds >> channel >> message >> data; | 493 | ds >> channel >> message >> data; |
493 | d->enqueueQCop( channel, message, data ); | 494 | d->enqueueQCop( channel, message, data ); |
494 | } | 495 | } |
495 | 496 | ||
496 | flock( f.handle(), LOCK_UN ); | 497 | flock( f.handle(), LOCK_UN ); |
497 | f.close(); | 498 | f.close(); |
498 | f.remove(); | 499 | f.remove(); |
499 | } | 500 | } |
500 | 501 | ||
501 | for ( int a = 0; a < argc; a++ ) { | 502 | for ( int a = 0; a < argc; a++ ) { |
502 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 503 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
503 | argv[ a ] = argv[ a + 1 ]; | 504 | argv[ a ] = argv[ a + 1 ]; |
504 | a++; | 505 | a++; |
505 | d->preloaded = TRUE; | 506 | d->preloaded = TRUE; |
506 | argc -= 1; | 507 | argc -= 1; |
507 | } | 508 | } |
508 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 509 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
509 | argv[ a ] = argv[ a + 1 ]; | 510 | argv[ a ] = argv[ a + 1 ]; |
510 | a++; | 511 | a++; |
511 | d->preloaded = TRUE; | 512 | d->preloaded = TRUE; |
512 | d->forceshow = TRUE; | 513 | d->forceshow = TRUE; |
513 | argc -= 1; | 514 | argc -= 1; |
514 | } | 515 | } |
515 | } | 516 | } |
516 | 517 | ||
517 | /* overide stored arguments */ | 518 | /* overide stored arguments */ |
518 | setArgs( argc, argv ); | 519 | setArgs( argc, argv ); |
519 | 520 | ||
520 | #endif | 521 | #endif |
521 | 522 | ||
522 | //qwsSetDecoration( new QPEDecoration() ); | 523 | //qwsSetDecoration( new QPEDecoration() ); |
523 | 524 | ||
524 | #ifndef QT_NO_TRANSLATION | 525 | #ifndef QT_NO_TRANSLATION |
525 | 526 | ||
526 | QStringList langs = Global::languageList(); | 527 | QStringList langs = Global::languageList(); |
527 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
528 | QString lang = *it; | 529 | QString lang = *it; |
529 | 530 | ||
530 | QTranslator * trans; | 531 | QTranslator * trans; |
531 | QString tfn; | 532 | QString tfn; |
532 | 533 | ||
533 | trans = new QTranslator( this ); | 534 | trans = new QTranslator( this ); |
534 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 535 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
535 | if ( trans->load( tfn ) ) | 536 | if ( trans->load( tfn ) ) |
536 | installTranslator( trans ); | 537 | installTranslator( trans ); |
537 | else | 538 | else |
538 | delete trans; | 539 | delete trans; |
539 | 540 | ||
540 | trans = new QTranslator( this ); | 541 | trans = new QTranslator( this ); |
541 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
542 | if ( trans->load( tfn ) ) | 543 | if ( trans->load( tfn ) ) |
543 | installTranslator( trans ); | 544 | installTranslator( trans ); |
544 | else | 545 | else |
545 | delete trans; | 546 | delete trans; |
546 | 547 | ||
547 | //###language/font hack; should look it up somewhere | 548 | //###language/font hack; should look it up somewhere |
548 | #ifdef QWS | 549 | #ifdef QWS |
549 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
550 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
551 | setFont( fn ); | 552 | setFont( fn ); |
552 | } | 553 | } |
553 | #endif | 554 | #endif |
554 | } | 555 | } |
555 | #endif | 556 | #endif |
556 | 557 | ||
557 | applyStyle(); | 558 | applyStyle(); |
558 | 559 | ||
559 | if ( type() == GuiServer ) { | 560 | if ( type() == GuiServer ) { |
560 | setVolume(); | 561 | setVolume(); |
561 | } | 562 | } |
562 | 563 | ||
563 | installEventFilter( this ); | 564 | installEventFilter( this ); |
564 | 565 | ||
565 | QPEMenuToolFocusManager::initialize(); | 566 | QPEMenuToolFocusManager::initialize(); |
566 | 567 | ||
567 | #ifdef QT_NO_QWS_CURSOR | 568 | #ifdef QT_NO_QWS_CURSOR |
568 | // if we have no cursor, probably don't want tooltips | 569 | // if we have no cursor, probably don't want tooltips |
569 | QToolTip::setEnabled( FALSE ); | 570 | QToolTip::setEnabled( FALSE ); |
570 | #endif | 571 | #endif |
571 | } | 572 | } |
572 | 573 | ||
573 | static QPtrDict<void>* inputMethodDict = 0; | 574 | static QPtrDict<void>* inputMethodDict = 0; |
574 | static void createInputMethodDict() | 575 | static void createInputMethodDict() |
575 | { | 576 | { |
576 | if ( !inputMethodDict ) | 577 | if ( !inputMethodDict ) |
577 | inputMethodDict = new QPtrDict<void>; | 578 | inputMethodDict = new QPtrDict<void>; |
578 | } | 579 | } |
579 | 580 | ||
580 | /*! | 581 | /*! |
581 | Returns the currently set hint to the system as to whether | 582 | Returns the currently set hint to the system as to whether |
582 | widget \a w has any use for text input methods. | 583 | widget \a w has any use for text input methods. |
583 | 584 | ||
584 | 585 | ||
585 | \sa setInputMethodHint() InputMethodHint | 586 | \sa setInputMethodHint() InputMethodHint |
586 | */ | 587 | */ |
587 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
588 | { | 589 | { |
589 | if ( inputMethodDict && w ) | 590 | if ( inputMethodDict && w ) |
590 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
591 | return Normal; | 592 | return Normal; |
592 | } | 593 | } |
593 | 594 | ||
594 | /*! | 595 | /*! |
595 | \enum QPEApplication::InputMethodHint | 596 | \enum QPEApplication::InputMethodHint |
596 | 597 | ||
597 | \value Normal the application sometimes needs text input (the default). | 598 | \value Normal the application sometimes needs text input (the default). |
598 | \value AlwaysOff the application never needs text input. | 599 | \value AlwaysOff the application never needs text input. |
599 | \value AlwaysOn the application always needs text input. | 600 | \value AlwaysOn the application always needs text input. |
600 | */ | 601 | */ |
601 | 602 | ||
602 | /*! | 603 | /*! |
603 | Hints to the system that widget \a w has use for text input methods | 604 | Hints to the system that widget \a w has use for text input methods |
604 | as specified by \a mode. | 605 | as specified by \a mode. |
605 | 606 | ||
606 | \sa inputMethodHint() InputMethodHint | 607 | \sa inputMethodHint() InputMethodHint |
607 | */ | 608 | */ |
608 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
609 | { | 610 | { |
610 | createInputMethodDict(); | 611 | createInputMethodDict(); |
611 | if ( mode == Normal ) { | 612 | if ( mode == Normal ) { |
612 | inputMethodDict->remove | 613 | inputMethodDict->remove |
613 | ( w ); | 614 | ( w ); |
614 | } | 615 | } |
615 | else { | 616 | else { |
616 | inputMethodDict->insert( w, ( void* ) mode ); | 617 | inputMethodDict->insert( w, ( void* ) mode ); |
617 | } | 618 | } |
618 | } | 619 | } |
619 | 620 | ||
620 | class HackDialog : public QDialog | 621 | class HackDialog : public QDialog |
621 | { | 622 | { |
622 | public: | 623 | public: |
623 | void acceptIt() { accept(); } | 624 | void acceptIt() { accept(); } |
624 | void rejectIt() { reject(); } | 625 | void rejectIt() { reject(); } |
625 | }; | 626 | }; |
626 | 627 | ||
627 | 628 | ||
628 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
629 | { | 630 | { |
630 | // specialised actions for certain widgets. May want to | 631 | // specialised actions for certain widgets. May want to |
631 | // add more stuff here. | 632 | // add more stuff here. |
632 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 633 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
633 | && activePopupWidget() ->parentWidget() | 634 | && activePopupWidget() ->parentWidget() |
634 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 635 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
635 | key = Qt::Key_Return; | 636 | key = Qt::Key_Return; |
636 | 637 | ||
637 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
638 | key = Qt::Key_Return; | 639 | key = Qt::Key_Return; |
639 | 640 | ||
640 | #ifdef QWS | 641 | #ifdef QWS |
641 | ke->simpleData.keycode = key; | 642 | ke->simpleData.keycode = key; |
642 | #endif | 643 | #endif |
643 | } | 644 | } |
644 | 645 | ||
645 | class HackWidget : public QWidget | 646 | class HackWidget : public QWidget |
646 | { | 647 | { |
647 | public: | 648 | public: |
648 | bool needsOk() | 649 | bool needsOk() |
649 | { return ( getWState() & WState_Reserved1 ); } | 650 | { return ( getWState() & WState_Reserved1 ); } |
650 | }; | 651 | }; |
651 | 652 | ||
652 | /*! | 653 | /*! |
653 | \internal | 654 | \internal |
654 | */ | 655 | */ |
655 | 656 | ||
656 | #ifdef QWS | 657 | #ifdef QWS |
657 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
658 | { | 659 | { |
659 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 660 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
660 | if ( qApp->type() != QApplication::GuiServer ) { | 661 | if ( qApp->type() != QApplication::GuiServer ) { |
661 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 662 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
662 | e << d->appName; | 663 | e << d->appName; |
663 | } | 664 | } |
664 | d->notbusysent = TRUE; | 665 | d->notbusysent = TRUE; |
665 | } | 666 | } |
666 | if ( type() == GuiServer ) { | 667 | if ( type() == GuiServer ) { |
667 | switch ( e->type ) { | 668 | switch ( e->type ) { |
668 | case QWSEvent::Mouse: | 669 | case QWSEvent::Mouse: |
669 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 670 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
670 | emit clientMoused(); | 671 | emit clientMoused(); |
671 | break; | 672 | break; |
672 | default: | 673 | default: |
673 | break; | 674 | break; |
674 | } | 675 | } |
675 | } | 676 | } |
676 | if ( e->type == QWSEvent::Key ) { | 677 | if ( e->type == QWSEvent::Key ) { |
677 | if ( d->kbgrabber == 1 ) | 678 | if ( d->kbgrabber == 1 ) |
678 | return TRUE; | 679 | return TRUE; |
679 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 680 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
680 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 681 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
681 | // Use special "OK" key to press "OK" on top level widgets | 682 | // Use special "OK" key to press "OK" on top level widgets |
682 | QWidget * active = activeWindow(); | 683 | QWidget * active = activeWindow(); |
683 | QWidget *popup = 0; | 684 | QWidget *popup = 0; |
684 | if ( active && active->isPopup() ) { | 685 | if ( active && active->isPopup() ) { |
685 | popup = active; | 686 | popup = active; |
686 | active = active->parentWidget(); | 687 | active = active->parentWidget(); |
687 | } | 688 | } |
688 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 689 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
689 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 690 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
690 | if ( ke->simpleData.is_press ) { | 691 | if ( ke->simpleData.is_press ) { |
691 | if ( popup ) | 692 | if ( popup ) |
692 | popup->close(); | 693 | popup->close(); |
693 | if ( active->inherits( "QDialog" ) ) { | 694 | if ( active->inherits( "QDialog" ) ) { |
694 | HackDialog * d = ( HackDialog * ) active; | 695 | HackDialog * d = ( HackDialog * ) active; |
695 | d->acceptIt(); | 696 | d->acceptIt(); |
696 | return TRUE; | 697 | return TRUE; |
697 | } | 698 | } |
698 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 699 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
699 | QSignal s; | 700 | QSignal s; |
700 | s.connect( active, SLOT( accept() ) ); | 701 | s.connect( active, SLOT( accept() ) ); |
701 | s.activate(); | 702 | s.activate(); |
702 | } | 703 | } |
703 | else { | 704 | else { |
704 | // do the same as with the select key: Map to the default action of the widget: | 705 | // do the same as with the select key: Map to the default action of the widget: |
705 | mapToDefaultAction( ke, Qt::Key_Return ); | 706 | mapToDefaultAction( ke, Qt::Key_Return ); |
706 | } | 707 | } |
707 | } | 708 | } |
708 | } | 709 | } |
709 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
710 | // Use special "select" key to do whatever default action a widget has | 711 | // Use special "select" key to do whatever default action a widget has |