diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index ddbf77c03..99c5b281b 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -220,6 +220,7 @@ ConductorProperties::ConductorProperties() : type(Multi), color(Qt::black), text("_"), + text_size(9), verti_rotate_text(270), horiz_rotate_text(0), style(Qt::SolidLine) @@ -248,6 +249,7 @@ void ConductorProperties::toXml(QDomElement &e) const { singleLineProperties.toXml(e); } else if (type == Multi) { e.setAttribute("num", text); + e.setAttribute("numsize", text_size); e.setAttribute("vertirotatetext", verti_rotate_text); e.setAttribute("horizrotatetext", horiz_rotate_text); } @@ -284,6 +286,7 @@ void ConductorProperties::fromXml(QDomElement &e) { } else { // recupere le champ de texte text = e.attribute("num"); + text_size = e.attribute("numsize", QString::number(9)).toInt(); verti_rotate_text = e.attribute("vertirotatetext").toDouble(); horiz_rotate_text = e.attribute("horizrotatetext").toDouble(); type = Multi; @@ -299,6 +302,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 + "textsize", QString::number(text_size)); settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text)); settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text)); singleLineProperties.toSettings(settings, prefix); @@ -327,6 +331,7 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi } singleLineProperties.fromSettings(settings, prefix); text = settings.value(prefix + "text", "_").toString(); + text_size = settings.value(prefix + "textsize", "7").toInt(); verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble(); horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble(); @@ -350,12 +355,13 @@ QString ConductorProperties::typeToString(ConductorType t) { @param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison @return true si les deux ensembles de proprietes sont identiques, false sinon */ -int ConductorProperties::operator==(const ConductorProperties &other) { +bool ConductorProperties::operator==(const ConductorProperties &other) const{ return( other.type == type &&\ other.color == color &&\ other.style == style &&\ other.text == text &&\ + other.text_size == text_size &&\ other.verti_rotate_text == verti_rotate_text &&\ other.horiz_rotate_text == horiz_rotate_text &&\ other.singleLineProperties == singleLineProperties @@ -366,12 +372,13 @@ int ConductorProperties::operator==(const ConductorProperties &other) { @param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison @return true si les deux ensembles de proprietes sont differents, false sinon */ -int ConductorProperties::operator!=(const ConductorProperties &other) { +bool ConductorProperties::operator!=(const ConductorProperties &other) const{ return( other.type != type ||\ other.color != color ||\ other.style != style ||\ other.text != text ||\ + other.text_size != text_size ||\ other.verti_rotate_text != verti_rotate_text ||\ other.horiz_rotate_text != horiz_rotate_text ||\ other.singleLineProperties != singleLineProperties diff --git a/sources/conductorproperties.h b/sources/conductorproperties.h index aeb50dacc..d128f845f 100644 --- a/sources/conductorproperties.h +++ b/sources/conductorproperties.h @@ -79,6 +79,8 @@ class ConductorProperties { QColor color; /// Texte displayed for multiline conductors QString text; + /// size of text + int text_size; /// rotation angle texte double verti_rotate_text; double horiz_rotate_text; @@ -96,8 +98,8 @@ class ConductorProperties { static QString typeToString(ConductorType); // operators - int operator==(const ConductorProperties &); - int operator!=(const ConductorProperties &); + bool operator==(const ConductorProperties &) const; + bool operator!=(const ConductorProperties &) const; private: void readStyle(const QString &); diff --git a/sources/conductorpropertieswidget.cpp b/sources/conductorpropertieswidget.cpp index 7a15f132a..5ac44317b 100644 --- a/sources/conductorpropertieswidget.cpp +++ b/sources/conductorpropertieswidget.cpp @@ -63,8 +63,13 @@ void ConductorPropertiesWidget::buildInterface() { QHBoxLayout *multiline_layout = new QHBoxLayout(); QLabel *text = new QLabel(tr("Texte :")); text_field = new QLineEdit(); + QLabel *size_text = new QLabel(tr("Taille"), this); + text_size_sb = new QSpinBox(this); + text_size_sb->setRange(5,9); multiline_layout -> addWidget(text); multiline_layout -> addWidget(text_field); + multiline_layout -> addWidget(size_text); + multiline_layout -> addWidget(text_size_sb); QGridLayout *rotate_text_layout = new QGridLayout; QLabel *rotate_label = new QLabel(tr("Rotation du texte sur conducteur :")); @@ -179,6 +184,7 @@ void ConductorPropertiesWidget::buildConnections() { connect(color_button, SIGNAL(clicked()), this, SLOT(chooseColor())); connect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); connect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); + connect(text_size_sb, SIGNAL(valueChanged(int)), this, SLOT(updateConfig())); } /** @@ -225,6 +231,7 @@ void ConductorPropertiesWidget::destroyConnections() { disconnect(line_style, SIGNAL(currentIndexChanged(int)), this, SLOT(updateConfig())); disconnect(verti_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); disconnect(horiz_select, SIGNAL(editingFinished(double)), this, SLOT(updateConfig())); + disconnect(text_size_sb, SIGNAL(valueChanged(int)), this, SLOT(updateConfig())); } /// Destructeur @@ -239,6 +246,7 @@ void ConductorPropertiesWidget::updateConfig() { properties_.color = colorButton(); properties_.style = static_cast(line_style -> itemData(line_style -> currentIndex()).toInt()); properties_.text = text_field -> text(); + properties_.text_size = text_size_sb->value(); properties_.verti_rotate_text = verti_select -> value(); properties_.horiz_rotate_text = horiz_select -> value(); properties_.singleLineProperties.hasGround = ground_checkbox -> isChecked(); @@ -258,6 +266,7 @@ void ConductorPropertiesWidget::updateDisplay() { int index = line_style -> findData(properties_.style); if (index != -1) line_style -> setCurrentIndex(index); text_field -> setText(properties_.text); + text_size_sb -> setValue(properties_.text_size); ground_checkbox -> setChecked(properties_.singleLineProperties.hasGround); neutral_checkbox -> setChecked(properties_.singleLineProperties.hasNeutral); merge_checkbox -> setChecked(properties_.singleLineProperties.is_pen); @@ -338,6 +347,7 @@ void ConductorPropertiesWidget::setReadOnly(bool ro) { multiline -> setDisabled(ro); singleline -> setDisabled(ro); text_field -> setReadOnly(ro); + text_size_sb -> setReadOnly(ro); phase_checkbox -> setDisabled(ro); phase_spinbox -> setReadOnly(ro); ground_checkbox -> setDisabled(ro); diff --git a/sources/conductorpropertieswidget.h b/sources/conductorpropertieswidget.h index 93d6fbbc1..02b608890 100644 --- a/sources/conductorpropertieswidget.h +++ b/sources/conductorpropertieswidget.h @@ -75,6 +75,7 @@ class ConductorPropertiesWidget : public QWidget { QPushButton *color_button; QComboBox *line_style; QCheckBox *merge_checkbox; + QSpinBox *text_size_sb; ConductorProperties properties_; diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 22cb53608..1050b04ce 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1213,7 +1213,9 @@ QString Conductor::text() const { @param t Nouveau texte du conducteur */ void Conductor::setText(const QString &t) { + text_item -> setFontSize(properties_.text_size); text_item -> setPlainText(t); + } /// @param p les proprietes de ce conducteur diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index 272eac655..77e35fdc2 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -184,6 +184,10 @@ QPointF DiagramTextItem::mapMovementFromParent(const QPointF &movement) const { return(local_movement_point - local_origin); } +void DiagramTextItem::setFontSize(int &s) { + setFont(QETApp::diagramTextsFont(s)); +} + /** Dessine le champ de texte. Cette methode delegue simplement le travail a QGraphicsTextItem::paint apres diff --git a/sources/qetgraphicsitem/diagramtextitem.h b/sources/qetgraphicsitem/diagramtextitem.h index e02e91965..86c7862cf 100644 --- a/sources/qetgraphicsitem/diagramtextitem.h +++ b/sources/qetgraphicsitem/diagramtextitem.h @@ -58,6 +58,7 @@ class DiagramTextItem : public QGraphicsTextItem { QPointF mapMovementFromScene(const QPointF &) const; QPointF mapMovementToParent(const QPointF &) const; QPointF mapMovementFromParent(const QPointF &) const; + void setFontSize(int &s); protected: virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);