43 #include "cxuienums.h" |
44 #include "cxuienums.h" |
44 #include "cxutils.h" |
45 #include "cxutils.h" |
45 #include "cxuizoomslider.h" |
46 #include "cxuizoomslider.h" |
46 #include "cxuicapturekeyhandler.h" |
47 #include "cxuicapturekeyhandler.h" |
47 #include "cxuidocumentloader.h" |
48 #include "cxuidocumentloader.h" |
|
49 #include "cxuiserviceprovider.h" |
|
50 |
48 #include "OstTraceDefinitions.h" |
51 #include "OstTraceDefinitions.h" |
49 #ifdef OST_TRACE_COMPILER_IN_USE |
52 #ifdef OST_TRACE_COMPILER_IN_USE |
50 #include "cxuivideoprecaptureviewTraces.h" |
53 #include "cxuivideoprecaptureviewTraces.h" |
51 #endif |
54 #endif |
52 #include "cxuiserviceprovider.h" |
|
53 |
55 |
54 |
56 |
55 using namespace Cxe; |
57 using namespace Cxe; |
56 using namespace CxUiLayout; |
58 using namespace CxUiLayout; |
57 using namespace CxUiInternal; |
59 using namespace CxUiInternal; |
131 |
140 |
132 CX_DEBUG_EXIT_FUNCTION(); |
141 CX_DEBUG_EXIT_FUNCTION(); |
133 |
142 |
134 } |
143 } |
135 |
144 |
|
145 /*! |
|
146 * Loads widgets that are needed right from the start. |
|
147 */ |
136 void CxuiVideoPrecaptureView::loadDefaultWidgets() |
148 void CxuiVideoPrecaptureView::loadDefaultWidgets() |
137 { |
149 { |
138 CX_DEBUG_ENTER_FUNCTION(); |
150 CX_DEBUG_ENTER_FUNCTION(); |
139 CX_DEBUG_ASSERT(mDocumentLoader); |
151 CX_ASSERT_ALWAYS(mDocumentLoader); |
140 |
152 |
141 // get pointers to ui components from the layout data |
153 // get pointers to ui components from the layout data |
142 QGraphicsWidget *widget = NULL; |
154 QGraphicsWidget *widget = NULL; |
143 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER); |
155 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIEWFINDER); |
144 mViewfinder = qobject_cast<HbTransparentWindow *> (widget); |
156 mViewfinder = qobject_cast<HbTransparentWindow *> (widget); |
145 CX_DEBUG_ASSERT(mViewfinder); |
157 CX_ASSERT_ALWAYS(mViewfinder); |
146 |
158 |
|
159 reloadIndicatorWidgets(); |
|
160 |
|
161 CX_DEBUG_EXIT_FUNCTION(); |
|
162 } |
|
163 |
|
164 /*! |
|
165 * Loads default indicators from docml and modifies the visibility |
|
166 * according to current settings. |
|
167 */ |
|
168 void CxuiVideoPrecaptureView::reloadIndicatorWidgets() |
|
169 { |
|
170 CX_DEBUG_ENTER_FUNCTION(); |
|
171 CX_ASSERT_ALWAYS(mDocumentLoader); |
|
172 |
|
173 bool ok = false; |
|
174 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_INDICATORS_SECTION, &ok); |
|
175 CX_ASSERT_ALWAYS(ok); |
|
176 |
|
177 QGraphicsWidget *widget = NULL; |
147 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON); |
178 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_QUALITY_ICON); |
148 mQualityIcon = qobject_cast<HbLabel *> (widget); |
179 mQualityIcon = qobject_cast<HbLabel *> (widget); |
149 CX_DEBUG_ASSERT(mQualityIcon); |
180 CX_ASSERT_ALWAYS(mQualityIcon); |
|
181 |
|
182 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_VIDEOAUDIOMUTE_INDICATOR_ICON); |
|
183 HbLabel *videoaudiomuteIndicatorIcon = qobject_cast<HbLabel *>(widget); |
|
184 CX_ASSERT_ALWAYS(videoaudiomuteIndicatorIcon); |
|
185 |
|
186 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_STABILITY_INDICATOR_ICON); |
|
187 HbLabel *videoStabilityIndicatorIcon = qobject_cast<HbLabel *>(widget); |
|
188 CX_ASSERT_ALWAYS(videoStabilityIndicatorIcon); |
150 |
189 |
151 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP); |
190 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP); |
152 mIndicators = qobject_cast<HbWidget *>(widget); |
191 mIndicators = qobject_cast<HbWidget *>(widget); |
153 CX_DEBUG_ASSERT(mIndicators); |
192 CX_ASSERT_ALWAYS(mIndicators); |
|
193 |
|
194 QGraphicsLayout *layout = mIndicators->layout(); |
|
195 QGraphicsLayoutItem *graphicsLayoutItem = NULL; |
|
196 QGraphicsItem *graphicsItem = NULL; |
|
197 QString key = ""; |
|
198 int currentSettingValue = -1; |
|
199 bool isSettingOff = false; |
|
200 // Go through the items in the layout to check whether they should be |
|
201 // shown or not in the indicator pane. Start from the last towards |
|
202 // the first, so that removing items from between works correctly. |
|
203 for (int i = layout->count() - 1; i >= 0; i--) { |
|
204 graphicsLayoutItem = layout->itemAt(i); |
|
205 isSettingOff = false; |
|
206 if (graphicsLayoutItem) { |
|
207 graphicsItem = graphicsLayoutItem->graphicsItem(); |
|
208 currentSettingValue = -1; |
|
209 if (graphicsItem == videoaudiomuteIndicatorIcon) { |
|
210 key = CxeSettingIds::VIDEO_MUTE_SETTING; |
|
211 mEngine->settings().get(key, currentSettingValue); |
|
212 // video mute implementation does not use |
|
213 // enum for on/off values but instead |
|
214 // 0 for off and 1 for on. |
|
215 if (currentSettingValue == 0) { |
|
216 isSettingOff = true; |
|
217 } |
|
218 } else if (graphicsItem == videoStabilityIndicatorIcon) { |
|
219 // remove video stability indicator. |
|
220 isSettingOff = true; |
|
221 } |
|
222 if (isSettingOff) { |
|
223 layout->removeAt(i); |
|
224 } |
|
225 } |
|
226 } |
|
227 |
154 // Create background graphics for indicator container |
228 // Create background graphics for indicator container |
155 createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC); |
229 createWidgetBackgroundGraphic(mIndicators, TRANSPARENT_BACKGROUND_GRAPHIC); |
156 |
230 |
157 CX_DEBUG_EXIT_FUNCTION(); |
231 mIndicators->setVisible(true); |
158 } |
232 |
159 |
233 CX_DEBUG_EXIT_FUNCTION(); |
|
234 } |
|
235 |
|
236 /*! |
|
237 * Loads widgets that are not part of the default section in layouts xml. |
|
238 * Widgets are created at the time they are first loaded. |
|
239 */ |
160 void CxuiVideoPrecaptureView::loadWidgets() |
240 void CxuiVideoPrecaptureView::loadWidgets() |
161 { |
241 { |
162 CX_DEBUG_ENTER_FUNCTION(); |
242 CX_DEBUG_ENTER_FUNCTION(); |
163 CX_DEBUG_ASSERT(mDocumentLoader); |
243 CX_ASSERT_ALWAYS(mDocumentLoader); |
164 |
244 |
165 if (mWidgetsLoaded) { |
245 if (mWidgetsLoaded) { |
166 CX_DEBUG(("Widgets already loaded")); |
246 CX_DEBUG(("Widgets already loaded")); |
167 CX_DEBUG_EXIT_FUNCTION(); |
247 CX_DEBUG_EXIT_FUNCTION(); |
168 return; |
248 return; |
174 // load the "secondary" widgets |
254 // load the "secondary" widgets |
175 bool ok = false; |
255 bool ok = false; |
176 |
256 |
177 // load widgets section (creates the widgets) |
257 // load widgets section (creates the widgets) |
178 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok); |
258 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_WIDGETS_SECTION, &ok); |
179 Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing"); |
259 CX_ASSERT_ALWAYS(ok); |
180 if (CxuiServiceProvider::isCameraEmbedded()) { |
260 if (CxuiServiceProvider::isCameraEmbedded()) { |
181 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok); |
261 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_EMBEDDED_SECTION, &ok); |
182 } else { |
262 } else { |
183 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok); |
263 mDocumentLoader->load(VIDEO_1ST_XML, VIDEO_PRE_CAPTURE_STANDALONE_SECTION, &ok); |
184 } |
264 } |
185 Q_ASSERT_X(ok, "camerax ui", "error in xml file parsing"); |
265 CX_ASSERT_ALWAYS(ok); |
186 // get needed pointers to some of the widgets |
266 // get needed pointers to some of the widgets |
187 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER); |
267 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ZOOM_SLIDER); |
188 mSlider = qobject_cast<CxuiZoomSlider *> (widget); |
268 mSlider = qobject_cast<CxuiZoomSlider *> (widget); |
189 CX_DEBUG_ASSERT(mSlider); |
269 CX_ASSERT_ALWAYS(mSlider); |
190 |
270 |
191 //Let's add a plus and minus buttons to the slider |
271 //Let's add a plus and minus buttons to the slider |
192 mSlider->addZoomButtons(); |
272 mSlider->addZoomButtons(); |
193 createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC); |
273 createWidgetBackgroundGraphic(mSlider, TRANSPARENT_BACKGROUND_GRAPHIC); |
194 |
274 |
238 |
318 |
239 // Create background graphic for indicator container |
319 // Create background graphic for indicator container |
240 HbWidget *indicatorContainer; |
320 HbWidget *indicatorContainer; |
241 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
321 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM); |
242 indicatorContainer = qobject_cast<HbWidget *>(widget); |
322 indicatorContainer = qobject_cast<HbWidget *>(widget); |
243 CX_DEBUG_ASSERT(indicatorContainer); |
323 CX_ASSERT_ALWAYS(indicatorContainer); |
244 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
324 createWidgetBackgroundGraphic(indicatorContainer, TRANSPARENT_BACKGROUND_GRAPHIC); |
245 |
325 |
246 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL); |
326 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_ELAPSED_TIME_LABEL); |
247 mElapsedTimeText = qobject_cast<HbLabel *> (widget); |
327 mElapsedTimeText = qobject_cast<HbLabel *> (widget); |
248 CX_DEBUG_ASSERT(mElapsedTimeText); |
328 CX_ASSERT_ALWAYS(mElapsedTimeText); |
249 |
329 |
250 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL); |
330 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_REMAINING_TIME_LABEL); |
251 mRemainingTimeText = qobject_cast<HbLabel *> (widget); |
331 mRemainingTimeText = qobject_cast<HbLabel *> (widget); |
252 CX_DEBUG_ASSERT(mRemainingTimeText); |
332 CX_ASSERT_ALWAYS(mRemainingTimeText); |
253 |
333 |
254 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
334 widget = mDocumentLoader->findWidget(VIDEO_PRE_CAPTURE_RECORDING_ICON); |
255 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
335 mRecordingIcon = qobject_cast<HbLabel *> (widget); |
256 CX_DEBUG_ASSERT(mRecordingIcon); |
336 CX_ASSERT_ALWAYS(mRecordingIcon); |
257 |
337 |
258 mWidgetsLoaded = true; |
338 mWidgetsLoaded = true; |
259 |
339 |
260 // Initializing recording indicator animation |
340 // Initializing recording indicator animation |
261 mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity"); |
341 mRecordingAnimation = new QPropertyAnimation(mRecordingIcon, "opacity"); |