[qet] qet/qet: [5353] Dynamic element text item : add new feature -> alignment

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


Revision: 5353
Author:   blacksun
Date:     2018-05-11 20:14:41 +0200 (Fri, 11 May 2018)
Log Message:
-----------
Dynamic element text item : add new feature -> alignment

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/diagramtextitem.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.h
    trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
    trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/ui/dynamicelementtextmodel.cpp
    trunk/sources/ui/dynamicelementtextmodel.h

Added Paths:
-----------
    trunk/sources/ui/alignmenttextdialog.cpp
    trunk/sources/ui/alignmenttextdialog.h
    trunk/sources/ui/alignmenttextdialog.ui

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2018-05-11 18:14:41 UTC (rev 5353)
@@ -171,6 +171,17 @@
 	return defaultTextColor();
 }
 
+void DiagramTextItem::setAlignment(const Qt::Alignment &alignment)
+{
+	m_alignment = alignment;
+	emit alignmentChanged(alignment);
+}
+
+Qt::Alignment DiagramTextItem::alignment() const
+{
+	return m_alignment;
+}
+
 /**
  * @brief DiagramTextItem::paint
  * Draw this text field. This method draw the text by calling QGraphicsTextItem::paint.
@@ -329,6 +340,46 @@
 }
 
 /**
+ * @brief DiagramTextItem::prepareAlignment
+ * Call this function before changing the bounding rect of this text.
+ */
+void DiagramTextItem::prepareAlignment()
+{
+	m_alignment_rect = mapToParent(boundingRect()).boundingRect();
+}
+
+/**
+ * @brief DiagramTextItem::finishAlignment
+ * Call this function after changing the bouding rect of this text
+ * to set the position of this text according the alignment property.
+ */
+void DiagramTextItem::finishAlignment()
+{
+	if(m_block_alignment)
+		return;
+	
+	QPointF pos = this->pos();
+
+	if(m_alignment &Qt::AlignRight)
+		pos.setX(m_alignment_rect.right() - boundingRect().width());
+	else if(m_alignment &Qt::AlignHCenter)
+	{
+		qreal x = m_alignment_rect.x() + (m_alignment_rect.width()/2);
+		pos.setX(x - boundingRect().width()/2);
+	}
+	
+	if(m_alignment &Qt::AlignBottom)
+		pos.setY(m_alignment_rect.bottom() - boundingRect().height());
+	else if(m_alignment &Qt::AlignVCenter)
+	{
+		qreal y = m_alignment_rect.y() + (m_alignment_rect.height()/2);
+		pos.setY(y - boundingRect().height()/2);
+	}
+	
+	setPos(pos);
+}
+
+/**
  * @brief Edit the text with HtmlEditor
  */
 void DiagramTextItem::edit()

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.h	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.h	2018-05-11 18:14:41 UTC (rev 5353)
@@ -35,10 +35,14 @@
     
     Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+	Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
 	
 	signals:
 		void fontSizeChanged(int size);
 		void colorChanged(QColor color);
+		void alignmentChanged(Qt::Alignment alignment);
+		void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
+		void textEdited(const QString &old_str, const QString &new_str);
 
 	public:
 		DiagramTextItem(QGraphicsItem * = nullptr);
@@ -68,6 +72,10 @@
         QColor color() const;
         
 		void setNoEditable(bool e = true) {m_no_editable = e;}
+		
+		void setAlignment(const Qt::Alignment &alignment);
+		Qt::Alignment alignment() const;
+		bool m_block_alignment = false;
 
 	protected:
 		void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
@@ -84,10 +92,9 @@
 		void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
 
 		virtual void applyRotation(const qreal &);
+		void prepareAlignment();
+		void finishAlignment();
 
-	signals:
-		void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
-		void textEdited(const QString &old_str, const QString &new_str);
 	
 	protected:
 		bool m_mouse_hover = false,
@@ -98,5 +105,9 @@
 				m_previous_text;
 		
 		QPointF m_mouse_to_origin_movement;
+		
+	private:
+		QRectF m_alignment_rect;
+		Qt::Alignment m_alignment = (Qt::AlignTop | Qt::AlignLeft);
 };
 #endif

Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp	2018-05-11 18:14:41 UTC (rev 5353)
@@ -97,6 +97,22 @@
 	QMetaEnum me = textFromMetaEnum();
 	root_element.setAttribute("text_from", me.valueToKey(m_text_from));
 	
