Preferences, Hotkey list: Avoid list to be shown twice.
The bug was due to the fact TransferDataToWindow was called twice, and the hotkey list was not cleared before rebuild it
This commit is contained in:
parent
5ff7c61003
commit
6388189f48
|
@ -71,7 +71,7 @@ wxString HOTKEY_STORE::GetSectionName( TOOL_ACTION* aAction )
|
|||
};
|
||||
|
||||
wxString appName = GetAppName( aAction );
|
||||
|
||||
|
||||
if( s_AppNames.count( appName ) )
|
||||
return s_AppNames[ appName ];
|
||||
else
|
||||
|
@ -87,11 +87,11 @@ HOTKEY_STORE::HOTKEY_STORE()
|
|||
void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncludeGestures )
|
||||
{
|
||||
m_toolManagers = std::move( aToolManagerList );
|
||||
|
||||
|
||||
// Collect all action maps into a single master map. This will re-group everything
|
||||
// and collect duplicates together
|
||||
std::map<std::string, HOTKEY> masterMap;
|
||||
|
||||
|
||||
for( TOOL_MANAGER* toolMgr : m_toolManagers )
|
||||
{
|
||||
for( const auto& entry : toolMgr->GetActions() )
|
||||
|
@ -105,10 +105,13 @@ void HOTKEY_STORE::Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncl
|
|||
hotkey.m_EditKeycode = entry.second->GetHotKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxString currentApp;
|
||||
HOTKEY_SECTION* currentSection = nullptr;
|
||||
|
||||
// If a previous list was built, ensure this previous list is cleared:
|
||||
m_hk_sections.clear();
|
||||
|
||||
for( const auto& entry : masterMap )
|
||||
{
|
||||
TOOL_ACTION* entryAction = entry.second.m_Actions[ 0 ];
|
||||
|
@ -184,12 +187,12 @@ bool HOTKEY_STORE::CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY**
|
|||
{
|
||||
if( section.m_SectionName != sectionName )
|
||||
continue;
|
||||
|
||||
|
||||
for( HOTKEY& hotkey: section.m_HotKeys )
|
||||
{
|
||||
if( hotkey.m_Actions[ 0 ] == aAction )
|
||||
continue;
|
||||
|
||||
|
||||
if( hotkey.m_EditKeycode == aKey )
|
||||
{
|
||||
*aConflict = &hotkey;
|
||||
|
@ -197,6 +200,6 @@ bool HOTKEY_STORE::CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY**
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
|
@ -141,9 +141,10 @@ bool PAGED_DIALOG::TransferDataToWindow()
|
|||
{
|
||||
finishInitialization();
|
||||
|
||||
#if 1 // Call TransferDataToWindow() only once: this is enough
|
||||
if( !DIALOG_SHIM::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
#else
|
||||
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
||||
{
|
||||
wxWindow* page = m_treebook->GetPage( i );
|
||||
|
@ -151,6 +152,7 @@ bool PAGED_DIALOG::TransferDataToWindow()
|
|||
if( !page->TransferDataToWindow() )
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Search for a page matching the lastParentPageTitle/lastPageTitle hierarchy
|
||||
wxString lastPage = g_lastPage[ m_title ];
|
||||
|
@ -184,9 +186,10 @@ bool PAGED_DIALOG::TransferDataToWindow()
|
|||
|
||||
bool PAGED_DIALOG::TransferDataFromWindow()
|
||||
{
|
||||
#if 1 // Call TransferDataFromWindow() only once: this is enough
|
||||
if( !DIALOG_SHIM::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
#else
|
||||
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
||||
{
|
||||
wxWindow* page = m_treebook->GetPage( i );
|
||||
|
@ -194,6 +197,7 @@ bool PAGED_DIALOG::TransferDataFromWindow()
|
|||
if( !page->TransferDataFromWindow() )
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ void WIDGET_HOTKEY_LIST::UpdateFromClientData()
|
|||
|
||||
if( label.IsEmpty() )
|
||||
label = changed_hk.m_Actions[ 0 ]->GetName();
|
||||
|
||||
|
||||
// mark unsaved changes
|
||||
if( changed_hk.m_EditKeycode != changed_hk.m_Actions[ 0 ]->GetHotKey() )
|
||||
key_text += " *";
|
||||
|
@ -428,7 +428,7 @@ bool WIDGET_HOTKEY_LIST::ResolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
|
|||
|
||||
if( !conflictingHotKey )
|
||||
return true;
|
||||
|
||||
|
||||
TOOL_ACTION* conflictingAction = conflictingHotKey->m_Actions[ 0 ];
|
||||
wxString msg = wxString::Format( _( "\"%s\" is already assigned to \"%s\" in section \"%s\". "
|
||||
"Are you sure you want to change its assignment?" ),
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
HOTKEY_STORE();
|
||||
|
||||
void Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncludeGestures );
|
||||
|
||||
|
||||
static wxString GetAppName( TOOL_ACTION* aAction );
|
||||
static wxString GetSectionName( TOOL_ACTION* aAction );
|
||||
|
||||
|
|
Loading…
Reference in New Issue