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 
28 #ifndef HOTKEY_STORE__H
29 #define HOTKEY_STORE__H
30 
31 
32 #include <hotkeys_basic.h>
33 
34 
40 {
41 public:
42  CHANGED_HOTKEY( EDA_HOTKEY& aHotkey, const wxString& aTag ):
43  m_orig( aHotkey ),
44  m_changed( aHotkey ),
45  m_tag( aTag )
46  {}
47 
49  {
50  return m_changed;
51  }
52 
53  const EDA_HOTKEY& GetCurrentValue() const
54  {
55  return m_changed;
56  }
57 
65  {
66  return m_orig;
67  }
68 
72  void SaveHotkey()
73  {
74  m_orig = m_changed;
75  }
76 
81  bool HasUnsavedChange() const
82  {
84  }
85 
86  const wxString& GetSectionTag() const
87  {
88  return m_tag;
89  }
90 
91 private:
92  // Reference to an "original" hotkey config
94 
95  // A separate changeable config
97 
98  // The hotkey section tag, used to spot conflicts
99  const wxString& m_tag;
100 
101 };
102 
107 {
108  // The displayed, translated, name of the section
109  wxString m_name;
110 
111  // List of update-able hotkey data for this section
112  std::vector<CHANGED_HOTKEY> m_hotkeys;
113 
114  // Back reference to the underlying hotkey data of this section
116 };
117 
118 
124 {
125 public:
126 
127  using SECTION_LIST = std::vector<HOTKEY_SECTION>;
128 
134  HOTKEY_STORE( EDA_HOTKEY_CONFIG* aHotkeys );
135 
139  SECTION_LIST& GetSections();
140 
141 
146  CHANGED_HOTKEY* FindHotkey( const wxString& aTag, int aCmdId );
147 
152  void SaveAllHotkeys();
153 
157  void ResetAllHotkeysToDefault();
158 
162  void ResetAllHotkeysToOriginal();
163 
172  bool CheckKeyConflicts( long aKey, const wxString& aSectionTag,
173  EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect );
174 
175 private:
176 
181  HOTKEY_SECTION genSection( EDA_HOTKEY_CONFIG& aSection );
182 
183  // Internal data for every hotkey passed in
185 };
186 
187 #endif // HOTKEY_STORE__H
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
void SaveHotkey()
Save changed hotkey to the original location.
Definition: hotkey_store.h:72
Class that manages a hotkey that can be changed, reset to its old value, a default or saved...
Definition: hotkey_store.h:39
A class that contains a set of hotkeys, arranged into "sections" and provides some book-keeping funct...
Definition: hotkey_store.h:123
EDA_HOTKEY m_changed
Definition: hotkey_store.h:96
CHANGED_HOTKEY(EDA_HOTKEY &aHotkey, const wxString &aTag)
Definition: hotkey_store.h:42
EDA_HOTKEY & GetCurrentValue()
Definition: hotkey_store.h:48
EDA_HOTKEY_CONFIG & m_section
Definition: hotkey_store.h:115
const wxString & GetSectionTag() const
Definition: hotkey_store.h:86
bool HasUnsavedChange() const
Return true if the hotkey doesn&#39;t match the original (i.e.
Definition: hotkey_store.h:81
std::vector< CHANGED_HOTKEY > m_hotkeys
Definition: hotkey_store.h:112
const EDA_HOTKEY & GetOriginalValue() const
Gets the original value of the hotkey.
Definition: hotkey_store.h:64
SECTION_LIST m_hk_sections
Definition: hotkey_store.h:184
EDA_HOTKEY & m_orig
Definition: hotkey_store.h:93
class EDA_HOTKEY is a class to handle hot key commands.
Definition: hotkeys_basic.h:59
wxString m_name
Definition: hotkey_store.h:109
std::vector< HOTKEY_SECTION > SECTION_LIST
Definition: hotkey_store.h:127
const wxString & m_tag
Definition: hotkey_store.h:99
Some functions to handle hotkeys in KiCad.
const EDA_HOTKEY & GetCurrentValue() const
Definition: hotkey_store.h:53
Associates a set of hotkeys (a section) with a display name and the hotkeys.
Definition: hotkey_store.h:106