[qet] qet/qet: [5775] Element editor :

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5775
Author:   blacksun
Date:     2019-03-10 18:58:33 +0100 (Sun, 10 Mar 2019)
Log Message:
-----------
Element editor :
The font of the dynamic text field can be edited.
The font of the static text field can be edited.
The color of the static text field can be edited. 

Modified Paths:
--------------
    trunk/sources/editor/graphicspart/partdynamictextfield.cpp
    trunk/sources/editor/graphicspart/partdynamictextfield.h
    trunk/sources/editor/graphicspart/parttext.cpp
    trunk/sources/editor/graphicspart/parttext.h
    trunk/sources/editor/ui/dynamictextfieldeditor.cpp
    trunk/sources/editor/ui/dynamictextfieldeditor.h
    trunk/sources/editor/ui/dynamictextfieldeditor.ui
    trunk/sources/factory/elementpicturefactory.cpp

Added Paths:
-----------
    trunk/sources/editor/ui/texteditor.cpp
    trunk/sources/editor/ui/texteditor.h
    trunk/sources/editor/ui/texteditor.ui

Removed Paths:
-------------
    trunk/sources/editor/texteditor.cpp
    trunk/sources/editor/texteditor.h

Modified: trunk/sources/editor/graphicspart/partdynamictextfield.cpp
===================================================================
--- trunk/sources/editor/graphicspart/partdynamictextfield.cpp	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/graphicspart/partdynamictextfield.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -33,8 +33,8 @@
 	setDefaultTextColor(Qt::black);
 	setFont(QETApp::dynamicTextsItemFont());
 	QSettings settings;
-	setRotation(settings.value("dynamic_rotation", 0).toInt());
-	setTextWidth(settings.value("dynamic_with", -1).toInt());
+	setRotation(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt());
+	setTextWidth(settings.value("diagrameditor/dynamic_text_width", -1).toInt());
 	setText("_");
 	setTextFrom(DynamicElementTextItem::UserText);
 	setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsMovable);
@@ -94,8 +94,7 @@
 	root_element.setAttribute("y", QString::number(pos().y()));
 	root_element.setAttribute("z", QString::number(zValue()));
 	root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
-	root_element.setAttribute("font_size", font().pointSize());
-	root_element.setAttribute("font_family", (QETApp::dynamicTextsItemFont().family()));
+	root_element.setAttribute("font", font().toString());
 	root_element.setAttribute("uuid", m_uuid.toString());
 	root_element.setAttribute("frame", m_frame? "true" : "false");
 	root_element.setAttribute("text_width", QString::number(m_text_width));
@@ -165,7 +164,16 @@
 							  dom_elmt.attribute("y", QString::number(0)).toDouble());
 	setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
 	QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
-	setFont(QETApp::diagramTextsFont(dom_elmt.attribute("font_size", QString::number(9)).toInt()));
+
+	if (dom_elmt.hasAttribute("font"))
+	{
+		QFont font_;
+		font_.fromString(dom_elmt.attribute("font"));
+		setFont(font_);
+	} else {	//Keep compatibility TODO remove in futur
+		setFont(QETApp::dynamicTextsItemFont(9));
+	}
+
 	m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
 	setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
 	setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
@@ -352,22 +360,6 @@
 	return defaultTextColor();
 }
 
-/**
- * @brief PartDynamicTextField::setFontSize
- * @param s
- */
-void PartDynamicTextField::setFontSize(int s)
-{
-	prepareAlignment();
-	setFont(QETApp::dynamicTextsItemFont(s));
-	finishAlignment();
-	emit fontSizeChanged(s);
-}
-
-int PartDynamicTextField::fontSize() const {
-	return font().pointSize();
-}
-
 void PartDynamicTextField::setFrame(bool frame)
 {
 	m_frame = frame;
@@ -425,6 +417,17 @@
 	return m_alignment;
 }
 
