[TD]fix line numbering in preferences

- resolve conflict between comboBox currentIndex [0,n] and
  line numbering [1, n]
This commit is contained in:
wandererfan
2023-12-02 09:44:58 -05:00
committed by WandererFan
parent 4ea5c2b611
commit 9e7f21fcb2
2 changed files with 18 additions and 8 deletions

View File

@@ -439,24 +439,31 @@ std::string Preferences::lineElementsLocation()
return prefDir;
}
// Note: line numbering starts at 1, but the saved parameter is the position of the
// line style in the list, starting at 0. We add 1 to the stored value to get the
// correct line number.
int Preferences::SectionLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleSection", 4);
// default is line #4 long dash dotted, which is index 3
return getPreferenceGroup("Decorations")->GetInt("LineStyleSection", 3) + 1;
}
int Preferences::CenterLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleCenter", 10);
// default is line #5 long dash double dotted, which is index 4
return getPreferenceGroup("Decorations")->GetInt("LineStyleCenter", 4) + 1;
}
int Preferences::HighlightLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHighLight", 10);
// default is line #2 dashed, which is index 1
return getPreferenceGroup("Decorations")->GetInt("LineStyleHighLight", 1) + 1;
}
int Preferences::HiddenLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1);
// default is line #2 dashed, which is index 1
return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1) + 1;
}
int Preferences::LineSpacingISO()

View File

@@ -130,28 +130,31 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings()
ui->pcbLineStandard->setCurrentIndex(Preferences::lineStandard());
}
// note: line numbering starts at 1, not 0. we set the preference to the
// currentIndex in saveSettings, Preferences returns the actual line number,
// so we need to subtract 1 here to get the index.
ui->pcbSectionStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbSectionStyle, m_lineGenerator);
if (ui->pcbSectionStyle->count() > Preferences::SectionLineStyle()) {
ui->pcbSectionStyle->setCurrentIndex(Preferences::SectionLineStyle());
ui->pcbSectionStyle->setCurrentIndex(Preferences::SectionLineStyle() - 1);
}
ui->pcbCenterStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbCenterStyle, m_lineGenerator);
if (ui->pcbCenterStyle->count() > Preferences::CenterLineStyle()) {
ui->pcbCenterStyle->setCurrentIndex(Preferences::CenterLineStyle());
ui->pcbCenterStyle->setCurrentIndex(Preferences::CenterLineStyle() - 1);
}
ui->pcbHighlightStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbHighlightStyle, m_lineGenerator);
if (ui->pcbHighlightStyle->count() > Preferences::HighlightLineStyle()) {
ui->pcbHighlightStyle->setCurrentIndex(Preferences::HighlightLineStyle());
ui->pcbHighlightStyle->setCurrentIndex(Preferences::HighlightLineStyle() - 1);
}
ui->pcbHiddenStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbHiddenStyle, m_lineGenerator);
if (ui->pcbHiddenStyle->count() > Preferences::HiddenLineStyle()) {
ui->pcbHiddenStyle->setCurrentIndex(Preferences::HiddenLineStyle());
ui->pcbHiddenStyle->setCurrentIndex(Preferences::HiddenLineStyle() - 1);
}
}