satui/satapp/src/main.cpp
changeset 39 cee7e9e0906c
parent 15 d7fc66ccd6fb
equal deleted inserted replaced
32:1f002146abb4 39:cee7e9e0906c
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description: satapp main
    15 *
    15 *
    16 *
    16 *
    17 */
    17 */
    18 
    18 
       
    19 #include <QtGlobal>
    19 #include <QApplication>
    20 #include <QApplication>
    20 #include <QTranslator>
    21 #include <QTranslator>
    21 #include <hbapplication.h>
    22 #include <hbapplication.h>
    22 #include <hbmainwindow.h>
    23 #include <hbmainwindow.h>
       
    24 #include "satappmainhandler.h"
    23 
    25 
    24 #include "satappmainhandler.h"
       
    25 #include "tflogger.h"
       
    26 
    26 
       
    27 #ifdef SAT_DEBUG_TO_FILE
       
    28     // ------------------------------------------------------------
       
    29     // this segment provides functionality that copies all QT debug
       
    30     // output to RFileLogger, and also the standard QT debug stream
       
    31     #include <flogger.h>
       
    32     #include <e32svr.h>
       
    33     _LIT(KTfLogFolder, "sat");
       
    34     _LIT(KTfLogFile, "satui.txt");
       
    35     // original message handler
       
    36     QtMsgHandler originalMsgHandler;
       
    37     // debug redirection function
       
    38     void qDebugToRFileLogger(QtMsgType type, const char *msg)
       
    39     {
       
    40         TPtrC8 symbian_msg((const TUint8*)msg);
       
    41         RFileLogger::Write(KTfLogFolder,KTfLogFile,
       
    42             EFileLoggingModeAppend,symbian_msg);
       
    43         if (originalMsgHandler) originalMsgHandler(type,msg);
       
    44     }
       
    45     // ------------------------------------------------------------
       
    46 #endif
       
    47 
       
    48 
       
    49     
    27 int main(int argc, char *argv[])
    50 int main(int argc, char *argv[])
    28 {
    51 {
    29     TFLOGSTRING("SATAPP: main")
    52 #ifdef SAT_DEBUG_TO_FILE
       
    53     originalMsgHandler = qInstallMsgHandler(qDebugToRFileLogger);
       
    54 #endif
       
    55 
       
    56     qDebug("SATAPP: main");
    30 
    57 
    31     HbApplication app(argc, argv);
    58     HbApplication app(argc, argv);
    32     TFLOGSTRING("SATAPP: main app created")
    59     qDebug("SATAPP: main app created");
    33     
    60     
    34     QTranslator translator;
    61     QTranslator translator;
    35     bool ok = translator.load(":/translations/satapp_en");
    62     bool ok = translator.load(":/translations/satapp");
    36     TFLOGSTRING2("SATUI: main, translation %d (1=OK, 0=fail)", ok )
    63     qDebug("SATUI: main, translation %d (1=OK, 0=fail)", ok );
    37     app.installTranslator(&translator);
    64     app.installTranslator(&translator);
    38 
    65 
    39     HbMainWindow window;
    66     HbMainWindow window;
    40     TFLOGSTRING("SATAPP: main window created")
    67     qDebug("SATAPP: main window created");
    41 
    68 
    42     SatAppMainHandler *mainHandler = new SatAppMainHandler(window);
    69     SatAppMainHandler *mainHandler = new SatAppMainHandler(window);
    43         
    70 
    44     window.show();
    71     window.show();
    45     TFLOGSTRING("SATAPP: main view showed")
    72     qDebug("SATAPP: main view showed");
    46 
    73 
    47     int result = app.exec();
    74     int result = app.exec();
    48     TFLOGSTRING2("SATAPP: main exit %d", result)
    75     qDebug("SATAPP: main exit %d", result);
    49 
    76 
    50     delete mainHandler;
    77     delete mainHandler;
    51     return result;
    78     return result;
    52 }
    79 }
    53 
    80