bool CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue) { bool bChanged(false); map<CStdString, CSetting *>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { if ((*it).second->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) { bChanged = !StringUtils::EqualsNoCase(stringSetting->GetValue(), strValue); stringSetting->SetValue(strValue); if (bChanged && m_bInitialised) m_changedSettings.insert(strKey); } } else if ((*it).second->GetType() == SettingTypeInteger) bChanged = SetSetting(strKey, (int) (strValue.empty() ? 0 : atoi(strValue.c_str()))); else if ((*it).second->GetType() == SettingTypeNumber) bChanged = SetSetting(strKey, (float) (strValue.empty() ? 0 : atof(strValue.c_str()))); else if ((*it).second->GetType() == SettingTypeBool) bChanged = SetSetting(strKey, strValue.Equals("1")); } return bChanged; }
std::string CLangInfo::GetSubtitleCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::Get().GetSetting("subtitles.charset")); if (charsetSetting->IsDefault()) return m_strSubtitleCharSet; return charsetSetting->GetValue(); }
std::string CLangInfo::GetSubtitleCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_SUBTITLES_CHARSET)); if (charsetSetting->IsDefault()) return m_strSubtitleCharSet; return charsetSetting->GetValue(); }
std::string CLangInfo::GetGuiCharSet() const { CSettingString* charsetSetting = static_cast<CSettingString*>(CSettings::GetInstance().GetSetting(CSettings::SETTING_LOCALE_CHARSET)); if (charsetSetting == NULL || charsetSetting->IsDefault()) return m_strGuiCharSet; return charsetSetting->GetValue(); }
void CPeripheral::PersistSettings(bool bExiting /* = false */) { CXBMCTinyXML doc; TiXmlElement node("settings"); doc.InsertEndChild(node); for (map<CStdString, CSetting *>::const_iterator itr = m_settings.begin(); itr != m_settings.end(); itr++) { TiXmlElement nodeSetting("setting"); nodeSetting.SetAttribute("id", itr->first.c_str()); CStdString strValue; switch ((*itr).second->GetType()) { case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) (*itr).second; if (stringSetting) strValue = stringSetting->GetValue(); } break; case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) (*itr).second; if (intSetting) strValue = StringUtils::Format("%d", intSetting->GetValue()); } break; case SettingTypeNumber: { CSettingNumber *floatSetting = (CSettingNumber *) (*itr).second; if (floatSetting) strValue = StringUtils::Format("%.2f", floatSetting->GetValue()); } break; case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) (*itr).second; if (boolSetting) strValue = StringUtils::Format("%d", boolSetting->GetValue() ? 1:0); } break; default: break; } nodeSetting.SetAttribute("value", strValue.c_str()); doc.RootElement()->InsertEndChild(nodeSetting); } doc.SaveFile(m_strSettingsFile); if (!bExiting) { for (set<CStdString>::const_iterator it = m_changedSettings.begin(); it != m_changedSettings.end(); it++) OnSettingChanged(*it); } m_changedSettings.clear(); }
void CGUIWindowSettingsCategory::FillControl(CSetting *pSetting, CGUIControl *pSettingControl) { void *filler = CSettings::Get().GetSettingOptionsFiller(pSetting); if (filler == NULL) return; if (pSetting->GetType() == SettingTypeInteger) { CSettingInt *pSettingInt = (CSettingInt*)pSetting; // get the list of options and the current option IntegerSettingOptions options; int currentOption = pSettingInt->GetValue(); ((IntegerSettingOptionsFiller)filler)(pSetting, options, currentOption); // clear the spinner control CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; pSpinControl->Clear(); // fill the spinner control for (IntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) pSpinControl->AddLabel(option->first, option->second); // set the current option pSpinControl->SetValue(currentOption); // check if the current setting has changed if (currentOption != pSettingInt->GetValue()) pSettingInt->SetValue(currentOption); } else if (pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString*)pSetting; // get the list of options and the current option StringSettingOptions options; std::string currentOption = pSettingString->GetValue(); ((StringSettingOptionsFiller)filler)(pSetting, options, currentOption); // clear the spinner control CGUISpinControlEx *pSpinControl = (CGUISpinControlEx *)pSettingControl; pSpinControl->Clear(); // fill the spinner control for (StringSettingOptions::const_iterator option = options.begin(); option != options.end(); option++) pSpinControl->AddLabel(option->first, option->second); // set the current option pSpinControl->SetStringValue(currentOption); // check if the current setting has changed if (currentOption.compare(pSettingString->GetValue()) != 0) pSettingString->SetValue(currentOption); } }
const CStdString CPeripheral::GetSettingString(const CStdString &strKey) const { map<CStdString, CSetting *>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) return stringSetting->GetValue(); } return StringUtils::EmptyString; }
const std::string CPeripheral::GetSettingString(const std::string &strKey) const { std::map<std::string, PeripheralDeviceSetting>::const_iterator it = m_settings.find(strKey); if (it != m_settings.end() && (*it).second.m_setting->GetType() == SettingTypeString) { CSettingString *stringSetting = (CSettingString *) (*it).second.m_setting; if (stringSetting) return stringSetting->GetValue(); } return ""; }
void CSettings::InitializeVisibility() { // hide some settings if necessary #if defined(TARGET_DARWIN) CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry"); CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone"); if (!g_sysinfo.IsAppleTV2() || GetIOSVersion() >= 4.3) { timezonecountry->SetRequirementsMet(false); timezone->SetRequirementsMet(false); } #endif }
CGUIControlEditSetting::CGUIControlEditSetting(CGUIEditControl *pEdit, int id, CSetting *pSetting) : CGUIControlBaseSetting(id, pSetting) { m_pEdit = pEdit; m_pEdit->SetID(id); int heading = m_pSetting->GetLabel(); if (m_pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)m_pSetting; if (pSettingString->GetHeading() > 0) heading = pSettingString->GetHeading(); } if (heading < 0) heading = 0; CGUIEditControl::INPUT_TYPE inputType = CGUIEditControl::INPUT_TYPE_TEXT; const CSettingControl& control = pSetting->GetControl(); switch (control.GetFormat()) { case SettingControlFormatString: if (control.GetAttributes() & SettingControlAttributeHidden) inputType = CGUIEditControl::INPUT_TYPE_PASSWORD; break; case SettingControlFormatInteger: if (control.GetAttributes() & SettingControlAttributeVerifyNew) inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW; else inputType = CGUIEditControl::INPUT_TYPE_NUMBER; break; case SettingControlFormatIP: inputType = CGUIEditControl::INPUT_TYPE_IPADDRESS; break; case SettingControlFormatMD5: inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_MD5; break; default: break; } m_pEdit->SetInputType(inputType, heading); Update(); // this will automatically trigger validation so it must be executed after // having set the value of the control based on the value of the setting m_pEdit->SetInputValidation(InputValidation, this); }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_VIDEOSCREEN_SCREENMODE) { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive // no 3d mode existed before, so just assume std modes if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "pstd"); if (screenmode.size() == 21) return screenmodeSetting->SetValue(screenmode + "std"); } else if (settingId == CSettings::SETTING_VIDEOSCREEN_VSYNC) { // This ifdef is intended to catch everything except Linux and FreeBSD #if !defined(TARGET_LINUX) || defined(TARGET_DARWIN) || defined(TARGET_ANDROID) || defined(TARGET_RASPBERRY_PI) // in the Gotham alphas through beta3 the default value for darwin and android was set incorrectly. CSettingInt *vsyncSetting = (CSettingInt*)setting; if (vsyncSetting->GetValue() == VSYNC_DRIVER) return vsyncSetting->SetValue(VSYNC_ALWAYS); #endif } else if (settingId == CSettings::SETTING_VIDEOSCREEN_PREFEREDSTEREOSCOPICMODE) { CSettingInt *stereomodeSetting = (CSettingInt*)setting; STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::Get().GetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE); if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_OFF) { // if preferred playback mode was OFF, update playback mode to ignore if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::Get().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_IGNORE); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } else if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_MONO) { // if preferred playback mode was MONO, update playback mode if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::Get().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_MONO); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } } return false; }
void CPeripheral::PersistSettings(void) const { TiXmlDocument doc; TiXmlElement node("settings"); doc.InsertEndChild(node); for (map<CStdString, CSetting *>::const_iterator itr = m_settings.begin(); itr != m_settings.end(); itr++) { TiXmlElement nodeSetting("setting"); nodeSetting.SetAttribute("id", itr->first.c_str()); CStdString strValue; switch ((*itr).second->GetType()) { case SETTINGS_TYPE_STRING: { CSettingString *stringSetting = (CSettingString *) (*itr).second; if (stringSetting) strValue = stringSetting->GetData(); } break; case SETTINGS_TYPE_INT: { CSettingInt *intSetting = (CSettingInt *) (*itr).second; if (intSetting) strValue.Format("%d", intSetting->GetData()); } break; case SETTINGS_TYPE_FLOAT: { CSettingFloat *floatSetting = (CSettingFloat *) (*itr).second; if (floatSetting) strValue.Format("%.2f", floatSetting->GetData()); } break; case SETTINGS_TYPE_BOOL: { CSettingBool *boolSetting = (CSettingBool *) (*itr).second; if (boolSetting) strValue.Format("%d", boolSetting->GetData() ? 1:0); } break; default: break; } nodeSetting.SetAttribute("value", strValue.c_str()); doc.RootElement()->InsertEndChild(nodeSetting); } doc.SaveFile(m_strSettingsFile); }
void CGUIControlSpinExSetting::FillControl() { m_pSpin->Clear(); switch (m_pSetting->GetControl().GetFormat()) { case SettingControlFormatNumber: { CSettingNumber *pSettingNumber = (CSettingNumber *)m_pSetting; m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT); m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum()); m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep()); m_pSpin->SetFloatValue((float)pSettingNumber->GetValue()); break; } case SettingControlFormatInteger: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); FillIntegerSettingControl(); break; } case SettingControlFormatString: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); if (m_pSetting->GetType() == SettingTypeInteger) FillIntegerSettingControl(); else if (m_pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)m_pSetting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (std::vector< std::pair<std::string, std::string> >::const_iterator option = options.begin(); option != options.end(); ++option) m_pSpin->AddLabel(option->first, option->second); m_pSpin->SetStringValue(pSettingString->GetValue()); } } break; } default: break; } }
CSettingString* CGUIDialogSettingsManualBase::AddInfoLabelButton(CSettingGroup *group, const std::string &id, int label, int level, std::string info, bool visible /* = true */, int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) return NULL; CSettingString *setting = new CSettingString(id, label, info, m_settingsManager); if (setting == NULL) return NULL; setting->SetControl(GetButtonControl("infolabel", false)); setSettingDetails(setting, level, visible, help); group->AddSetting(setting); return setting; }
CGUIControlEditSetting::CGUIControlEditSetting(CGUIEditControl *pEdit, int id, CSetting *pSetting) : CGUIControlBaseSetting(id, pSetting) { m_pEdit = pEdit; m_pEdit->SetID(id); int heading = m_pSetting->GetLabel(); if (m_pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)m_pSetting; if (pSettingString->GetHeading() > 0) heading = pSettingString->GetHeading(); } if (heading < 0) heading = 0; CGUIEditControl::INPUT_TYPE inputType = CGUIEditControl::INPUT_TYPE_TEXT; const CSettingControl& control = pSetting->GetControl(); switch (control.GetFormat()) { case SettingControlFormatString: if (control.GetAttributes() & SettingControlAttributeHidden) inputType = CGUIEditControl::INPUT_TYPE_PASSWORD; break; case SettingControlFormatInteger: if (control.GetAttributes() & SettingControlAttributeVerifyNew) inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW; else inputType = CGUIEditControl::INPUT_TYPE_NUMBER; break; case SettingControlFormatIP: inputType = CGUIEditControl::INPUT_TYPE_IPADDRESS; break; case SettingControlFormatMD5: inputType = CGUIEditControl::INPUT_TYPE_PASSWORD_MD5; break; default: break; } m_pEdit->SetInputType(inputType, heading); Update(); }
void CSettingsManager::UpdateSettingByDependency(const std::string &settingId, const CSettingDependency &dependency) { CSetting *setting = GetSetting(settingId); if (setting == NULL) return; switch (dependency.GetType()) { case SettingDependencyTypeEnable: // just trigger the property changed callback and a call to // CSetting::IsEnabled() will automatically determine the new // enabled state OnSettingPropertyChanged(setting, "enabled"); break; case SettingDependencyTypeUpdate: { SettingType type = (SettingType)setting->GetType(); if (type == SettingTypeInteger) { CSettingInt *settingInt = ((CSettingInt*)setting); if (settingInt->GetOptionsType() == SettingOptionsTypeDynamic) settingInt->UpdateDynamicOptions(); } else if (type == SettingTypeString) { CSettingString *settingString = ((CSettingString*)setting); if (settingString->GetOptionsType() == SettingOptionsTypeDynamic) settingString->UpdateDynamicOptions(); } break; } case SettingDependencyTypeVisible: // just trigger the property changed callback and a call to // CSetting::IsVisible() will automatically determine the new // visible state OnSettingPropertyChanged(setting, "visible"); break; case SettingDependencyTypeNone: default: break; } }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == "videoscreen.screenmode") { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "p"); } return false; }
CSettingString* CGUIDialogSettingsManualBase::AddList(CSettingGroup *group, const std::string &id, int label, int level, std::string value, StringSettingOptionsFiller filler, int heading, bool visible /* = true */, int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) return NULL; CSettingString *setting = new CSettingString(id, label, value, m_settingsManager); if (setting == NULL) return NULL; setting->SetControl(GetListControl("string", false, heading, false)); setting->SetOptionsFiller(filler, this); setSettingDetails(setting, level, visible, help); group->AddSetting(setting); return setting; }
CSettingString* CGUIDialogSettingsManualBase::AddPasswordMd5(CSettingGroup *group, const std::string &id, int label, int level, std::string value, bool allowEmpty /* = false */, int heading /* = -1 */, bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) return NULL; CSettingString *setting = new CSettingString(id, label, value, m_settingsManager); if (setting == NULL) return NULL; setting->SetControl(GetEditControl("md5", delayed, false, false, heading)); setting->SetAllowEmpty(allowEmpty); setSettingDetails(setting, level, visible, help); group->AddSetting(setting); return setting; }
CSettingList* CGUIDialogSettingsManualBase::AddList(CSettingGroup *group, const std::string &id, int label, int level, std::vector<std::string> values, StringSettingOptionsFiller filler, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */, bool visible /* = true */, int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || filler == NULL || GetSetting(id) != NULL) return NULL; CSettingString *settingDefinition = new CSettingString(id, m_settingsManager); if (settingDefinition == NULL) return NULL; settingDefinition->SetOptionsFiller(filler, this); CSettingList *setting = new CSettingList(id, settingDefinition, label, m_settingsManager); if (setting == NULL) { delete settingDefinition; return NULL; } std::vector<CVariant> valueList; for (std::vector<std::string>::const_iterator itValue = values.begin(); itValue != values.end(); ++itValue) valueList.push_back(CVariant(*itValue)); SettingPtrList settingValues; if (!CSettingUtils::ValuesToList(setting, valueList, settingValues)) { delete settingDefinition; delete setting; return NULL; } // setting the default will also set the actual value on an unchanged setting setting->SetDefault(settingValues); setting->SetControl(GetListControl("string", false, heading, true)); setting->SetMinimumItems(minimumItems); setting->SetMaximumItems(maximumItems); setSettingDetails(setting, level, visible, help); group->AddSetting(setting); return setting; }
bool CDisplaySettings::OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { if (setting == NULL) return false; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_VIDEOSCREEN_SCREENMODE) { CSettingString *screenmodeSetting = (CSettingString*)setting; std::string screenmode = screenmodeSetting->GetValue(); // in Eden there was no character ("i" or "p") indicating interlaced/progressive // at the end so we just add a "p" and assume progressive // no 3d mode existed before, so just assume std modes if (screenmode.size() == 20) return screenmodeSetting->SetValue(screenmode + "pstd"); if (screenmode.size() == 21) return screenmodeSetting->SetValue(screenmode + "std"); } else if (settingId == CSettings::SETTING_VIDEOSCREEN_PREFEREDSTEREOSCOPICMODE) { CSettingInt *stereomodeSetting = (CSettingInt*)setting; STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE); if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_OFF) { // if preferred playback mode was OFF, update playback mode to ignore if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::GetInstance().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_IGNORE); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } else if (stereomodeSetting->GetValue() == RENDER_STEREO_MODE_MONO) { // if preferred playback mode was MONO, update playback mode if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_PREFERRED) CSettings::GetInstance().SetInt(CSettings::SETTING_VIDEOPLAYER_STEREOSCOPICPLAYBACKMODE, STEREOSCOPIC_PLAYBACK_MODE_MONO); return stereomodeSetting->SetValue(RENDER_STEREO_MODE_AUTO); } } return false; }
const CStdString &CGUISettings::GetString(const char *strSetting, bool bPrompt) const { ASSERT(settingsMap.size()); constMapIter it = settingsMap.find(CStdString(strSetting).ToLower()); if (it != settingsMap.end()) { CSettingString* result = ((CSettingString *)(*it).second); if (result->GetData() == "select folder" || result->GetData() == "select writable folder") { CStdString strData = ""; if (bPrompt) { VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares,g_localizeStrings.Get(result->GetLabel()),strData,result->GetData() == "select writable folder")) { result->SetData(strData); g_settings.Save(); } else return StringUtils::EmptyString; } else return StringUtils::EmptyString; } return result->GetData(); } // Assert here and write debug output CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); //ASSERT(false); // hardcoded return value so that compiler is happy return StringUtils::EmptyString; }
bool CGUIControlListSetting::GetItems(CSetting *setting, CFileItemList &items) { switch (setting->GetControl().GetFormat()) { case SettingControlFormatInteger: return GetIntegerItems(setting, items); case SettingControlFormatString: { if (setting->GetType() == SettingTypeInteger) return GetIntegerItems(setting, items); else if (setting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)setting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (DynamicStringSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option) { CFileItemPtr pItem = GetItem(option->first, option->second); if (StringUtils::EqualsNoCase(option->second, pSettingString->GetValue())) pItem->Select(true); items.Add(pItem); } } } break; } default: return false; } return true; }
void CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue) { map<CStdString, CSetting *>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { if ((*it).second->GetType() == SETTINGS_TYPE_STRING) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) { bool bChanged(!stringSetting->GetData().Equals(strValue)); stringSetting->SetData(strValue); if (bChanged && m_bInitialised) OnSettingChanged(strKey); } } else if ((*it).second->GetType() == SETTINGS_TYPE_INT) SetSetting(strKey, (int) (strValue.IsEmpty() ? 0 : atoi(strValue.c_str()))); else if ((*it).second->GetType() == SETTINGS_TYPE_FLOAT) SetSetting(strKey, (float) (strValue.IsEmpty() ? 0 : atof(strValue.c_str()))); else if ((*it).second->GetType() == SETTINGS_TYPE_BOOL) SetSetting(strKey, strValue.Equals("1")); } }
void CSettings::InitializeDefaults() { // set some default values if necessary #if defined(HAS_SKIN_TOUCHED) && defined(TARGET_DARWIN_IOS) && !defined(TARGET_DARWIN_IOS_ATV2) ((CSettingAddon*)m_settingsManager->GetSetting("lookandfeel.skin"))->SetDefault("skin.touched"); #endif #if defined(TARGET_POSIX) CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry"); CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone"); if (timezonecountry->IsVisible()) timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone())); if (timezone->IsVisible()) timezone->SetDefault(g_timezone.GetOSConfiguredTimezone()); #endif // defined(TARGET_POSIX) #if defined(TARGET_WINDOWS) #if defined(HAS_DX) ((CSettingString*)m_settingsManager->GetSetting("musicplayer.visualisation"))->SetDefault("visualization.milkdrop"); #endif #if !defined(HAS_GL) // We prefer a fake fullscreen mode (window covering the screen rather than dedicated fullscreen) // as it works nicer with switching to other applications. However on some systems vsync is broken // when we do this (eg non-Aero on ATI in particular) and on others (AppleTV) we can't get XBMC to // the front if (g_sysinfo.IsAeroDisabled()) ((CSettingBool*)m_settingsManager->GetSetting("videoscreen.fakefullscreen"))->SetDefault(false); #endif #endif #if defined(TARGET_DARWIN) #if !defined(TARGET_DARWIN_IOS) CStdString defaultAudioDeviceName; CCoreAudioHardware::GetOutputDeviceName(defaultAudioDeviceName); ((CSettingString*)m_settingsManager->GetSetting("audiooutput.audiodevice"))->SetDefault(defaultAudioDeviceName); ((CSettingString*)m_settingsManager->GetSetting("audiooutput.passthroughdevice"))->SetDefault(defaultAudioDeviceName); #endif #else ((CSettingString*)m_settingsManager->GetSetting("audiooutput.audiodevice"))->SetDefault(CAEFactory::GetDefaultDevice(false)); ((CSettingString*)m_settingsManager->GetSetting("audiooutput.passthroughdevice"))->SetDefault(CAEFactory::GetDefaultDevice(true)); #endif if (g_application.IsStandAlone()) ((CSettingInt*)m_settingsManager->GetSetting("powermanagement.shutdownstate"))->SetDefault(POWERSTATE_SHUTDOWN); #if defined(HAS_WEB_SERVER) if (CUtil::CanBindPrivileged()) ((CSettingInt*)m_settingsManager->GetSetting("services.webserverport"))->SetDefault(80); #endif }
void CSettings::InitializeVisibility() { // hide some settings if necessary #if defined(TARGET_LINUX) || defined(TARGET_DARWIN) CSettingString* timezonecountry = (CSettingString*)m_settingsManager->GetSetting("locale.timezonecountry"); CSettingString* timezone = (CSettingString*)m_settingsManager->GetSetting("locale.timezone"); #if defined(TARGET_DARWIN) if (!g_sysinfo.IsAppleTV2() || GetIOSVersion() >= 4.3) { timezonecountry->SetVisible(false); timezone->SetVisible(false); } #endif #if defined(TARGET_LINUX) if (timezonecountry->IsVisible()) timezonecountry->SetDefault(g_timezone.GetCountryByTimezone(g_timezone.GetOSConfiguredTimezone())); if (timezone->IsVisible()) timezone->SetDefault(g_timezone.GetOSConfiguredTimezone()); #endif #endif }
void CGUIDialogPeripheralSettings::CreateSettings() { m_bIsInitialising = true; m_usePopupSliders = g_SkinInfo->HasSkinFile("DialogSlider.xml"); if (m_item) { CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath()); if (peripheral) { vector<CSetting *> settings = peripheral->GetSettings(); for (size_t iPtr = 0; iPtr < settings.size(); iPtr++) { CSetting *setting = settings[iPtr]; if (!setting->IsVisible()) { CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__); continue; } switch(setting->GetType()) { case SettingTypeBool: { CSettingBool *boolSetting = (CSettingBool *) setting; if (boolSetting) { m_boolSettings.insert(make_pair(CStdString(boolSetting->GetId()), boolSetting->GetValue())); AddBool(m_settingId++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetId()], true); } } break; case SettingTypeInteger: { CSettingInt *intSetting = (CSettingInt *) setting; if (intSetting) { if (intSetting->GetControl()->GetFormat() == "integer") { m_intSettings.insert(make_pair(CStdString(intSetting->GetId()), (float) intSetting->GetValue())); AddSlider(m_settingId++, intSetting->GetLabel(), &m_intSettings[intSetting->GetId()], (float)intSetting->GetMinimum(), (float)intSetting->GetStep(), (float)intSetting->GetMaximum(), CGUIDialogVideoSettings::FormatInteger, false); } else if (intSetting->GetControl()->GetFormat() == "string") { m_intTextSettings.insert(make_pair(CStdString(intSetting->GetId()), intSetting->GetValue())); vector<pair<int, int> > entries; StaticIntegerSettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin(); while (entriesItr != intSetting->GetOptions().end()) { entries.push_back(make_pair(entriesItr->first, entriesItr->second)); ++entriesItr; } AddSpin(m_settingId++, intSetting->GetLabel(), &m_intTextSettings[intSetting->GetId()], entries); } } } break; case SettingTypeNumber: { CSettingNumber *floatSetting = (CSettingNumber *) setting; if (floatSetting) { m_floatSettings.insert(make_pair(CStdString(floatSetting->GetId()), (float)floatSetting->GetValue())); AddSlider(m_settingId++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetId()], (float)floatSetting->GetMinimum(), (float)floatSetting->GetStep(), (float)floatSetting->GetMaximum(), CGUIDialogVideoSettings::FormatFloat, false); } } break; case SettingTypeString: { CSettingString *stringSetting = (CSettingString *) setting; if (stringSetting) { m_stringSettings.insert(make_pair(CStdString(stringSetting->GetId()), stringSetting->GetValue())); AddString(m_settingId++, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetId()]); } } break; default: //TODO add more types if needed CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__); break; } } } else { CLog::Log(LOGDEBUG, "%s - no peripheral", __FUNCTION__); } } m_bIsInitialising = false; }
void CPeripheral::AddSetting(const std::string &strKey, const CSetting *setting, int order) { if (!setting) { CLog::Log(LOGERROR, "%s - invalid setting", __FUNCTION__); return; } if (!HasSetting(strKey)) { PeripheralDeviceSetting deviceSetting = { NULL, order }; switch(setting->GetType()) { case SettingTypeBool: { const CSettingBool *mappedSetting = (const CSettingBool *) setting; CSettingBool *boolSetting = new CSettingBool(strKey, *mappedSetting); if (boolSetting) { boolSetting->SetVisible(mappedSetting->IsVisible()); deviceSetting.m_setting = boolSetting; } } break; case SettingTypeInteger: { const CSettingInt *mappedSetting = (const CSettingInt *) setting; CSettingInt *intSetting = new CSettingInt(strKey, *mappedSetting); if (intSetting) { intSetting->SetVisible(mappedSetting->IsVisible()); deviceSetting.m_setting = intSetting; } } break; case SettingTypeNumber: { const CSettingNumber *mappedSetting = (const CSettingNumber *) setting; CSettingNumber *floatSetting = new CSettingNumber(strKey, *mappedSetting); if (floatSetting) { floatSetting->SetVisible(mappedSetting->IsVisible()); deviceSetting.m_setting = floatSetting; } } break; case SettingTypeString: { const CSettingString *mappedSetting = (const CSettingString *) setting; CSettingString *stringSetting = new CSettingString(strKey, *mappedSetting); if (stringSetting) { stringSetting->SetVisible(mappedSetting->IsVisible()); deviceSetting.m_setting = stringSetting; } } break; default: //! @todo add more types if needed break; } if (deviceSetting.m_setting != NULL) m_settings.insert(make_pair(strKey, deviceSetting)); } }
void CPeripheral::AddSetting(const CStdString &strKey, const CSetting *setting) { if (!setting) { CLog::Log(LOGERROR, "%s - invalid setting", __FUNCTION__); return; } if (!HasSetting(strKey)) { switch(setting->GetType()) { case SettingTypeBool: { const CSettingBool *mappedSetting = (const CSettingBool *) setting; CSettingBool *boolSetting = new CSettingBool(strKey, *mappedSetting); if (boolSetting) { boolSetting->SetVisible(mappedSetting->IsVisible()); m_settings.insert(make_pair(strKey, boolSetting)); } } break; case SettingTypeInteger: { const CSettingInt *mappedSetting = (const CSettingInt *) setting; CSettingInt *intSetting = new CSettingInt(strKey, *mappedSetting); if (intSetting) { intSetting->SetVisible(mappedSetting->IsVisible()); m_settings.insert(make_pair(strKey, intSetting)); } } break; case SettingTypeNumber: { const CSettingNumber *mappedSetting = (const CSettingNumber *) setting; CSettingNumber *floatSetting = new CSettingNumber(strKey, *mappedSetting); if (floatSetting) { floatSetting->SetVisible(mappedSetting->IsVisible()); m_settings.insert(make_pair(strKey, floatSetting)); } } break; case SettingTypeString: { const CSettingString *mappedSetting = (const CSettingString *) setting; CSettingString *stringSetting = new CSettingString(strKey, *mappedSetting); if (stringSetting) { stringSetting->SetVisible(mappedSetting->IsVisible()); m_settings.insert(make_pair(strKey, stringSetting)); } } break; default: //TODO add more types if needed break; } } }
void CGUIDialogPeripheralSettings::InitializeSettings() { if (m_item == NULL) { m_initialising = false; return; } m_initialising = true; bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml"); CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath()); if (peripheral == NULL) { CLog::Log(LOGDEBUG, "%s - no peripheral", __FUNCTION__); m_initialising = false; return; } m_settingsMap.clear(); CGUIDialogSettingsManualBase::InitializeSettings(); CSettingCategory *category = AddCategory("peripheralsettings", -1); if (category == NULL) { CLog::Log(LOGERROR, "CGUIDialogPeripheralSettings: unable to setup settings"); return; } CSettingGroup *group = AddGroup(category); if (group == NULL) { CLog::Log(LOGERROR, "CGUIDialogPeripheralSettings: unable to setup settings"); return; } std::vector<CSetting*> settings = peripheral->GetSettings(); for (std::vector<CSetting*>::iterator itSetting = settings.begin(); itSetting != settings.end(); ++itSetting) { CSetting *setting = *itSetting; if (setting == NULL) continue; if (!setting->IsVisible()) { CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__); continue; } // we need to create a copy of the setting because the CSetting instances // are destroyed when leaving the dialog CSetting *settingCopy = NULL; switch(setting->GetType()) { case SettingTypeBool: { CSettingBool *settingBool = new CSettingBool(setting->GetId(), *static_cast<CSettingBool*>(setting)); settingBool->SetControl(GetCheckmarkControl()); settingCopy = static_cast<CSetting*>(settingBool); break; } case SettingTypeInteger: { CSettingInt *intSetting = static_cast<CSettingInt*>(setting); if (intSetting == NULL) break; CSettingInt *settingInt = new CSettingInt(setting->GetId(), *intSetting); if (settingInt->GetOptions().empty()) settingInt->SetControl(GetSliderControl("integer", false, -1, usePopup, -1, "%i")); else settingInt->SetControl(GetSpinnerControl("string")); settingCopy = static_cast<CSetting*>(settingInt); break; } case SettingTypeNumber: { CSettingNumber *settingNumber = new CSettingNumber(setting->GetId(), *static_cast<CSettingNumber*>(setting)); settingNumber->SetControl(GetSliderControl("number", false, -1, usePopup, -1, "%2.2f")); settingCopy = static_cast<CSetting*>(settingNumber); break; } case SettingTypeString: { CSettingString *settingString = new CSettingString(setting->GetId(), *static_cast<CSettingString*>(setting)); settingString->SetControl(GetEditControl("string")); settingCopy = static_cast<CSetting*>(settingString); break; } default: // TODO: add more types if needed CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__); break; } if (settingCopy != NULL && settingCopy->GetControl() != NULL) { settingCopy->SetLevel(SettingLevelBasic); group->AddSetting(settingCopy); m_settingsMap.insert(std::make_pair(setting->GetId(), setting)); } } m_initialising = false; }