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

View File

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

View File

@ -1552,6 +1552,7 @@ void Conductor::setProperties(const ConductorProperties &property)
QFont font = m_text_item->font(); QFont font = m_text_item->font();
font.setPointSize(m_properties.text_size); font.setPointSize(m_properties.text_size);
m_text_item->setFont(font); m_text_item->setFont(font);
m_text_item->setColor(m_properties.text_color);
if (m_properties.type != ConductorProperties::Multi) if (m_properties.type != ConductorProperties::Multi)
m_text_item->setVisible(false); 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_phase_slider -> setValue (m_properties.singleLineProperties.phasesCount());
ui->m_color_kpb -> setColor(m_properties.color); ui->m_color_kpb -> setColor(m_properties.color);
ui->m_color_2_kpb -> setColor(m_properties.m_color_2); 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_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); 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_.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_.m_formula = ui->m_formula_le->text();
properties_.text = ui -> m_text_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_function = ui -> m_function_le->text();
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text(); properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
properties_.m_wire_color = ui -> m_wire_color_le->text(); properties_.m_wire_color = ui -> m_wire_color_le->text();

View File

@ -7,14 +7,14 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>662</width> <width>662</width>
<height>346</height> <height>372</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QGridLayout" name="gridLayout_9">
<item> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>0</number>
@ -51,153 +51,169 @@
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </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"> <item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_3"> <widget class="QLabel" name="label_2">
<item row="4" column="0"> <property name="text">
<widget class="QLabel" name="m_autonum_label"> <string>Taille du texte :</string>
<property name="text"> </property>
<string>Autonumérotation</string> </widget>
</property> </item>
</widget> <item row="1" column="1">
</item> <widget class="QSpinBox" name="m_text_size_sb">
<item row="2" column="3"> <property name="toolTip">
<widget class="QLabel" name="label_9"> <string>Taille du texte</string>
<property name="text"> </property>
<string>Tension / Protocole :</string> <property name="wrapping">
</property> <bool>false</bool>
</widget> </property>
</item> <property name="buttonSymbols">
<item row="2" column="4"> <enum>QAbstractSpinBox::UpDownArrows</enum>
<widget class="QLineEdit" name="m_tension_protocol_le"> </property>
<property name="clearButtonEnabled"> <property name="prefix">
<bool>true</bool> <string/>
</property> </property>
</widget> <property name="minimum">
</item> <number>3</number>
<item row="1" column="3"> </property>
<widget class="QLabel" name="label_8"> <property name="maximum">
<property name="text"> <number>99</number>
<string>Fonction :</string> </property>
</property> </widget>
</widget> </item>
</item> <item row="1" column="3">
<item row="3" column="2"> <widget class="QLabel" name="label_8">
<widget class="QCheckBox" name="m_show_text_cb"> <property name="text">
<property name="toolTip"> <string>Fonction :</string>
<string>Texte visible</string> </property>
</property> </widget>
<property name="text"> </item>
<string/> <item row="1" column="4">
</property> <widget class="QLineEdit" name="m_function_le">
<property name="checked"> <property name="clearButtonEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="2" column="0">
<widget class="QLineEdit" name="m_function_le"> <widget class="QLabel" name="label_11">
<property name="clearButtonEnabled"> <property name="text">
<bool>true</bool> <string>Formule du texte :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="2" column="1">
<widget class="QLabel" name="label"> <widget class="QLineEdit" name="m_formula_le"/>
<property name="text"> </item>
<string>Texte :</string> <item row="2" column="3">
</property> <widget class="QLabel" name="label_9">
</widget> <property name="text">
</item> <string>Tension / Protocole :</string>
<item row="2" column="0"> </property>
<widget class="QLabel" name="label_11"> </widget>
<property name="text"> </item>
<string>Formule du texte :</string> <item row="2" column="4">
</property> <widget class="QLineEdit" name="m_tension_protocol_le">
</widget> <property name="clearButtonEnabled">
</item> <bool>true</bool>
<item row="4" column="2"> </property>
<widget class="QPushButton" name="m_edit_autonum_pb"> </widget>
<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>
</item> </item>
<item row="3" column="0"> <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"> <layout class="QGridLayout" name="m_text_angle_gl">
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="m_horiz_cb"> <widget class="QComboBox" name="m_horiz_cb">
@ -239,19 +255,9 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item row="6" column="0" colspan="2">
<layout class="QVBoxLayout" name="m_autonum_layout"/> <layout class="QVBoxLayout" name="m_autonum_layout"/>
</item> </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> </layout>
</widget> </widget>
</item> </item>
@ -405,7 +411,17 @@
<string>Apparence</string> <string>Apparence</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_4"> <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"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -418,29 +434,13 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_7">
<property name="toolTip"> <property name="toolTip">
<string>Couleur du conducteur</string> <string>Style du conducteur</string>
</property> </property>
<property name="text"> <property name="text">
<string>Couleur :</string> <string>Style :</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>
</property> </property>
</widget> </widget>
</item> </item>
@ -489,10 +489,19 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="1">
<widget class="QLabel" name="label_10"> <widget class="QDoubleSpinBox" name="m_cond_size_sb">
<property name="text"> <property name="minimum">
<string>Taille :</string> <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> </property>
</widget> </widget>
</item> </item>
@ -503,19 +512,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_6">
<property name="toolTip"> <property name="toolTip">
<string>Style du conducteur</string> <string>Couleur du conducteur</string>
</property> </property>
<property name="text"> <property name="text">
<string>Style :</string> <string>Couleur :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="KColorButton" name="m_color_kpb"/>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>