add font color of the conductors

This commit is contained in:
Simon De Backer 2020-06-20 16:27:25 +02:00 committed by Laurent Trinques
parent 53447b41c9
commit ddf88bbed7
5 changed files with 225 additions and 194 deletions

View File

@ -222,6 +222,7 @@ void SingleLineProperties::fromXml(QDomElement &e) {
ConductorProperties::ConductorProperties() :
type(Multi),
color(Qt::black),
text_color(Qt::black),
text("_"),
text_size(9),
cond_size(1),
@ -259,6 +260,7 @@ void ConductorProperties::toXml(QDomElement &e) const
singleLineProperties.toXml(e);
e.setAttribute("num", text);
e.setAttribute("text_color", text_color.name());
e.setAttribute("formula", m_formula);
e.setAttribute("function", m_function);
e.setAttribute("tension-protocol", m_tension_protocol);
@ -295,7 +297,7 @@ void ConductorProperties::fromXml(QDomElement &e)
QString bicolor_str = e.attribute("bicolor", "false");
m_bicolor = bicolor_str == "true"? true : false;
QColor xml_color_2 = QColor(e.attribute("color2"));
QColor xml_color_2 = QColor(e.attribute("color2"));
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
@ -313,6 +315,9 @@ void ConductorProperties::fromXml(QDomElement &e)
type = Multi;
text = e.attribute("num");
// get text color
QColor xml_text_color= QColor(e.attribute("text_color"));
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
m_formula = e.attribute("formula");
m_function = e.attribute("function");
m_tension_protocol = e.attribute("tension-protocol");
@ -348,6 +353,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
settings.setValue(prefix + "style", writeStyle());
settings.setValue(prefix + "type", typeToString(type));
settings.setValue(prefix + "text", text);
settings.setValue(prefix + "text_color", text_color.name());
settings.setValue(prefix + "formula", m_formula);
settings.setValue(prefix + "function", m_function);
settings.setValue(prefix + "tension-protocol", m_tension_protocol);
@ -388,6 +394,8 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
singleLineProperties.fromSettings(settings, prefix);
text = settings.value(prefix + "text", "_").toString();
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
m_formula = settings.value(prefix + "formula", "").toString();
m_function = settings.value(prefix + "function", "").toString();
m_tension_protocol = settings.value(prefix + "tension-protocol", "").toString();
@ -441,6 +449,7 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
m_color_2 = cp.m_color_2;
m_dash_size = cp.m_dash_size;
text = cp.text;
text_color = cp.text_color;
m_formula = cp.m_formula;
m_function = cp.m_function;
m_tension_protocol = cp.m_tension_protocol;
@ -521,6 +530,17 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
text = s_value;
equal = true;
//text color
c_value = clist.first().text_color;
for(ConductorProperties cp : clist)
{
if (cp.text_color != c_value)
equal = false;
}
if (equal)
text_color = c_value;
equal = true;
//formula
s_value = clist.first().m_formula;
for(ConductorProperties cp : clist)
@ -695,6 +715,7 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const
other.m_dash_size == m_dash_size &&\
other.style == style &&\
other.text == text &&\
other.text_color == text_color &&\
other.m_formula == m_formula &&\
other.m_function == m_function &&\
other.m_tension_protocol == m_tension_protocol &&\

View File

@ -79,8 +79,9 @@ class ConductorProperties
//Attributes
ConductorType type;
QColor color,
m_color_2;
QColor color,
m_color_2,
text_color;
QString text,
m_function,

View File

@ -1552,6 +1552,7 @@ void Conductor::setProperties(const ConductorProperties &property)
QFont font = m_text_item->font();
font.setPointSize(m_properties.text_size);
m_text_item->setFont(font);
m_text_item->setColor(m_properties.text_color);
if (m_properties.type != ConductorProperties::Multi)
m_text_item->setVisible(false);

View File

@ -95,6 +95,7 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert
ui->m_phase_slider -> setValue (m_properties.singleLineProperties.phasesCount());
ui->m_color_kpb -> setColor(m_properties.color);
ui->m_color_2_kpb -> setColor(m_properties.m_color_2);
ui->m_text_color_kpb -> setColor(m_properties.text_color);
ui->m_horiz_cb->setCurrentIndex(m_properties.m_horizontal_alignment == Qt::AlignTop? 0 : 1);
ui->m_verti_cb->setCurrentIndex(m_properties.m_vertical_alignment == Qt::AlignLeft? 0 : 1);
@ -122,6 +123,7 @@ ConductorProperties ConductorPropertiesWidget::properties() const
properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
properties_.m_formula = ui->m_formula_le->text();
properties_.text = ui -> m_text_le -> text();
properties_.text_color = ui -> m_text_color_kpb->color();
properties_.m_function = ui -> m_function_le->text();
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
properties_.m_wire_color = ui -> m_wire_color_le->text();

View File

@ -7,14 +7,14 @@
<x>0</x>
<y>0</y>
<width>662</width>
<height>346</height>
<height>372</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
@ -51,153 +51,169 @@
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="m_one_text_per_folio_cb">
<property name="toolTip">
<string>activer l'option un texte par potentiel</string>
</property>
<property name="text">
<string>Afficher un texte de potentiel par folio. </string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="4" column="0">
<widget class="QLabel" name="m_autonum_label">
<property name="text">
<string>Autonumérotation</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tension / Protocole :</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLineEdit" name="m_tension_protocol_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Fonction :</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="m_show_text_cb">
<property name="toolTip">
<string>Texte visible</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="m_function_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Texte :</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Formule du texte :</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="m_edit_autonum_pb">
<property name="toolTip">
<string>éditer les numérotations</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Taille du texte :</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Couleur du conducteur</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLineEdit" name="m_wire_color_le"/>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_text_size_sb">
<property name="toolTip">
<string>Taille du texte</string>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_formula_le"/>
</item>
<item row="4" column="4">
<widget class="QLineEdit" name="m_wire_section_le"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_text_le">
<property name="toolTip">
<string>Texte</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Section du conducteur</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
</layout>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Taille du texte :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="m_text_size_sb">
<property name="toolTip">
<string>Taille du texte</string>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Fonction :</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="m_function_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Formule du texte :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_formula_le"/>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tension / Protocole :</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLineEdit" name="m_tension_protocol_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Texte :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_text_le">
<property name="toolTip">
<string>Texte</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="m_show_text_cb">
<property name="toolTip">
<string>Texte visible</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Couleur du conducteur</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLineEdit" name="m_wire_color_le"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Text color:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KColorButton" name="m_text_color_kpb"/>
</item>
<item row="4" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Section du conducteur</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QLineEdit" name="m_wire_section_le"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_autonum_label">
<property name="text">
<string>Autonumérotation</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="m_edit_autonum_pb">
<property name="toolTip">
<string>éditer les numérotations</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
<item row="7" column="0" colspan="5">
<layout class="QGridLayout" name="m_text_angle_gl">
<item row="1" column="1">
<widget class="QComboBox" name="m_horiz_cb">
@ -239,19 +255,9 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="6" column="0" colspan="2">
<layout class="QVBoxLayout" name="m_autonum_layout"/>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="m_one_text_per_folio_cb">
<property name="toolTip">
<string>activer l'option un texte par potentiel</string>
</property>
<property name="text">
<string>Afficher un texte de potentiel par folio. </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -405,7 +411,17 @@
<string>Apparence</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="4" column="0">
<item row="0" column="1">
<widget class="KColorButton" name="m_color_kpb"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Taille :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -418,29 +434,13 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Couleur du conducteur</string>
<string>Style du conducteur</string>
</property>
<property name="text">
<string>Couleur :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="m_cond_size_sb">
<property name="minimum">
<double>0.400000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
<property name="singleStep">
<double>0.200000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
<string>Style :</string>
</property>
</widget>
</item>
@ -489,10 +489,19 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Taille :</string>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="m_cond_size_sb">
<property name="minimum">
<double>0.400000000000000</double>
</property>
<property name="maximum">
<double>20.000000000000000</double>
</property>
<property name="singleStep">
<double>0.200000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
@ -503,19 +512,16 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="toolTip">
<string>Style du conducteur</string>
<string>Couleur du conducteur</string>
</property>
<property name="text">
<string>Style :</string>
<string>Couleur :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KColorButton" name="m_color_kpb"/>
</item>
</layout>
</widget>
</widget>