+void PartDynamicTextField::setFont(const QFont &font)
+{
+	if (font == this->font()) {
+		return;
+	}
+	prepareAlignment();
+	QGraphicsTextItem::setFont(font);
+	finishAlignment();
+	emit fontChanged(font);
+}
+
 /**
  * @brief PartDynamicTextField::mouseMoveEvent
  * @param event
@@ -501,13 +504,13 @@
 	if (m_frame)
 	{
 		painter->save();
-		painter->setFont(QETApp::dynamicTextsItemFont(fontSize()));
+		painter->setFont(this->font());
 		
 			//Adjust the thickness according to the font size, 
 		qreal w=0.3;
-		if(fontSize() >= 5)
+		if(this->font().pointSize() >= 5)
 		{
-			w = (qreal)fontSize()*0.1;
+			w = this->font().pointSizeF()*0.1;
 			if(w > 2.5)
 				w = 2.5;
 		}
@@ -534,7 +537,7 @@
 		pos.ry() -= size.height()/2;
 		
 			//Adjust the rounding of the rectangle according to the size of the font
-		qreal ro = (qreal)fontSize()/3;
+		qreal ro = this->font().pointSizeF()/3;
 		painter->drawRoundedRect(QRectF(pos, size), ro, ro);
 		
 		painter->restore();

Modified: trunk/sources/editor/graphicspart/partdynamictextfield.h
===================================================================
--- trunk/sources/editor/graphicspart/partdynamictextfield.h	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/graphicspart/partdynamictextfield.h	2019-03-10 17:58:33 UTC (rev 5775)
@@ -38,10 +38,10 @@
 	Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
 	Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
 	Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
-	Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
 	Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
 	Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
 	Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+	Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
 	
 	public:
 			///PROPERTY
@@ -55,10 +55,10 @@
 		void infoNameChanged(QString info);
 		void compositeTextChanged(QString text);
 		void colorChanged(QColor color);
-		void fontSizeChanged(int size);
 		void frameChanged(bool frame);
 		void textWidthChanged(qreal width);
 		void alignmentChanged(Qt::Alignment alignment);
+		void fontChanged(QFont font);
 	
 	public:
 		PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
@@ -88,8 +88,6 @@
 		QString compositeText() const;
 		void setColor(const QColor& color);
         QColor color() const;
-		void setFontSize(int s);
-        int fontSize()const;
 		void setFrame(bool frame);
 		bool frame() const;
 		void setTextWidth(qreal width);
@@ -96,6 +94,7 @@
 		void setPlainText(const QString &text);
 		void setAlignment(Qt::Alignment alignment);
 		Qt::Alignment alignment() const;
+		void setFont(const QFont &font);
 		
 	protected:
 		void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;

Modified: trunk/sources/editor/graphicspart/parttext.cpp
===================================================================
--- trunk/sources/editor/graphicspart/parttext.cpp	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/graphicspart/parttext.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -55,24 +55,32 @@
 	Importe les proprietes d'un texte statique depuis un element XML
 	@param xml_element Element XML a lire
 */
