From 17c34c88dcc5d71a4201320a12cc921835aa8d6c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 28 Feb 2023 12:58:58 -0800 Subject: [PATCH] Avoid forcing all units When the enduser is not allowed to change the status of "common to all units", then it should be disabled Fixes https://gitlab.com/kicad/code/kicad/issues/14084 (cherry picked from commit 3207d1386e820f7d2105186b9a1773bb953e17bc) --- eeschema/dialogs/dialog_lib_shape_properties.cpp | 3 ++- eeschema/dialogs/dialog_lib_text_properties.cpp | 10 ++++++++-- eeschema/dialogs/dialog_lib_textbox_properties.cpp | 6 +++++- eeschema/dialogs/dialog_pin_properties.cpp | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_shape_properties.cpp b/eeschema/dialogs/dialog_lib_shape_properties.cpp index e8fc57db14..2928f095bc 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties.cpp @@ -119,7 +119,8 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow() wxFAIL_MSG( "Line type not found in the type lookup map" ); m_privateCheckbox->SetValue( m_shape->IsPrivate() ); - m_checkApplyToAllUnits->SetValue( m_shape->GetUnit() == 0 ); + m_checkApplyToAllUnits->SetValue( + symbol && symbol->GetUnitCount() > 1 && m_shape->GetUnit() == 0 ); m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); m_checkApplyToAllConversions->SetValue( m_shape->GetConvert() == 0 ); diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index 03422a97ae..196a3fc42f 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -122,6 +122,8 @@ DIALOG_LIB_TEXT_PROPERTIES::~DIALOG_LIB_TEXT_PROPERTIES() bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() { + LIB_SYMBOL* symbol = m_graphicText->GetParent(); + if( m_graphicText ) { m_textSize.SetValue( m_graphicText->GetTextWidth() ); @@ -135,7 +137,8 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_bold->Check( m_graphicText->IsBold() ); m_privateCheckbox->SetValue( m_graphicText->IsPrivate() ); - m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 ); + m_CommonUnit->SetValue( + symbol && symbol->GetUnitCount() > 1 && m_graphicText->GetUnit() == 0 ); m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 ); if( m_graphicText->GetTextAngle().IsHorizontal() ) @@ -164,7 +167,8 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_textSize.SetValue( schIUScale.MilsToIU( cfg->m_Defaults.text_size ) ); - m_CommonUnit->SetValue( !tools->GetDrawSpecificUnit() ); + m_CommonUnit->SetValue( + symbol && symbol->GetUnitCount() > 1 && !tools->GetDrawSpecificUnit() ); m_CommonConvert->SetValue( !tools->GetDrawSpecificConvert() ); if( tools->GetLastTextAngle().IsHorizontal() ) @@ -173,6 +177,8 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_vertical->Check(); } + m_CommonUnit->Enable( symbol && symbol->GetUnitCount() > 1 ); + return true; } diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.cpp b/eeschema/dialogs/dialog_lib_textbox_properties.cpp index 86586ca0c0..512ccaf584 100644 --- a/eeschema/dialogs/dialog_lib_textbox_properties.cpp +++ b/eeschema/dialogs/dialog_lib_textbox_properties.cpp @@ -141,6 +141,8 @@ bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; + LIB_SYMBOL* symbol = m_currentText->GetParent(); + m_textCtrl->SetValue( m_currentText->GetText() ); m_textCtrl->EmptyUndoBuffer(); @@ -204,7 +206,9 @@ bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow() m_fillColorSwatch->Enable( m_currentText->IsFilled() ); m_privateCheckbox->SetValue( m_currentText->IsPrivate() ); - m_CommonUnit->SetValue( m_currentText->GetUnit() == 0 ); + m_CommonUnit->SetValue( + symbol && symbol->GetUnitCount() > 1 && m_currentText->GetUnit() == 0 ); + m_CommonUnit->Enable( symbol && symbol->GetUnitCount() > 1 ); m_CommonConvert->SetValue( m_currentText->GetConvert() == 0 ); return true; diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index f409f6d6a9..b7d5766260 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -266,7 +266,7 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() m_numberSize.SetValue( m_pin->GetNumberTextSize() ); m_pinLength.SetValue( m_pin->GetLength() ); m_checkApplyToAllParts->Enable( m_pin->GetParent()->IsMulti() ); - m_checkApplyToAllParts->SetValue( m_pin->GetUnit() == 0 ); + m_checkApplyToAllParts->SetValue( m_pin->GetParent()->IsMulti() && m_pin->GetUnit() == 0 ); m_checkApplyToAllConversions->SetValue( m_pin->GetConvert() == 0 ); m_checkShow->SetValue( m_pin->IsVisible() );