summaryrefslogtreecommitdiff
authordrw <drw>2002-06-20 00:32:56 (UTC)
committer drw <drw>2002-06-20 00:32:56 (UTC)
commit2ae11eec4c1b90093e464b863131de07c4528d96 (patch) (unidiff)
treef8df2cf39b9fe183944be3f6453cbfe383729e57
parent51ef8523daa3874e7b5542de6b19423fba261de6 (diff)
downloadopie-2ae11eec4c1b90093e464b863131de07c4528d96.zip
opie-2ae11eec4c1b90093e464b863131de07c4528d96.tar.gz
opie-2ae11eec4c1b90093e464b863131de07c4528d96.tar.bz2
Allow apps to use font selected in appearance app
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index cf437da..f84bc0e 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -41,64 +41,66 @@
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qevent.h> 48#include <qevent.h>
49#include <qtooltip.h> 49#include <qtooltip.h>
50#include <qsignal.h> 50#include <qsignal.h>
51#include <linux/fb.h> 51#include <linux/fb.h>
52 52
53#include <qsignal.h> 53#include <qsignal.h>
54#include "qpeapplication.h" 54#include "qpeapplication.h"
55#include "qpestyle.h" 55#include "qpestyle.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64#endif 64#endif
65#include "global.h" 65#include "global.h"
66#include "resource.h" 66#include "resource.h"
67#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 67#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
68#include "qutfcodec.h" 68#include "qutfcodec.h"
69#endif 69#endif
70#include "config.h" 70#include "config.h"
71#include "network.h" 71#include "network.h"
72#include "fontmanager.h" 72#include "fontmanager.h"
73#include "fontdatabase.h"
74
73#include "power.h" 75#include "power.h"
74#include "alarmserver.h" 76#include "alarmserver.h"
75#include "applnk.h" 77#include "applnk.h"
76#include "qpemenubar.h" 78#include "qpemenubar.h"
77 79
78#include <unistd.h> 80#include <unistd.h>
79#include <sys/file.h> 81#include <sys/file.h>
80#include <sys/ioctl.h> 82#include <sys/ioctl.h>
81#include <sys/soundcard.h> 83#include <sys/soundcard.h>
82 84
83// for setBacklight() 85// for setBacklight()
84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 86#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
85#include <linux/fb.h> 87#include <linux/fb.h>
86#include <sys/types.h> 88#include <sys/types.h>
87#include <sys/stat.h> 89#include <sys/stat.h>
88#endif 90#endif
89#include <stdlib.h> 91#include <stdlib.h>
90 92
91 93
92class QPEApplicationData { 94class QPEApplicationData {
93public: 95public:
94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 96 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 97 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 98 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
97 keep_running(TRUE) 99 keep_running(TRUE)
98 { 100 {
99 qcopq.setAutoDelete(TRUE); 101 qcopq.setAutoDelete(TRUE);
100 } 102 }
101 103
102 int presstimer; 104 int presstimer;
103 QWidget* presswidget; 105 QWidget* presswidget;
104 QPoint presspos; 106 QPoint presspos;
@@ -356,65 +358,65 @@ public:
356 } 358 }
357 bool save(int level) 359 bool save(int level)
358 { 360 {
359 int fd; 361 int fd;
360 362
361 switch ( level ) { 363 switch ( level ) {
362 case 0: 364 case 0:
363 if ( disable_suspend > 0 && dim_on ) { 365 if ( disable_suspend > 0 && dim_on ) {
364 if (backlight() > 1) 366 if (backlight() > 1)
365 setBacklight(1); // lowest non-off 367 setBacklight(1); // lowest non-off
366 } 368 }
367 return TRUE; 369 return TRUE;
368 break; 370 break;
369 case 1: 371 case 1:
370 if ( disable_suspend > 1 && lightoff_on ) { 372 if ( disable_suspend > 1 && lightoff_on ) {
371 setBacklight(0); // off 373 setBacklight(0); // off
372 } 374 }
373 return TRUE; 375 return TRUE;
374 break; 376 break;
375 case 2: 377 case 2:
376 Config config( "qpe" ); 378 Config config( "qpe" );
377 config.setGroup( "Screensaver" ); 379 config.setGroup( "Screensaver" );
378 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD 380 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD
379 { 381 {
380 fd=open("/dev/fb0",O_RDWR); 382 fd=open("/dev/fb0",O_RDWR);
381 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } 383 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); }
382 LcdOn = FALSE; 384 LcdOn = FALSE;
383 } 385 }
384 else // We're going to suspend the whole machine 386 else // We're going to suspend the whole machine
385 { 387 {
386 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 388 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
387 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 389 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
388 return TRUE; 390 return TRUE;
389 } 391 }
390 } 392 }
391 break; 393 break;
392 } 394 }
393 return FALSE; 395 return FALSE;
394 } 396 }
395}; 397};
396 398
397static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) 399static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def)
398{ 400{
399 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 401 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
400 return 0; 402 return 0;
401 403
402 if ( interval < 0 ) { 404 if ( interval < 0 ) {
403 // Restore screen blanking and power saving state 405 // Restore screen blanking and power saving state
404 interval = config.readNumEntry( value, def ); 406 interval = config.readNumEntry( value, def );
405 } 407 }
406 return interval; 408 return interval;
407} 409}
408 410
409static void setScreenSaverIntervals(int i1, int i2, int i3) 411static void setScreenSaverIntervals(int i1, int i2, int i3)
410{ 412{
411 Config config( "qpe" ); 413 Config config( "qpe" );
412 config.setGroup( "Screensaver" ); 414 config.setGroup( "Screensaver" );
413 415
414 int v[4]; 416 int v[4];
415 i1 = ssi(i1, config, "Dim","Interval_Dim", 30); 417 i1 = ssi(i1, config, "Dim","Interval_Dim", 30);
416 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); 418 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20);
417 i3 = ssi(i3, config, "","Interval", 60); 419 i3 = ssi(i3, config, "","Interval", 60);
418 420
419 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 421 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
420 422
@@ -475,65 +477,65 @@ static void setScreenSaverInterval(int interval)
475 This signal is emitted when a message is received on the 477 This signal is emitted when a message is received on the
476 QPE/Application/<i>appname</i> QCop channel for this application. 478 QPE/Application/<i>appname</i> QCop channel for this application.
477 479
478 The slot to which you connect this signal uses \a msg and \a data 480 The slot to which you connect this signal uses \a msg and \a data
479 in the following way: 481 in the following way:
480 482
481\code 483\code
482 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 484 void MyWidget::receive( const QCString& msg, const QByteArray& data )
483 { 485 {
484 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
485 if ( msg == "someMessage(int,int,int)" ) { 487 if ( msg == "someMessage(int,int,int)" ) {
486 int a,b,c; 488 int a,b,c;
487 stream >> a >> b >> c; 489 stream >> a >> b >> c;
488 ... 490 ...
489 } else if ( msg == "otherMessage(QString)" ) { 491 } else if ( msg == "otherMessage(QString)" ) {
490 ... 492 ...
491 } 493 }
492 } 494 }
493\endcode 495\endcode
494 496
495 \sa qcop.html 497 \sa qcop.html
496*/ 498*/
497 499
498/*! 500/*!
499 Constructs a QPEApplication just as you would construct 501 Constructs a QPEApplication just as you would construct
500 a QApplication, passing \a argc, \a argv, and \a t. 502 a QApplication, passing \a argc, \a argv, and \a t.
501*/ 503*/
502QPEApplication::QPEApplication( int& argc, char **argv, Type t ) 504QPEApplication::QPEApplication( int& argc, char **argv, Type t )
503 : QApplication( hack(argc), argv, t ) 505 : QApplication( hack(argc), argv, t )
504{ 506{
505 int dw = desktop()->width(); 507 int dw = desktop()->width();
506 if ( dw < 200 ) { 508 if ( dw < 200 ) {
507 setFont( QFont( "helvetica", 8 ) ); 509// setFont( QFont( "helvetica", 8 ) );
508 AppLnk::setSmallIconSize(10); 510 AppLnk::setSmallIconSize(10);
509 AppLnk::setBigIconSize(28); 511 AppLnk::setBigIconSize(28);
510 } 512 }
511 513
512 d = new QPEApplicationData; 514 d = new QPEApplicationData;
513 QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory); 515 QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory);
514 516
515 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit())); 517 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit()));
516#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 518#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
517 519
518 QString qcopfn("/tmp/qcop-msg-"); 520 QString qcopfn("/tmp/qcop-msg-");
519 qcopfn += QString(argv[0]); // append command name 521 qcopfn += QString(argv[0]); // append command name
520 522
521 QFile f(qcopfn); 523 QFile f(qcopfn);
522 if ( f.open(IO_ReadOnly) ) { 524 if ( f.open(IO_ReadOnly) ) {
523 flock(f.handle(), LOCK_EX); 525 flock(f.handle(), LOCK_EX);
524 } 526 }
525 527
526 sysChannel = new QCopChannel( "QPE/System", this ); 528 sysChannel = new QCopChannel( "QPE/System", this );
527 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 529 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
528 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 530 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
529 531
530 QCString channel = QCString(argv[0]); 532 QCString channel = QCString(argv[0]);
531 channel.replace(QRegExp(".*/"),""); 533 channel.replace(QRegExp(".*/"),"");
532 d->appName = channel; 534 d->appName = channel;
533 channel = "QPE/Application/" + channel; 535 channel = "QPE/Application/" + channel;
534 pidChannel = new QCopChannel( channel, this); 536 pidChannel = new QCopChannel( channel, this);
535 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 537 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
536 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 538 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
537 539
538 if ( f.isOpen() ) { 540 if ( f.isOpen() ) {
539 d->keep_running = FALSE; 541 d->keep_running = FALSE;
@@ -570,65 +572,79 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
570 572
571#endif 573#endif
572 574
573 qwsSetDecoration( new QPEDecoration() ); 575 qwsSetDecoration( new QPEDecoration() );
574 576
575#ifndef QT_NO_TRANSLATION 577#ifndef QT_NO_TRANSLATION
576 QStringList langs = Global::languageList(); 578 QStringList langs = Global::languageList();
577 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 579 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
578 QString lang = *it; 580 QString lang = *it;
579 581
580 QTranslator * trans; 582 QTranslator * trans;
581 QString tfn; 583 QString tfn;
582 584
583 trans = new QTranslator(this); 585 trans = new QTranslator(this);
584 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm"; 586 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
585 if ( trans->load( tfn )) 587 if ( trans->load( tfn ))
586 installTranslator( trans ); 588 installTranslator( trans );
587 else 589 else
588 delete trans; 590 delete trans;
589 591
590 trans = new QTranslator(this); 592 trans = new QTranslator(this);
591 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm"; 593 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
592 if ( trans->load( tfn )) 594 if ( trans->load( tfn ))
593 installTranslator( trans ); 595 installTranslator( trans );
594 else 596 else
595 delete trans; 597 delete trans;
596 598
597 //###language/font hack; should look it up somewhere 599 //###language/font hack; should look it up somewhere
598 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 600 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
599 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 601 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
600 setFont( fn ); 602 setFont( fn );
601 } 603 }
604 else {
605 Config config( "qpe" );
606 config.setGroup( "Appearance" );
607 QString familyStr = config.readEntry( "FontFamily", "fixed" );
608 QString styleStr = config.readEntry( "FontStyle", "Regular" );
609 QString sizeStr = config.readEntry( "FontSize", "10" );
610 QString charSetStr = config.readEntry( "FontCharSet", "iso10646-1" );
611 bool ok;
612 int i_size = sizeStr.toInt( &ok, 10 );
613 FontDatabase fdb;
614 QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr );
615 setFont( selectedFont );
616 }
602 } 617 }
618
603#endif 619#endif
604 620
605 applyStyle(); 621 applyStyle();
606 622
607 if ( type() == GuiServer ) { 623 if ( type() == GuiServer ) {
608 setScreenSaverInterval(-1); 624 setScreenSaverInterval(-1);
609 setVolume(); 625 setVolume();
610 QWSServer::setScreenSaver(new QPEScreenSaver); 626 QWSServer::setScreenSaver(new QPEScreenSaver);
611 } 627 }
612 628
613 installEventFilter( this ); 629 installEventFilter( this );
614 630
615 QPEMenuToolFocusManager::initialize(); 631 QPEMenuToolFocusManager::initialize();
616 632
617#ifdef QT_NO_QWS_CURSOR 633#ifdef QT_NO_QWS_CURSOR
618 // if we have no cursor, probably don't want tooltips 634 // if we have no cursor, probably don't want tooltips
619 QToolTip::setEnabled( FALSE ); 635 QToolTip::setEnabled( FALSE );
620#endif 636#endif
621} 637}
622 638
623static QPtrDict<void>* inputMethodDict=0; 639static QPtrDict<void>* inputMethodDict=0;
624static void createInputMethodDict() 640static void createInputMethodDict()
625{ 641{
626 if ( !inputMethodDict ) 642 if ( !inputMethodDict )
627 inputMethodDict = new QPtrDict<void>; 643 inputMethodDict = new QPtrDict<void>;
628} 644}
629 645
630/*! 646/*!
631 Returns the currently set hint to the system as to whether 647 Returns the currently set hint to the system as to whether
632 \a w has any use for text input methods. 648 \a w has any use for text input methods.
633 649
634 \sa setInputMethodHint() 650 \sa setInputMethodHint()