-void PartText::fromXml(const QDomElement &xml_element) {
+void PartText::fromXml(const QDomElement &xml_element)
+{
 	bool ok;
-	int font_size = xml_element.attribute("size").toInt(&ok);
-	if (!ok || font_size < 1) font_size = 20;
+
+	if (xml_element.hasAttribute("size"))
+	{
+		int font_size = xml_element.attribute("size").toInt(&ok);
+		if (!ok || font_size < 1) {
+			font_size = 20;
+		}
+		QFont font_ = this->font();
+		font_.setPointSize(font_size);
+		setFont(font_);
+	}
+	else if (xml_element.hasAttribute("font"))
+	{
+		QFont font_;
+		font_.fromString(xml_element.attribute("font"));
+		setFont(font_);
+	}
 	
-	setBlack(xml_element.attribute("color") != "white");
-	setProperty("size" , font_size);
+	setDefaultTextColor(QColor(xml_element.attribute("color", "#000000")));
 	setPlainText(xml_element.attribute("text"));
-	
-	qreal default_rotation_angle = 0.0;
-	if (QET::attributeIsAReal(xml_element, "rotation", &default_rotation_angle)) {
-		setRotation(default_rotation_angle);
-	}
-	
-	setPos(
-		xml_element.attribute("x").toDouble(),
-		xml_element.attribute("y").toDouble()
-	);
+	setPos(xml_element.attribute("x").toDouble(),
+		   xml_element.attribute("y").toDouble());
+	setRotation(xml_element.attribute("rotation", QString::number(0)).toDouble());
 }
 
 /**
@@ -80,19 +88,17 @@
 	@param xml_document Document XML a utiliser pour creer l'element XML
 	@return un element XML decrivant le texte statique
 */
-const QDomElement PartText::toXml(QDomDocument &xml_document) const {
-	QDomElement xml_element = xml_document.createElement("text");
-	xml_element.setAttribute("x", QString("%1").arg(pos().x()));
-	xml_element.setAttribute("y", QString("%1").arg(pos().y()));
+const QDomElement PartText::toXml(QDomDocument &xml_document) const
+{
+	QDomElement xml_element = xml_document.createElement(xmlName());
+
+	xml_element.setAttribute("x", QString::number(pos().x()));
+	xml_element.setAttribute("y", QString::number(pos().y()));
 	xml_element.setAttribute("text", toPlainText());
-	xml_element.setAttribute("size", font().pointSize());
-	// angle de rotation du champ de texte
-	if (rotation()) {
-		xml_element.setAttribute("rotation", QString("%1").arg(rotation()));
-	}
-	if (!isBlack()) {
-		xml_element.setAttribute("color", "white");
-	}
+	xml_element.setAttribute("font", font().toString());
+	xml_element.setAttribute("rotation", QString::number(rotation()));
+	xml_element.setAttribute("color", defaultTextColor().name());
+
 	return(xml_element);
 }
 
@@ -228,7 +234,34 @@
 	setProperty("real_size", qMax(1, qRound(new_font_size)));
 }
 
+void PartText::setDefaultTextColor(const QColor &color)
+{
+	if (color != this->defaultTextColor())
+	{
+		QGraphicsTextItem::setDefaultTextColor(color);
+		emit colorChanged(color);
+	}
+}
 
+void PartText::setPlainText(const QString &text)
+{
+	if (text != this->toPlainText())
+	{
+		QGraphicsTextItem::setPlainText(text);
+		emit plainTextChanged(text);
+	}
+}
+
+void PartText::setFont(const QFont &font)
+{
+	if (font != this->font())
+	{
+		QGraphicsTextItem::setFont(font);
+		emit fontChanged(font);
+	}
+}
+
+
 void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
     if((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable))

Modified: trunk/sources/editor/graphicspart/parttext.h
===================================================================
--- trunk/sources/editor/graphicspart/parttext.h	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/graphicspart/parttext.h	2019-03-10 17:58:33 UTC (rev 5775)
@@ -26,53 +26,55 @@
 	This class represents an static text primitive which may be used to compose
 	the drawing of an electrical element within the element editor.
 */
-class PartText : public QGraphicsTextItem, public CustomElementPart {
+class PartText : public QGraphicsTextItem, public CustomElementPart
+{
 	Q_OBJECT
+
+	Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
+	Q_PROPERTY(QColor color READ defaultTextColor WRITE setDefaultTextColor NOTIFY colorChanged)
+	Q_PROPERTY(QString text READ toPlainText WRITE setPlainText NOTIFY plainTextChanged)
+	Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+
+	signals:
+		void fontChanged(const QFont &font);
+		void colorChanged(const QColor &color);
+		void plainTextChanged(const QString &text);
 	
-	// constructors, destructor
+		// constructors, destructor
 	public:
-    PartText(QETElementEditor *, QGraphicsItem * = nullptr);
-	~PartText() override;
+		PartText(QETElementEditor *, QGraphicsItem * = nullptr);
+		~PartText() override;
 	
 	private:
-	PartText(const PartText &);
+		PartText(const PartText &);
 	
-	// methods
+		// methods
 	public:
-	enum { Type = UserType + 1107 };
-	/**
-		Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
-		PartText.
-		@return the QGraphicsItem type
-	*/
-	int type() const override { return Type; }
-	QString name() const override { return(QObject::tr("texte", "element part name")); }
-	QString xmlName() const override { return(QString("text")); }
-	void fromXml(const QDomElement &) override;
-	const QDomElement toXml(QDomDocument &) const override;
-	void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
-	bool isUseless() const override;
-	QRectF sceneGeometricRect() const override;
-	void startUserTransformation(const QRectF &) override;
-	void handleUserTransformation(const QRectF &, const QRectF &) override;
+		enum { Type = UserType + 1107 };
+		/**
+			Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
+			PartText.
+			@return the QGraphicsItem type
+		*/
+		int type() const override { return Type; }
+		QString name() const override { return(QObject::tr("texte", "element part name")); }
+		QString xmlName() const override { return(QString("text")); }
+		void fromXml(const QDomElement &) override;
+		const QDomElement toXml(QDomDocument &) const override;
+		void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
+		bool isUseless() const override;
+		QRectF sceneGeometricRect() const override;
+		void startUserTransformation(const QRectF &) override;
+		void handleUserTransformation(const QRectF &, const QRectF &) override;
 
-	///PROPERTY
-	void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
-	QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
-	// Size value
-	Q_PROPERTY(qreal size READ size WRITE setSize)
-		qreal size () const {return font().pointSize();}
-		void setSize (qreal s) {setFont(QETApp::dynamicTextsItemFont(s));}
-	// Real size value
-	Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
+		void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
+		QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
+
 		qreal realSize() const {return real_font_size_;}
 		void setRealSize(qreal rs) {real_font_size_ = rs;}
-	// Color value (true = black , false = white)
-	Q_PROPERTY(bool color READ isBlack WRITE setBlack)
-		bool isBlack() const {return defaultTextColor() == Qt::black;}
-		void setBlack(bool b) {setDefaultTextColor(b ? Qt::black : Qt::white);}
-	// displayed string
-	Q_PROPERTY(QString text READ toPlainText WRITE setPlainText)
+		void setDefaultTextColor(const QColor &color);
+		void setPlainText(const QString &text);
+		void setFont(const QFont &font);
 	
 	public slots:
         void adjustItemPosition(int = 0);

Deleted: trunk/sources/editor/texteditor.cpp
===================================================================
--- trunk/sources/editor/texteditor.cpp	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/texteditor.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -1,241 +0,0 @@
-/*
-	Copyright 2006-2019 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech is free software: you can redistribute it and/or modify
-	it under the terms of the GNU General Public License as published by
-	the Free Software Foundation, either version 2 of the License, or
-	(at your option) any later version.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "texteditor.h"
-#include "parttext.h"
-#include "qetapp.h"
-#include "qtextorientationspinboxwidget.h"
-#include "QPropertyUndoCommand/qpropertyundocommand.h"
-
-/**
-	Constructeur
-	@param editor L'editeur d'element concerne
-	@param text Champ de texte a editer
-	@param parent QWidget parent de ce widget
-*/
-TextEditor::TextEditor(QETElementEditor *editor, PartText *text, QWidget *parent) :
-	ElementItemEditor(editor, parent),
-	part(text),
-	m_locked(false)
-{
-	qle_x     = new QDoubleSpinBox();
-	qle_y     = new QDoubleSpinBox();
-	qle_text  = new QLineEdit();
-	qle_text  ->setClearButtonEnabled(true);
-	font_size = new QSpinBox();
-	font_size -> setRange(0, 144);
-	black_color_ = new QRadioButton(tr("Noir", "element text part color"));
-	white_color_ = new QRadioButton(tr("Blanc", "element text part color"));
-	color_ = new QButtonGroup(this);
-	color_ -> addButton(black_color_, true);
-	color_ -> addButton(white_color_, false);
-	connect(color_, SIGNAL(buttonClicked(int)), this, SLOT(updateTextC()));
-	QLabel *rotation_angle_label = new QLabel(tr("Angle de rotation : "));
-	rotation_angle_label -> setWordWrap(true);
-	rotation_angle_ = QETApp::createTextOrientationSpinBoxWidget();
-	
-	qle_x -> setRange(-5000, 5000);
-	qle_y -> setRange(-5000, 5000);
-	
-	QVBoxLayout *main_layout = new QVBoxLayout();
-	main_layout -> addWidget(new QLabel(tr("Position : ")));
-	
-	QHBoxLayout *position = new QHBoxLayout();
-	position -> addWidget(new QLabel(tr("x : ")));
-	position -> addWidget(qle_x                 );
-	position -> addWidget(new QLabel(tr("y : ")));
-	position -> addWidget(qle_y                 );
-	main_layout -> addLayout(position);
-	
-	QHBoxLayout *fs = new QHBoxLayout();
-	fs -> addWidget(new QLabel(tr("Taille : ")));
-	fs -> addWidget(font_size);
-	main_layout -> addLayout(fs);
-	
-	QHBoxLayout *color_layout = new QHBoxLayout();
-	color_layout -> addWidget(new QLabel(tr("Couleur : ")));
-	color_layout -> addWidget(black_color_);
-	color_layout -> addWidget(white_color_);
-	color_layout -> addStretch();
-	main_layout -> addLayout(color_layout);
-	
-	QHBoxLayout *t = new QHBoxLayout();
-	t -> addWidget(new QLabel(tr("Texte : ")));
-	t -> addWidget(qle_text);
-	
-	QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
-	rotation_angle_layout -> addWidget(rotation_angle_label);
-	rotation_angle_layout -> addWidget(rotation_angle_);
-	
-	main_layout -> addLayout(t);
-	main_layout -> addLayout(rotation_angle_layout);
-	main_layout -> addStretch();
-	setLayout(main_layout);
-	
-	updateForm();
-}
-
-/**
-	Destructeur
-*/
-TextEditor::~TextEditor() {
-}
-
-/**
-	Permet de specifier a cet editeur quelle primitive il doit editer. A noter
-	qu'un editeur peut accepter ou refuser d'editer une primitive.
-	L'editeur de texte statique acceptera d'editer la primitive new_part s'il
-	s'agit d'un objet de la classe PartText.
-	@param new_part Nouvelle primitive a editer
-	@return true si l'editeur a accepter d'editer la primitive, false sinon
-*/
-bool TextEditor::setPart(CustomElementPart *new_part)
-{
-	if (!new_part)
-	{
-		part = nullptr;
-		return(true);
-	}
-	if (PartText *part_text = dynamic_cast<PartText *>(new_part))
-	{
-		if (part == part_text) return true;
-		part = part_text;
-		updateForm();
-		return(true);
-	}
-	return(false);
-}
-
-/**
-	@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
-*/
-CustomElementPart *TextEditor::currentPart() const {
-	return(part);
-}
-
-/// Met a jour le texte et cree un objet d'annulation
-void TextEditor::updateTextT()
-{
-	if(m_locked) return;
-	m_locked = true;
-	QString text = qle_text->text();
-	if (text != part->property("text"))
-	{
-		QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "text", part->property("text"), text);
-		undo->setText(tr("Modifier le contenu d'un champ texte"));
-		undoStack().push(undo);
-	}
-	m_locked= false;
-}
-
-/// Met a jour la taille du texte et cree un objet d'annulation
-void TextEditor::updateTextS()
-{
-	if(m_locked) return;
-	m_locked = true;
-	int size = font_size->value();
-	if (size != part->property("size"))
-	{
-		QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "size", part->property("size"), size);
-		undo->setText(tr("Modifier la taille d'un champ texte"));
-		undo->enableAnimation();
-		undoStack().push(undo);
-	}
-	m_locked= false;
-}
-
-/// Update the text color and create an undo object
-void TextEditor::updateTextC()
-{
-	if(m_locked) return;
-	m_locked = true;
-	int color = color_->checkedId();
-	if (color != part->property("color"))
-	{
-		QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "color", part->property("color"), color);
-		undo->setText(tr("Modifier la couleur d'un champ texte"));
-		undoStack().push(undo);
-	}
-	m_locked= false;
-}
-/// Met a jour l'angle de rotation du champ de texte et cree un objet d'annulation
-void TextEditor::updateTextRotationAngle()
-{
-	if(m_locked) return;
-	m_locked = true;
-	double rot = rotation_angle_->value();
-	if (rot != part->property("rotation"))
-	{
-		QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "rotation", part->property("rotation"), rot);
-		undo->setText(tr("Modifier l'angle d'un champ texte"));
-		undo->enableAnimation();
-		undoStack().push(undo);
-	}
-	m_locked= false;
-}
-
-void TextEditor::updatePos()
-{
-	if(m_locked) return;
-	m_locked = true;
-	QPointF pos(qle_x->value(), qle_y->value());
-	if (pos != part->pos())
-	{
-		QPropertyUndoCommand *undo = new QPropertyUndoCommand(part, "pos", part->pos(), pos);
-		undo->setText(tr("Déplacer un champ texte"));
-		undo->enableAnimation();
-		undoStack().push(undo);
-	}
-	m_locked= false;
-}
-
-/**
-	Met a jour le formulaire a partir du champ de texte
-*/
-void TextEditor::updateForm() {
-	if (!part) return;
-	activeConnections(false);
-	qle_x     -> setValue(part->property("x").toReal());
-	qle_y     -> setValue(part->property("y").toReal());
-	qle_text  -> setText(part -> property("text").toString());
-	font_size -> setValue(part -> property("size").toInt());
-	if (QAbstractButton *button = color_ -> button(part -> property("color").toBool())) {
-		button -> setChecked(true);
-	}
-	rotation_angle_ -> setValue(part -> property("rotation").toReal());
-	activeConnections(true);
-}
-
-void TextEditor::activeConnections(bool active)
-{
-	if (active)
-	{
-		connect(qle_x,     SIGNAL(editingFinished()), this, SLOT(updatePos()));
-		connect(qle_y,     SIGNAL(editingFinished()), this, SLOT(updatePos()));
-		connect(qle_text,  SIGNAL(editingFinished()), this, SLOT(updateTextT()));
-		connect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextS()));
-		connect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextRotationAngle()));
-	}
-	else
-	{
-		disconnect(qle_x,     SIGNAL(editingFinished()), this, SLOT(updatePos()));
-		disconnect(qle_y,     SIGNAL(editingFinished()), this, SLOT(updatePos()));
-		disconnect(qle_text,  SIGNAL(editingFinished()), this, SLOT(updateTextT()));
-		disconnect(font_size, SIGNAL(editingFinished()), this, SLOT(updateTextS()));
-		disconnect(rotation_angle_, SIGNAL(editingFinished()), this, SLOT(updateTextRotationAngle()));
-	}
-}

