61 |
68 |
62 // Creating and initializing engine as early as possible. |
69 // Creating and initializing engine as early as possible. |
63 // Reserve and power on can then proceed in parallel with |
70 // Reserve and power on can then proceed in parallel with |
64 // ui construction. |
71 // ui construction. |
65 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
72 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
66 CxeEngine *eng = CxeEngine::createEngine(); |
73 CxeEngine *engine = CxeEngine::createEngine(); |
67 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
74 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
68 |
75 |
69 if (app.activateReason() == Hb::ActivationReasonService) { |
76 if (app.activateReason() == Hb::ActivationReasonService || |
|
77 // @todo: There's a bug in orbit and we never get Hb::ActivationReasonService as |
|
78 // activation reason. Use XQServiceUtil to determine if starting service as |
|
79 // a workaround for now |
|
80 XQServiceUtil::isService()) { |
|
81 CX_DEBUG(("CxUI: Camera started as service")); |
70 // Embedded mode. Engine is inited to correct mode |
82 // Embedded mode. Engine is inited to correct mode |
71 // by service provider when request arrives |
83 // by service provider when request arrives |
72 CX_DEBUG(("CxUI: creating serviceprovider")); |
84 CX_DEBUG(("CxUI: creating serviceprovider")); |
73 CxuiServiceProvider::create(eng); |
85 CxuiServiceProvider::create(engine); |
74 CX_DEBUG(("CxUI: done")); |
86 CX_DEBUG(("CxUI: done")); |
75 } else { |
87 } else if (app.activateReason() == Hb::ActivationReasonActivity) { |
76 // Normal mode. Init engine now. |
88 CX_DEBUG(("CxUI: Camera started as activity")); |
77 OstTrace0( camerax_performance, DUP9__MAIN, "msg: e_CX_INIT_ENGINE 1" ); |
89 Cxe::CameraMode mode = Cxe::ImageMode; |
78 //! @todo temporarily commented as part of a hack to change the startup sequence |
90 QString activityId = app.activateId(); |
79 // to avoid GOOM issues |
91 if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY || |
80 //eng->initMode(Cxe::ImageMode); |
92 activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
81 OstTrace0( camerax_performance, DUP10__MAIN, "msg: e_CX_INIT_ENGINE 0" ); |
93 mode = Cxe::VideoMode; |
82 } |
94 } |
|
95 |
|
96 if (activityId == CxuiActivityIds::STILL_PRECAPTURE_ACTIVITY || |
|
97 activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY) { |
|
98 // init engine only if going to pre-capture |
|
99 engine->initMode(mode); |
|
100 } else { |
|
101 // in post-capture don't init but set the correct mode to engine |
|
102 // so init can be done later |
|
103 engine->setMode(mode); |
|
104 } |
|
105 } else { |
|
106 CX_DEBUG(("CxUI: Camera started as normal app")); |
|
107 // normal start |
|
108 engine->initMode(engine->mode()); |
|
109 } |
|
110 |
|
111 #ifdef Q_OS_SYMBIAN |
|
112 //!@todo: Yield run time to system to get enough resources released to start camera. |
|
113 CX_DEBUG(("CxUI: yield control for resource freeing..")); |
|
114 User::After(2*1000*1000); // 2s |
|
115 CX_DEBUG(("CxUI: waiting done..")); |
|
116 #endif // Q_OS_SYMBIAN |
83 |
117 |
84 // Load language specific application localization file, e.g. "camera_en.qm" |
118 // Load language specific application localization file, e.g. "camera_en.qm" |
|
119 // Translations need to be loaded before any widgets are created. |
85 CX_DEBUG(("CxUI: Load translations..")); |
120 CX_DEBUG(("CxUI: Load translations..")); |
86 OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" ); |
121 OstTrace0( camerax_performance, DUP3__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 1" ); |
87 HbTranslator* trans = new HbTranslator(TRANSLATIONS_PATH, TRANSLATIONS_FILE); |
122 HbTranslator translator(TRANSLATIONS_PATH, TRANSLATIONS_FILE); |
88 // Load language specific common localization file |
123 // Load language specific common localization file |
89 trans->loadCommon(); |
124 translator.loadCommon(); |
90 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
125 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
91 CX_DEBUG(("CxUI: ..translations loaded")); |
126 CX_DEBUG(("CxUI: ..translations loaded")); |
92 |
127 |
|
128 // Create main window |
93 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
129 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
94 HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent | |
130 HbMainWindow mainWindow(0, Hb::WindowFlagTransparent | Hb::WindowFlagNoBackground); |
95 Hb::WindowFlagNoBackground); |
131 mainWindow.setAttribute(Qt::WA_NoBackground); |
96 mainWindow->setAttribute(Qt::WA_NoBackground); |
|
97 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
132 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
98 |
133 |
|
134 // Set main window to landscape and full screen |
|
135 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
|
136 mainWindow.setOrientation(Qt::Horizontal); |
|
137 OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" ); |
|
138 OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" ); |
|
139 |
|
140 #ifdef Q_OS_SYMBIAN |
|
141 mainWindow.showFullScreen(); |
|
142 #else |
|
143 /* |
|
144 * todo : check if this is an Orbit bug or if there's a better solution |
|
145 */ |
|
146 mainWindow.resize(640, 360); |
|
147 mainWindow.setOrientation(Qt::Vertical, false); |
|
148 mainWindow.show(); |
|
149 mainWindow.setOrientation(Qt::Horizontal, false); |
|
150 #endif //Q_OS_SYMBIAN |
|
151 OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" ); |
|
152 |
|
153 // Create view manager |
99 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
154 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
100 CxuiViewManager *viewManager = new CxuiViewManager(app, *mainWindow, *eng); |
155 CxuiViewManager *viewManager = new CxuiViewManager(app, mainWindow, *engine); |
101 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
156 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
102 |
157 |
103 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
158 // 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" ); |
159 OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" ); |
112 eng->viewfinderControl().setWindow(mainWindow->effectiveWinId()); |
160 engine->viewfinderControl().setWindow(mainWindow.effectiveWinId()); |
113 OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" ); |
161 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 |
162 |
130 int returnValue = app.exec(); |
163 int returnValue = app.exec(); |
131 |
164 |
132 delete viewManager; |
165 delete viewManager; |
133 |
166 CxuiServiceProvider::destroy(); // delete service provider instance |
134 // delete service provider instance |
167 delete engine; |
135 CxuiServiceProvider::destroy(); |
|
136 |
|
137 delete mainWindow; |
|
138 delete trans; |
|
139 delete eng; |
|
140 |
168 |
141 return returnValue; |
169 return returnValue; |
142 } |
170 } |