kicad/include/hotkey_store.h

108 lines
3.1 KiB
C
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HOTKEY_STORE__H
#define HOTKEY_STORE__H
#include <hotkeys_basic.h>
#include <tool/tool_action.h>
2019-06-09 21:57:23 +00:00
class TOOL_MANAGER;
2019-06-09 21:57:23 +00:00
struct HOTKEY
{
TOOL_ACTION* m_Parent;
int m_EditKeycode;
HOTKEY( TOOL_ACTION* aParent ) :
m_Parent( aParent ),
m_EditKeycode( aParent->GetHotKey() )
{ }
};
2019-06-09 21:57:23 +00:00
struct HOTKEY_SECTION
{
2019-06-09 21:57:23 +00:00
wxString m_SectionName; // The displayed, translated, name of the section
std::vector<HOTKEY> m_HotKeys;
};
/**
* A class that contains a set of hotkeys, arranged into "sections"
* and provides some book-keeping functions for them.
*/
class HOTKEY_STORE
{
public:
/**
* Construct a HOTKEY_STORE from a list of hotkey sections
*
* @param aHotkeys the hotkey configs that will be managed by this store.
*/
2019-06-09 21:57:23 +00:00
HOTKEY_STORE();
2019-06-09 21:57:23 +00:00
void Init( std::vector<TOOL_MANAGER*> aToolManagerList );
static wxString GetAppName( TOOL_ACTION* aAction );
static wxString GetSectionName( TOOL_ACTION* aAction );
/**
2019-06-09 21:57:23 +00:00
* Get the list of sections managed by this store
*/
2019-06-09 21:57:23 +00:00
std::vector<HOTKEY_SECTION>& GetSections();
/**
* Persist all changes to hotkeys in the store to the underlying
* data structures.
*/
void SaveAllHotkeys();
/**
* Reset every hotkey in the store to the default values
*/
void ResetAllHotkeysToDefault();
/**
* Resets every hotkey to the original values.
*/
void ResetAllHotkeysToOriginal();
/**
* Check whether the given key conflicts with anything in this store.
*
2019-06-09 21:57:23 +00:00
* @param aAction - the action the key is proposed to be assigned to. Only conflicts
* within the same section will be flagged.
* @param aKey - key to check
2019-06-09 21:57:23 +00:00
* @param aConflict - outparam getting the section this one conflicts with
*/
2019-06-09 21:57:23 +00:00
bool CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict );
private:
2019-06-09 21:57:23 +00:00
std::vector<TOOL_MANAGER*> m_toolManagers;
std::vector<HOTKEY_SECTION> m_hk_sections;
};
#endif // HOTKEY_STORE__H