+	me = QMetaEnum::fromType<Qt::Alignment>();
+	if(this->alignment() &Qt::AlignRight)
+		root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
+	else if(this->alignment() &Qt::AlignLeft)
+		root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
+	else if(this->alignment() &Qt::AlignHCenter)
+		root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
+	
+	if(this->alignment() &Qt::AlignBottom)
+		root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
+	else if(this->alignment() & Qt::AlignTop)
+		root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
+	else if(this->alignment() &Qt::AlignVCenter)
+		root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
+	
+	
     QDomElement dom_text = dom_doc.createElement("text");
     dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
     root_element.appendChild(dom_text);
@@ -140,8 +156,6 @@
 		return;
 	}
 	
-	QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
-							  dom_elmt.attribute("y", QString::number(0)).toDouble());
 	QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
 	setFont(QETApp::diagramTextsFont(dom_elmt.attribute("font_size", QString::number(9)).toInt()));
 	m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
@@ -151,6 +165,12 @@
 		//Text from
 	QMetaEnum me = textFromMetaEnum();
 	setTextFrom(DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data())));
+	
+	me = QMetaEnum::fromType<Qt::Alignment>();
+	if(dom_elmt.hasAttribute("Halignment"))
+		setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
+	if(dom_elmt.hasAttribute(("Valignment")))
+		setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this->alignment());
 
 		//Text
     QDomElement dom_text = dom_elmt.firstChildElement("text");
@@ -174,6 +194,9 @@
 	
 		//Force the update of the displayed text
 	setTextFrom(m_text_from);
+	
+	QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
+							  dom_elmt.attribute("y", QString::number(0)).toDouble());
 }
 
 /**
@@ -1291,6 +1314,8 @@
 
 void DynamicElementTextItem::setPlainText(const QString &text)
 {
+	prepareAlignment();
+	
 	DiagramTextItem::setPlainText(text);
 	
 		//User define a text width
@@ -1306,6 +1331,8 @@
 		}
 	}
 	
+	finishAlignment();
+	
 	if(m_Xref_item)
 		m_Xref_item->autoPos();
 	else if(m_slave_Xref_item)
@@ -1323,4 +1350,3 @@
 	m_text_width = width;
 	emit textWidthChanged(width);
 }
-

Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.h	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.h	2018-05-11 18:14:41 UTC (rev 5353)
@@ -130,6 +130,7 @@
 		void conductorPropertiesChanged();
 		QString reportReplacedCompositeText() const;
 		void zoomToLinkedElement();
+
 		
 	private:
 		QPointer <Element> m_parent_element,

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/qetgraphicsitem/element.cpp	2018-05-11 18:14:41 UTC (rev 5353)
@@ -551,8 +551,15 @@
 	   !m_element_informations.value("label").toString().isEmpty())
 		dc.addValue("label", m_element_informations.value("label"));
 	
+		//We must to block the update of the alignment when load the information
+		//otherwise the pos of the text will not be the same as it was at save time.
+	for(DynamicElementTextItem *deti : m_dynamic_text_list)
+		deti->m_block_alignment = true;
 	setElementInformations(dc);
+	for(DynamicElementTextItem *deti : m_dynamic_text_list)
+		deti->m_block_alignment = false;
 	
+	
 	/**
 	  During the devel of the version 0.7, the "old text" was replaced by the dynamic element text item.
 	  When open a project made befor the 0.7, we must to reproduce the same visual when the label are not empty and visible,

Added: trunk/sources/ui/alignmenttextdialog.cpp
===================================================================
--- trunk/sources/ui/alignmenttextdialog.cpp	                        (rev 0)
+++ trunk/sources/ui/alignmenttextdialog.cpp	2018-05-11 18:14:41 UTC (rev 5353)
@@ -0,0 +1,94 @@
+/*
+	Copyright 2006-2017 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 "alignmenttextdialog.h"
+#include "ui_alignmenttextdialog.h"
+#include "dynamicelementtextitem.h"
+
+AlignmentTextDialog::AlignmentTextDialog(DynamicElementTextItem *text, QWidget *parent) :
+	QDialog(parent),
+	ui(new Ui::AlignmentTextDialog)
+{
+	ui->setupUi(this);
+	
+	Qt::Alignment align = text->alignment();
+	if(align == (Qt::AlignTop|Qt::AlignLeft))
+		ui->top_left->setChecked(true);
+	else if(align == (Qt::AlignTop|Qt::AlignHCenter))
+		ui->top->setChecked(true);
+	else if(align == (Qt::AlignTop|Qt::AlignRight))
+		ui->top_right->setChecked(true);
+	else if(align == (Qt::AlignVCenter|Qt::AlignLeft))
+		ui->left->setChecked(true);
+	else if(align == Qt::AlignCenter)
+		ui->center->setChecked(true);
+	else if(align == (Qt::AlignVCenter|Qt::AlignRight))
+		ui->right->setChecked(true);
+	else if(align == (Qt::AlignBottom|Qt::AlignLeft))
+		ui->bottom_left->setChecked(true);
+	else if(align == (Qt::AlignBottom|Qt::AlignHCenter))
+		ui->bottom->setChecked(true);
+	else if(align == (Qt::AlignBottom|Qt::AlignRight))
+		ui->bottom_right->setChecked(true);
+}
+
+AlignmentTextDialog::~AlignmentTextDialog()
+{
+	delete ui;
+}
+
+/**
+ * @brief AlignmentTextDialog::alignment
+ * @return the selected alignment
+ */
+Qt::Alignment AlignmentTextDialog::alignment() const
+{
+	if(ui->top_left->isChecked())
+		return (Qt::AlignTop|Qt::AlignLeft);
+	else if(ui->top->isChecked())
+		return (Qt::AlignTop|Qt::AlignHCenter);
+	else if(ui->top_right->isChecked())
+		return (Qt::AlignTop|Qt::AlignRight);
+	else if(ui->left->isChecked())
+		return (Qt::AlignVCenter|Qt::AlignLeft);
+	else if (ui->center->isChecked())
+		return Qt::AlignCenter;
+	else if(ui->right->isChecked())
+		return (Qt::AlignVCenter|Qt::AlignRight);
+	else if(ui->bottom_left->isChecked())
+		return (Qt::AlignBottom|Qt::AlignLeft);
+	else if(ui->bottom->isChecked())
+		return (Qt::AlignBottom|Qt::AlignHCenter);
+	else if(ui->bottom_right->isChecked())
+		return (Qt::AlignBottom|Qt::AlignRight);
+	else
+		return (Qt::AlignTop|Qt::AlignLeft);
+}
+
+bool AlignmentTextDialog::event(QEvent *event)
+{
+		//Little hack to set focus to a radio button
+		//if we not do that, when the user click on the title bar (for move the dialog) or try to resize the dialog,
+		//the dialog lose focus and close.
+	if(event->type() == QEvent::Show && m_first_show)
+	{
+		QTimer::singleShot(50, [this](){ui->top_left->setFocus();});
+		m_first_show = false;
+	}
+	
+	return QDialog::event(event);
+}

