13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <coemain.h> |
|
19 #include <eikenv.h> |
|
20 #include <QApplication> |
18 #include <QApplication> |
21 #include <QGraphicsProxyWidget> |
19 #include <QGraphicsProxyWidget> |
22 // needed for localization |
20 // needed for localization |
|
21 #include <QLocale> |
23 #include <HbTranslator> |
22 #include <HbTranslator> |
24 #include <QLocale> |
|
25 #include <hbmainwindow.h> |
23 #include <hbmainwindow.h> |
|
24 |
|
25 #ifdef Q_OS_SYMBIAN |
|
26 #include <coemain.h> |
|
27 #include <eikenv.h> |
|
28 #endif // Q_OS_SYMBIAN |
26 |
29 |
27 #include "cxeengine.h" |
30 #include "cxeengine.h" |
28 #include "cxecameradevicecontrol.h" |
31 #include "cxecameradevicecontrol.h" |
29 #include "cxuiapplication.h" |
32 #include "cxuiapplication.h" |
30 #include "cxuiviewmanager.h" |
33 #include "cxuiviewmanager.h" |
31 #include "cxuiapplicationstate.h" |
34 #include "cxuiapplicationstate.h" |
|
35 #include "cxuienums.h" |
32 #include "cxutils.h" |
36 #include "cxutils.h" |
33 #include "cxuiserviceprovider.h" |
37 #include "cxuiserviceprovider.h" |
34 |
38 |
|
39 #ifdef Q_OS_SYMBIAN |
35 #include "OstTraceDefinitions.h" |
40 #include "OstTraceDefinitions.h" |
36 #ifdef OST_TRACE_COMPILER_IN_USE |
41 #ifdef OST_TRACE_COMPILER_IN_USE |
37 #include "mainTraces.h" |
42 #include "mainTraces.h" |
38 #endif |
43 #endif // OST_TRACE_COMPILER_IN_USE |
|
44 #else |
|
45 #include "cxuimacrosdesktop.h" |
|
46 #endif // Q_OS_SYMBIAN |
39 |
47 |
40 using namespace Cxe; |
48 using namespace Cxe; |
41 |
49 |
42 // CONSTANTS |
50 // CONSTANTS |
43 const QString TRANSLATIONS_PATH = "/resource/qt/translations/"; |
51 const QString TRANSLATIONS_PATH = "/resource/qt/translations/"; |
61 |
69 |
62 // Creating and initializing engine as early as possible. |
70 // Creating and initializing engine as early as possible. |
63 // Reserve and power on can then proceed in parallel with |
71 // Reserve and power on can then proceed in parallel with |
64 // ui construction. |
72 // ui construction. |
65 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
73 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
66 CxeEngine *eng = CxeEngine::createEngine(); |
74 CxeEngine *engine = CxeEngine::createEngine(); |
67 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
75 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
68 |
76 |
69 if (app.activateReason() == Hb::ActivationReasonService) { |
77 if (app.activateReason() == Hb::ActivationReasonService) { |
70 // Embedded mode. Engine is inited to correct mode |
78 // Embedded mode. Engine is inited to correct mode |
71 // by service provider when request arrives |
79 // by service provider when request arrives |
72 CX_DEBUG(("CxUI: creating serviceprovider")); |
80 CX_DEBUG(("CxUI: creating serviceprovider")); |
73 CxuiServiceProvider::create(eng); |
81 CxuiServiceProvider::create(engine); |
74 CX_DEBUG(("CxUI: done")); |
82 CX_DEBUG(("CxUI: done")); |
75 } else { |
83 } else if (app.activateReason() == Hb::ActivationReasonActivity) { |
76 // Normal mode. Init engine now. |
84 Cxe::CameraMode mode = Cxe::ImageMode; |
77 OstTrace0( camerax_performance, DUP9__MAIN, "msg: e_CX_INIT_ENGINE 1" ); |
85 QString activityId = app.activateId(); |
78 //! @todo temporarily commented as part of a hack to change the startup sequence |
86 if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY || |
79 // to avoid GOOM issues |
87 activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
80 //eng->initMode(Cxe::ImageMode); |
88 mode = Cxe::VideoMode; |
81 OstTrace0( camerax_performance, DUP10__MAIN, "msg: e_CX_INIT_ENGINE 0" ); |
89 } |
82 } |
90 |
|
91 if (activityId == CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY || |
|
92 activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY) { |
|
93 // init engine only if going to pre-capture |
|
94 engine->initMode(mode); |
|
95 } else { |
|
96 // in post-capture don't init but set the correct mode to engine |
|
97 // so init can be done later |
|
98 engine->setMode(mode); |
|
99 } |
|
100 } else { |
|
101 // normal start |
|
102 engine->initMode(engine->mode()); |
|
103 } |
|
104 |
|
105 #ifdef Q_OS_SYMBIAN |
|
106 //!@todo: Yield run time to system to get enough resources released to start camera. |
|
107 CX_DEBUG(("CxUI: yield control for resource freeing..")); |
|
108 User::After(300*1000); // 300ms |
|
109 CX_DEBUG(("CxUI: waiting done..")); |
|
110 #endif // Q_OS_SYMBIAN |
83 |
111 |
84 // Load language specific application localization file, e.g. "camera_en.qm" |
112 // Load language specific application localization file, e.g. "camera_en.qm" |
|
113 // Translations need to be loaded before any widgets are created. |
85 CX_DEBUG(("CxUI: Load translations..")); |
114 CX_DEBUG(("CxUI: Load translations..")); |
86 OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" ); |
115 OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" ); |
87 HbTranslator* trans = new HbTranslator(TRANSLATIONS_PATH, TRANSLATIONS_FILE); |
116 HbTranslator translator(TRANSLATIONS_PATH, TRANSLATIONS_FILE); |
88 // Load language specific common localization file |
117 // Load language specific common localization file |
89 trans->loadCommon(); |
118 translator.loadCommon(); |
90 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
119 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
91 CX_DEBUG(("CxUI: ..translations loaded")); |
120 CX_DEBUG(("CxUI: ..translations loaded")); |
92 |
121 |
|
122 // Create main window |
93 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
123 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
94 HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent | |
124 HbMainWindow mainWindow(0, Hb::WindowFlagTransparent | Hb::WindowFlagNoBackground); |
95 Hb::WindowFlagNoBackground); |
125 mainWindow.setAttribute(Qt::WA_NoBackground); |
96 mainWindow->setAttribute(Qt::WA_NoBackground); |
|
97 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
126 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
98 |
127 |
|
128 // Set main window to landscape and full screen |
|
129 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
|
130 mainWindow.setOrientation(Qt::Horizontal); |
|
131 OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" ); |
|
132 OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" ); |
|
133 |
|
134 #ifdef Q_OS_SYMBIAN |
|
135 mainWindow.showFullScreen(); |
|
136 #else |
|
137 /* |
|
138 * todo : check if this is an Orbit bug or if there's a better solution |
|
139 */ |
|
140 mainWindow.resize(640, 360); |
|
141 mainWindow.setOrientation(Qt::Vertical, false); |
|
142 mainWindow.show(); |
|
143 mainWindow.setOrientation(Qt::Horizontal, false); |
|
144 #endif //Q_OS_SYMBIAN |
|
145 OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" ); |
|
146 |
|
147 // Create view manager |
99 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
148 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
100 CxuiViewManager *viewManager = new CxuiViewManager(app, *mainWindow, *eng); |
149 CxuiViewManager *viewManager = new CxuiViewManager(app, mainWindow, *engine); |
101 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
150 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
102 |
151 |
103 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
152 // Give main window id to engine for setting up viewfinder window behind it |
104 mainWindow->setOrientation(Qt::Horizontal); |
|
105 OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" ); |
|
106 |
|
107 OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" ); |
|
108 mainWindow->showFullScreen(); |
|
109 OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" ); |
|
110 |
|
111 OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" ); |
153 OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" ); |
112 eng->viewfinderControl().setWindow(mainWindow->effectiveWinId()); |
154 engine->viewfinderControl().setWindow(mainWindow.effectiveWinId()); |
113 OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" ); |
155 OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" ); |
114 |
|
115 //! @todo initMode call added here as a temporary hack to change the startup sequence |
|
116 // in order to avoid GOOM issues. |
|
117 if (app.activateReason() != Hb::ActivationReasonService |
|
118 && viewManager->applicationState().currentState() == CxuiApplicationState::Normal) { |
|
119 User::After(2000000); |
|
120 if (app.activateReason() == Hb::ActivationReasonActivity) { |
|
121 // when started by activity, let viewmanager init |
|
122 // to correct mode |
|
123 viewManager->initEngine(); |
|
124 } else { |
|
125 // normal start |
|
126 eng->initMode(eng->mode()); |
|
127 } |
|
128 } |
|
129 |
156 |
130 int returnValue = app.exec(); |
157 int returnValue = app.exec(); |
131 |
158 |
132 delete viewManager; |
159 delete viewManager; |
133 |
160 CxuiServiceProvider::destroy(); // delete service provider instance |
134 // delete service provider instance |
161 delete engine; |
135 CxuiServiceProvider::destroy(); |
|
136 |
|
137 delete mainWindow; |
|
138 delete trans; |
|
139 delete eng; |
|
140 |
162 |
141 return returnValue; |
163 return returnValue; |
142 } |
164 } |