Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qpeapplication.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef __QPE_APPLICATION_H__
00021 #define __QPE_APPLICATION_H__
00022 
00023 #include <stdlib.h> // for setenv()
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         // RightOnHoldLeftDelayed, etc.
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     /* Merge setTempScreenSaverMode */
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     /* linkChanged signal */
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 }; /* from qgfxtransformed_qws.cpp */
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  * Set current rotation of Opie, and rotation for newly started apps.
00201  * Differs from setDefaultRotation in that 1) it rotates currently running apps,
00202  * and 2) does not set deforient or save orientation to qpe.conf.
00203  */
00204 
00205 inline void QPEApplication::setCurrentRotation( int r )
00206 {
00207     // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
00208     // for compatibility with the SharpROM use fallback to setDefaultTransformation()
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  * Qtopia 1.7 SDK compatibility macros
00223  * FIXME: Support Opie Quicklaunch Interface
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  * -remove me
00237  */ 
00238 #ifdef Q_WS_QWS
00239 extern Q_EXPORT QRect qt_maxWindowRect;
00240 #endif
00241 
00242 #endif

Generated on Sat Nov 5 16:16:39 2005 for OPIE by  doxygen 1.4.2