Added: trunk/sources/ui/alignmenttextdialog.h
===================================================================
--- trunk/sources/ui/alignmenttextdialog.h	                        (rev 0)
+++ trunk/sources/ui/alignmenttextdialog.h	2018-05-11 18:14:41 UTC (rev 5353)
@@ -0,0 +1,47 @@
+/*
+	Copyright 2006-2017 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 ALIGNMENTTEXTDIALOG_H
+#define ALIGNMENTTEXTDIALOG_H
+
+#include <QDialog>
+
+class DynamicElementTextItem;
+
+namespace Ui {
+	class AlignmentTextDialog;
+}
+
+class AlignmentTextDialog : public QDialog
+{
+	Q_OBJECT
+	
+	public:
+		explicit AlignmentTextDialog(DynamicElementTextItem *text, QWidget *parent = nullptr);
+		~AlignmentTextDialog();
+	
+		Qt::Alignment alignment() const;
+	
+	protected:
+		bool event(QEvent *event);
+	
+	private:
+		bool m_first_show = true;
+		Ui::AlignmentTextDialog *ui;
+};
+
+#endif // ALIGNMENTTEXTDIALOG_H

Added: trunk/sources/ui/alignmenttextdialog.ui
===================================================================
--- trunk/sources/ui/alignmenttextdialog.ui	                        (rev 0)
+++ trunk/sources/ui/alignmenttextdialog.ui	2018-05-11 18:14:41 UTC (rev 5353)
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AlignmentTextDialog</class>
+ <widget class="QDialog" name="AlignmentTextDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>160</width>
+    <height>158</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+    <horstretch>200</horstretch>
+    <verstretch>150</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>160</width>
+    <height>158</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Alignement du texte</string>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="1" column="3">
+      <widget class="QRadioButton" name="right">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="4">
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item row="0" column="2">
+      <widget class="QRadioButton" name="top">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="2">
+      <widget class="QRadioButton" name="bottom">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="3">
+      <widget class="QRadioButton" name="top_right">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QRadioButton" name="left">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="3">
+      <widget class="QRadioButton" name="bottom_right">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QRadioButton" name="bottom_left">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QRadioButton" name="top_left">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="2">
+      <widget class="QRadioButton" name="center">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <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>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>AlignmentTextDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>AlignmentTextDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp	2018-05-11 18:14:41 UTC (rev 5353)
@@ -33,6 +33,7 @@
 #include "qeticons.h"
 #include "diagram.h"
 #include "addelementtextcommand.h"
+#include "alignmenttextdialog.h"
 
 int src_txt_row   = 0;
 int usr_txt_row   = 1;
@@ -45,6 +46,7 @@
 int x_txt_row     = 8;
 int y_txt_row     = 9;
 int rot_txt_row   = 10;
+int align_txt_row = 11;
 
 int align_grp_row  = 0;
 int rot_grp_row    = 1;
@@ -277,6 +279,19 @@
 		qsi_list.clear();;
 		qsi_list << rot << rot_a;
 		qsi->appendRow(qsi_list);
+		
+			//Alignment
+		QStandardItem *alignment = new QStandardItem(tr("Alignement"));
+		alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+		
+		QStandardItem *alignmenta = new QStandardItem(tr("Éditer"));
+		alignmenta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+		alignmenta->setData(DynamicElementTextModel::txtAlignment, Qt::UserRole+1);
+		alignmenta->setData(QVariant::fromValue(deti->alignment()), Qt::UserRole+2);
+		
+		qsi_list.clear();
+		qsi_list << alignment << alignmenta;
+		qsi->appendRow(qsi_list);
 	}
 	
 	
@@ -451,6 +466,13 @@
 			new QPropertyUndoCommand(deti, "compositeText", QVariant(deti->compositeText()), QVariant(composite_text), undo);
 	}
 	
+	Qt::Alignment alignment = text_qsi->child(align_txt_row, 1)->data(Qt::UserRole+2).value<Qt::Alignment>();
+	if (alignment != deti->alignment())
+	{
+		QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "alignment", QVariant(deti->alignment()), QVariant(alignment), undo);
+		quc->setText(tr("Modifier l'alignement d'un texte d'élément"));
+	}
+	
 	int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt();
 	if (fs != deti->fontSize())
 	{
@@ -1368,6 +1390,22 @@
 			cted->setObjectName("composite_text");
 			return cted;
 		}
+		case DynamicElementTextModel::txtAlignment:
+		{
+			const DynamicElementTextModel *detm = static_cast<const DynamicElementTextModel *>(index.model());
+			QStandardItem *qsi = detm->itemFromIndex(index);
+			
+			if(!qsi)
+				break;
+			
+			DynamicElementTextItem *deti = detm->textFromIndex(index);
+			if(!deti)
+				break;
+			
+			AlignmentTextDialog *atd = new AlignmentTextDialog(deti, parent);
+			atd->setObjectName("alignment_text");
+			return atd;
+		}
 		case DynamicElementTextModel::size:
 		{
 			QSpinBox *sb = new QSpinBox(parent);
@@ -1502,6 +1540,19 @@
 				}
 			}
 		}
+		else if (editor->objectName() == "alignment_text")
+		{	
+			if(QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
+			{
+				if(QStandardItem *qsi = qsim->itemFromIndex(index))
+				{
+					AlignmentTextDialog *atd = static_cast<AlignmentTextDialog *>(editor);
+					Qt::Alignment align = atd->alignment();
+					qsi->setData(QVariant::fromValue(align), Qt::UserRole+2);
+					return;
+				}
+			}
+		}
 		else if (editor->objectName() == "group_alignment")
 		{
 			if(QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))

Modified: trunk/sources/ui/dynamicelementtextmodel.h
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.h	2018-05-06 19:44:29 UTC (rev 5352)
+++ trunk/sources/ui/dynamicelementtextmodel.h	2018-05-11 18:14:41 UTC (rev 5353)
@@ -42,6 +42,7 @@
 			userText,
 			infoText,
 			compositeText,
+			txtAlignment,
             size,
             color,
 			pos,


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