Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZApplication.h

Go to the documentation of this file.
00001 //-------------------------------------------------------------------------------------------------
00002 //
00003 //  Header Name: ZApplication.h
00004 //
00005 //  General Description: Main application class (similar to QApplication)
00006 //
00007 //-------------------------------------------------------------------------------------------------
00008 //
00009 //                            Motorola Confidential Proprietary
00010 //                     Template ID and version: TMP_LFC_50068  Version 1.2
00011 //                      (c) Copyright Motorola 2004, All Rights Reserved
00012 //
00013 //-------------------------------------------------------------------------------------------------
00014 
00015 #ifndef Z_APPLICATION_H
00016 #define Z_APPLICATION_H
00017 
00018 #ifndef __cplusplus
00019 #error "This is a C++ header file;it requires C++ to compile."
00020 #endif
00021 
00022 
00023 #include "ZGlobal.h"
00024 
00025 #include <qapplication.h>
00026 #include <qwindowsystem_qws.h>
00027 #include <qcopchannel_qws.h>
00028 #include <qwsevent_qws.h>
00029 
00030 class ZApplicationData;
00031 class ZIMServer;
00032 class QUuid;
00033 
00034 #ifndef QT_NO_QWS_MMI_TEST
00035 class QTestCaptureHandler;
00036 #endif
00037 
00038 /**
00039  * The ZApplication class implements various services that are available to 
00040  * EZX applications.
00041  *
00042  * Qt applications that use ZApplication instead of QApplication, should 
00043  * became standard EZX applications. They inherit EZX Styles, and some 
00044  * EZX-specific features
00045  *
00046  * @code
00047  * ZApplication a(argc,argv);
00048  * ZMainWidget* w = new ZMainWidget(true,0);
00049  * w->show();
00050  * a.exec();
00051  * delete w;
00052  * @endcode
00053  *
00054  * @see ZMainWidget
00055  */
00056 class ZApplication : public QApplication
00057 {
00058     Q_OBJECT
00059 
00060 public:
00061 
00062     /**
00063      * Constructor of ZApplication. argc, argv and Type are same as QApplication's.
00064      * for applications, Type should be GuiClient, only the EZX Server can pass GuiServer.
00065      */
00066     ZApplication( int& argc, char **argv, Type = GuiClient );
00067 
00068     /**
00069      * Destructor of ZApplication. 
00070      */
00071     virtual ~ZApplication();
00072 
00073     /**
00074      * Reimplement
00075      * Set the main widget of the application
00076      *
00077      * @see the setMainWidget() of the QApplication
00078      *
00079      * @param mainWidget will be the application's main widget
00080      */
00081     virtual void setMainWidget( QWidget* mainWidget );
00082 
00083     /**
00084      * Set the main widget of the application and show it
00085      *
00086      * @param mainWidget will be the application's main widget
00087      */
00088     void showMainWidget( QWidget* mainWidget );
00089 
00090     /**
00091      * Reimplement
00092      * enter the application main event loop
00093      *
00094      * @see the exec() of the QApplication
00095      */
00096     int exec();
00097 
00098     /**
00099      * Set the flag to enable/disable invoking the input widget automatically
00100      * when text entry is clicked.
00101      *
00102      * @param invoke if true when text entry is clicked, the input widget will 
00103      * be invoked automatically; if false the input widget will not be invoked, 
00104      * the function affects all text entries in the application.
00105      *
00106      * The default is to invoke input widget automatically.
00107      */
00108     void setAutoInvokeKb( bool invoke = true );
00109 
00110     /**
00111      * Get the flag to enable/disable invoking the input widget automatically 
00112      * when text entry is clicked.
00113      *
00114      * @retval if true, input widget will be invoke automatically
00115      * or return false.
00116      */
00117     bool getAutoInvokeKb();
00118 
00119     /**
00120      * Set the flag to enable/disable hiding the input widget automatically by 
00121      * clicking a non-text-entry widget when the input widget is visible.
00122      *
00123      * @param hide if true when a non-text-entry widget is clicked the input 
00124      * widget will be hidden automatically; if false the input widget will not 
00125      * be hidden.
00126      *
00127      * The default is to hide input widget automatically.
00128      */
00129     void setAutoHideKb( bool hide = false );
00130 
00131     /**
00132      * Get the flag that indicates whether or not the input widget should 
00133      * be automatically hidden when a non-text-entry widget is clicked.
00134      *
00135      * @retval if true, input widget will be hidden automatically
00136      * or return false.
00137      */
00138     bool getAutoHideKb();
00139 
00140     /**
00141      * Set the application's default input method.
00142      *
00143      * @param method the default input method name.
00144      *
00145      * @see ZMainWidget for how to bind special input methods
00146      * to a text entry and to a ZMainWidget.
00147      * @see ZGlobal for system default input methods name list.
00148      *
00149      * @note if application does not set the default input method,
00150      * the initial input method is system default input method.
00151      *
00152      * @note if the lastest input method user used is not been
00153      * bound to a special text entry, the application default input method
00154      * will be set to remember it, but the input method bound by a text entry
00155      * will be ignored.
00156      *
00157      * For example:
00158      * There are three text entries: text entries A,C do not bind to any 
00159      * input method, another text entry B binds number keyboard, user uses 
00160      * the Keyboard as follows:
00161      *
00162      * A --> English Keyboard 
00163      * B --> Number keyboard  
00164      * C --> English Keyboard --> Change to Hand Writing Keyboard
00165      * A --> Hand Writing Keyboard (application default is changed)
00166      * B --> Number keyboard (not affected)
00167      */
00168     void setDefaultKbMethod( const QUuid& method ); 
00169 
00170     /**
00171      * Get the application default input method
00172      *
00173      * @param readConfig if false, when the application initial input method is
00174      * IMID_UNDEFINED, the function will not read the system config to get the system
00175      * defualt value or the function will read the system config.
00176      */
00177     const QUuid getDefaultKbMethod( bool readConfig = false ); 
00178 
00179     /**
00180      * EZX widgets have two mouse respond modes:
00181      *
00182      * 1. Application only responds to press (left) mouse events.
00183      * 2. Application also responds to press-and-hold (right) mouse events.
00184      *
00185      * Can use the setMouseMode() to set the widget's responsive mode. 
00186      */
00187     enum
00188     {
00189         LEFT_ONLY = 0, ///< \a \c Only support LEFT mouse events 
00190         PRESS_HOLD     ///< \a \c support PRESS_HOLD funstions
00191     };
00192 
00193     /**
00194      * Enable/disable the press-and-hold for a widget
00195      *
00196      * @param widget the QWidget whose press-and-hold will be enabled/disabled
00197      * @param mode mouse mode
00198      *
00199      * @code
00200      * QLineEdit* ln = new QLineEdit(parent);
00201      * //enable Press and Hold
00202      * if ( ln )
00203      * {
00204      *    ZApplication::setMouseMode(ln, ZApplication::PRESS_HOLD);   
00205      * }
00206      * @endcode
00207      *
00208      * @note Most widgets default mouse mode is LEFT_ONLY, except for some 
00209      * special widgets such as ZMultiLineEdit etc...
00210      *
00211      * @note when PRESS_HOLD is enabled, the mouse events sequence that the widget may
00212      * receive are:
00213      *
00214      * Left mouse press, Right Mouse Press, Right Mouse Release, Left Mouse Release  
00215      */
00216     static void setMouseMode( QWidget* widget, int mode );
00217 
00218     /**
00219      * Get the widget's mouse mode
00220      *
00221      * @retval LEFT_ONLY or PRESS_HOLD
00222      */
00223     static int getMouseMode( QWidget* widget ); 
00224 
00225     /**
00226      * Start to show a wait cursor
00227      *
00228      * @code
00229      * //start to show a wait cusor
00230      * ZApplication* app = (ZApplication*)qApp;
00231      * app->startShowWaitCursor();
00232      *
00233      * //chance to handle event
00234      * app->processEvents();
00235      * ...
00236      * app->stopShowWaitCursor();
00237      * @endcode
00238      *
00239      * @note param startTime and param resId have not been implemented in the A760
00240      *
00241      * @note the application needs to call stopShowWaitCursor() to stop the wait cursor,
00242      * so the application's UI will be blocked.
00243      */
00244     void startShowWaitCursor( int startTime = 0,const QString& resId = QString::null );
00245 
00246     /**
00247      * Stop a wait cursor
00248      */
00249     void stopShowWaitCursor();
00250 
00251     /**
00252      * Load string resource files (.qm files)
00253      */
00254     void loadString( const QString& strFileName );
00255 
00256     /**
00257      * Get the application's name
00258      */
00259     const QString& getAppName() { return appName; }
00260 
00261     /**
00262      * Enable/disable the touch panel's sound when the application's widgets are 
00263      * clicked.
00264      *
00265      * @param enable enable/disable the touch panel's sound
00266      * The default is to enable touch panel's sound
00267      */
00268     void enableTouchSound( bool enable = true );
00269 
00270     /**
00271      * Enable/disable the hardkey event filter
00272      *
00273      * @note the function is not implemented in the A760 and A768
00274      */
00275     void enableHardKeyEventFilter( bool enable = true );
00276     
00277     /**
00278      * Get the flag to enable/disable the hardkey event filter
00279      *
00280      * @note the function is not implemented in the A760 and A768
00281      */
00282     bool getHardKeyEventFilter();
00283 
00284     /**
00285      * Raise all widgets in this application
00286      *
00287      * @internal
00288      */
00289     void raiseAppWindows();
00290 
00291     /**
00292      * Get input method name list
00293      *
00294      * @internal
00295      */
00296     const QIMMap& getIMList();
00297 
00298     /**
00299      * Update input methods name
00300      *
00301      * @note if language is changed, and the application is a deamon,
00302      * it must call this function to update the imput method names list.
00303      *
00304      * @internal
00305      */
00306     void updateIMNameList();
00307 
00308     /**
00309      * Flush the messages in the message queue
00310      *
00311      * @internal
00312      */
00313     void flushMsgs();
00314 
00315     /**
00316      * Get the touch panel msg queue
00317      *
00318      * @internal
00319      */
00320     int getTouchSoundMsgQueue();
00321 
00322 #ifndef QT_NO_QWS_MMI_TEST
00323     virtual void insertStr( QWSEvent * e );
00324 #endif
00325 
00326 signals:
00327 
00328     /**
00329      * Emitted when the application receive a message over the application Channel 
00330      * which is pre-created and its channel name is EZX/Application/appname.
00331      *
00332      * @param msg the name of the message
00333      * @param data the data of the message
00334      */
00335     void appMessage( const QCString &msg, const QByteArray &data );
00336 
00337     /**
00338      * Emitted when the phone is going to shutdown
00339      */
00340     void shutdown();
00341 
00342     /**
00343      * Emitted when the application manager requests this application to quit.
00344      * The application manager will do this to save RAM.
00345      *
00346      * By default, quickQuit() is connected to slotQuickQuit().
00347      *
00348      * @see slotQuickQuit()
00349      */
00350     void quickQuit();
00351 
00352     /**
00353      * Emitted when this application icon on the home screen is clicked.
00354      */
00355     void clickAppIcon();
00356 
00357     /**
00358      * Emitted when this application is raised from the background to the foreground.
00359      */
00360     void signalRaise();
00361 
00362     /**
00363      * Emitted when another application requests this application to open a file.
00364      *
00365      * @param doc full path name of the document file
00366      */
00367     void signalOpenDoc( const QString &doc );
00368 
00369     /**
00370      * Emitted when another application sends a message to this application.
00371      *
00372      * If this application is not running when the message is sent, it will be 
00373      * launched and then the signal sent.
00374      *
00375      * If already running, this application will be raised from the background 
00376      * to the foreground
00377      *
00378      * @param data information sent from another application
00379      *
00380      * @see signalBridgeMessage( const QCString &action, const QByteArray &data )
00381      */
00382     void signalBridgeMessage( const QByteArray &data );
00383 
00384     /**
00385      * Emitted when another application sends a message to this application.
00386      *
00387      * If this application is not running when the message is sent, it will be 
00388      * launched and then the signal sent.
00389      *
00390      * If already running, this application will be raised from the background 
00391      * to the foreground
00392      *
00393      * @param action another application indicate this application what should
00394      * be done by this parameter
00395      * @param data information sent from another application
00396      *
00397      * @see signalBridgeMessageWithoutRaise( const QCString &action, const QByteArray &data )
00398      */
00399     void signalBridgeMessage( const QCString &action, const QByteArray &data );
00400 
00401     /**
00402      * Emitted when another application sends a message to this application.
00403      *
00404      * If this application is not running when the message is sent, it will be 
00405      * launched and then the signal sent.
00406      *
00407      * If already running, this application will be raised from the background 
00408      * to the foreground
00409      *
00410      * @param action another application indicate this application what
00411      * should be done by this parameter
00412      * @param data information sent from another application
00413      *
00414      * @see signalBridgeMessage( const QCString &action, const QByteArray &data )
00415      */
00416     void signalBridgeMessageWithoutRaise( const QCString &action, const QByteArray &data );
00417 
00418     /**
00419      * Emitted when the 'Home' hardkey is clicked.
00420      * @internal
00421      */
00422     void signalHomeKeyClicked();
00423 
00424     /**
00425      * Emitted when user has selected to do a master clear.
00426      */
00427     void signalMasterClear();
00428 
00429     /**
00430      * Emitted when the system is doing a master reset.
00431      */
00432     void signalMasterReset();
00433 
00434     /**
00435      * Emitted when the user has clicked in an editable widget
00436      * @internal
00437      */
00438     void editableWidgetClicked( int mwId,bool canClick );
00439 
00440     /**
00441      * Emitted when the application received a message via the system
00442      * QCopChannel.
00443      *
00444      * @param msg the name of the message
00445      * @param data the data of the message
00446      *
00447      * @internal
00448      */
00449     void systemMessage( const QCString &msg, const QByteArray &data );
00450 
00451 protected:
00452 
00453     /**
00454      * Reimplement
00455      */
00456     bool qwsEventFilter( QWSEvent* e );
00457 
00458     /**
00459      * Reimplement
00460      */
00461     virtual bool eventFilter( QObject* o, QEvent* e);
00462 
00463     /**
00464      * Reimplement
00465      */
00466     virtual void timerEvent( QTimerEvent* e);
00467 
00468     /**
00469      * Try to quit the application
00470      */
00471     virtual void tryQuit();
00472 
00473     /**
00474      * Event filter for the ezx hard keys
00475      *
00476      * @retval if true the application can stop the default hardkey behaviors.
00477      *
00478      * @note the function is not implemented in the A760 and 768
00479      */
00480     virtual bool hardKeyEventFilter( QEvent* e );
00481 
00482     /**
00483      * Set the applications max screen size 
00484      *
00485      * @note the function is not implemented in the A760 and A768
00486      */
00487     void setMaxWindowRect();
00488 
00489     /**
00490      * Set the environment variable
00491      *
00492      * @param env the environment variable
00493      */
00494     void setEnv( const QString& env );
00495 
00496 
00497 protected slots:
00498 
00499     /**
00500      * The default implementation of this slot will cause the current 
00501      * application to exit.
00502      *
00503      * By default, this slot is connected to signal shutdown().
00504      */
00505     virtual void slotShutdown();
00506 
00507     /**
00508      * The default implementation of this slot will cause the current 
00509      * application to exit.
00510      *
00511      * By default, this slot is connected to signal quickQuit().
00512      */
00513     virtual void slotQuickQuit();
00514 
00515     /**
00516      * By default, this slot is connected to signal clickAppIcon() 
00517      */
00518     virtual void slotClickAppIcon();
00519 
00520     /**
00521      * By default, this slot is connected to signal signalRaise()
00522      *
00523      * By default, this function will raise the current application from 
00524      * the background to the foreground
00525      */
00526     virtual void slotRaise();
00527 
00528 private:
00529 
00530     QCopChannel*  getAppChannel() { return appChannel; }
00531     void soundTouchPanel( QWSEvent* e );
00532     void loadEZXFonts();
00533     bool createChannel();
00534     void startShowPHCursor( int startTime = 0,const QString& resId = QString::null );
00535     void stopShowPHCursor();
00536     void resetPHTimer();
00537 
00538     void createTouchSoundMsgQueue();
00539 
00540     bool getIMConnectedState() { return imConnected; }
00541     void setIMConnectedState( bool connected ) {imConnected = connected;}
00542     void showInputWidgetAux( int mwId,int show );
00543     void editableWidgetClicked( QWidget* widget,bool canClick = true );
00544 
00545     enum
00546     {
00547         WINS_LOWER = -1,
00548         WINS_HOLD = 0,
00549         WINS_SHOW,
00550         WINS_RAISE
00551     };
00552     void manipulateAppWindows( int show );
00553     void serverManipulateAppWindows( int show,const QString& clientName );
00554     void clientManipulateAppWindows( int show,QValueList<int>& winList );
00555     void setFocusToLatestWindow( int winId );
00556 
00557     int applyStyle();
00558     int initPalette();
00559     int applyPalette();
00560     int initTextSize();
00561     int changeTextSize();
00562 
00563 private slots:
00564 
00565     void animationTimeOut();
00566     void animationStatus( int status );
00567 
00568     void slotSystemMessage( const QCString &msg, const QByteArray &data );
00569     void slotServerMessage( const QCString &msg, const QByteArray &data );
00570     void slotAppMessage( const QCString &msg, const QByteArray &data );
00571     void pidMessage( const QCString &message, const QByteArray &data );
00572     void updateEditorInfo( QWSWindow* w, QWSServer::WindowEvent e );
00573     void resetMouseMode();
00574     void resetPressHoldStatus();
00575 
00576 private:
00577 
00578     ZApplicationData* d;
00579 
00580     QCopChannel* serverChannel;
00581     QCopChannel* sysChannel;
00582     QCopChannel* appChannel;
00583     QCopChannel* pidChannel;
00584     QString appName;
00585 
00586     bool canSoundTouch;
00587     int touchMsgQId;
00588 
00589     bool autoInvokeKb;
00590     bool autoHideKb;
00591     bool imConnected;
00592 
00593     int mouseMode;
00594 
00595     ZIMServer* imServer;
00596 
00597 #ifndef QT_NO_QWS_MMI_TEST
00598     QTestCaptureHandler* captureServer;
00599 #endif
00600 
00601     friend class ZMainWidget;
00602 };
00603 
00604 #endif // Z_APPLICATION_H

Generated at Wed Mar 3 13:21:59 2004 by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001