KiCad PCB EDA Suite
hotkey_store.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef HOTKEY_STORE__H
25 #define HOTKEY_STORE__H
26 
27 #include <hotkeys_basic.h>
28 #include <tool/tool_action.h>
29 
30 class TOOL_MANAGER;
31 
32 
33 struct HOTKEY
34 {
35  std::vector<TOOL_ACTION*> m_Actions;
37 
38  HOTKEY() :
39  m_EditKeycode( 0 )
40  { }
41 
42  HOTKEY( TOOL_ACTION* aAction ) :
43  m_EditKeycode( aAction->GetHotKey() )
44  {
45  m_Actions.push_back( aAction );
46  }
47 };
48 
49 
51 {
52  wxString m_SectionName; // The displayed, translated, name of the section
53  std::vector<HOTKEY> m_HotKeys;
54 };
55 
56 
62 {
63 public:
64 
70  HOTKEY_STORE();
71 
72  void Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncludeGestures );
73 
74  static wxString GetAppName( TOOL_ACTION* aAction );
75  static wxString GetSectionName( TOOL_ACTION* aAction );
76 
80  std::vector<HOTKEY_SECTION>& GetSections();
81 
86  void SaveAllHotkeys();
87 
92 
97 
106  bool CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict );
107 
108 private:
109  std::vector<TOOL_MANAGER*> m_toolManagers;
110  std::vector<HOTKEY_SECTION> m_hk_sections;
111 };
112 
113 #endif // HOTKEY_STORE__H
A class that contains a set of hotkeys, arranged into "sections" and provides some book-keeping funct...
Definition: hotkey_store.h:61
void SaveAllHotkeys()
Persist all changes to hotkeys in the store to the underlying data structures.
std::vector< HOTKEY > m_HotKeys
Definition: hotkey_store.h:53
HOTKEY(TOOL_ACTION *aAction)
Definition: hotkey_store.h:42
Class TOOL_MANAGER.
Definition: tool_manager.h:50
HOTKEY_STORE()
Construct a HOTKEY_STORE from a list of hotkey sections.
std::vector< TOOL_MANAGER * > m_toolManagers
Definition: hotkey_store.h:109
static wxString GetAppName(TOOL_ACTION *aAction)
void ResetAllHotkeysToDefault()
Reset every hotkey in the store to the default values.
bool CheckKeyConflicts(TOOL_ACTION *aAction, long aKey, HOTKEY **aConflict)
Check whether the given key conflicts with anything in this store.
std::vector< TOOL_ACTION * > m_Actions
Definition: hotkey_store.h:35
std::vector< HOTKEY_SECTION > & GetSections()
Get the list of sections managed by this store.
std::vector< HOTKEY_SECTION > m_hk_sections
Definition: hotkey_store.h:110
Class TOOL_ACTION.
Definition: tool_action.h:46
void ResetAllHotkeysToOriginal()
Resets every hotkey to the original values.
void Init(std::vector< TOOL_MANAGER * > aToolManagerList, bool aIncludeGestures)
int m_EditKeycode
Definition: hotkey_store.h:36
wxString m_SectionName
Definition: hotkey_store.h:52
static wxString GetSectionName(TOOL_ACTION *aAction)