bool CGUIControlButtonSetting::OnClick() { if (m_pButton == NULL) return false; const std::string &controlFormat = m_pSetting->GetControl()->GetFormat(); if (controlFormat == "addon") { // prompt for the addon CSettingAddon *setting = (CSettingAddon *)m_pSetting; CStdString addonID = setting->GetValue(); if (!CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty()) == 1) return false; return setting->SetValue(addonID); } if (controlFormat == "path") return GetPath((CSettingPath *)m_pSetting); if (controlFormat == "action") { // simply call the OnSettingAction callback and whoever knows what to // do can do so (based on the setting's identification CSettingAction *pSettingAction = (CSettingAction *)m_pSetting; pSettingAction->OnSettingAction(pSettingAction); return true; } return false; }
void CGUIDialogNetworkSetup::InitializeSettings() { CGUIDialogSettingsManualBase::InitializeSettings(); CSettingCategory *category = AddCategory("networksetupsettings", -1); if (category == NULL) { CLog::Log(LOGERROR, "CGUIDialogNetworkSetup: unable to setup settings"); return; } CSettingGroup *group = AddGroup(category); if (group == NULL) { CLog::Log(LOGERROR, "CGUIDialogNetworkSetup: unable to setup settings"); return; } // Add our protocols StaticIntegerSettingOptions labels; #ifdef HAS_FILESYSTEM_SMB labels.push_back(std::make_pair(20171, NET_PROTOCOL_SMB)); #endif labels.push_back(std::make_pair(20301, NET_PROTOCOL_HTTPS)); labels.push_back(std::make_pair(20300, NET_PROTOCOL_HTTP)); labels.push_back(std::make_pair(20254, NET_PROTOCOL_DAVS)); labels.push_back(std::make_pair(20253, NET_PROTOCOL_DAV)); labels.push_back(std::make_pair(20173, NET_PROTOCOL_FTP)); labels.push_back(std::make_pair(20175, NET_PROTOCOL_UPNP)); labels.push_back(std::make_pair(20304, NET_PROTOCOL_RSS)); #ifdef HAS_FILESYSTEM_NFS labels.push_back(std::make_pair(20259, NET_PROTOCOL_NFS)); #endif #ifdef HAS_FILESYSTEM_SFTP labels.push_back(std::make_pair(20260, NET_PROTOCOL_SFTP)); #endif AddSpinner(group, SETTING_PROTOCOL, 1008, 0, m_protocol, labels); AddEdit(group, SETTING_SERVER_ADDRESS, 1010, 0, m_server, true); CSettingAction *subsetting = AddButton(group, SETTING_SERVER_BROWSE, 1024, 0, false); if (subsetting != NULL) subsetting->SetParent(SETTING_SERVER_ADDRESS); AddEdit(group, SETTING_REMOTE_PATH, 1012, 0, m_path, true); AddEdit(group, SETTING_PORT_NUMBER, 1013, 0, m_port, true); AddEdit(group, SETTING_USERNAME, 1014, 0, m_username, true); AddEdit(group, SETTING_PASSWORD, 15052, 0, m_password, true, true); }
CSettingAction* CGUIDialogSettingsManualBase::AddButton(CSettingGroup *group, const std::string &id, int label, int level, bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */) { if (group == NULL || id.empty() || label < 0 || GetSetting(id) != NULL) return NULL; CSettingAction *setting = new CSettingAction(id, label, m_settingsManager); if (setting == NULL) return NULL; setting->SetControl(GetButtonControl("action", delayed)); setSettingDetails(setting, level, visible, help); group->AddSetting(setting); return setting; }
bool CGUIControlButtonSetting::OnClick() { if (m_pButton == NULL) return false; bool success = false; switch (m_pSetting->GetControl().GetFormat()) { case SettingControlFormatAddon: { // prompt for the addon CSettingAddon *setting = (CSettingAddon *)m_pSetting; CStdString addonID = setting->GetValue(); if (!CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty()) == 1) return false; success = setting->SetValue(addonID); break; } case SettingControlFormatPath: { success = GetPath((CSettingPath *)m_pSetting); break; } case SettingControlFormatAction: { // simply call the OnSettingAction callback and whoever knows what to // do can do so (based on the setting's identification CSettingAction *pSettingAction = (CSettingAction *)m_pSetting; pSettingAction->OnSettingAction(pSettingAction); success = true; break; } default: return false; } return success; }
bool CGUIControlButtonSetting::OnClick() { if (m_pButton == NULL) return false; const ISettingControl *control = m_pSetting->GetControl(); const std::string &controlType = control->GetType(); const std::string &controlFormat = control->GetFormat(); if (controlType == "button") { const CSettingControlButton *buttonControl = static_cast<const CSettingControlButton*>(control); if (controlFormat == "addon") { // prompt for the addon CSettingAddon *setting = (CSettingAddon *)m_pSetting; std::string addonID = setting->GetValue(); if (CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty(), buttonControl->ShowAddonDetails(), buttonControl->ShowInstalledAddons(), buttonControl->ShowInstallableAddons(), buttonControl->ShowMoreAddons()) != 1) return false; SetValid(setting->SetValue(addonID)); } else if (controlFormat == "path") SetValid(GetPath((CSettingPath *)m_pSetting)); else if (controlFormat == "action") { // simply call the OnSettingAction callback and whoever knows what to // do can do so (based on the setting's identification CSettingAction *pSettingAction = (CSettingAction *)m_pSetting; pSettingAction->OnSettingAction(pSettingAction); SetValid(true); } } else if (controlType == "slider") { float value, min, step, max; if (m_pSetting->GetType() == SettingTypeInteger) { CSettingInt *settingInt = static_cast<CSettingInt*>(m_pSetting); value = (float)settingInt->GetValue(); min = (float)settingInt->GetMinimum(); step = (float)settingInt->GetStep(); max = (float)settingInt->GetMaximum(); } else if (m_pSetting->GetType() == SettingTypeNumber) { CSettingNumber *settingNumber = static_cast<CSettingNumber*>(m_pSetting); value = (float)settingNumber->GetValue(); min = (float)settingNumber->GetMinimum(); step = (float)settingNumber->GetStep(); max = (float)settingNumber->GetMaximum(); } else return false; const CSettingControlSlider *sliderControl = static_cast<const CSettingControlSlider*>(control); CGUIDialogSlider::ShowAndGetInput(g_localizeStrings.Get(sliderControl->GetHeading()), value, min, step, max, this, NULL); SetValid(true); } return IsValid(); }
void CGUIDialogContentSettings::InitializeSettings() { CGUIDialogSettingsManualBase::InitializeSettings(); if (m_content == CONTENT_NONE) m_showScanSettings = false; else if (m_scraper != NULL && !CAddonMgr::GetInstance().IsAddonDisabled(m_scraper->ID())) m_showScanSettings = true; CSettingCategory *category = AddCategory("contentsettings", -1); if (category == NULL) { CLog::Log(LOGERROR, "CGUIDialogContentSettings: unable to setup settings"); return; } CSettingGroup *group = AddGroup(category); if (group == NULL) { CLog::Log(LOGERROR, "CGUIDialogContentSettings: unable to setup settings"); return; } AddButton(group, SETTING_CONTENT_TYPE, 20344, 0); AddButton(group, SETTING_SCRAPER_LIST, 38025, 0); CSettingAction *subsetting = AddButton(group, SETTING_SCRAPER_SETTINGS, 10004, 0); if (subsetting != NULL) subsetting->SetParent(SETTING_SCRAPER_LIST); group = AddGroup(category, 20322); if (category == NULL) { CLog::Log(LOGERROR, "CGUIDialogContentSettings: unable to setup scanning settings"); return; } switch (m_content) { case CONTENT_TVSHOWS: { AddToggle(group, SETTING_CONTAINS_SINGLE_ITEM, 20379, 0, m_containsSingleItem, false, m_showScanSettings); AddToggle(group, SETTING_NO_UPDATING, 20432, 0, m_noUpdating, false, m_showScanSettings); break; } case CONTENT_MOVIES: case CONTENT_MUSICVIDEOS: { AddToggle(group, SETTING_USE_DIRECTORY_NAMES, m_content == CONTENT_MOVIES ? 20329 : 20330, 0, m_useDirectoryNames, false, m_showScanSettings); CSettingBool *settingScanRecursive = AddToggle(group, SETTING_SCAN_RECURSIVE, 20346, 0, m_scanRecursive, false, m_showScanSettings); CSettingBool *settingContainsSingleItem = AddToggle(group, SETTING_CONTAINS_SINGLE_ITEM, 20383, 0, m_containsSingleItem, false, m_showScanSettings); AddToggle(group, SETTING_NO_UPDATING, 20432, 0, m_noUpdating, false, m_showScanSettings); // define an enable dependency with (m_useDirectoryNames && !m_containsSingleItem) || !m_useDirectoryNames CSettingDependency dependencyScanRecursive(SettingDependencyTypeEnable, m_settingsManager); dependencyScanRecursive.Or() ->Add(CSettingDependencyConditionCombinationPtr((new CSettingDependencyConditionCombination(BooleanLogicOperationAnd, m_settingsManager)) // m_useDirectoryNames && !m_containsSingleItem ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition(SETTING_USE_DIRECTORY_NAMES, "true", SettingDependencyOperatorEquals, false, m_settingsManager))) // m_useDirectoryNames ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition(SETTING_CONTAINS_SINGLE_ITEM, "false", SettingDependencyOperatorEquals, false, m_settingsManager))))) // !m_containsSingleItem ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition(SETTING_USE_DIRECTORY_NAMES, "false", SettingDependencyOperatorEquals, false, m_settingsManager))); // !m_useDirectoryNames // define an enable dependency with m_useDirectoryNames && !m_scanRecursive CSettingDependency depdendencyContainsSingleItem(SettingDependencyTypeEnable, m_settingsManager); depdendencyContainsSingleItem.And() ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition(SETTING_USE_DIRECTORY_NAMES, "true", SettingDependencyOperatorEquals, false, m_settingsManager))) // m_useDirectoryNames ->Add(CSettingDependencyConditionPtr(new CSettingDependencyCondition(SETTING_SCAN_RECURSIVE, "false", SettingDependencyOperatorEquals, false, m_settingsManager))); // !m_scanRecursive SettingDependencies deps; deps.push_back(dependencyScanRecursive); settingScanRecursive->SetDependencies(deps); deps.clear(); deps.push_back(depdendencyContainsSingleItem); settingContainsSingleItem->SetDependencies(deps); break; } case CONTENT_ALBUMS: case CONTENT_ARTISTS: break; case CONTENT_NONE: default: AddToggle(group, SETTING_EXCLUDE, 20380, 0, m_exclude, false, !m_showScanSettings); break; } }