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 #include <vector>
30 
31 class TOOL_MANAGER;
32 
33 
34 struct HOTKEY
35 {
36  std::vector<TOOL_ACTION*> m_Actions;
38 
39  HOTKEY() :
40  m_EditKeycode( 0 )
41  { }
42 
43  HOTKEY( TOOL_ACTION* aAction ) :
44  m_EditKeycode( aAction->GetHotKey() )
45  {
46  m_Actions.push_back( aAction );
47  }
48 };
49 
50 
52 {
53  wxString m_SectionName; // The displayed, translated, name of the section
54  std::vector<HOTKEY> m_HotKeys;
55 };
56 
57 
63 {
64 public:
65 
71  HOTKEY_STORE();
72 
73  void Init( std::vector<TOOL_MANAGER*> aToolManagerList, bool aIncludeGestures );
74 
75  static wxString GetAppName( TOOL_ACTION* aAction );
76  static wxString GetSectionName( TOOL_ACTION* aAction );
77 
81  std::vector<HOTKEY_SECTION>& GetSections();
82 
87  void SaveAllHotkeys();
88 
93 
98 
107  bool CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict );
108 
109 private:
110  std::vector<TOOL_MANAGER*> m_toolManagers;
111  std::vector<HOTKEY_SECTION> m_hk_sections;
112 };
113 
114 #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:62
void SaveAllHotkeys()
Persist all changes to hotkeys in the store to the underlying data structures.
std::vector< HOTKEY > m_HotKeys
Definition: hotkey_store.h:54
HOTKEY(TOOL_ACTION *aAction)
Definition: hotkey_store.h:43
Master controller class:
Definition: tool_manager.h:52
HOTKEY_STORE()
Construct a HOTKEY_STORE from a list of hotkey sections.
std::vector< TOOL_MANAGER * > m_toolManagers
Definition: hotkey_store.h:110
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:36
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:111
Represent a single user action.
Definition: tool_action.h:49
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:37
wxString m_SectionName
Definition: hotkey_store.h:53
static wxString GetSectionName(TOOL_ACTION *aAction)