diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index 974dbd1af2..be13fd3148 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -117,8 +117,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) if( idx == static_cast( m_cbTheme->GetCount() ) - 2 ) { - // separator; re-select active theme - m_cbTheme->SetStringSelection( m_currentSettings->GetName() ); + m_cbTheme->SetStringSelection( GetSettingsDropdownName( m_currentSettings ) ); return; } @@ -217,10 +216,7 @@ void PANEL_COLOR_SETTINGS::createThemeList( const wxString& aCurrent ) for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) { - wxString name = settings->GetName(); - - if( settings->IsReadOnly() ) - name += wxS( " " ) + _( "(read-only)" ); + wxString name = GetSettingsDropdownName( settings ); int pos = m_cbTheme->Append( name, static_cast( settings ) ); @@ -286,6 +282,8 @@ void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLaye auto selected = static_cast( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) ); + wxCHECK_RET( selected, wxT( "Invalid color theme selected" ) ); + COLOR4D current = m_currentSettings->GetColor( aLayer ); COLOR4D saved = selected->GetColor( aLayer ); bool readOnly = m_currentSettings->IsReadOnly(); @@ -379,3 +377,14 @@ bool PANEL_COLOR_SETTINGS::saveCurrentTheme( bool aValidate ) return true; } + + +wxString PANEL_COLOR_SETTINGS::GetSettingsDropdownName(COLOR_SETTINGS* aSettings) +{ + wxString name = aSettings->GetName(); + + if( aSettings->IsReadOnly() ) + name += wxS( " " ) + _( "(read-only)" ); + + return name; +} \ No newline at end of file diff --git a/include/dialogs/panel_color_settings.h b/include/dialogs/panel_color_settings.h index 36bf236670..0d41e638ad 100644 --- a/include/dialogs/panel_color_settings.h +++ b/include/dialogs/panel_color_settings.h @@ -97,6 +97,11 @@ protected: */ virtual void onColorChanged() {} + /** + * Retrieves the drop down name to be displayed for a color setting + */ + wxString GetSettingsDropdownName( COLOR_SETTINGS* aSettings ); + COLOR_SETTINGS* m_currentSettings; std::map m_labels;