本文整理汇总了C++中AppConfig::IsOkApplyPreset方法的典型用法代码示例。如果您正苦于以下问题:C++ AppConfig::IsOkApplyPreset方法的具体用法?C++ AppConfig::IsOkApplyPreset怎么用?C++ AppConfig::IsOkApplyPreset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppConfig
的用法示例。
在下文中一共展示了AppConfig::IsOkApplyPreset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsOkApplyPreset
//Behavior when unchecking 'Presets' is to keep the GUI settings at the last preset (even if not yet applied).
//
//Alternative possible behavior when unchecking 'Presets' (currently not implemented) is to set the GUI to
// the last applied settings. If such behavior is to be implemented, g_Conf->EnablePresets should be set to
// false before it's applied to the GUI and then restored to it's original state such that the GUI reflects
// g_Conf's settings as if it doesn't force presets. (if a settings which has presets enable is applied to the
// GUI then most of the GUI is disabled).
void Dialogs::SysConfigDialog::UpdateGuiForPreset ( int presetIndex, bool presetsEnabled )
{
if( !m_listbook )
return;
//Console.WriteLn("Applying config to Gui: preset #%d, presets enabled: %s", presetIndex, presetsEnabled?"true":"false");
AppConfig preset = *g_Conf;
preset.IsOkApplyPreset( presetIndex ); //apply a preset to a copy of g_Conf.
preset.EnablePresets = presetsEnabled; //override IsOkApplyPreset (which always applies/enabled) to actual required state
//update the config panels of SysConfigDialog to reflect the preset.
size_t pages = m_labels.GetCount();
for( size_t i=0; i<pages; ++i )
{
//NOTE: We should only apply the preset to panels of class BaseApplicableConfigPanel_SpecificConfig
// which supports it, and BaseApplicableConfigPanel implements IsSpecificConfig() as lame RTTI to detect it.
// However, the panels in general (m_listbook->GetPage(i)) are of type wxNotebookPage which doesn't
// support IsSpecificConfig(), so the panels (pages) that SysConfigDialog holds must be of class
// BaseApplicableConfigPanel or derived, and not of the parent class wxNotebookPage.
if ( ((BaseApplicableConfigPanel*)(m_listbook->GetPage(i)))->IsSpecificConfig() )
{
((BaseApplicableConfigPanel_SpecificConfig*)(m_listbook->GetPage(i)))
->ApplyConfigToGui( preset, AppConfig::APPLY_FLAG_FROM_PRESET | AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE );
}
}
//Main menus behavior regarding presets and changes/cancel/apply from SysConfigDialog:
//1. As long as preset-related values were not changed at SysConfigDialog, menus behave normally.
//2. After the first preset-related change at SysConfigDialog (this function) and before Apply/Ok/Cancel:
// - The menus reflect the temporary pending values, but these preset-controlled items are grayed out even if temporarily presets is unchecked.
//3. When clicking Ok/Apply/Cancel at SysConfigDialog, the menus are re-alligned with g_Conf (including gray out or not as needed).
//NOTE: Enabling the presets and disabling them wihout clicking Apply leaves the pending menu config at last preset values
// (consistent with SysConfigDialog behavior). But unlike SysConfigDialog, the menu items stay grayed out.
// Clicking cancel will revert all pending changes, but clicking apply will commit them, and this includes the menus.
// E.g.:
// 1. Patches (menu) is disabled and presets (SysConfigDialog) is disabled.
// 2. Opening config and checking presets without apply --> patches are visually enabled and grayed out (not yet applied to g_Conf)
// 3. Unchecking presets, still without clicking apply --> patches are visually still enabled (last preset values) and grayed out.
// 4. Clicking Apply (presets still unchecked) --> patches will be enabled and not grayed out, presets are disabled.
// --> If clicking Cancel instead of Apply at 4., will revert everything to the state of 1 (preset disabled, patches disabled and not grayed out).
bool origEnable=preset.EnablePresets;
preset.EnablePresets=true; // will cause preset-related items to be grayed out at the menus regardless of their value.
if ( GetMainFramePtr() )
GetMainFramePtr()->ApplyConfigToGui( preset, AppConfig::APPLY_FLAG_FROM_PRESET | AppConfig::APPLY_FLAG_MANUALLY_PROPAGATE );
// Not really needed as 'preset' is local and dumped anyway. For the sake of future modifications of more GUI elements.
preset.EnablePresets=origEnable;
}