Simplify user model for editing color themes.

This commit is contained in:
Jeff Young 2020-04-08 22:34:18 +01:00
parent c877cb967f
commit 317e98b344
11 changed files with 152 additions and 890 deletions

View File

@ -18,22 +18,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <confirm.h>
#include <launch_ext.h>
#include <panel_color_settings.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
PANEL_COLOR_SETTINGS::PANEL_COLOR_SETTINGS( wxWindow* aParent ) :
PANEL_COLOR_SETTINGS_BASE( aParent )
{
#ifdef __APPLE__
m_btnOpenFolder->SetLabel( _( "Reveal Themes in Finder" ) );
#endif
}
void PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked( wxCommandEvent& event )
{
wxString cmd;
wxString dir( Pgm().GetSettingsManager().GetColorSettingsPath() );
wxString dir( SETTINGS_MANAGER::GetColorSettingsPath() );
LaunchExternal( dir );
}

View File

@ -28,23 +28,6 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
bControlSizer->Add( m_cbTheme, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_btnSave = new wxButton( this, wxID_ANY, _("&Save"), wxDefaultPosition, wxDefaultSize, 0 );
m_btnSave->Enable( false );
m_btnSave->SetToolTip( _("Save the active color theme") );
bControlSizer->Add( m_btnSave, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_btnNew = new wxButton( this, wxID_ANY, _("&New"), wxDefaultPosition, wxDefaultSize, 0 );
m_btnNew->SetToolTip( _("Create a new color theme based on the current one") );
bControlSizer->Add( m_btnNew, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_btnRename = new wxButton( this, wxID_ANY, _("Rename"), wxDefaultPosition, wxDefaultSize, 0 );
m_btnRename->Enable( false );
m_btnRename->SetToolTip( _("The \"User\" theme cannot be renamed") );
bControlSizer->Add( m_btnRename, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bControlSizer->Add( 0, 0, 1, wxEXPAND, 5 );
@ -61,53 +44,8 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
m_mainSizer->Add( bControlSizer, 0, wxEXPAND|wxRIGHT, 10 );
m_panelThemeProperties = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_panelThemeProperties->Hide();
m_sizerThemeProperties = new wxBoxSizer( wxHORIZONTAL );
m_staticText6 = new wxStaticText( m_panelThemeProperties, wxID_ANY, _("Theme name:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
m_sizerThemeProperties->Add( m_staticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_txtThemeName = new wxTextCtrl( m_panelThemeProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !m_txtThemeName->HasFlag( wxTE_MULTILINE ) )
{
m_txtThemeName->SetMaxLength( 48 );
}
#else
m_txtThemeName->SetMaxLength( 48 );
#endif
m_txtThemeName->SetToolTip( _("Name of the theme") );
m_txtThemeName->SetMinSize( wxSize( 200,-1 ) );
m_sizerThemeProperties->Add( m_txtThemeName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_sizerThemeProperties->Add( 24, 0, 0, wxEXPAND, 5 );
m_staticText7 = new wxStaticText( m_panelThemeProperties, wxID_ANY, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText7->Wrap( -1 );
m_sizerThemeProperties->Add( m_staticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_txtFilename = new wxTextCtrl( m_panelThemeProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_txtFilename->SetToolTip( _("Filename to save the theme to (must end in .json)") );
m_txtFilename->SetMinSize( wxSize( 200,-1 ) );
m_sizerThemeProperties->Add( m_txtFilename, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_lblThemePropertiesError = new wxStaticText( m_panelThemeProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_lblThemePropertiesError->Wrap( -1 );
m_lblThemePropertiesError->SetForegroundColour( wxColour( 255, 0, 0 ) );
m_sizerThemeProperties->Add( m_lblThemePropertiesError, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_panelThemeProperties->SetSizer( m_sizerThemeProperties );
m_panelThemeProperties->Layout();
m_sizerThemeProperties->Fit( m_panelThemeProperties );
m_mainSizer->Add( m_panelThemeProperties, 0, wxEXPAND | wxALL, 0 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_mainSizer->Add( m_staticline1, 0, wxEXPAND|wxALL, 5 );
m_colorsMainSizer = new wxBoxSizer( wxHORIZONTAL );
@ -136,14 +74,8 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
// Connect Events
this->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_btnSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnSaveClicked ), NULL, this );
m_btnNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnNewClicked ), NULL, this );
m_btnRename->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnRenameClicked ), NULL, this );
m_btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
m_txtThemeName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeNameChanged ), NULL, this );
m_txtFilename->Connect( wxEVT_CHAR, wxKeyEventHandler( PANEL_COLOR_SETTINGS_BASE::OnFilenameChar ), NULL, this );
m_txtFilename->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnFilenameChanged ), NULL, this );
}
PANEL_COLOR_SETTINGS_BASE::~PANEL_COLOR_SETTINGS_BASE()
@ -151,13 +83,7 @@ PANEL_COLOR_SETTINGS_BASE::~PANEL_COLOR_SETTINGS_BASE()
// Disconnect Events
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_btnSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnSaveClicked ), NULL, this );
m_btnNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnNewClicked ), NULL, this );
m_btnRename->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnRenameClicked ), NULL, this );
m_btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
m_txtThemeName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeNameChanged ), NULL, this );
m_txtFilename->Disconnect( wxEVT_CHAR, wxKeyEventHandler( PANEL_COLOR_SETTINGS_BASE::OnFilenameChar ), NULL, this );
m_txtFilename->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnFilenameChanged ), NULL, this );
}

