本文整理汇总了C++中PeripheralPtr::GetSettings方法的典型用法代码示例。如果您正苦于以下问题:C++ PeripheralPtr::GetSettings方法的具体用法?C++ PeripheralPtr::GetSettings怎么用?C++ PeripheralPtr::GetSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PeripheralPtr
的用法示例。
在下文中一共展示了PeripheralPtr::GetSettings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSettingAction
void CPeripherals::OnSettingAction(const CSetting *setting)
{
if (setting == nullptr)
return;
const std::string &settingId = setting->GetId();
if (settingId == CSettings::SETTING_INPUT_PERIPHERALS)
{
CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
CFileItemList items;
GetDirectory("peripherals://all/", items);
int iPos = -1;
do
{
pDialog->Reset();
pDialog->SetHeading(CVariant{35000});
pDialog->SetUseDetails(true);
pDialog->SetItems(items);
pDialog->SetSelected(iPos);
pDialog->Open();
iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedItem() : -1;
if (iPos >= 0)
{
CFileItemPtr pItem = items.Get(iPos);
// show an error if the peripheral doesn't have any settings
PeripheralPtr peripheral = GetByPath(pItem->GetPath());
if (!peripheral || peripheral->GetSettings().empty())
{
CGUIDialogOK::ShowAndGetInput(CVariant{35000}, CVariant{35004});
continue;
}
CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS);
if (pItem && pSettingsDialog)
{
// pass peripheral item properties to settings dialog so skin authors
// can use it to show more detailed information about the device
pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor"));
pSettingsDialog->SetProperty("product", pItem->GetProperty("product"));
pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus"));
pSettingsDialog->SetProperty("location", pItem->GetProperty("location"));
pSettingsDialog->SetProperty("class", pItem->GetProperty("class"));
pSettingsDialog->SetProperty("version", pItem->GetProperty("version"));
// open settings dialog
pSettingsDialog->SetFileItem(pItem.get());
pSettingsDialog->Open();
}
}
} while (pDialog->IsConfirmed());
}
else if (settingId == CSettings::SETTING_INPUT_CONTROLLERCONFIG)
g_windowManager.ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS);
else if (settingId == CSettings::SETTING_INPUT_TESTRUMBLE)
TestFeature(FEATURE_RUMBLE);
}
示例2: InitializeSettings
void CGUIDialogPeripheralSettings::InitializeSettings()
{
if (m_item == NULL)
{
m_initialising = false;
return;
}
m_initialising = true;
bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml");
PeripheralPtr peripheral = g_peripherals.GetByPath(m_item->GetPath());
if (!peripheral)
{
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 *settingInt = new CSettingInt(setting->GetId(), *static_cast<CSettingInt*>(setting));
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)
//.........这里部分代码省略.........