mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-24 07:54:13 +02:00
Merge pull request #1584 from Kellermorph/feature/terminal-label-split
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m38s
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m38s
Terminal labelling: option to draw label and number apart, and a Show name box for terminals
This commit is contained in:
@@ -191,6 +191,11 @@ void ProjectMainConfigPage::applyProjectConf()
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
if (m_project -> terminalLabelSplit() != terminal_label_split_rb_ -> isChecked()) {
|
||||
m_project -> setTerminalLabelSplit(terminal_label_split_rb_ -> isChecked());
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
//Following the application's rules stores nothing in the project
|
||||
WiringRules::Settings wiring_rules;
|
||||
if (!use_application_rules_cb_ -> isChecked()) {
|
||||
@@ -266,6 +271,27 @@ void ProjectMainConfigPage::initWidgets()
|
||||
"text. Uncheck to make them turn with the element, as before.",
|
||||
"tooltip"));
|
||||
|
||||
//How the terminals draw their label: a setting of this project,
|
||||
//so the same file draws the same way on every machine which
|
||||
//opens it, like every other choice of how the sheets are drawn
|
||||
terminal_label_gb_ = new QGroupBox(tr("Display of the terminal labelling", "group box title"));
|
||||
terminal_label_combined_rb_ = new QRadioButton(
|
||||
tr("Show the label and the terminal number in one field", "radio button label"));
|
||||
terminal_label_combined_rb_ -> setToolTip(tr(
|
||||
"A terminal's label (X1:1) is drawn as a whole, the way it has always been.",
|
||||
"tooltip"));
|
||||
terminal_label_split_rb_ = new QRadioButton(tr("Split the label and the terminal number",
|
||||
"radio button label"));
|
||||
terminal_label_split_rb_ -> setToolTip(tr(
|
||||
"The label (X1) is drawn in one field and the terminal number (1) in another, "
|
||||
"which a terminal symbol may place where it wants -- and hide when it must. "
|
||||
"A symbol without such a field shows the two, one under the other.",
|
||||
"tooltip"));
|
||||
terminal_label_help_ = new QLabel(tr("Only the drawing changes: what is written in the element, "
|
||||
"the numbering, the sorting and the exports keep the whole label.",
|
||||
"informative label"));
|
||||
terminal_label_help_ -> setWordWrap(true);
|
||||
|
||||
//How many wires a terminal may take (discussion #1158)
|
||||
wiring_rules_gb_ = new QGroupBox(tr("Conductors per terminal", "group box title"));
|
||||
use_application_rules_cb_ = new QCheckBox(tr("Use the application settings", "checkbox label"));
|
||||
@@ -335,6 +361,13 @@ void ProjectMainConfigPage::initLayout()
|
||||
main_layout0 -> addWidget(upright_symbol_texts_cb_);
|
||||
main_layout0 -> addSpacing(10);
|
||||
|
||||
QVBoxLayout *terminal_label_layout = new QVBoxLayout(terminal_label_gb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_combined_rb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_split_rb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_help_);
|
||||
main_layout0 -> addWidget(terminal_label_gb_);
|
||||
main_layout0 -> addSpacing(10);
|
||||
|
||||
QVBoxLayout *wiring_rules_layout = new QVBoxLayout(wiring_rules_gb_);
|
||||
wiring_rules_layout -> addWidget(use_application_rules_cb_);
|
||||
QHBoxLayout *max_wires_layout = new QHBoxLayout();
|
||||
@@ -369,6 +402,11 @@ void ProjectMainConfigPage::readValuesFromProject()
|
||||
const int wire_hops_index = wire_hops_cb_ -> findData(WireHops::toString(m_project -> wireHops()));
|
||||
wire_hops_cb_ -> setCurrentIndex(qMax(0, wire_hops_index));
|
||||
upright_symbol_texts_cb_ -> setChecked(m_project -> uprightSymbolTexts());
|
||||
if (m_project -> terminalLabelSplit()) {
|
||||
terminal_label_split_rb_ -> setChecked(true);
|
||||
} else {
|
||||
terminal_label_combined_rb_ -> setChecked(true);
|
||||
}
|
||||
|
||||
//The rules that apply: the project's own or the application's
|
||||
const WiringRules::Settings wiring_rules = m_project -> wiringRules();
|
||||
@@ -425,6 +463,7 @@ void ProjectMainConfigPage::adjustReadOnly()
|
||||
usage_reset_pb_ -> setDisabled(is_read_only);
|
||||
wire_hops_cb_ -> setDisabled(is_read_only);
|
||||
upright_symbol_texts_cb_ -> setDisabled(is_read_only);
|
||||
terminal_label_gb_ -> setDisabled(is_read_only);
|
||||
wiring_rules_gb_ -> setDisabled(is_read_only);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class QLabel;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class QPushButton;
|
||||
class QSpinBox;
|
||||
class QGroupBox;
|
||||
@@ -140,6 +141,10 @@ class ProjectMainConfigPage : public ProjectConfigPage {
|
||||
QLabel *wire_hops_label_;
|
||||
QComboBox *wire_hops_cb_;
|
||||
QCheckBox *upright_symbol_texts_cb_;
|
||||
QGroupBox *terminal_label_gb_;
|
||||
QRadioButton *terminal_label_combined_rb_;
|
||||
QRadioButton *terminal_label_split_rb_;
|
||||
QLabel *terminal_label_help_;
|
||||
QGroupBox *wiring_rules_gb_;
|
||||
QCheckBox *use_application_rules_cb_;
|
||||
QLabel *max_wires_label_;
|
||||
|
||||
@@ -262,6 +262,9 @@ void ElementInfoWidget::enableLiveEdit()
|
||||
if (m_freeze_cb) {
|
||||
connect(m_freeze_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
connect(m_label_shown_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_number_cb) {
|
||||
connect(m_number_cb, QOverload<int>::of(&QComboBox::activated), this, &ElementInfoWidget::apply);
|
||||
}
|
||||
@@ -283,6 +286,9 @@ void ElementInfoWidget::disableLiveEdit()
|
||||
if (m_freeze_cb) {
|
||||
disconnect(m_freeze_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
disconnect(m_label_shown_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_number_cb) {
|
||||
disconnect(m_number_cb, QOverload<int>::of(&QComboBox::activated), this, &ElementInfoWidget::apply);
|
||||
}
|
||||
@@ -307,6 +313,13 @@ void ElementInfoWidget::buildInterface()
|
||||
//line that currentInfo() then fills with "true"/"false".
|
||||
keys.removeAll(QStringLiteral("exclude_from_bom"));
|
||||
|
||||
//The terminal number is not a property of the element: it is
|
||||
//derived from its label, so an edit row here would store a value
|
||||
//nothing reads -- and the nomenclature query has no such column,
|
||||
//which is why the export does not offer it either. The number
|
||||
//stays a text variable (%{terminal_number}) of the element editor.
|
||||
keys.removeAll(QETInformation::ELMT_TERMINAL_NUMBER);
|
||||
|
||||
for (auto str : keys)
|
||||
{
|
||||
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
|
||||
@@ -318,6 +331,7 @@ void ElementInfoWidget::buildInterface()
|
||||
setupSchemeRow();
|
||||
setupNumberRow();
|
||||
setupFreezeRow();
|
||||
setupLabelShownRow();
|
||||
|
||||
m_add_custom_property_btn = new QPushButton(tr("Add a custom property"), this);
|
||||
connect(m_add_custom_property_btn, &QPushButton::clicked, this, [this]() { addCustomProperty(); });
|
||||
@@ -367,7 +381,8 @@ QStringList ElementInfoWidget::predefinedKeys() const
|
||||
keys << QETInformation::ELMT_FORMULA_ID
|
||||
<< QStringLiteral("auto_num_locked")
|
||||
<< QStringLiteral("potential_isolating")
|
||||
<< QStringLiteral("exclude_from_bom");
|
||||
<< QStringLiteral("exclude_from_bom")
|
||||
<< QStringLiteral("label_shown");
|
||||
|
||||
return keys;
|
||||
}
|
||||
@@ -672,6 +687,9 @@ void ElementInfoWidget::updateUi()
|
||||
m_freeze_cb->setChecked(m_element->isFreezeLabel());
|
||||
updateFreezeRow();
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
m_label_shown_cb->setChecked(m_element->labelShown());
|
||||
}
|
||||
refreshNumberRow();
|
||||
updateSuggestions();
|
||||
|
||||
@@ -759,6 +777,13 @@ DiagramContext ElementInfoWidget::currentInfo() const
|
||||
info_.addValue(QStringLiteral("exclude_from_bom"), m_exclude_from_bom_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
|
||||
}
|
||||
|
||||
// The name is drawn unless the element says otherwise: only a name
|
||||
// which is not drawn needs an information, so that elements which
|
||||
// draw it keep their files exactly as they are.
|
||||
if (m_label_shown_cb && !m_label_shown_cb->isChecked()) {
|
||||
info_.addValue(QStringLiteral("label_shown"), QStringLiteral("false"));
|
||||
}
|
||||
|
||||
//The element keeps following its numbering scheme as long as its
|
||||
//formula is left as it is; a formula edited by hand is its own.
|
||||
const DiagramContext &elmt_info = m_element->elementInformations();
|
||||
@@ -846,6 +871,38 @@ void ElementInfoWidget::updateFreezeRow()
|
||||
updateNumberRow();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementInfoWidget::setupLabelShownRow
|
||||
Add under the freeze box a check box which decides whether the name
|
||||
of this element is drawn on the sheet: the choice belongs to the
|
||||
placed element, not to the symbol, so everyone can decide for
|
||||
himself.
|
||||
*/
|
||||
void ElementInfoWidget::setupLabelShownRow()
|
||||
{
|
||||
//The box means something for a terminal only, so it is drawn
|
||||
//for a terminal only - the same rule as the function separation
|
||||
//box just below it.
|
||||
if (!m_element || m_element->elementData().m_type != ElementData::Terminal) {
|
||||
return;
|
||||
}
|
||||
m_label_shown_cb = new QCheckBox(tr("Show name"), this);
|
||||
m_label_shown_cb->setObjectName(QStringLiteral("m_label_shown_cb"));
|
||||
m_label_shown_cb->setToolTip(tr("Untick to not draw the name of this element on the sheet: "
|
||||
"its data is kept, and a terminal keeps its number."));
|
||||
|
||||
int row = ui->scroll_vlayout->indexOf(m_freeze_cb);
|
||||
if (row < 0) {
|
||||
ElementInfoPartWidget *label = infoPartWidgetForKey(QETInformation::ELMT_LABEL);
|
||||
row = label ? ui->scroll_vlayout->indexOf(label) : -1;
|
||||
}
|
||||
if (row >= 0) {
|
||||
ui->scroll_vlayout->insertWidget(row + 1, m_label_shown_cb);
|
||||
} else {
|
||||
ui->scroll_vlayout->addWidget(m_label_shown_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementInfoWidget::setupNumberRow
|
||||
Add under the numbering a list of the numbers the element may be given
|
||||
|
||||
@@ -76,6 +76,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
||||
void updateSuggestions();
|
||||
void setupSchemeRow();
|
||||
void setupFreezeRow();
|
||||
void setupLabelShownRow();
|
||||
void setupNumberRow();
|
||||
void refreshNumberRow();
|
||||
void updateNumberRow();
|
||||
@@ -103,6 +104,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
|
||||
QCheckBox *m_exclude_from_bom_cb = nullptr;
|
||||
QComboBox *m_scheme_cb = nullptr;
|
||||
QCheckBox *m_freeze_cb = nullptr;
|
||||
QCheckBox *m_label_shown_cb = nullptr;
|
||||
QWidget *m_number_row = nullptr;
|
||||
QComboBox *m_number_cb = nullptr;
|
||||
int m_number_current = -1; ///< the number the element has, -1 if unknown
|
||||
|
||||
@@ -75,6 +75,15 @@ quint64 s_last_session = 0;
|
||||
const QString EXCLUDE_FROM_BOM = QStringLiteral("exclude_from_bom");
|
||||
const QString AUTO_NUM_LOCKED = QStringLiteral("auto_num_locked");
|
||||
const QString POTENTIAL_ISOLATING = QStringLiteral("potential_isolating");
|
||||
//The name is drawn unless the element says otherwise (@sa
|
||||
//Element::labelShown): an element which never got the box unticked
|
||||
//has no information for it, and counts as "shown".
|
||||
const QString LABEL_SHOWN = QStringLiteral("label_shown");
|
||||
|
||||
bool flagDefaultIsOn(const QString &key)
|
||||
{
|
||||
return key == LABEL_SHOWN;
|
||||
}
|
||||
|
||||
QString flagText(bool on)
|
||||
{
|
||||
@@ -449,7 +458,8 @@ void MultiElementInfoWidget::buildInterface()
|
||||
const QList<QPair<QString, QString>> flags {
|
||||
{EXCLUDE_FROM_BOM, tr("Exclude from the bill of materials")},
|
||||
{POTENTIAL_ISOLATING, tr("Function separation")},
|
||||
{AUTO_NUM_LOCKED, tr("Exclude from automatic numbering")}
|
||||
{AUTO_NUM_LOCKED, tr("Exclude from automatic numbering")},
|
||||
{LABEL_SHOWN, tr("Show name")}
|
||||
};
|
||||
for (const auto &pair : flags)
|
||||
{
|
||||
@@ -486,6 +496,9 @@ void MultiElementInfoWidget::buildInterface()
|
||||
QStringList keys = QETInformation::elementInfoKeys();
|
||||
//It has its own check box above, see ElementInfoWidget::buildInterface
|
||||
keys.removeAll(EXCLUDE_FROM_BOM);
|
||||
//Not an editable property but derived from the label, see
|
||||
//ElementInfoWidget::buildInterface
|
||||
keys.removeAll(QETInformation::ELMT_TERMINAL_NUMBER);
|
||||
|
||||
int line = 0;
|
||||
for (const QString &key : std::as_const(keys))
|
||||
@@ -588,12 +601,19 @@ void MultiElementInfoWidget::fillRows()
|
||||
|
||||
for (Flag *flag : std::as_const(m_flags))
|
||||
{
|
||||
//"Show name" means something for a terminal only, so it is
|
||||
//shown for terminals only - the same rule as the two flags
|
||||
//before it.
|
||||
flag->check->setVisible(flag->key == EXCLUDE_FROM_BOM || all_terminals);
|
||||
flag->restore->setVisible(flag->check->isVisible());
|
||||
|
||||
int on = 0;
|
||||
for (Element *element : list) {
|
||||
if (QET::infoFlagIsTrue(m_snapshot.value(element).value(flag->key).toString())) {
|
||||
const QVariant value = m_snapshot.value(element).value(flag->key);
|
||||
const bool is_on = value.isValid()
|
||||
? QET::infoFlagIsTrue(value.toString())
|
||||
: flagDefaultIsOn(flag->key);
|
||||
if (is_on) {
|
||||
++on;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user