camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp
changeset 29 699651f2666f
parent 21 fa6d9f75d6a6
child 32 5c1e3c6aa4ef
equal deleted inserted replaced
24:2094593137f5 29:699651f2666f
    81 
    81 
    82 /*!
    82 /*!
    83 * CxuiSettingsInfo::CxuiSettingsInfo
    83 * CxuiSettingsInfo::CxuiSettingsInfo
    84 */
    84 */
    85 CxuiSettingsInfo::CxuiSettingsInfo(CxeEngine *engine)
    85 CxuiSettingsInfo::CxuiSettingsInfo(CxeEngine *engine)
    86 : mEngine(engine)
    86     : mMode(-1), mEngine(engine)
    87 {
    87 {
    88     CX_DEBUG_ENTER_FUNCTION();
    88     CX_DEBUG_ENTER_FUNCTION();
    89     CX_ASSERT_ALWAYS(engine);
    89     CX_ASSERT_ALWAYS(engine);
    90 
    90 
    91     mXmlReader = new CxuiSettingXmlReader();
    91     mXmlReader = new CxuiSettingXmlReader();
    92 
       
    93     // Initialize for the mode already so that the UI
       
    94     // can already use the settings info even if engine isn't ready yet.
       
    95     initForCurrentMode(CxeError::None);
       
    96 
       
    97     // Follow engine mode changes
       
    98     connect(&engine->cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)),
       
    99             this, SLOT(initForCurrentMode(CxeError::Id)));
       
   100 
       
   101     CX_DEBUG_EXIT_FUNCTION();
    92     CX_DEBUG_EXIT_FUNCTION();
   102 }
    93 }
   103 
    94 
   104 /*!
    95 /*!
   105 * CxuiSettingsInfo::~CxuiSettingsInfo
    96 * CxuiSettingsInfo::~CxuiSettingsInfo
   122 */
   113 */
   123 bool CxuiSettingsInfo::getSettingsContent(const QString &key,
   114 bool CxuiSettingsInfo::getSettingsContent(const QString &key,
   124                                           RadioButtonListParams &settings)
   115                                           RadioButtonListParams &settings)
   125 {
   116 {
   126     CX_DEBUG_ENTER_FUNCTION();
   117     CX_DEBUG_ENTER_FUNCTION();
       
   118 
       
   119     // Check that right content is loaded. Load now if not.
       
   120     checkMode();
   127 
   121 
   128     bool found(false);
   122     bool found(false);
   129 
   123 
   130     if (key == CxeSettingIds::IMAGE_QUALITY ||
   124     if (key == CxeSettingIds::IMAGE_QUALITY ||
   131         key == CxeSettingIds::VIDEO_QUALITY) {
   125         key == CxeSettingIds::VIDEO_QUALITY) {
   151 */
   145 */
   152 bool CxuiSettingsInfo::getSettingsContent(const QString &key,
   146 bool CxuiSettingsInfo::getSettingsContent(const QString &key,
   153                                           SliderParams &settings)
   147                                           SliderParams &settings)
   154 {
   148 {
   155     CX_DEBUG_ENTER_FUNCTION();
   149     CX_DEBUG_ENTER_FUNCTION();
       
   150 
       
   151     // Check that right content is loaded. Load now if not.
       
   152     checkMode();
   156 
   153 
   157     bool found(false);
   154     bool found(false);
   158 
   155 
   159     if (mXmlReader) {
   156     if (mXmlReader) {
   160         settings = mXmlReader->getSliderSettingInfo(key, found);
   157         settings = mXmlReader->getSliderSettingInfo(key, found);
   324     }
   321     }
   325 
   322 
   326     CX_DEBUG_EXIT_FUNCTION();
   323     CX_DEBUG_EXIT_FUNCTION();
   327 }
   324 }
   328 
   325 
   329 /**
   326 /*!
   330 * Load new setting content based on the new mode.
   327 * Check that the right content for current mode is loaded.
   331 */
   328 *
   332 void CxuiSettingsInfo::initForCurrentMode(CxeError::Id status)
   329 * UI gets "settings changed" / "scene changed" events quite
   333 {
   330 * early when switching mode (image / video). We cannot rely
   334     CX_DEBUG_ENTER_FUNCTION();
   331 * on CxeCameraDeviceControl::initModeComplete signal since
   335 
   332 * that would be coming too late. (We would be using setting XML
   336     if (status == CxeError::None) {
   333 * for the old mode, and setting keys/values/icons would not
       
   334 * be found.) Better check this whenever UI requests for
       
   335 * content for a setting, and reload the XML when needed.
       
   336 * @see CxuiSettingsInfo::getSettingsContent(const QString &, RadioButtonListParams &)
       
   337 * @see CxuiSettingsInfo::getSettingsContent(const QString &, SliderParams &)
       
   338 * @see CxeCameraDeviceControl::initModeComplete(CxeError::Id)
       
   339 */
       
   340 void CxuiSettingsInfo::checkMode()
       
   341 {
       
   342     CX_DEBUG_ENTER_FUNCTION();
       
   343 
       
   344     int oldMode = mMode;
       
   345     mMode = mEngine->cameraDeviceControl().mode();
       
   346     if (mMode != oldMode) {
   337         // Select the setting XML file based on mode.
   347         // Select the setting XML file based on mode.
   338         QString sourceXml(mEngine->cameraDeviceControl().mode() == Cxe::ImageMode
   348         QString sourceXml(mEngine->cameraDeviceControl().mode() == Cxe::ImageMode
   339                          ? CxUiSettings::IMAGE_SETTING_MAPPING_FILE
   349                          ? CxUiSettings::IMAGE_SETTING_MAPPING_FILE
   340                          : CxUiSettings::VIDEO_SETTING_MAPPING_FILE);
   350                          : CxUiSettings::VIDEO_SETTING_MAPPING_FILE);
   341 
   351 
   342         mXmlReader->setXmlSource(sourceXml);
   352         mXmlReader->setXmlSource(sourceXml);
   343     } else {
       
   344         // Clear XML reader content on error.
       
   345         mXmlReader->setXmlSource(QString());
       
   346     }
   353     }
   347 
   354 
   348     CX_DEBUG_EXIT_FUNCTION();
   355     CX_DEBUG_EXIT_FUNCTION();
   349 }
   356 }
   350 
   357