summaryrefslogtreecommitdiff
authordrw <drw>2002-06-20 00:32:56 (UTC)
committer drw <drw>2002-06-20 00:32:56 (UTC)
commit2ae11eec4c1b90093e464b863131de07c4528d96 (patch) (side-by-side diff)
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
@@ -25,96 +25,98 @@
#include <qfile.h>
#ifdef Q_WS_QWS
#ifndef QT_NO_COP
#if QT_VERSION <= 231
#define private public
#define sendLocally processEvent
#include "qcopenvelope_qws.h"
#undef private
#else
#include "qcopenvelope_qws.h"
#endif
#endif
#include <qwindowsystem_qws.h>
#endif
#include <qtextstream.h>
#include <qpalette.h>
#include <qbuffer.h>
#include <qptrdict.h>
#include <qregexp.h>
#include <qdir.h>
#include <qlabel.h>
#include <qdialog.h>
#include <qdragobject.h>
#include <qevent.h>
#include <qtooltip.h>
#include <qsignal.h>
#include <linux/fb.h>
#include <qsignal.h>
#include "qpeapplication.h"
#include "qpestyle.h"
#if QT_VERSION >= 300
#include <qstylefactory.h>
#else
#include <qplatinumstyle.h>
#include <qwindowsstyle.h>
#include <qmotifstyle.h>
#include <qmotifplusstyle.h>
#include "lightstyle.h"
#endif
#include "global.h"
#include "resource.h"
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
#include "qutfcodec.h"
#endif
#include "config.h"
#include "network.h"
#include "fontmanager.h"
+#include "fontdatabase.h"
+
#include "power.h"
#include "alarmserver.h"
#include "applnk.h"
#include "qpemenubar.h"
#include <unistd.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
// for setBacklight()
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
#include <linux/fb.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <stdlib.h>
class QPEApplicationData {
public:
QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
keep_running(TRUE)
{
qcopq.setAutoDelete(TRUE);
}
int presstimer;
QWidget* presswidget;
QPoint presspos;
bool rightpressed;
int kbgrabber;
bool kbregrab;
bool notbusysent;
QString appName;
struct QCopRec {
QCopRec(const QCString &ch, const QCString &msg,
const QByteArray &d) :
channel(ch), message(msg), data(d) { }
QCString channel;
QCString message;
QByteArray data;
};
bool preloaded;
bool forceshow;
@@ -340,97 +342,97 @@ public:
int fd;
LcdOn = TRUE;
// Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
}
void restore()
{
if (!LcdOn) // We must have turned it off
{
int fd;
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
}
setBacklight(-1);
}
bool save(int level)
{
int fd;
switch ( level ) {
case 0:
if ( disable_suspend > 0 && dim_on ) {
if (backlight() > 1)
setBacklight(1); // lowest non-off
}
return TRUE;
break;
case 1:
if ( disable_suspend > 1 && lightoff_on ) {
setBacklight(0); // off
}
return TRUE;
break;
case 2:
Config config( "qpe" );
config.setGroup( "Screensaver" );
if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD
{
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); }
LcdOn = FALSE;
}
else // We're going to suspend the whole machine
{
if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
- return TRUE;
+ return TRUE;
}
}
break;
}
return FALSE;
}
};
static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def)
{
if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
return 0;
if ( interval < 0 ) {
// Restore screen blanking and power saving state
interval = config.readNumEntry( value, def );
}
return interval;
}
static void setScreenSaverIntervals(int i1, int i2, int i3)
{
Config config( "qpe" );
config.setGroup( "Screensaver" );
int v[4];
i1 = ssi(i1, config, "Dim","Interval_Dim", 30);
i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20);
i3 = ssi(i3, config, "","Interval", 60);
//qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
v[0] = QMAX( 1000*i1, 100);
v[1] = QMAX( 1000*i2, 100);
v[2] = QMAX( 1000*i3, 100);
v[3] = 0;
dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE );
lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE );
if ( !i1 && !i2 && !i3 )
QWSServer::setScreenSaverInterval(0);
else
QWSServer::setScreenSaverIntervals(v);
}
static void setScreenSaverInterval(int interval)
{
setScreenSaverIntervals(-1,-1,interval);
}
@@ -459,192 +461,206 @@ static void setScreenSaverInterval(int interval)
This signal is emitted when the time jumps forward or backwards
by more than the normal passage of time.
*/
/*!
\fn void QPEApplication::clockChanged( bool ampm );
This signal is emitted when the user changes the style
of clock. If \a ampm is TRUE, the user wants a 12-hour
AM/PM close, otherwise, they want a 24-hour clock.
*/
/*!
\fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
This signal is emitted when a message is received on the
QPE/Application/<i>appname</i> QCop channel for this application.
The slot to which you connect this signal uses \a msg and \a data
in the following way:
\code
void MyWidget::receive( const QCString& msg, const QByteArray& data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "someMessage(int,int,int)" ) {
int a,b,c;
stream >> a >> b >> c;
...
} else if ( msg == "otherMessage(QString)" ) {
...
}
}
\endcode
\sa qcop.html
*/
/*!
Constructs a QPEApplication just as you would construct
a QApplication, passing \a argc, \a argv, and \a t.
*/
QPEApplication::QPEApplication( int& argc, char **argv, Type t )
: QApplication( hack(argc), argv, t )
{
int dw = desktop()->width();
if ( dw < 200 ) {
- setFont( QFont( "helvetica", 8 ) );
+// setFont( QFont( "helvetica", 8 ) );
AppLnk::setSmallIconSize(10);
AppLnk::setBigIconSize(28);
}
d = new QPEApplicationData;
QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory);
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit()));
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
QString qcopfn("/tmp/qcop-msg-");
qcopfn += QString(argv[0]); // append command name
QFile f(qcopfn);
if ( f.open(IO_ReadOnly) ) {
flock(f.handle(), LOCK_EX);
}
sysChannel = new QCopChannel( "QPE/System", this );
connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
QCString channel = QCString(argv[0]);
channel.replace(QRegExp(".*/"),"");
d->appName = channel;
channel = "QPE/Application/" + channel;
pidChannel = new QCopChannel( channel, this);
connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(pidMessage(const QCString &, const QByteArray &)));
if ( f.isOpen() ) {
d->keep_running = FALSE;
QDataStream ds(&f);
QCString channel, message;
QByteArray data;
while(!ds.atEnd()) {
ds >> channel >> message >> data;
d->enqueueQCop(channel,message,data);
}
flock(f.handle(), LOCK_UN);
f.close();
f.remove();
}
for (int a=0; a<argc; a++) {
if ( qstrcmp(argv[a],"-preload")==0 ) {
argv[a] = argv[a+1];
a++;
d->preloaded = TRUE;
argc-=1;
} else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
argv[a] = argv[a+1];
a++;
d->preloaded = TRUE;
d->forceshow = TRUE;
argc-=1;
}
}
/* overide stored arguments */
setArgs(argc, argv);
#endif
qwsSetDecoration( new QPEDecoration() );
#ifndef QT_NO_TRANSLATION
QStringList langs = Global::languageList();
for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
QString lang = *it;
QTranslator * trans;
QString tfn;
trans = new QTranslator(this);
tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
if ( trans->load( tfn ))
installTranslator( trans );
else
delete trans;
trans = new QTranslator(this);
tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
if ( trans->load( tfn ))
installTranslator( trans );
else
delete trans;
//###language/font hack; should look it up somewhere
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
setFont( fn );
}
+ else {
+ Config config( "qpe" );
+ config.setGroup( "Appearance" );
+ QString familyStr = config.readEntry( "FontFamily", "fixed" );
+ QString styleStr = config.readEntry( "FontStyle", "Regular" );
+ QString sizeStr = config.readEntry( "FontSize", "10" );
+ QString charSetStr = config.readEntry( "FontCharSet", "iso10646-1" );
+ bool ok;
+ int i_size = sizeStr.toInt( &ok, 10 );
+ FontDatabase fdb;
+ QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr );
+ setFont( selectedFont );
+ }
}
+
#endif
applyStyle();
if ( type() == GuiServer ) {
setScreenSaverInterval(-1);
setVolume();
QWSServer::setScreenSaver(new QPEScreenSaver);
}
installEventFilter( this );
QPEMenuToolFocusManager::initialize();
#ifdef QT_NO_QWS_CURSOR
// if we have no cursor, probably don't want tooltips
QToolTip::setEnabled( FALSE );
#endif
}
static QPtrDict<void>* inputMethodDict=0;
static void createInputMethodDict()
{
if ( !inputMethodDict )
inputMethodDict = new QPtrDict<void>;
}
/*!
Returns the currently set hint to the system as to whether
\a w has any use for text input methods.
\sa setInputMethodHint()
*/
QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w )
{
if ( inputMethodDict && w )
return (InputMethodHint)(int)inputMethodDict->find(w);
return Normal;
}
/*!
\enum QPEApplication::InputMethodHint
\value Normal the application sometimes needs text input (the default).
\value AlwaysOff the application never needs text input.
\value AlwaysOn the application always needs text input.
*/