00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __QPE_APPLICATION_H__
00021 #define __QPE_APPLICATION_H__
00022
00023 #include <stdlib.h>
00024
00025 #include <qglobal.h>
00026 #include <qapplication.h>
00027 #include <qdialog.h>
00028 #include <qwsdisplay_qws.h>
00029 #if defined(_WS_QWS_) && !defined(Q_WS_QWS)
00030 #define Q_WS_QWS
00031 #endif
00032 #include "qpedecoration_qws.h"
00033 #include "timestring.h"
00034 #include "qpeglobal.h"
00035
00036 class QCopChannel;
00037 class QPEApplicationData;
00038 class QWSEvent;
00039 class QWSKeyEvent;
00040
00080 class QPEApplication : public QApplication
00081 {
00082 Q_OBJECT
00083 public:
00084 QPEApplication( int& argc, char **argv, Type=GuiClient );
00085 ~QPEApplication();
00086
00087 static QString qpeDir();
00088 static QString documentDir();
00089 void applyStyle();
00090 void reset();
00091 static int defaultRotation();
00092 static void setDefaultRotation(int r);
00093 static void setCurrentRotation(int r);
00094 static void setCurrentMode(int x, int y, int depth );
00095 static void grabKeyboard();
00096 static void ungrabKeyboard();
00097
00098 enum StylusMode {
00099 LeftOnly,
00100 RightOnHold
00101
00102 };
00103 static void setStylusOperation( QWidget*, StylusMode );
00104 static StylusMode stylusOperation( QWidget* );
00105
00106 enum InputMethodHint {
00107 Normal,
00108 AlwaysOff,
00109 AlwaysOn
00110 };
00111
00112 enum screenSaverHint {
00113 Disable = 0,
00114 DisableLightOff = 1,
00115 DisableSuspend = 2,
00116 Enable = 100
00117 };
00118
00119 static void setInputMethodHint( QWidget *, InputMethodHint );
00120 static InputMethodHint inputMethodHint( QWidget * );
00121
00122 void showMainWidget( QWidget*, bool nomax=FALSE );
00123 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
00124
00125 static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
00126 static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
00127 static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
00128
00129 #ifdef QTOPIA_INTERNAL_INITAPP
00130 void initApp( int argv, char **argv );
00131 #endif
00132
00133 static void setKeepRunning();
00134 bool keepRunning() const;
00135
00136 bool keyboardGrabbed() const;
00137
00138 int exec();
00139
00140 signals:
00141 void clientMoused();
00142 void timeChanged();
00143 void clockChanged( bool pm );
00144 void micChanged( bool muted );
00145 void volumeChanged( bool muted );
00146 void appMessage( const QCString& msg, const QByteArray& data);
00147 void weekChanged( bool startOnMonday );
00148 void dateFormatChanged( DateFormat );
00149 void flush();
00150 void reload();
00151
00152
00153 private slots:
00154 void systemMessage( const QCString &msg, const QByteArray &data );
00155 void pidMessage( const QCString &msg, const QByteArray &data );
00156 void removeSenderFromStylusDict();
00157 void hideOrQuit();
00158
00159 protected:
00160 bool qwsEventFilter( QWSEvent * );
00161 void internalSetStyle( const QString &style );
00162 void prepareForTermination(bool willrestart);
00163 virtual void restart();
00164 virtual void shutdown();
00165 bool eventFilter( QObject *, QEvent * );
00166 void timerEvent( QTimerEvent * );
00167 bool raiseAppropriateWindow();
00168 virtual void tryQuit();
00169 private:
00170 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
00171 void processQCopFile();
00172
00173 #if defined(Q_WS_QWS) && !defined(QT_NO_COP)
00174 QCopChannel *sysChannel;
00175 QCopChannel *pidChannel;
00176 #endif
00177 QPEApplicationData *d;
00178
00179 bool reserved_sh;
00180
00181 };
00182
00183
00184
00185 enum Transformation { Rot0, Rot90, Rot180, Rot270 };
00186
00187 inline int TransToDeg ( Transformation t )
00188 {
00189 int d = static_cast<int>( t );
00190 return d * 90;
00191 }
00192
00193 inline Transformation DegToTrans ( int d )
00194 {
00195 Transformation t = static_cast<Transformation>( d / 90 );
00196 return t;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205 inline void QPEApplication::setCurrentRotation( int r )
00206 {
00207
00208
00209 #if QT_VERSION > 233
00210 Transformation e = DegToTrans( r );
00211 QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed";
00212 int j = 0;
00213 QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() );
00214 ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 );
00215 qApp->desktop()->qwsDisplay()->setTransformation( e );
00216 #else
00217 setDefaultRotation( r );
00218 #endif
00219 }
00220
00221
00222
00223
00224
00225 #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \
00226 int main( int argc, char** argv ) \
00227 { \
00228 QPEApplication app( argc, argv ); \
00229 IMPLEMENTATION* mw = new IMPLEMENTATION(); \
00230 app.showMainWidget( mw ); \
00231 app.exec(); \
00232 }
00233 #define QTOPIA_MAIN // Bee-Bop-Alula
00234
00235
00236
00237
00238 #ifdef Q_WS_QWS
00239 extern Q_EXPORT QRect qt_maxWindowRect;
00240 #endif
00241
00242 #endif