ginebra/emulator/main.cpp
branchGCC_SURGE
changeset 8 2e16851ffecd
parent 2 bf4420e9fa4d
parent 6 1c3b8676e58c
equal deleted inserted replaced
2:bf4420e9fa4d 8:2e16851ffecd
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtGui>
       
    19 #include "../chromeview.h"
       
    20 #ifndef Q_OS_SYMBIAN
       
    21 #include "chromewindow.h"
       
    22 #endif
       
    23 
       
    24 #include <QDir>
       
    25 #include <QTranslator>
       
    26 #include <QLocale>
       
    27 #include "bedrockprovisioning.h"
       
    28 #include "webpagecontroller.h"
       
    29 #include "viewstack.h"
       
    30 
       
    31 //#define HARDWARE_DEBUG_TRACE
       
    32 #ifdef HARDWARE_DEBUG_TRACE
       
    33 
       
    34 static const QString DebugLogPath("C:/Data/debug.txt");
       
    35 
       
    36 static void initDebugOutput()
       
    37 {
       
    38     QFile file(DebugLogPath);
       
    39     file.remove();
       
    40 }
       
    41 
       
    42 static void debugOutput(QtMsgType type, const char *msg)
       
    43 {
       
    44     QFile file(DebugLogPath);
       
    45     
       
    46     if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))
       
    47         return;
       
    48     
       
    49     QTextStream out(&file);
       
    50     out << "\nDebug: " << msg;
       
    51     
       
    52     file.flush();
       
    53     file.close();
       
    54 }
       
    55 #endif
       
    56 
       
    57 int main(int argc, char * argv[])
       
    58 {
       
    59     int res = 0;
       
    60     
       
    61 #ifdef HARDWARE_DEBUG_TRACE
       
    62     initDebugOutput();    
       
    63     qInstallMsgHandler(debugOutput);
       
    64 #endif
       
    65     
       
    66     QApplication app(argc, argv);
       
    67     qDebug() << "main: currentPath=" << QDir::currentPath();
       
    68     
       
    69     QLocale language;
       
    70     QString langCountryCode = language.name();
       
    71     langCountryCode.replace(QString("-"), QString("_"));
       
    72     //qDebug() << "ChromeView::loadChrome: "  << langCountryCode;  
       
    73     //Todo: when platform delivers .ts file
       
    74     //QString transFilePath = "Z:/resource/qt/translations/";
       
    75     QString transFilePath = ":/translations";
       
    76     QTranslator translator;
       
    77     QString transFile = QLatin1String("browserLoc_") + langCountryCode.toLower();
       
    78     bool installed = translator.load(transFile, transFilePath);
       
    79     if (installed)
       
    80     {
       
    81         QApplication::installTranslator(&translator);
       
    82     }
       
    83     else if (transFile.count("_") > 1) 
       
    84     {
       
    85         transFile = transFile.left(transFile.lastIndexOf("_"));
       
    86         installed = translator.load(transFile, transFilePath);
       
    87         qDebug() << "[LocaleDelegate::loadTranslator()] translation file installed:" << installed;
       
    88         if (installed)
       
    89             QApplication::installTranslator(&translator);
       
    90         else
       
    91         {
       
    92             qDebug() << " LocaleDelegate::loadTranslator not loaded!";
       
    93         }
       
    94     }
       
    95     
       
    96 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
       
    97     // Display in bare-bones widget.
       
    98     GiWidget *gw = new GiWidget;
       
    99     //app.setMainWindow(gw);
       
   100     
       
   101     ChromeView *view = new ChromeView(gw);
       
   102     gw->setChromeView(view);
       
   103     gw->showFullScreen();
       
   104     view->setGeometry(0, 0, gw->width(), gw->height());
       
   105     
       
   106 #else // Desktop build.
       
   107     // Display in a top-level window with menubar and toolbar etc...
       
   108     ChromeWindow *chrome = new ChromeWindow();
       
   109     chrome->show();
       
   110 #endif
       
   111     res = app.exec();
       
   112 
       
   113 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
       
   114 	delete view;
       
   115 	delete gw;
       
   116 #else
       
   117 	delete chrome;
       
   118 #endif
       
   119 
       
   120     delete WebPageController::getSingleton();
       
   121     delete ViewStack::getSingleton();
       
   122 
       
   123 	return res;
       
   124 }