View File

@ -190,225 +190,6 @@
<event name="OnChoice">OnThemeChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">0</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Save</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnSave</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Save the active color theme</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnBtnSaveClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;New</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnNew</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Create a new color theme based on the current one</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnBtnNewClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">0</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Rename</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnRename</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">The &quot;User&quot; theme cannot be renamed</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnBtnRenameClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
@ -568,10 +349,10 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">0</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="1">
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -597,7 +378,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">1</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -606,7 +387,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelThemeProperties</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -616,342 +397,13 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">m_sizerThemeProperties</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Theme name:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText6</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength">48</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">200,-1</property>
<property name="moveable">1</property>
<property name="name">m_txtThemeName</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Name of the theme</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnText">OnThemeNameChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">24</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Filename:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText7</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">200,-1</property>
<property name="moveable">1</property>
<property name="name">m_txtFilename</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Filename to save the theme to (must end in .json)</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar">OnFilenameChar</event>
<event name="OnText">OnFilenameChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">1</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">255,0,0</property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_lblThemePropertiesError</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -22,9 +22,9 @@
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/textctrl.h>
#include <wx/panel.h>
#include <wx/statline.h>
#include <wx/scrolwin.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -39,18 +39,9 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
wxBoxSizer* m_mainSizer;
wxStaticText* m_staticText9;
wxChoice* m_cbTheme;
wxButton* m_btnSave;
wxButton* m_btnNew;
wxButton* m_btnRename;
wxButton* m_btnReset;
wxButton* m_btnOpenFolder;
wxPanel* m_panelThemeProperties;
wxBoxSizer* m_sizerThemeProperties;
wxStaticText* m_staticText6;
wxTextCtrl* m_txtThemeName;
wxStaticText* m_staticText7;
wxTextCtrl* m_txtFilename;
wxStaticText* m_lblThemePropertiesError;
wxStaticLine* m_staticline1;
wxBoxSizer* m_colorsMainSizer;
wxScrolledWindow* m_colorsListWindow;
wxFlexGridSizer* m_colorsGridSizer;
@ -58,14 +49,8 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
// Virtual event handlers, overide them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnSaveClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnNewClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnRenameClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnResetClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnThemeNameChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFilenameChar( wxKeyEvent& event ) { event.Skip(); }
virtual void OnFilenameChanged( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -43,7 +43,8 @@ const char* traceSettings = "SETTINGS";
SETTINGS_MANAGER::SETTINGS_MANAGER() :
m_common_settings( nullptr ), m_migration_source()
m_common_settings( nullptr ),
m_migration_source()
{
// Check if the settings directory already exists, and if not, perform a migration if possible
if( !MigrateIfNeeded() )
@ -95,8 +96,9 @@ void SETTINGS_MANAGER::Load()
void SETTINGS_MANAGER::Load( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr )
{
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
@ -120,8 +122,9 @@ void SETTINGS_MANAGER::Save()
void SETTINGS_MANAGER::Save( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr )
{
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
@ -135,9 +138,10 @@ void SETTINGS_MANAGER::Save( JSON_SETTINGS* aSettings )
void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
} );
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr )
{
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
{
@ -150,21 +154,17 @@ void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings )
COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( const wxString& aName )
{
if( m_color_settings.count( aName ) )
return m_color_settings.at( aName );
COLOR_SETTINGS* ret = nullptr;
try
{
ret = m_color_settings.at( aName );
}
catch( std::out_of_range& )
{
if( !aName.empty() )
ret = loadColorSettingsByName( aName );
if( !aName.empty() )
ret = loadColorSettingsByName( aName );
// This had better work
if( !ret )
ret = m_color_settings.at( "user" );
}
// This had better work
if( !ret )
ret = m_color_settings.at( "user" );
return ret;
}
@ -254,8 +254,10 @@ void SETTINGS_MANAGER::loadAllColorSettings()
registerColorSettings( "user" );
// Search for and load any other settings
COLOR_SETTINGS_LOADER loader(
[&]( const wxString& aFilename ) { registerColorSettings( aFilename ); } );
COLOR_SETTINGS_LOADER loader( [&]( const wxString& aFilename )
{
registerColorSettings( aFilename );
} );
wxDir colors_dir( GetColorSettingsPath() );
@ -264,13 +266,22 @@ void SETTINGS_MANAGER::loadAllColorSettings()
}
void SETTINGS_MANAGER::ReloadColorSettings()
{
m_color_settings.clear();
loadAllColorSettings();
}
void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std::string& aNamespace )
{
// The passed settings should already be managed
wxASSERT( std::find_if( m_color_settings.begin(), m_color_settings.end(),
[aSettings] ( const auto& el ) {
return el.second == aSettings;
} ) != m_color_settings.end() );
[aSettings] ( const std::pair<wxString, COLOR_SETTINGS*>& el )
{
return el.second->GetFilename() == aSettings->GetFilename();
}
) != m_color_settings.end() );
nlohmann::json::json_pointer ptr = JSON_SETTINGS::PointerFromString( aNamespace );

