logsui/logsapp/src/main.cpp
author hgs
Fri, 03 Sep 2010 14:26:05 +0300
changeset 17 90fe74753f71
parent 15 76d2cf7a585e
child 18 acd4e87b24b4
permissions -rw-r--r--
201035

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
//USER
#include "logsapplication.h"
#include "logsmainwindow.h"
#include "logsviewmanager.h"
#include "logsservicehandler.h"
#include "logsservicehandlerold.h"
#include "logslogger.h"
#include "logsdefs.h"

//SYSTEM
#include <QObject>
#include <hbmainwindow.h>
#include <hbapplication.h>
#include <hbstyleloader.h>
#include <hbtranslator.h>
#include <QTranslator>

// TODO: Use QTranslator for now as HbTranslator has some bugs regarding
// language fallback handling, start using HbTranslator once those problems
// are fixed 
#define LOGS_USE_QTRANSLATOR

int main(int argc, char *argv[])
{
    LOGS_QDEBUG( "logs [UI] -> main()" )

    LogsApplication app(argc, argv);

#ifdef LOGS_USE_QTRANSLATOR
    QString lang = QLocale::system().name();
    QTranslator trans;
    QString path = "z:/resource/qt/translations/";
    if ( trans.load(path + "qt_" + lang) ){
        app.installTranslator(&trans);
    }
    QTranslator trans2;
    if ( trans2.load(path + "dialer_" + lang) ){
        app.installTranslator(&trans2);
    }
    QTranslator trans3;
    if ( trans3.load(path + "common_" + lang) ){
        app.installTranslator(&trans3);
    }
    
#else
    HbTranslator translator("dialer");
    translator.loadCommon();
#endif
    
    LogsMainWindow window;
    //Application ready signal is emitted after startup when UI is fully loaded and functional
    QObject::connect( &window, SIGNAL(viewReady()), &app, SLOT(testLogsHandleAppViewReady()) );    
    HbStyleLoader::registerFilePath(":/logslayouts");
    
    // Create service handler asap so that services are published fast.
    // Servicehandler cannot be created before HbApplication creation.
    // This can cause problem of service request not coming through if
    // HbApplication creation takes long time.
    LogsServiceHandler service;
    LogsServiceHandlerOld serviceOld;
    LogsViewManager viewManager(window, service, serviceOld);
    
    // Don't show window yet as app might be started at background
    int err = app.exec();
    
    HbStyleLoader::unregisterFilePath(":/logslayouts");
    
    LOGS_QDEBUG( "logs [UI] <- main()" )
    return err;
}