Deleted: trunk/sources/editor/texteditor.h
===================================================================
--- trunk/sources/editor/texteditor.h	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/texteditor.h	2019-03-10 17:58:33 UTC (rev 5775)
@@ -1,73 +0,0 @@
-/*
-	Copyright 2006-2019 The QElectroTech Team
-	This file is part of QElectroTech.
-	
-	QElectroTech is free software: you can redistribute it and/or modify
-	it under the terms of the GNU General Public License as published by
-	the Free Software Foundation, either version 2 of the License, or
-	(at your option) any later version.
-	
-	QElectroTech is distributed in the hope that it will be useful,
-	but WITHOUT ANY WARRANTY; without even the implied warranty of
-	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-	GNU General Public License for more details.
-	
-	You should have received a copy of the GNU General Public License
-	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef TEXT_EDITOR_H
-#define TEXT_EDITOR_H
-
-#include "elementitemeditor.h"
-
-class PartText;
-class QTextOrientationSpinBoxWidget;
-class QLineEdit;
-class QDoubleSpinBox;
-class QSpinBox;
-class QButtonGroup;
-class QRadioButton;
-
-/**
-	This class provides a widget to edit static texts within the element
-	editor.
-*/
-class TextEditor : public ElementItemEditor
-{
-	Q_OBJECT
-
-		// Constructors, destructor
-	public:
-		TextEditor(QETElementEditor *, PartText * = nullptr, QWidget * = nullptr);
-		~TextEditor() override;
-	private:
-		TextEditor(const TextEditor &);
-	
-		// attributes
-	private:
-		PartText *part;
-		QLineEdit *qle_text;
-		QDoubleSpinBox *qle_x, *qle_y;
-		QSpinBox *font_size;
-		QButtonGroup *color_;
-		QRadioButton *black_color_, *white_color_;
-		QTextOrientationSpinBoxWidget *rotation_angle_;
-		bool m_locked;
-	
-		// methods
-	public:
-		bool setPart(CustomElementPart *) override;
-		CustomElementPart *currentPart() const override;
-	
-	public slots:
-		void updateTextT();
-		void updateTextS();
-		void updateTextC();
-		void updateTextRotationAngle();
-		void updatePos();
-		void updateForm() override;
-	
-	private:
-		void activeConnections(bool);
-};
-#endif

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.cpp
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.cpp	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -73,7 +73,7 @@
 	
 		//Setup the connection
 	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,    [this](){this->updateForm();});
-	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontSizeChanged, [this](){this->updateForm();});
+	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
 	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged,     [this](){this->updateForm();});
 	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
 	m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged,     [this](){this->updateForm();});
@@ -104,9 +104,10 @@
 		ui->m_rotation_sb->setValue(QET::correctAngle(m_text_field.data()->rotation()));
 		ui->m_frame_cb->setChecked(m_text_field.data()->frame());
 		ui->m_user_text_le->setText(m_text_field.data()->text());
-		ui->m_size_sb->setValue(m_text_field.data()->fontSize());
+		ui->m_size_sb->setValue(m_text_field.data()->font().pointSize());
 		setColorPushButton(m_text_field.data()->color());
 		ui->m_width_sb->setValue(m_text_field.data()->textWidth());
+		ui->m_font_pb->setText(m_text_field->font().family());
 		
 		switch (m_text_field.data()->textFrom())
 		{
@@ -117,12 +118,10 @@
 			{
 				ui->m_text_from_cb->setCurrentIndex(1);
 				ui->m_elmt_info_cb->setCurrentIndex(ui->m_elmt_info_cb->findData(m_text_field.data()->infoName()));
+				break;
 			}
-				break;
 			case DynamicElementTextItem::CompositeText:
 				ui->m_text_from_cb->setCurrentIndex(2);
-			default:
-				break;
 		}
 
 		on_m_text_from_cb_activated(ui->m_text_from_cb->currentIndex()); //For enable the good widget
@@ -195,9 +194,10 @@
 
 void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
 {
-	QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "fontSize", m_text_field.data()->fontSize(), ui->m_size_sb->value());
-	undo->setText(tr("Modifier la taille d'un champ texte"));
-	undo->enableAnimation(true);
+	QFont font_ = m_text_field->font();
+	font_.setPointSize(ui->m_size_sb->value());
+	QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "font", m_text_field.data()->font(), font_);
+	undo->setText(tr("Modifier la police d'un champ texte"));
 	undoStack().push(undo);
 }
 
@@ -306,3 +306,18 @@
 		undoStack().push(undo);
 	}
 }
+
+void DynamicTextFieldEditor::on_m_font_pb_clicked()
+{
+	bool ok;
+	QFont font_ = QFontDialog::getFont(&ok, m_text_field->font(), this);
+	if (ok && font_ != this->font())
+	{
+		ui->m_font_pb->setText(font_.family());
+		ui->m_size_sb->setValue(font_.pointSize());
+
+		QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field.data(), "font", m_text_field->font(), font_);
+		undo->setText(tr("Modifier la police d'un champ texte"));
+		undoStack().push(undo);
+	}
+}

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.h
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.h	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.h	2019-03-10 17:58:33 UTC (rev 5775)
@@ -58,8 +58,9 @@
 		void on_m_text_from_cb_activated(int index);
 		void on_m_composite_text_pb_clicked();
 		void on_m_alignment_pb_clicked();
-		
-		private:
+		void on_m_font_pb_clicked();
+
+	private:
 		Ui::DynamicTextFieldEditor *ui;
 		QPointer<PartDynamicTextField> m_text_field;
 		QList<QMetaObject::Connection> m_connection_list;

Modified: trunk/sources/editor/ui/dynamictextfieldeditor.ui
===================================================================
--- trunk/sources/editor/ui/dynamictextfieldeditor.ui	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/editor/ui/dynamictextfieldeditor.ui	2019-03-10 17:58:33 UTC (rev 5775)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>299</width>
-    <height>332</height>
+    <width>344</width>
+    <height>285</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -76,13 +76,10 @@
    <item row="6" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
-      <string>Taille</string>
+      <string>Police</string>
      </property>
     </widget>
    </item>
-   <item row="6" column="1" colspan="2">
-    <widget class="QSpinBox" name="m_size_sb"/>
-   </item>
    <item row="2" column="0">
     <widget class="QLabel" name="label_4">
      <property name="text">
@@ -206,6 +203,16 @@
      </layout>
     </widget>
    </item>
+   <item row="6" column="1">
+    <widget class="QSpinBox" name="m_size_sb"/>
+   </item>
+   <item row="6" column="2">
+    <widget class="QPushButton" name="m_font_pb">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>