View File

@ -45,6 +45,7 @@
#include <view/view.h>
#include <ws_proxy_view_item.h>
#include <sch_base_frame.h>
#include <validators.h>
// Width and height of every (color-displaying / bitmap) button in dialog units
const wxSize BUTTON_SIZE( 24, 12 );
@ -62,16 +63,17 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF
m_currentSettings( nullptr ),
m_page( nullptr ),
m_titleBlock( nullptr ),
m_ws( nullptr ),
m_previewItems(),
m_buttons(),
m_filenameEdited( false ),
m_isNewTheme( false ),
m_dirty( false ),
m_copied( COLOR4D::UNSPECIFIED )
{
m_buttonSizePx = ConvertDialogToPixels( BUTTON_SIZE );
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
mgr.ReloadColorSettings();
COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
EESCHEMA_SETTINGS* app_settings = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
@ -86,6 +88,9 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF
m_cbTheme->SetSelection( pos );
}
m_cbTheme->Append( wxT( "---" ) );
m_cbTheme->Append( _( "New Theme..." ) );
m_currentSettings = new COLOR_SETTINGS( *current );
KIGFX::GAL_DISPLAY_OPTIONS options;
@ -127,7 +132,16 @@ PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS()
bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow()
{
return saveCurrentTheme();
if( !saveCurrentTheme( true ) )
return false;
m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( m_currentSettings );
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
EESCHEMA_SETTINGS* app_settings = settingsMgr.GetAppSettings<EESCHEMA_SETTINGS>();
app_settings->m_ColorTheme = m_currentSettings->GetFilename();
return true;
}
@ -138,49 +152,31 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataToWindow()
}
bool PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme()
bool PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme( bool aValidate )
{
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
COLOR4D bgcolor = m_currentSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
if( aValidate )
{
if( bgcolor == m_currentSettings->GetColor( layer )
&& layer != LAYER_SCHEMATIC_BACKGROUND && layer != LAYER_SHEET_BACKGROUND )
COLOR4D bgcolor = m_currentSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
{
wxString msg = _( "Some items have the same color as the background\n"
"and they will not be seen on the screen. Are you\n"
"sure you want to use these colors?" );
if( bgcolor == m_currentSettings->GetColor( layer )
&& layer != LAYER_SCHEMATIC_BACKGROUND && layer != LAYER_SHEET_BACKGROUND )
{
wxString msg = _( "Some items have the same color as the background\n"
"and they will not be seen on the screen. Are you\n"
"sure you want to use these colors?" );
if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
return false;
if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
return false;
break;
break;
}
}
}
bool dirty = m_dirty;
COLOR_SETTINGS* selected;
if( !m_isNewTheme )
{
int idx = m_cbTheme->GetSelection();
selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
}
else
{
if( !validateFilename() )
return false;
selected = settingsMgr.AddNewColorSettings( m_txtFilename->GetValue().ToStdString() );
selected->SetName( m_txtThemeName->GetValue() );
settingsMgr.Save( selected );
dirty = true;
m_cbTheme->SetSelection( m_cbTheme->Append( m_txtThemeName->GetValue(),
static_cast<void*>( selected ) ) );
}
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
COLOR_SETTINGS* selected = settingsMgr.GetColorSettings( m_currentSettings->GetFilename() );
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
{
@ -201,24 +197,10 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme()
color.Darken( 0.01 );
}
if( !dirty && selected->GetColor( layer ) != color )
dirty = true;
selected->SetColor( layer, color );
}
KIGFX::RENDER_SETTINGS* settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();
settings->LoadColors( selected );
if( dirty )
{
settingsMgr.SaveColorSettings( selected, "schematic" );
m_dirty = false;
}
EESCHEMA_SETTINGS* app_settings = settingsMgr.GetAppSettings<EESCHEMA_SETTINGS>();
app_settings->m_ColorTheme = selected->GetFilename();
settingsMgr.SaveColorSettings( selected, "schematic" );
return true;
}
@ -445,8 +427,6 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::SetColor( wxCommandEvent& event )
void PANEL_EESCHEMA_COLOR_SETTINGS::updateColor( SCH_LAYER_ID aLayer, const KIGFX::COLOR4D& aColor )
{
m_currentSettings->SetColor( aLayer, aColor );
m_dirty = true;
m_btnSave->Enable();
drawButton( m_buttons[aLayer], aColor );
@ -467,9 +447,6 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::OnBtnResetClicked( wxCommandEvent& event )
drawButton( button, defaultColor );
}
m_dirty = true;
m_btnSave->Enable();
updatePreview();
}
@ -512,140 +489,70 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::OnSize( wxSizeEvent& aEvent )
}
void PANEL_EESCHEMA_COLOR_SETTINGS::showThemeNamePanel( bool aShow )
{
m_panelThemeProperties->Show( aShow );
Layout();
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnBtnNewClicked( wxCommandEvent& event )
{
m_txtFilename->Enable();
m_txtThemeName->SetValue( "" );
m_txtFilename->SetValue( "" );
showThemeNamePanel();
m_btnSave->Enable();
m_txtThemeName->SetFocus();
m_filenameEdited = false;
m_isNewTheme = true;
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnBtnRenameClicked( wxCommandEvent& event )
{
// "User" theme can't be renamed, it is the default if no other themes exist
if( m_currentSettings->GetFilename() == "user" )
return;
m_isNewTheme = false;
m_txtFilename->Disable();
showThemeNamePanel();
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnBtnSaveClicked( wxCommandEvent& event )
{
if( ( !m_isNewTheme || validateFilename() ) && saveCurrentTheme() )
{
m_isNewTheme = false;
showThemeNamePanel( false );
m_btnSave->Disable();
}
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
{
// TODO(JE) If dirty here, we should prompt to save the previous theme first
int idx = m_cbTheme->GetSelection();
auto selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
int idx = m_cbTheme->GetSelection();
if( selected->GetFilename() != m_currentSettings->GetFilename() )
if( idx == m_cbTheme->GetCount() - 2 )
{
*m_currentSettings = *selected;
updatePreview();
for( auto pair : m_buttons )
drawButton( pair.second, m_currentSettings->GetColor( pair.first ) );
// separator; re-select active theme
m_cbTheme->SetStringSelection( m_currentSettings->GetName() );
return;
}
m_isNewTheme = false;
m_filenameEdited = false;
showThemeNamePanel( false );
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnThemeNameChanged( wxCommandEvent& event )
{
if( !m_filenameEdited )
m_txtFilename->SetValue( suggestFilename( m_txtThemeName->GetValue() ) );
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnFilenameChanged( wxCommandEvent& event )
{
}
void PANEL_EESCHEMA_COLOR_SETTINGS::OnFilenameChar( wxKeyEvent& event )
{
// Once the user has typed something in the filename box, stop suggesting things
m_filenameEdited = true;
if( !m_lblThemePropertiesError->GetLabel().empty() )
validateFilename();
event.Skip();
}
bool PANEL_EESCHEMA_COLOR_SETTINGS::validateFilename()
{
wxFileName fn( m_txtFilename->GetValue() );
fn.SetPath( Pgm().GetSettingsManager().GetColorSettingsPath() );
if( !fn.IsOk() )
if( idx == m_cbTheme->GetCount() - 1 )
{
m_lblThemePropertiesError->SetLabel( _( "Invalid filename" ) );
return false;
}
// New Theme...
if( fn.Exists() && m_isNewTheme )
if( !saveCurrentTheme( false ) )
return;
MODULE_NAME_CHAR_VALIDATOR themeNameValidator;
wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
dlg.SetTextValidator( themeNameValidator );
if( dlg.ShowModal() != wxID_OK )
return;
wxString themeName = dlg.GetValue();
wxFileName fn( themeName + wxT( ".json" ) );
fn.SetPath( SETTINGS_MANAGER::GetColorSettingsPath() );
if( fn.Exists() )
{
wxMessageBox( _( "Theme already exists!" ) );
return;
}
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
COLOR_SETTINGS* newSettings = settingsMgr.AddNewColorSettings( themeName );
newSettings->SetName( themeName );
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) );
idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
m_cbTheme->SetSelection( idx );
*m_currentSettings = *newSettings;
}
else
{
m_lblThemePropertiesError->SetLabel( _( "File already exists!" ) );
return false;
COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
if( selected->GetFilename() != m_currentSettings->GetFilename() )
{
if( !saveCurrentTheme( false ) )
return;
*m_currentSettings = *selected;
updatePreview();
for( auto pair : m_buttons )
drawButton( pair.second, m_currentSettings->GetColor( pair.first ) );
}
}
if( fn.GetExt() != "json" )
{
m_lblThemePropertiesError->SetLabel( _( "File must end in .json" ) );
return false;
}
return true;
}
wxString PANEL_EESCHEMA_COLOR_SETTINGS::suggestFilename( const wxString& aThemeName )
{
static const std::regex invalidChars( "[^-\\w_ ]+" );
static const std::regex whitespace( "\\s+" );
std::string themeName( aThemeName.ToUTF8() );
themeName = std::regex_replace( themeName, invalidChars, "" );
themeName = std::regex_replace( themeName, whitespace, "_" );
wxString filename( themeName.c_str(), wxConvUTF8 );
filename.MakeLower();
filename.Append( ".json" );
return filename;
}

View File

@ -53,20 +53,8 @@ protected:
void OnBtnResetClicked( wxCommandEvent& aEvent ) override;
void OnBtnRenameClicked( wxCommandEvent& aEvent ) override;
void OnThemeChanged( wxCommandEvent& aEvent ) override;
void OnBtnSaveClicked( wxCommandEvent& aEvent ) override;
void OnBtnNewClicked( wxCommandEvent& aEvent ) override;
void OnThemeNameChanged( wxCommandEvent& aEvent ) override;
void OnFilenameChanged( wxCommandEvent& aEvent ) override;
void OnFilenameChar( wxKeyEvent& aEvent ) override;
void OnSize( wxSizeEvent& aEvent ) override;
void ShowColorContextMenu( wxMouseEvent& aEvent, SCH_LAYER_ID aLayer );
@ -97,15 +85,9 @@ private:
std::map<SCH_LAYER_ID, wxBitmapButton*> m_buttons;
bool m_filenameEdited;
bool m_isNewTheme;
bool m_dirty;
KIGFX::COLOR4D m_copied;
bool saveCurrentTheme();
bool saveCurrentTheme( bool aValidate );
void createPreviewItems();
@ -118,12 +100,6 @@ private:
void updatePreview();
void zoomFitPreview();
bool validateFilename();
void showThemeNamePanel( bool aShow = true );
static wxString suggestFilename( const wxString& aThemeName );
};

View File

@ -174,6 +174,11 @@ public:
*/
bool GetPreviousVersionPaths( std::vector<wxString>* aName = nullptr );
/**
* Re-scans the color themes directory, reloading any changes it finds.
*/
void ReloadColorSettings();
/**
* Checks if a given path is probably a valid KiCad configuration directory.
* Actually it just checks if a file called "kicad_common" exists, because that's probably

View File

@ -199,7 +199,7 @@ void KICAD_MANAGER_FRAME::RecreateBaseHToolbar()
m_mainToolBar->AddTool( ID_BROWSE_IN_FILE_EXPLORER, wxEmptyString,
KiScaledBitmap( directory_browser_xpm, this ),
#ifdef __APPLE__
_( "Reveal project directory in Finder" ) );
_( "Reveal project folder in Finder" ) );
#else
_( "Open project directory in file explorer" ) );
#endif

View File

@ -815,7 +815,7 @@ void PCB_BASE_FRAME::UpdateGridSelectBox()
}
m_gridSelectBox->Append( wxT( "---" ) );
m_gridSelectBox->Append( _( "Edit user grid..." ) );
m_gridSelectBox->Append( _( "Edit User Grid..." ) );
m_gridSelectBox->SetSelection( icurr );
}

View File

@ -527,7 +527,7 @@ void PCB_EDIT_FRAME::UpdateTrackWidthSelectBox( wxChoice* aTrackWidthSelectBox,
if( aEdit )
{
aTrackWidthSelectBox->Append( wxT( "---" ) );
aTrackWidthSelectBox->Append( _( "Edit pre-defined sizes..." ) );
aTrackWidthSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
}
if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
@ -579,7 +579,7 @@ void PCB_EDIT_FRAME::UpdateViaSizeSelectBox( wxChoice* aViaSizeSelectBox, bool a
if( aEdit )
{
aViaSizeSelectBox->Append( wxT( "---" ) );
aViaSizeSelectBox->Append( _( "Edit pre-defined sizes..." ) );
aViaSizeSelectBox->Append( _( "Edit Pre-defined Sizes..." ) );
}
if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )