Add Open preferences folder button in Preferences Dialog

This commit is contained in:
Josue Huaroto 2023-07-13 14:10:31 +00:00 committed by Ian McInerney
parent cf8294b5c2
commit 4cad021ef4
5 changed files with 34 additions and 5 deletions

View File

@ -1059,7 +1059,7 @@ void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParent
{
wxBeginBusyCursor( wxHOURGLASS_CURSOR );
PAGED_DIALOG dlg( this, _( "Preferences" ), true, wxEmptyString, wxSize( 980, 560 ) );
PAGED_DIALOG dlg( this, _( "Preferences" ), true, true, wxEmptyString, wxSize( 980, 560 ) );
dlg.SetEvtHandlerEnabled( false );

View File

@ -32,6 +32,10 @@
#include <wx/listctrl.h>
#include <wx/stc/stc.h>
#include <settings/settings_manager.h>
#include <launch_ext.h>
#include <algorithm>
// Maps from dialogTitle <-> pageTitle for keeping track of last-selected pages.
@ -40,7 +44,7 @@ std::map<wxString, wxString> g_lastPage;
std::map<wxString, wxString> g_lastParentPage;
PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset,
PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset, bool aShowOpenFolder,
const wxString& aAuxiliaryAction, const wxSize& aInitialSize ) :
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
@ -80,6 +84,13 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
m_buttonsSizer->Add( m_resetButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
}
if( aShowOpenFolder )
{
m_openPreferencesButton = new wxButton( this, wxID_ANY, _( "Open preferences folder" ) );
m_buttonsSizer->Add( m_openPreferencesButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 5 );
}
if( !aAuxiliaryAction.IsEmpty() )
{
m_auxiliaryButton = new wxButton( this, wxID_ANY, aAuxiliaryAction );
@ -116,6 +127,11 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
m_resetButton->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onResetButton, this );
}
if( m_openPreferencesButton )
{
m_openPreferencesButton->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onOpenPreferencesButton, this );
}
m_treebook->Bind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this );
m_treebook->Bind( wxEVT_TREEBOOK_PAGE_CHANGED, &PAGED_DIALOG::onPageChanged, this );
m_treebook->Bind( wxEVT_TREEBOOK_PAGE_CHANGING, &PAGED_DIALOG::onPageChanging, this );
@ -183,6 +199,11 @@ PAGED_DIALOG::~PAGED_DIALOG()
m_resetButton->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onResetButton, this );
}
if( m_openPreferencesButton )
{
m_openPreferencesButton->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onOpenPreferencesButton, this );
}
m_treebook->Unbind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this );
m_treebook->Unbind( wxEVT_TREEBOOK_PAGE_CHANGED, &PAGED_DIALOG::onPageChanged, this );
m_treebook->Unbind( wxEVT_TREEBOOK_PAGE_CHANGING, &PAGED_DIALOG::onPageChanging, this );
@ -479,3 +500,9 @@ void PAGED_DIALOG::onResetButton( wxCommandEvent& aEvent )
panel->ProcessWindowEvent( resetCommand );
}
}
void PAGED_DIALOG::onOpenPreferencesButton( wxCommandEvent& aEvent )
{
wxString dir( SETTINGS_MANAGER::GetUserSettingsPath() );
LaunchExternal( dir );
}

View File

@ -37,7 +37,7 @@
DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
PAGED_DIALOG( aFrame, _( "Schematic Setup" ), true,
PAGED_DIALOG( aFrame, _( "Schematic Setup" ), true, false,
_( "Import Settings from Another Project..." ), wxSize( 920, 460 ) ),
m_frame( aFrame )
{

View File

@ -31,7 +31,7 @@ class WX_TREEBOOK;
class PAGED_DIALOG : public DIALOG_SHIM
{
public:
PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset,
PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset, bool aShowOpenFolder,
const wxString& aAuxiliaryAction = wxEmptyString,
const wxSize& aInitialSize = wxDefaultSize );
~PAGED_DIALOG() override;
@ -60,6 +60,7 @@ protected:
virtual void onAuxiliaryAction( wxCommandEvent& aEvent ) { aEvent.Skip(); }
virtual void onResetButton( wxCommandEvent& aEvent );
virtual void onOpenPreferencesButton( wxCommandEvent& aEvent );
virtual void onPageChanged( wxBookCtrlEvent& aEvent );
virtual void onPageChanging( wxBookCtrlEvent& aEvent );
virtual void onCharHook( wxKeyEvent& aEvent );
@ -67,6 +68,7 @@ protected:
WX_TREEBOOK* m_treebook;
wxButton* m_auxiliaryButton;
wxButton* m_resetButton;
wxButton* m_openPreferencesButton;
wxButton* m_cancelButton;
WX_INFOBAR* m_infoBar;

View File

@ -51,7 +51,7 @@ std::mutex DIALOG_BOARD_SETUP::g_Mutex;
#define RESOLVE_PAGE( T, pageIndex ) static_cast<T*>( m_treebook->ResolvePage( pageIndex ) )
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
PAGED_DIALOG( aFrame, _( "Board Setup" ), false,
PAGED_DIALOG( aFrame, _( "Board Setup" ), false, false,
_( "Import Settings from Another Board..." ), wxSize( 980, 600 ) ),
m_frame( aFrame ),
m_layers( nullptr ),