camerauis/cameraxui/cxui/src/main.cpp
changeset 40 2922f70fca82
parent 39 c5025ea871a1
child 41 67457b2ffb33
equal deleted inserted replaced
39:c5025ea871a1 40:2922f70fca82
    18 #include <coemain.h>
    18 #include <coemain.h>
    19 #include <eikenv.h>
    19 #include <eikenv.h>
    20 #include <QApplication>
    20 #include <QApplication>
    21 #include <QGraphicsProxyWidget>
    21 #include <QGraphicsProxyWidget>
    22 // needed for localization
    22 // needed for localization
    23 #include <QTranslator>
    23 #include <HbTranslator>
    24 #include <QLocale>
    24 #include <QLocale>
    25 #include <hbmainwindow.h>
    25 #include <hbmainwindow.h>
    26 #include <xqserviceutil.h>
    26 #include <xqserviceutil.h>
    27 
    27 
    28 #include "cxeengine.h"
    28 #include "cxeengine.h"
    38 #endif
    38 #endif
    39 
    39 
    40 using namespace Cxe;
    40 using namespace Cxe;
    41 
    41 
    42 // CONSTANTS
    42 // CONSTANTS
    43 const QString TRANSLATIONS_PATH = "z:/resource/qt/translations/";
    43 const QString TRANSLATIONS_PATH = "/resource/qt/translations/";
    44 const QString TRANSLATIONS_FILE_NAME = "camera_";
    44 const QString TRANSLATIONS_FILE = "camera";
    45 const QString COMMON_TRANSLATIONS_FILE_NAME = "common_";
       
    46 
    45 
    47 int main(int argc, char *argv[])
    46 int main(int argc, char *argv[])
    48 {
    47 {
    49     CX_DEBUG(("CxUI: entering main()"));
    48     CX_DEBUG(("CxUI: entering main()"));
    50     OstTrace0( camerax_performance, _MAIN, "msg: e_CX_STARTUP 1" );
    49     OstTrace0( camerax_performance, _MAIN, "msg: e_CX_STARTUP 1" );
    80          // to avoid GOOM issues
    79          // to avoid GOOM issues
    81         //eng->initMode(Cxe::ImageMode);
    80         //eng->initMode(Cxe::ImageMode);
    82         OstTrace0( camerax_performance, DUP10__MAIN, "msg: e_CX_INIT_ENGINE 0" );
    81         OstTrace0( camerax_performance, DUP10__MAIN, "msg: e_CX_INIT_ENGINE 0" );
    83     }
    82     }
    84 
    83 
    85     // Load the language specific localization files: application + common
    84     // Load language specific application localization file, e.g. "camera_en.qm"
       
    85     CX_DEBUG(("CxUI: Load translations.."));
    86     OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" );
    86     OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" );
    87     QTranslator translator;
    87     HbTranslator* trans = new HbTranslator(TRANSLATIONS_PATH, TRANSLATIONS_FILE);
    88     QString lang = QLocale::system().name();
    88     // Load language specific common localization file
    89 
    89     trans->loadCommon();
    90     CX_DEBUG(("CxUI: loading translation"));
       
    91     bool ret = false;
       
    92     ret = translator.load(TRANSLATIONS_PATH + TRANSLATIONS_FILE_NAME + lang);
       
    93     CX_DEBUG(("load ok=%d", ret));
       
    94     app.installTranslator( &translator );
       
    95 
       
    96     QTranslator commonTranslator;
       
    97     CX_DEBUG(("CxUI: loading common translation"));
       
    98     ret = false;
       
    99     ret = commonTranslator.load(TRANSLATIONS_PATH + COMMON_TRANSLATIONS_FILE_NAME + lang);
       
   100     CX_DEBUG(("load ok=%d", ret));
       
   101     app.installTranslator(&commonTranslator);
       
   102     OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" );
    90     OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" );
       
    91     CX_DEBUG(("CxUI: ..translations loaded"));
   103 
    92 
   104     OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" );
    93     OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" );
   105     HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent |
    94     HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent |
   106                                                    Hb::WindowFlagNoBackground);
    95                                                    Hb::WindowFlagNoBackground);
   107     mainWindow->setAttribute(Qt::WA_NoBackground);
    96     mainWindow->setAttribute(Qt::WA_NoBackground);
   122     OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" );
   111     OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" );
   123     viewManager->prepareWindow();
   112     viewManager->prepareWindow();
   124     OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" );
   113     OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" );
   125     //! @todo initMode call added here as a temporary hack to change the startup sequence
   114     //! @todo initMode call added here as a temporary hack to change the startup sequence
   126 	// in order to avoid GOOM issues
   115 	// in order to avoid GOOM issues
   127 	  User::After(2000000);
   116 	if (viewManager->proceedStartup()) {
   128     eng->initMode(Cxe::ImageMode);
   117     	User::After(2000000);
       
   118         eng->initMode(Cxe::ImageMode);
       
   119     }
       
   120 
   129     int returnValue = app.exec();
   121     int returnValue = app.exec();
   130 
   122 
   131     // delete service provider instance
   123     // delete service provider instance
   132     CxuiServiceProvider::destroy();
   124     CxuiServiceProvider::destroy();
   133 
   125 
   134     delete viewManager;
   126     delete viewManager;
   135     delete mainWindow;
   127     delete mainWindow;
       
   128     delete trans;
   136     delete eng;
   129     delete eng;
   137 
   130 
   138     return returnValue;
   131     return returnValue;
   139 }
   132 }