Added: trunk/sources/editor/ui/texteditor.cpp
===================================================================
--- trunk/sources/editor/ui/texteditor.cpp	                        (rev 0)
+++ trunk/sources/editor/ui/texteditor.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -0,0 +1,224 @@
+/*
+	Copyright 2006-2019 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "texteditor.h"
+#include "ui_texteditor.h"
+#include "parttext.h"
+#include "QPropertyUndoCommand/qpropertyundocommand.h"
+
+/**
+ * @brief TextEditor::TextEditor
+ * Default constructor
+ * @param editor : the element editor who use this editor
+ * @param text : the text to edit
+ * @param parent : the parent widget
+ */
+TextEditor::TextEditor(QETElementEditor *editor,  PartText *text, QWidget *parent) :
+	ElementItemEditor(editor, parent),
+	ui(new Ui::TextEditor)
+{
+    ui->setupUi(this);
+	setUpEditConnection();
+	if (text)
+	{
+		setPart(text);
+		updateForm();
+	}
+}
+
+/**
+ * @brief TextEditor::~TextEditor
+ */
+TextEditor::~TextEditor() {
+	delete ui;
+}
+
+/**
+ * @brief TextEditor::updateForm
+ * Update the gui
+ */
+void TextEditor::updateForm()
+{
+	if (m_text.isNull()) {
+		return;
+	}
+
+	for (QMetaObject::Connection c : m_edit_connection) {
+		disconnect(c);
+	}
+	m_edit_connection.clear();
+
+	ui->m_line_edit->setText(m_text->toPlainText());
+	ui->m_x_sb->setValue(m_text->pos().x());
+	ui->m_y_sb->setValue(m_text->pos().y());
+	ui->m_rotation_sb->setValue(m_text->rotation());
+	ui->m_size_sb->setValue(m_text->font().pointSize());
+	ui->m_font_pb->setText(m_text->font().family());
+	ui->m_color_pb->setColor(m_text->defaultTextColor());
+
+	setUpEditConnection();
+}
+
+/**
+ * @brief TextEditor::setPart
+ * Set the current text to edit.
+ * Set @part to nullptr to clear the current text.
+ * @param part : part to edit
+ * @return : return if @part is a partext or nullptr, else return false
+ */
+bool TextEditor::setPart(CustomElementPart *part)
+{
+	if (!part)
+	{
+		m_text = nullptr;
+		for (QMetaObject::Connection c : m_change_connection) {
+			disconnect(c);
+		}
+		m_change_connection.clear();
+		return true;
+	}
+
+	if (PartText *part_text = dynamic_cast<PartText *>(part))
+	{
+		if (part_text == m_text) {
+			return true;
+		}
+		m_text = part_text;
+
+		m_change_connection.clear();
+		m_change_connection << connect(part_text, &PartText::plainTextChanged, this, &TextEditor::updateForm);
+		m_change_connection << connect(part_text, &PartText::xChanged,         this, &TextEditor::updateForm);
+		m_change_connection << connect(part_text, &PartText::yChanged,         this, &TextEditor::updateForm);
+		m_change_connection << connect(part_text, &PartText::rotationChanged,  this, &TextEditor::updateForm);
+		m_change_connection << connect(part_text, &PartText::fontChanged,      this, &TextEditor::updateForm);
+		m_change_connection << connect(part_text, &PartText::colorChanged,     this, &TextEditor::updateForm);
+
+		updateForm();
+		return true;
+	}
+	return false;
+}
+
+/**
+ * @brief TextEditor::currentPart
+ * @return The current part
+ */
+CustomElementPart *TextEditor::currentPart() const {
+	return m_text;
+}
+
+/**
+ * @brief TextEditor::setUpEditConnection
+ * Setup the connection between the widgets of this editor and the undo command
+ * use to apply the change to the edited text.
+ */
+void TextEditor::setUpEditConnection()
+{
+	for (QMetaObject::Connection c : m_edit_connection) {
+		disconnect(c);
+	}
+	m_edit_connection.clear();
+
+	m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]()
+	{
+		QString text_ = ui->m_line_edit->text();
+		if (text_ != m_text->toPlainText())
+		{
+			QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "text", m_text->toPlainText(), text_);
+			undo->setText(tr("Modifier le contenu d'un champ texte"));
+			undoStack().push(undo);
+		}
+	});
+	m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
+	{
+		QPointF pos(ui->m_x_sb->value(), ui->m_y_sb->value());
+		if (pos != m_text->pos())
+		{
+			QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "pos", m_text->pos(), pos);
+			undo->setText(tr("Déplacer un champ texte"));
+			undo->setAnimated(true, false);
+			undoStack().push(undo);
+		}
+	});
+	m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
+	{
+		QPointF pos(ui->m_x_sb->value(), ui->m_y_sb->value());
+		if (pos != m_text->pos())
+		{
+			QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "pos", m_text->pos(), pos);
+			undo->setText(tr("Déplacer un champ texte"));
+			undo->setAnimated(true, false);
+			undoStack().push(undo);
+		}
+	});
+	m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
+	{
+		if (ui->m_rotation_sb->value() != m_text->rotation())
+		{
+			QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "rotation", m_text->rotation(), ui->m_rotation_sb->value());
+			undo->setText(tr("Pivoter un champ texte"));
+			undo->setAnimated(true, false);
+			undoStack().push(undo);
+		}
+	});
+	m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
+	{
+		if (m_text->font().pointSize() != ui->m_size_sb->value())
+		{
+			QFont font_ = m_text->font();
+			font_.setPointSize(ui->m_size_sb->value());
+			QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "font", m_text->font(), font_);
+			undo->setText(tr("Modifier la police d'un texte"));
+			undoStack().push(undo);
+		}
+	});
+}
+
+/**
+ * @brief TextEditor::on_m_font_pb_clicked
+ */
+void TextEditor::on_m_font_pb_clicked()
+{
+	bool ok;
+	QFont font_ = QFontDialog::getFont(&ok, m_text->font(), this);
+
+	if (ok && font_ != m_text->font())
+	{
+		ui->m_size_sb->blockSignals(true);
+		ui->m_size_sb->setValue(font_.pointSize());
+		ui->m_size_sb->blockSignals(false);
+
+		ui->m_font_pb->setText(font_.family());
+		QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "font", m_text->font(), font_);
+		undo->setText(tr("Modifier la police d'un texte"));
+		undoStack().push(undo);
+	}
+}
+
+/**
+ * @brief TextEditor::on_m_color_pb_changed
+ * @param newColor
+ */
+void TextEditor::on_m_color_pb_changed(const QColor &newColor)
+{
+	if (newColor != m_text->defaultTextColor())
+	{
+		QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text, "color", m_text->defaultTextColor(), newColor);
+		undo->setText(tr("Modifier la couleur d'un texte"));
+		undoStack().push(undo);
+	}
+}

