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
@@ -86,7 +86,8 @@
#include <sys/soundcard.h>
-class QPEApplicationData {
+class QPEApplicationData
+{
public:
QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ),
kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ),
@@ -99,25 +100,34 @@ 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,
@@ -125,23 +135,29 @@ public:
{
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();
}
}
@@ -175,12 +191,15 @@ public:
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);
}
}
@@ -200,7 +219,8 @@ public:
(void)iface->createForMib(*i);
// ### it exists now; need to remember if we can delete it
}
- } else {
+ }
+ else {
lib->unload();
delete lib;
}
@@ -222,7 +242,8 @@ public:
(void)iface->installIOHandler(*i);
// ### it exists now; need to remember if we can delete it
}
- } else {
+ }
+ else {
lib->unload();
delete lib;
}
@@ -232,7 +253,8 @@ public:
QString decorationName;
};
-class ResourceMimeFactory : public QMimeSourceFactory {
+class ResourceMimeFactory : public QMimeSourceFactory
+{
public:
ResourceMimeFactory()
{
@@ -448,11 +470,13 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
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 );
@@ -547,11 +571,13 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
//###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
@@ -621,8 +647,14 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
class HackDialog : public QDialog
{
public:
- void acceptIt() { accept(); }
- void rejectIt() { reject(); }
+ void acceptIt()
+ {
+ accept();
+ }
+ void rejectIt()
+ {
+ reject();
+ }
};
@@ -639,6 +671,7 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
key = Qt::Key_Return;
#ifdef QWS
+
ke->simpleData.keycode = key;
#endif
}
@@ -647,7 +680,9 @@ class HackWidget : public QWidget
{
public:
bool needsOk()
- { return ( getWState() & WState_Reserved1 ); }
+ {
+ return ( getWState() & WState_Reserved1 );
+ }
};
/*!
@@ -707,7 +742,8 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
}
}
}
- } 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 );
}
@@ -851,10 +887,14 @@ void QPEApplication::setDefaultRotation( int r )
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
+
}
}
@@ -910,25 +950,31 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
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() )
@@ -937,7 +983,8 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
d->kbgrabber = 1;
else
d->kbgrabber = 2;
- } else if ( msg == "language(QString)" ) {
+ }
+ else if ( msg == "language(QString)" ) {
if ( type() == GuiServer ) {
QString l;
stream >> l;
@@ -950,7 +997,8 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
restart();
}
}
- } else if ( msg == "timeChange(QString)" ) {
+ }
+ else if ( msg == "timeChange(QString)" ) {
QString t;
stream >> t;
if ( t.isNull() )
@@ -959,19 +1007,22 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
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;
@@ -979,7 +1030,8 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& 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;
@@ -987,33 +1039,40 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& 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 );
@@ -1030,7 +1089,8 @@ bool QPEApplication::raiseAppropriateWindow()
// ########## 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;
@@ -1065,35 +1125,43 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
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;
@@ -1103,13 +1171,15 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
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);
}
@@ -1408,7 +1478,8 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
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" ) ) {
@@ -1466,6 +1537,7 @@ void QPEApplication::ungrabKeyboard()
QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
e << QString::null;
#endif
+
d->kbregrab = FALSE;
d->kbgrabber = 0;
}
@@ -1490,6 +1562,7 @@ void QPEApplication::grabKeyboard()
QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
e << d->appName;
#endif
+
d->kbgrabber = 2; // me
}
}
@@ -1502,11 +1575,13 @@ 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;
@@ -1526,6 +1601,7 @@ 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;
@@ -1550,6 +1626,7 @@ void QPEApplication::hideOrQuit()
// 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;