Move preferences to an action instead of a wx event

This commit is contained in:
Ian McInerney 2023-08-08 00:51:22 +01:00
parent c41d78f2d3
commit a3a701a95e
17 changed files with 23 additions and 99 deletions

View File

@ -109,10 +109,7 @@ void EDA_3D_VIEWER_FRAME::CreateMenuBar()
BITMAPS::tools,
ACTION_MENU::CHECK );
prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->Add( _( "Reset to Default Settings" ), ID_MENU3D_RESET_DEFAULTS, BITMAPS::tools );

View File

@ -245,12 +245,7 @@ void BITMAP2CMP_FRAME::doReCreateMenuBar()
//
ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, tool );

View File

@ -101,7 +101,6 @@ static const wxSize defaultSize( FRAME_T aFrameType )
BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout )
EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences )
EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook )
EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent )
@ -1049,12 +1048,6 @@ void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
}
void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
{
ShowPreferences( wxEmptyString, wxEmptyString );
}
void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParentPage )
{
wxBeginBusyCursor( wxHOURGLASS_CURSOR );

View File

@ -738,10 +738,14 @@ TOOL_ACTION ACTIONS::updateSchematicFromPcb( "common.Control.updateSchematicFrom
_( "Update Schematic from PCB..." ), _( "Update schematic with changes made to PCB" ),
BITMAPS::update_sch_from_pcb );
TOOL_ACTION ACTIONS::openPreferences( "common.SuiteControl.openPreferences",
AS_GLOBAL, MD_CTRL + ',', "",
_( "Preferences..." ), _( "Show preferences for all open tools" ),
BITMAPS::preference );
TOOL_ACTION ACTIONS::openPreferences( TOOL_ACTION_ARGS()
.Name( "common.SuiteControl.openPreferences" )
.Scope( AS_GLOBAL )
.DefaultHotkey( MD_CTRL + ',' )
.MenuText( _( "Preferences..." ) )
.Tooltip( _( "Show preferences for all open tools" ) )
.Icon( BITMAPS::preference )
.UIId( wxID_PREFERENCES ) );
TOOL_ACTION ACTIONS::configurePaths( "common.SuiteControl.configurePaths",
AS_GLOBAL, 0, "",

View File

@ -68,10 +68,7 @@ void COMMON_CONTROL::Reset( RESET_REASON aReason )
int COMMON_CONTROL::OpenPreferences( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnPreferences( dummy );
m_frame->ShowPreferences( wxEmptyString, wxEmptyString );
return 0;
}

View File

@ -68,13 +68,7 @@ void CVPCB_MAINFRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showFootprintLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + wxS( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences);
prefsMenu->AppendSeparator();
prefsMenu->Add( CVPCB_ACTIONS::showEquFileTable);

View File

@ -313,13 +313,7 @@ void SCH_EDIT_FRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showSymbolLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );

View File

@ -146,13 +146,7 @@ void SIMULATOR_FRAME::doReCreateMenuBar()
//prefsMenu->Add( ACTIONS::configurePaths );
//prefsMenu->Add( EE_ACTIONS::showSimLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, tool );

View File

@ -165,13 +165,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showSymbolLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );

View File

@ -221,12 +221,7 @@ void GERBVIEW_FRAME::doReCreateMenuBar()
//
ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
preferencesMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
preferencesMenu->Add( ACTIONS::openPreferences );
preferencesMenu->AppendSeparator();
AddMenuLanguageList( preferencesMenu, selTool );

View File

@ -211,11 +211,6 @@ public:
void OnKicadAbout( wxCommandEvent& event );
/**
* Displays the preferences and settings of all opened editors paged dialog
*/
void OnPreferences( wxCommandEvent& event );
/**
* Displays the preferences and settings of all opened editors paged dialog, starting with
* a particular page

View File

@ -196,13 +196,7 @@ void KICAD_MANAGER_FRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showSymbolLibTable );
prefsMenu->Add( ACTIONS::showFootprintLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + wxS( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, controlTool );

View File

@ -156,12 +156,7 @@ void PL_EDITOR_FRAME::doReCreateMenuBar()
//
ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
preferencesMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
preferencesMenu->Add( ACTIONS::openPreferences );
// Language submenu
AddMenuLanguageList( preferencesMenu, selTool );

View File

@ -28,6 +28,7 @@
#include <geometry/shape_poly_set.h>
#include <kiface_base.h>
#include <menus_helpers.h>
#include <tool/actions.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/common_control.h>
@ -213,12 +214,7 @@ void PCB_CALCULATOR_FRAME::doReCreateMenuBar()
//
ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, tool );

View File

@ -239,13 +239,7 @@ void FOOTPRINT_EDIT_FRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showFootprintLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );

View File

@ -451,13 +451,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar()
prefsMenu->Add( ACTIONS::configurePaths );
prefsMenu->Add( ACTIONS::showFootprintLibTable );
// We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
// Mac, and it needs the wxID_PREFERENCES id to find it.
prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
_( "Show preferences for all open tools" ),
wxID_PREFERENCES,
BITMAPS::preference );
prefsMenu->Add( ACTIONS::openPreferences );
prefsMenu->AppendSeparator();
AddMenuLanguageList( prefsMenu, selTool );

View File

@ -3278,8 +3278,7 @@ void APPEARANCE_CONTROLS::onReadOnlySwatch()
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
[&]( wxHyperlinkEvent& aEvent )
{
wxCommandEvent dummy;
m_frame->OnPreferences( dummy );
m_frame->ShowPreferences( wxEmptyString, wxEmptyString );
} ) );
infobar->RemoveAllButtons();