camerauis/cameraxui/cxui/src/main.cpp
author hgs
Thu, 15 Jul 2010 01:49:11 +0300
changeset 40 2922f70fca82
parent 39 c5025ea871a1
child 41 67457b2ffb33
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d9aefe59d544 Revision: 201011
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".
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    17
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    18
#include <coemain.h>
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    19
#include <eikenv.h>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QApplication>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QGraphicsProxyWidget>
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    22
// needed for localization
40
hgs
parents: 39
diff changeset
    23
#include <HbTranslator>
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    24
#include <QLocale>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <hbmainwindow.h>
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    26
#include <xqserviceutil.h>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "cxeengine.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "cxecameradevicecontrol.h"
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    30
#include "cxuiapplication.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "cxuiviewmanager.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "cxutils.h"
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    33
#include "cxuiserviceprovider.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    34
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "OstTraceDefinitions.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#ifdef OST_TRACE_COMPILER_IN_USE
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "mainTraces.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#endif
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    40
using namespace Cxe;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    42
// CONSTANTS
40
hgs
parents: 39
diff changeset
    43
const QString TRANSLATIONS_PATH = "/resource/qt/translations/";
hgs
parents: 39
diff changeset
    44
const QString TRANSLATIONS_FILE = "camera";
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
int main(int argc, char *argv[])
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    CX_DEBUG(("CxUI: entering main()"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
    OstTrace0( camerax_performance, _MAIN, "msg: e_CX_STARTUP 1" );
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
    Q_INIT_RESOURCE(cxui);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
39
c5025ea871a1 201021_1
hgs
parents: 28
diff changeset
    53
    // Use software rendering / raster graphics system to save GPU memory.
c5025ea871a1 201021_1
hgs
parents: 28
diff changeset
    54
    CX_DEBUG(("CxUI: Take raster graphics system into use.."));
c5025ea871a1 201021_1
hgs
parents: 28
diff changeset
    55
    QApplication::setGraphicsSystem("raster");
c5025ea871a1 201021_1
hgs
parents: 28
diff changeset
    56
    CX_DEBUG(("CxUI: ..raster graphics system in use"));
c5025ea871a1 201021_1
hgs
parents: 28
diff changeset
    57
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    58
    OstTrace0( camerax_performance, DUP1__MAIN, "msg: e_CX_HBAPP_CREATION 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    59
    CxuiApplication app(argc, argv);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    60
    OstTrace0( camerax_performance, DUP2__MAIN, "msg: e_CX_HBAPP_CREATION 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    // Creating and initializing engine as early as possible.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
    // Reserve and power on can then proceed in parallel with
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
    // ui construction.
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    65
    OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
    CxeEngine *eng = CxeEngine::createEngine();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    67
    OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
    if (XQServiceUtil::isService()) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
        // Embedded mode.  Engine is inited to correct mode
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
        // by service provider when request arrives
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
        CX_DEBUG(("CxUI: creating serviceprovider"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
        CxuiServiceProvider::create(eng);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
        CX_DEBUG(("CxUI: done"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
    } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
        // Normal mode. Init engine now.
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    77
        OstTrace0( camerax_performance, DUP9__MAIN, "msg: e_CX_INIT_ENGINE 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    78
		 //! @todo temporarily commented as part of a hack to change the startup sequence
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    79
         // to avoid GOOM issues
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    80
        //eng->initMode(Cxe::ImageMode);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    81
        OstTrace0( camerax_performance, DUP10__MAIN, "msg: e_CX_INIT_ENGINE 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
40
hgs
parents: 39
diff changeset
    84
    // Load language specific application localization file, e.g. "camera_en.qm"
hgs
parents: 39
diff changeset
    85
    CX_DEBUG(("CxUI: Load translations.."));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    86
    OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" );
40
hgs
parents: 39
diff changeset
    87
    HbTranslator* trans = new HbTranslator(TRANSLATIONS_PATH, TRANSLATIONS_FILE);
hgs
parents: 39
diff changeset
    88
    // Load language specific common localization file
hgs
parents: 39
diff changeset
    89
    trans->loadCommon();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    90
    OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" );
40
hgs
parents: 39
diff changeset
    91
    CX_DEBUG(("CxUI: ..translations loaded"));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    93
    OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    94
    HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent |
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    95
                                                   Hb::WindowFlagNoBackground);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    96
    mainWindow->setAttribute(Qt::WA_NoBackground);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    97
    OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    98
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    99
    OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   100
    CxuiViewManager *viewManager = new CxuiViewManager(app, *mainWindow, *eng);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   101
    OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   103
    OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   104
    mainWindow->setOrientation(Qt::Horizontal);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   105
    OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   106
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   107
    OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   108
    mainWindow->showFullScreen();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   109
    OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   111
    OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   112
    viewManager->prepareWindow();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   113
    OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" );
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   114
    //! @todo initMode call added here as a temporary hack to change the startup sequence
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   115
	// in order to avoid GOOM issues
40
hgs
parents: 39
diff changeset
   116
	if (viewManager->proceedStartup()) {
hgs
parents: 39
diff changeset
   117
    	User::After(2000000);
hgs
parents: 39
diff changeset
   118
        eng->initMode(Cxe::ImageMode);
hgs
parents: 39
diff changeset
   119
    }
hgs
parents: 39
diff changeset
   120
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    int returnValue = app.exec();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    // delete service provider instance
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    CxuiServiceProvider::destroy();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   126
    delete viewManager;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   127
    delete mainWindow;
40
hgs
parents: 39
diff changeset
   128
    delete trans;
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   129
    delete eng;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   130
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    return returnValue;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
}