Added: trunk/sources/editor/ui/texteditor.h
===================================================================
--- trunk/sources/editor/ui/texteditor.h	                        (rev 0)
+++ trunk/sources/editor/ui/texteditor.h	2019-03-10 17:58:33 UTC (rev 5775)
@@ -0,0 +1,58 @@
+/*
+	Copyright 2006-2019 The QElectroTech Team
+	This file is part of QElectroTech.
+
+	QElectroTech is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 2 of the License, or
+	(at your option) any later version.
+
+	QElectroTech is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef TEXTEDITOR_H
+#define TEXTEDITOR_H
+
+#include "elementitemeditor.h"
+
+#include <QWidget>
+#include <QPointer>
+
+class PartText;
+
+namespace Ui {
+class TextEditor;
+}
+
+class TextEditor : public ElementItemEditor
+{
+    Q_OBJECT
+
+	public:
+		explicit TextEditor(QETElementEditor *editor,  PartText *text = nullptr, QWidget *parent = nullptr);
+		~TextEditor() override;
+
+		void updateForm() override;
+		bool setPart(CustomElementPart *part) override;
+		CustomElementPart *currentPart() const override;
+
+	private slots:
+		void on_m_font_pb_clicked();
+		void on_m_color_pb_changed(const QColor &newColor);
+	private:
+		void setUpEditConnection();
+
+	private:
+		Ui::TextEditor *ui;
+
+		QPointer <PartText> m_text;
+		QList <QMetaObject::Connection> m_edit_connection;
+		QList <QMetaObject::Connection> m_change_connection;
+};
+
+#endif // TEXTEDITOR_H

Added: trunk/sources/editor/ui/texteditor.ui
===================================================================
--- trunk/sources/editor/ui/texteditor.ui	                        (rev 0)
+++ trunk/sources/editor/ui/texteditor.ui	2019-03-10 17:58:33 UTC (rev 5775)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TextEditor</class>
+ <widget class="QWidget" name="TextEditor">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>378</width>
+    <height>133</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="1" column="3">
+    <widget class="QSpinBox" name="m_y_sb">
+     <property name="minimum">
+      <number>-10000</number>
+     </property>
+     <property name="maximum">
+      <number>10000</number>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Y :</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>Police :</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="5">
+    <widget class="QSpinBox" name="m_rotation_sb">
+     <property name="wrapping">
+      <bool>true</bool>
+     </property>
+     <property name="suffix">
+      <string>°</string>
+     </property>
+     <property name="maximum">
+      <number>360</number>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="4">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Rotation :</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QSpinBox" name="m_x_sb">
+     <property name="minimum">
+      <number>-10000</number>
+     </property>
+     <property name="maximum">
+      <number>10000</number>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>X :</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QSpinBox" name="m_size_sb"/>
+   </item>
+   <item row="0" column="0" colspan="6">
+    <widget class="QLineEdit" name="m_line_edit">
+     <property name="placeholderText">
+      <string>Entrer votre texte ici</string>
+     </property>
+     <property name="clearButtonEnabled">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="5">
+    <widget class="KColorButton" name="m_color_pb"/>
+   </item>
+   <item row="2" column="4">
+    <widget class="QLabel" name="label_5">
+     <property name="text">
+      <string>Couleur :</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2" colspan="2">
+    <widget class="QPushButton" name="m_font_pb">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="2">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KColorButton</class>
+   <extends>QPushButton</extends>
+   <header>kcolorbutton.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

Modified: trunk/sources/factory/elementpicturefactory.cpp
===================================================================
--- trunk/sources/factory/elementpicturefactory.cpp	2019-03-10 17:24:54 UTC (rev 5774)
+++ trunk/sources/factory/elementpicturefactory.cpp	2019-03-10 17:58:33 UTC (rev 5775)
@@ -470,13 +470,8 @@
 void ElementPictureFactory::parseText(const QDomElement &dom, QPainter &painter, ElementPictureFactory::primitives &prim) const
 {
 	Q_UNUSED(prim);
-	
-	qreal pos_x, pos_y;
-	int size;
-	if (!QET::attributeIsAReal(dom, "x", &pos_x) ||\
-		!QET::attributeIsAReal(dom, "y", &pos_y) ||\
-		!QET::attributeIsAnInteger(dom, "size", &size) ||\
-		!dom.hasAttribute("text")) {
+
+	if (dom.tagName() != "text") {
 		return;
 	}
 
@@ -484,24 +479,26 @@
 	setPainterStyle(dom, painter);
 
 		//Get the font and metric
-	QFont used_font = QETApp::diagramTextsFont(size);
-	QFontMetrics qfm(used_font);
-	QColor text_color = (dom.attribute("color") != "white"? Qt::black : Qt::white);
+	QFont font_;
+	if (dom.hasAttribute("size")) {
+		font_ = QETApp::diagramTextsFont(dom.attribute("size").toDouble());
+	}
+	else if (dom.hasAttribute("font")) {
+		font_.fromString(dom.attribute("font"));
+	}
 
+	QColor text_color(dom.attribute("color", "#000000"));
+
 		//Instanciate a QTextDocument (like the QGraphicsTextItem class)
 		//for generate the graphics rendering of the text
 	QTextDocument text_document;
-	text_document.setDefaultFont(used_font);
+	text_document.setDefaultFont(font_);
 	text_document.setPlainText(dom.attribute("text"));
 
 	painter.setTransform(QTransform(), false);
-	painter.translate(pos_x, pos_y);
+	painter.translate(dom.attribute("x").toDouble(), dom.attribute("y").toDouble());
+	painter.rotate(dom.attribute("rotation", "0").toDouble());
 
-	qreal default_rotation_angle = 0.0;
-	if (QET::attributeIsAReal(dom, "rotation", &default_rotation_angle)) {
-		painter.rotate(default_rotation_angle);
-	}
-
 	/*
 		Deplace le systeme de coordonnees du QPainter pour effectuer le rendu au
 		bon endroit ; note : on soustrait l'ascent() de la police pour
@@ -508,6 +505,7 @@
 		determiner le coin superieur gauche du texte alors que la position
 		indiquee correspond a la baseline.
 	*/
+	QFontMetrics qfm(font_);
 	QPointF qpainter_offset(0.0, -qfm.ascent());
 
 		//adjusts the offset by the margin of the text document


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/