--- a/camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp Thu May 13 21:30:19 2010 +0300
+++ b/camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp Thu Jul 15 01:55:05 2010 +0300
@@ -18,6 +18,7 @@
#include <QSize>
#include <QMetaType>
#include <QVariant>
+#include <hbparameterlengthlimiter.h>
#include "cxutils.h"
#include "cxuienums.h"
@@ -83,21 +84,12 @@
* CxuiSettingsInfo::CxuiSettingsInfo
*/
CxuiSettingsInfo::CxuiSettingsInfo(CxeEngine *engine)
-: mEngine(engine)
+ : mMode(-1), mEngine(engine)
{
CX_DEBUG_ENTER_FUNCTION();
CX_ASSERT_ALWAYS(engine);
mXmlReader = new CxuiSettingXmlReader();
-
- // Initialize for the mode already so that the UI
- // can already use the settings info even if engine isn't ready yet.
- initForCurrentMode(CxeError::None);
-
- // Follow engine mode changes
- connect(&engine->cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)),
- this, SLOT(initForCurrentMode(CxeError::Id)));
-
CX_DEBUG_EXIT_FUNCTION();
}
@@ -125,6 +117,9 @@
{
CX_DEBUG_ENTER_FUNCTION();
+ // Check that right content is loaded. Load now if not.
+ checkMode();
+
bool found(false);
if (key == CxeSettingIds::IMAGE_QUALITY ||
@@ -154,6 +149,9 @@
{
CX_DEBUG_ENTER_FUNCTION();
+ // Check that right content is loaded. Load now if not.
+ checkMode();
+
bool found(false);
if (mXmlReader) {
@@ -209,30 +207,31 @@
int index = 0;
// get the localized possible strings for each image quality setting
- QString vga = hbTrId("txt_cam_dblist_vga");
- QString normal = hbTrId("txt_cam_dblist_ln_mpix");
- QString imagesLeft = hbTrId("txt_cam_dblist_hd_720p_val_ln_images_left");
- QString widescreen = hbTrId("txt_cam_dblist_ln_mpix_widescreen");
+ QString vga = "txt_cam_dblist_vga";
+ QString normal = "txt_cam_dblist_ln_mpix";
+ QString imagesLeft = "txt_cam_dblist_hd_720p_val_ln_images_left";
+ QString widescreen = "txt_cam_dblist_ln_mpix_widescreen";
foreach(CxeImageDetails quality, list) {
// mapping the right value for each quality
QString settingString;
QString qualityIcon = "";
+ qreal pxCount = quality.mMpxCount.toDouble();
if (quality.mWidth == KResVGA.width() && quality.mHeight == KResVGA.height()) {
- settingString.append(vga);
+ settingString.append(hbTrId(vga.toAscii().constData()));
settingString.append(" ");
}
if (quality.mAspectRatio == Cxe::AspectRatio16to9) {
- settingString.append(widescreen.arg(quality.mMpxCount));
+ settingString.append(hbTrId(widescreen.toAscii().constData()).arg(pxCount,0,'g',3));
} else {
- settingString.append(normal.arg(quality.mMpxCount));
+ settingString.append(hbTrId(normal.toAscii().constData()).arg(pxCount,0,'g',3));
}
- settingString.append(",");
- settingString.append(imagesLeft.arg(quality.mPossibleImages));
+ settingString.append(NEW_LINE_CHAR);
+ settingString.append(HbParameterLengthLimiter(imagesLeft.toAscii().constData(), quality.mPossibleImages));
CX_DEBUG(( "Image quality setting string: %s", settingString.toAscii().constData()));
if (quality.mMpxCount == "12") {
@@ -307,7 +306,7 @@
qualityIcon = "qtg_mono_vga_wide";
}
- settingString.append(",");
+ settingString.append(NEW_LINE_CHAR);
time.sprintf("%02d:%02d", quality.mRemainingTime / 60, quality.mRemainingTime % 60);
settingString.append(timeleft.arg(time));
@@ -326,23 +325,33 @@
CX_DEBUG_EXIT_FUNCTION();
}
-/**
-* Load new setting content based on the new mode.
+/*!
+* Check that the right content for current mode is loaded.
+*
+* UI gets "settings changed" / "scene changed" events quite
+* early when switching mode (image / video). We cannot rely
+* on CxeCameraDeviceControl::initModeComplete signal since
+* that would be coming too late. (We would be using setting XML
+* for the old mode, and setting keys/values/icons would not
+* be found.) Better check this whenever UI requests for
+* content for a setting, and reload the XML when needed.
+* @see CxuiSettingsInfo::getSettingsContent(const QString &, RadioButtonListParams &)
+* @see CxuiSettingsInfo::getSettingsContent(const QString &, SliderParams &)
+* @see CxeCameraDeviceControl::initModeComplete(CxeError::Id)
*/
-void CxuiSettingsInfo::initForCurrentMode(CxeError::Id status)
+void CxuiSettingsInfo::checkMode()
{
CX_DEBUG_ENTER_FUNCTION();
- if (status == CxeError::None) {
+ int oldMode = mMode;
+ mMode = mEngine->cameraDeviceControl().mode();
+ if (mMode != oldMode) {
// Select the setting XML file based on mode.
QString sourceXml(mEngine->cameraDeviceControl().mode() == Cxe::ImageMode
? CxUiSettings::IMAGE_SETTING_MAPPING_FILE
: CxUiSettings::VIDEO_SETTING_MAPPING_FILE);
mXmlReader->setXmlSource(sourceXml);
- } else {
- // Clear XML reader content on error.
- mXmlReader->setXmlSource(QString());
}
CX_DEBUG_EXIT_FUNCTION();