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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
//USER
17
hgs
parents: 15
diff changeset
    18
#include "logsapplication.h"
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include "logsmainwindow.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "logsviewmanager.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "logsservicehandler.h"
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    22
#include "logsservicehandlerold.h"
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include "logslogger.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include "logsdefs.h"
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
//SYSTEM
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <QObject>
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <hbmainwindow.h>
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <hbapplication.h>
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <hbstyleloader.h>
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    31
#include <hbtranslator.h>
15
hgs
parents: 9
diff changeset
    32
#include <QTranslator>
hgs
parents: 9
diff changeset
    33
hgs
parents: 9
diff changeset
    34
// TODO: Use QTranslator for now as HbTranslator has some bugs regarding
hgs
parents: 9
diff changeset
    35
// language fallback handling, start using HbTranslator once those problems
hgs
parents: 9
diff changeset
    36
// are fixed 
hgs
parents: 9
diff changeset
    37
#define LOGS_USE_QTRANSLATOR
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
int main(int argc, char *argv[])
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
{
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    LOGS_QDEBUG( "logs [UI] -> main()" )
15
hgs
parents: 9
diff changeset
    42
17
hgs
parents: 15
diff changeset
    43
    LogsApplication app(argc, argv);
15
hgs
parents: 9
diff changeset
    44
hgs
parents: 9
diff changeset
    45
#ifdef LOGS_USE_QTRANSLATOR
hgs
parents: 9
diff changeset
    46
    QString lang = QLocale::system().name();
hgs
parents: 9
diff changeset
    47
    QTranslator trans;
hgs
parents: 9
diff changeset
    48
    QString path = "z:/resource/qt/translations/";
hgs
parents: 9
diff changeset
    49
    if ( trans.load(path + "qt_" + lang) ){
hgs
parents: 9
diff changeset
    50
        app.installTranslator(&trans);
hgs
parents: 9
diff changeset
    51
    }
hgs
parents: 9
diff changeset
    52
    QTranslator trans2;
hgs
parents: 9
diff changeset
    53
    if ( trans2.load(path + "dialer_" + lang) ){
hgs
parents: 9
diff changeset
    54
        app.installTranslator(&trans2);
hgs
parents: 9
diff changeset
    55
    }
hgs
parents: 9
diff changeset
    56
    QTranslator trans3;
hgs
parents: 9
diff changeset
    57
    if ( trans3.load(path + "common_" + lang) ){
hgs
parents: 9
diff changeset
    58
        app.installTranslator(&trans3);
hgs
parents: 9
diff changeset
    59
    }
hgs
parents: 9
diff changeset
    60
    
hgs
parents: 9
diff changeset
    61
#else
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    62
    HbTranslator translator("dialer");
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    63
    translator.loadCommon();
15
hgs
parents: 9
diff changeset
    64
#endif
hgs
parents: 9
diff changeset
    65
    
hgs
parents: 9
diff changeset
    66
    LogsMainWindow window;
17
hgs
parents: 15
diff changeset
    67
    //Application ready signal is emitted after startup when UI is fully loaded and functional
hgs
parents: 15
diff changeset
    68
    QObject::connect( &window, SIGNAL(viewReady()), &app, SLOT(testLogsHandleAppViewReady()) );    
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    HbStyleLoader::registerFilePath(":/logslayouts");
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
    // Create service handler asap so that services are published fast.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
    // Servicehandler cannot be created before HbApplication creation.
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    // This can cause problem of service request not coming through if
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    // HbApplication creation takes long time.
9
hgs
parents: 6
diff changeset
    75
    LogsServiceHandler service;
hgs
parents: 6
diff changeset
    76
    LogsServiceHandlerOld serviceOld;
6
41c0a814d878 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 2
diff changeset
    77
    LogsViewManager viewManager(window, service, serviceOld);
0
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    // Don't show window yet as app might be started at background
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    int err = app.exec();
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    HbStyleLoader::unregisterFilePath(":/logslayouts");
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    LOGS_QDEBUG( "logs [UI] <- main()" )
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    return err;
4a5361db8937 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
}