summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp189
1 files changed, 133 insertions, 56 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index f65f3ab..2432b65 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -85,9 +85,10 @@
#include <sys/ioctl.h>
#include <sys/soundcard.h>
-class QPEApplicationData {
+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 ),
@@ -98,51 +99,66 @@ public:
int presstimer;
QWidget* presswidget;
QPoint presspos;
- bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke
+bool rightpressed :
+ 1; // AEH why not use uint foobar :1; if it's tt style -zecke
int kbgrabber;
- bool kbregrab : 1;
- bool notbusysent : 1;
+bool kbregrab :
+ 1;
+bool notbusysent :
+ 1;
QString appName;
- struct QCopRec {
+ struct QCopRec
+ {
QCopRec( const QCString &ch, const QCString &msg,
const QByteArray &d ) :
- channel( ch ), message( msg ), data( d ) { }
+ channel( ch ), message( msg ), data( d )
+ { }
QCString channel;
QCString message;
QByteArray data;
};
- bool preloaded : 1;
- bool forceshow : 1;
- bool nomaximize : 1;
+bool preloaded :
+ 1;
+bool forceshow :
+ 1;
+bool nomaximize :
+ 1;
QWidget* qpe_main_widget;
- bool keep_running : 1;
+bool keep_running :
+ 1;
QList<QCopRec> qcopq;
void enqueueQCop( const QCString &ch, const QCString &msg,
const QByteArray &data )
{
qcopq.append( new QCopRec( ch, msg, data ) );
}
- void sendQCopQ() {
+ void sendQCopQ()
+ {
QCopRec * r;
#ifndef QT_NO_COP
+
for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
QCopChannel::sendLocally( r->channel, r->message, r->data );
#endif
+
qcopq.clear();
}
- static void show_mx(QWidget* mw, bool nomaximize) {
+ static void show_mx(QWidget* mw, bool nomaximize)
+ {
if ( mw->layout() && mw->inherits("QDialog") ) {
QPEApplication::showDialog((QDialog*)mw,nomaximize);
- } else {
+ }
+ else {
#ifdef Q_WS_QWS
if ( !nomaximize )
mw->showMaximized();
else
#endif
+
mw->show();
}
}
static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
@@ -174,14 +190,17 @@ public:
setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
nomaximize = nomax;
qpe_main_widget = mw;
#ifndef QT_NO_COP
+
sendQCopQ();
#endif
+
if ( preloaded ) {
if(forceshow)
show_mx(mw,nomax);
- } else if ( keep_running ) {
+ }
+ else if ( keep_running ) {
show_mx(mw,nomax);
}
}
@@ -199,9 +218,10 @@ public:
for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) {
(void)iface->createForMib(*i);
// ### it exists now; need to remember if we can delete it
}
- } else {
+ }
+ else {
lib->unload();
delete lib;
}
}
@@ -221,9 +241,10 @@ public:
for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) {
(void)iface->installIOHandler(*i);
// ### it exists now; need to remember if we can delete it
}
- } else {
+ }
+ else {
lib->unload();
delete lib;
}
}
@@ -231,9 +252,10 @@ public:
QString styleName;
QString decorationName;
};
-class ResourceMimeFactory : public QMimeSourceFactory {
+class ResourceMimeFactory : public QMimeSourceFactory
+{
public:
ResourceMimeFactory()
{
setFilePath( Global::helpPath() );
@@ -447,13 +469,15 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
if ( dw < 200 ) {
setFont( QFont( "helvetica", 8 ) );
AppLnk::setSmallIconSize( 10 );
AppLnk::setBigIconSize( 28 );
- }else if ( dw > 600 ) {
+ }
+ else if ( dw > 600 ) {
setFont( QFont( "helvetica", 12 ) );
AppLnk::setSmallIconSize( 24 );
AppLnk::setBigIconSize( 48 );
- }else if ( dw > 200 ) {
+ }
+ else if ( dw > 200 ) {
setFont( QFont( "helvetica", 12 ) );
AppLnk::setSmallIconSize( 16 );
AppLnk::setBigIconSize( 32 );
}
@@ -546,13 +570,15 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
delete trans;
//###language/font hack; should look it up somewhere
#ifdef QWS
+
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
setFont( fn );
}
#endif
+
}
#endif
applyStyle();
@@ -620,10 +646,16 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
class HackDialog : public QDialog
{
public:
- void acceptIt() { accept(); }
- void rejectIt() { reject(); }
+ void acceptIt()
+ {
+ accept();
+ }
+ void rejectIt()
+ {
+ reject();
+ }
};
void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
@@ -638,17 +670,20 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
key = Qt::Key_Return;
#ifdef QWS
+
ke->simpleData.keycode = key;
#endif
}
class HackWidget : public QWidget
{
public:
bool needsOk()
- { return ( getWState() & WState_Reserved1 ); }
+ {
+ return ( getWState() & WState_Reserved1 );
+ }
};
/*!
\internal
@@ -706,9 +741,10 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
mapToDefaultAction( ke, Qt::Key_Return );
}
}
}
- } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
+ }
+ else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
// Use special "select" key to do whatever default action a widget has
mapToDefaultAction( ke, Qt::Key_Space );
}
else if ( ke->simpleData.keycode == Qt::Key_Escape &&
@@ -850,12 +886,16 @@ void QPEApplication::setDefaultRotation( int r )
setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
Config config("qpe");
config.setGroup( "Rotation" );
config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
- } else {
+ }
+ else {
#ifndef QT_NO_COP
- { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; }
+ { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
+ e << r;
+ }
#endif
+
}
}
/*!
@@ -909,36 +949,43 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
#ifdef Q_WS_QWS
QDataStream stream( data, IO_ReadOnly );
if ( msg == "applyStyle()" ) {
applyStyle();
- } else if ( msg == "setDefaultRotation(int)" ) {
+ }
+ else if ( msg == "setDefaultRotation(int)" ) {
if ( type() == GuiServer ) {
int r;
stream >> r;
setDefaultRotation( r );
}
- } else if ( msg == "shutdown()" ) {
+ }
+ else if ( msg == "shutdown()" ) {
if ( type() == GuiServer )
shutdown();
- } else if ( msg == "quit()" ) {
+ }
+ else if ( msg == "quit()" ) {
if ( type() != GuiServer )
tryQuit();
- } else if ( msg == "forceQuit()" ) {
+ }
+ else if ( msg == "forceQuit()" ) {
if ( type() != GuiServer )
quit();
- } else if ( msg == "restart()" ) {
+ }
+ else if ( msg == "restart()" ) {
if ( type() == GuiServer )
restart();
- } else if ( msg == "grabKeyboard(QString)" ) {
+ }
+ else if ( msg == "grabKeyboard(QString)" ) {
QString who;
stream >> who;
if ( who.isEmpty() )
d->kbgrabber = 0;
else if ( who != d->appName )
d->kbgrabber = 1;
else
d->kbgrabber = 2;
- } else if ( msg == "language(QString)" ) {
+ }
+ else if ( msg == "language(QString)" ) {
if ( type() == GuiServer ) {
QString l;
stream >> l;
QString cl = getenv( "LANG" );
@@ -949,72 +996,84 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
setenv( "LANG", l.latin1(), 1 );
restart();
}
}
- } else if ( msg == "timeChange(QString)" ) {
+ }
+ else if ( msg == "timeChange(QString)" ) {
QString t;
stream >> t;
if ( t.isNull() )
unsetenv( "TZ" );
else
setenv( "TZ", t.latin1(), 1 );
// emit the signal so everyone else knows...
emit timeChanged();
- } else if ( msg == "execute(QString)" ) {
+ }
+ else if ( msg == "execute(QString)" ) {
if ( type() == GuiServer ) {
QString t;
stream >> t;
Global::execute( t );
}
- } else if ( msg == "execute(QString,QString)" ) {
+ }
+ else if ( msg == "execute(QString,QString)" ) {
if ( type() == GuiServer ) {
QString t, d;
stream >> t >> d;
Global::execute( t, d );
}
- } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
+ }
+ else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
if ( type() == GuiServer ) {
QDateTime when;
QCString channel, message;
int data;
stream >> when >> channel >> message >> data;
AlarmServer::addAlarm( when, channel, message, data );
}
- } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
+ }
+ else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
if ( type() == GuiServer ) {
QDateTime when;
QCString channel, message;
int data;
stream >> when >> channel >> message >> data;
AlarmServer::deleteAlarm( when, channel, message, data );
}
- } else if ( msg == "clockChange(bool)" ) {
+ }
+ else if ( msg == "clockChange(bool)" ) {
int tmp;
stream >> tmp;
emit clockChanged( tmp );
- } else if ( msg == "weekChange(bool)" ) {
+ }
+ else if ( msg == "weekChange(bool)" ) {
int tmp;
stream >> tmp;
emit weekChanged( tmp );
- } else if ( msg == "setDateFormat(DateFormat)" ) {
+ }
+ else if ( msg == "setDateFormat(DateFormat)" ) {
DateFormat tmp;
stream >> tmp;
emit dateFormatChanged( tmp );
- } else if ( msg == "setVolume(int,int)" ) {
+ }
+ else if ( msg == "setVolume(int,int)" ) {
int t, v;
stream >> t >> v;
setVolume( t, v );
emit volumeChanged( muted );
- } else if ( msg == "volumeChange(bool)" ) {
+ }
+ else if ( msg == "volumeChange(bool)" ) {
stream >> muted;
setVolume();
emit volumeChanged( muted );
- } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
+ }
+ else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
int t, v;
stream >> t >> v;
setMic( t, v );
emit micChanged( micMuted );
- } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
+ }
+ else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
stream >> micMuted;
setMic();
emit micChanged( micMuted );
}
@@ -1029,9 +1088,10 @@ bool QPEApplication::raiseAppropriateWindow()
bool r=FALSE;
// ########## raise()ing main window should raise and set active
// ########## it and then all childen. This belongs in Qt/Embedded
QWidget *top = d->qpe_main_widget;
- if ( !top ) top =mainWidget();
+ if ( !top )
+ top = mainWidget();
if ( top && d->keep_running ) {
if ( top->isVisible() )
r = TRUE;
else if (d->preloaded) {
@@ -1064,37 +1124,45 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
#ifdef Q_WS_QWS
if ( msg == "quit()" ) {
tryQuit();
- } else if ( msg == "quitIfInvisible()" ) {
+ }
+ else if ( msg == "quitIfInvisible()" ) {
if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
quit();
- } else if ( msg == "close()" ) {
+ }
+ else if ( msg == "close()" ) {
hideOrQuit();
- } else if ( msg == "disablePreload()" ) {
+ }
+ else if ( msg == "disablePreload()" ) {
d->preloaded = FALSE;
d->keep_running = TRUE;
/* so that quit will quit */
- } else if ( msg == "enablePreload()" ) {
+ }
+ else if ( msg == "enablePreload()" ) {
if (d->qpe_main_widget)
d->preloaded = TRUE;
d->keep_running = TRUE;
/* so next quit won't quit */
- } else if ( msg == "raise()" ) {
+ }
+ else if ( msg == "raise()" ) {
d->keep_running = TRUE;
d->notbusysent = FALSE;
raiseAppropriateWindow();
// Tell the system we're still chugging along...
QCopEnvelope e("QPE/System", "appRaised(QString)");
e << d->appName;
- } else if ( msg == "flush()" ) {
+ }
+ else if ( msg == "flush()" ) {
emit flush();
// we need to tell the desktop
QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
e << d->appName;
- } else if ( msg == "reload()" ) {
+ }
+ else if ( msg == "reload()" ) {
emit reload();
- } else if ( msg == "setDocument(QString)" ) {
+ }
+ else if ( msg == "setDocument(QString)" ) {
d->keep_running = TRUE;
QDataStream stream( data, IO_ReadOnly );
QString doc;
stream >> doc;
@@ -1102,15 +1170,17 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
if ( !mw )
mw = d->qpe_main_widget;
if ( mw )
Global::setDocument( mw, doc );
- } else if ( msg == "nextView()" ) {
+ }
+ else if ( msg == "nextView()" ) {
qDebug("got nextView()");
/*
if ( raiseAppropriateWindow() )
*/
emit appMessage( msg, data);
- } else {
+ }
+ else {
emit appMessage( msg, data);
}
#endif
@@ -1407,9 +1477,10 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
break;
default:
;
}
- }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
+ }
+ else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
QKeyEvent *ke = (QKeyEvent *)e;
if ( ke->key() == Key_Enter ) {
if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
@@ -1465,8 +1536,9 @@ void QPEApplication::ungrabKeyboard()
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
e << QString::null;
#endif
+
d->kbregrab = FALSE;
d->kbgrabber = 0;
}
}
@@ -1489,8 +1561,9 @@ void QPEApplication::grabKeyboard()
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
e << d->appName;
#endif
+
d->kbgrabber = 2; // me
}
}
@@ -1501,13 +1574,15 @@ int QPEApplication::exec()
{
#ifndef QT_NO_COP
d->sendQCopQ();
#endif
+
if ( d->keep_running )
//|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
return QApplication::exec();
#ifndef QT_NO_COP
+
{
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << d->appName;
}
@@ -1525,8 +1600,9 @@ void QPEApplication::tryQuit()
{
if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
return ; // Inside modal loop or konsole. Too hard to save state.
#ifndef QT_NO_COP
+
{
QCopEnvelope e( "QPE/System", "closing(QString)" );
e << d->appName;
}
@@ -1549,8 +1625,9 @@ void QPEApplication::hideOrQuit()
// If we are a preloaded application we don't actually quit, so emit
// a System message indicating we're quasi-closing.
if ( d->preloaded && d->qpe_main_widget )
#ifndef QT_NO_COP
+
{
QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
e << d->appName;
d->qpe_main_widget->hide();