2018-09-26 14:26:26 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2019-06-12 14:39:47 +00:00
|
|
|
#include <tool/tool_action.h>
|
2020-10-24 04:44:25 +00:00
|
|
|
#include <vector>
|
2018-09-26 14:26:26 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
class TOOL_MANAGER;
|
2018-09-26 14:26:26 +00:00
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
struct HOTKEY
|
|
|
|
{
|
2019-06-14 10:55:54 +00:00
|
|
|
std::vector<TOOL_ACTION*> m_Actions;
|
|
|
|
int m_EditKeycode;
|
2019-06-12 14:39:47 +00:00
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
HOTKEY() :
|
|
|
|
m_EditKeycode( 0 )
|
2019-06-12 14:39:47 +00:00
|
|
|
{ }
|
2019-06-14 10:55:54 +00:00
|
|
|
|
|
|
|
HOTKEY( TOOL_ACTION* aAction ) :
|
|
|
|
m_EditKeycode( aAction->GetHotKey() )
|
|
|
|
{
|
|
|
|
m_Actions.push_back( aAction );
|
|
|
|
}
|
2018-09-26 14:26:26 +00:00
|
|
|
};
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
|
2018-09-26 14:26:26 +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;
|
2018-09-26 14:26:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
2018-09-26 14:26:26 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
void Init( std::vector<TOOL_ACTION*> aActionsList, bool aIncludeReadOnlyCmds );
|
2019-07-16 16:29:50 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
static wxString GetAppName( TOOL_ACTION* aAction );
|
|
|
|
static wxString GetSectionName( TOOL_ACTION* aAction );
|
2018-09-27 14:48:52 +00:00
|
|
|
|
|
|
|
/**
|
2019-06-09 21:57:23 +00:00
|
|
|
* Get the list of sections managed by this store
|
2018-09-27 14:48:52 +00:00
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
std::vector<HOTKEY_SECTION>& GetSections();
|
2018-09-27 14:48:52 +00:00
|
|
|
|
2018-09-26 14:26:26 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2018-09-26 14:26:26 +00:00
|
|
|
* @param aKey - key to check
|
2019-06-09 21:57:23 +00:00
|
|
|
* @param aConflict - outparam getting the section this one conflicts with
|
2018-09-26 14:26:26 +00:00
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
bool CheckKeyConflicts( TOOL_ACTION* aAction, long aKey, HOTKEY** aConflict );
|
2018-09-26 14:26:26 +00:00
|
|
|
|
|
|
|
private:
|
2019-06-09 21:57:23 +00:00
|
|
|
std::vector<TOOL_MANAGER*> m_toolManagers;
|
|
|
|
std::vector<HOTKEY_SECTION> m_hk_sections;
|
2018-09-26 14:26:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HOTKEY_STORE__H
|