mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Independent text editor can now edit several texts.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5738 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2017 The QElectroTech Team
|
Copyright 2006-2017 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -80,12 +80,30 @@ void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
|
|||||||
void DiagramPropertiesEditorDockWidget::selectionChanged()
|
void DiagramPropertiesEditorDockWidget::selectionChanged()
|
||||||
{
|
{
|
||||||
if (!m_diagram) return;
|
if (!m_diagram) return;
|
||||||
//This editor can edit only one item.
|
|
||||||
if (m_diagram->selectedItems().size() != 1)
|
int count_ = m_diagram->selectedItems().size();
|
||||||
|
|
||||||
|
//The editor widget can only edit one item
|
||||||
|
//or several items of the same type
|
||||||
|
if (count_ != 1)
|
||||||
{
|
{
|
||||||
clear();
|
if (count_ == 0) {
|
||||||
m_edited_qgi_type = -1;
|
clear();
|
||||||
return;
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<QGraphicsItem *> list_ = m_diagram->selectedItems();
|
||||||
|
int type_ = list_.first()->type();
|
||||||
|
for (QGraphicsItem *qgi : list_)
|
||||||
|
{
|
||||||
|
if (qgi->type() != type_)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem *item = m_diagram->selectedItems().first();
|
QGraphicsItem *item = m_diagram->selectedItems().first();
|
||||||
@@ -95,6 +113,12 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
{
|
{
|
||||||
case Element::Type: //1000
|
case Element::Type: //1000
|
||||||
{
|
{
|
||||||
|
if (count_ > 1)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
//We already edit an element, just update the editor with a new element
|
//We already edit an element, just update the editor with a new element
|
||||||
if (m_edited_qgi_type == type_)
|
if (m_edited_qgi_type == type_)
|
||||||
{
|
{
|
||||||
@@ -109,19 +133,31 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
}
|
}
|
||||||
case IndependentTextItem::Type: //1005
|
case IndependentTextItem::Type: //1005
|
||||||
{
|
{
|
||||||
|
QList<IndependentTextItem *> text_list;
|
||||||
|
for (QGraphicsItem *qgi : m_diagram->selectedItems()) {
|
||||||
|
text_list.append(static_cast<IndependentTextItem*>(qgi));
|
||||||
|
}
|
||||||
|
|
||||||
if (m_edited_qgi_type == type_)
|
if (m_edited_qgi_type == type_)
|
||||||
{
|
{
|
||||||
static_cast<IndiTextPropertiesWidget*>(editors().first())->setText(static_cast<IndependentTextItem*>(item));
|
static_cast<IndiTextPropertiesWidget*>(editors().first())->setText(text_list);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
m_edited_qgi_type = type_;
|
m_edited_qgi_type = type_;
|
||||||
addEditor(new IndiTextPropertiesWidget(static_cast<IndependentTextItem*>(item), this));
|
addEditor(new IndiTextPropertiesWidget(text_list, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DiagramImageItem::Type: //1007
|
case DiagramImageItem::Type: //1007
|
||||||
{
|
{
|
||||||
|
if (count_ > 1)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
m_edited_qgi_type = type_;
|
m_edited_qgi_type = type_;
|
||||||
addEditor(new ImagePropertiesWidget(static_cast<DiagramImageItem*>(item), this));
|
addEditor(new ImagePropertiesWidget(static_cast<DiagramImageItem*>(item), this));
|
||||||
@@ -129,6 +165,13 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
}
|
}
|
||||||
case QetShapeItem::Type: //1008
|
case QetShapeItem::Type: //1008
|
||||||
{
|
{
|
||||||
|
if (count_ > 1)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_edited_qgi_type == type_)
|
if (m_edited_qgi_type == type_)
|
||||||
{
|
{
|
||||||
static_cast<ShapeGraphicsItemPropertiesWidget*>(editors().first())->setItem(static_cast<QetShapeItem*>(item));
|
static_cast<ShapeGraphicsItemPropertiesWidget*>(editors().first())->setItem(static_cast<QetShapeItem*>(item));
|
||||||
@@ -142,6 +185,13 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
}
|
}
|
||||||
case DynamicElementTextItem::Type: //1010
|
case DynamicElementTextItem::Type: //1010
|
||||||
{
|
{
|
||||||
|
if (count_ > 1)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DynamicElementTextItem *deti = static_cast<DynamicElementTextItem *>(item);
|
DynamicElementTextItem *deti = static_cast<DynamicElementTextItem *>(item);
|
||||||
|
|
||||||
//For dynamic element text, we open the element editor to edit it
|
//For dynamic element text, we open the element editor to edit it
|
||||||
@@ -159,6 +209,13 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
}
|
}
|
||||||
case QGraphicsItemGroup::Type:
|
case QGraphicsItemGroup::Type:
|
||||||
{
|
{
|
||||||
|
if (count_ > 1)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
m_edited_qgi_type = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(ElementTextItemGroup *group = dynamic_cast<ElementTextItemGroup *>(item))
|
if(ElementTextItemGroup *group = dynamic_cast<ElementTextItemGroup *>(item))
|
||||||
{
|
{
|
||||||
//For element text item group, we open the element editor to edit it
|
//For element text item group, we open the element editor to edit it
|
||||||
@@ -180,8 +237,9 @@ void DiagramPropertiesEditorDockWidget::selectionChanged()
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (PropertiesEditorWidget *pew, editors())
|
for (PropertiesEditorWidget *pew : editors()) {
|
||||||
pew->setLiveEdit(true);
|
pew->setLiveEdit(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ IndiTextPropertiesWidget::IndiTextPropertiesWidget(IndependentTextItem *text, QW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief IndiTextPropertiesWidget::IndiTextPropertiesWidget
|
||||||
|
* @param text_list : a list of texts to edit
|
||||||
|
* @param parent : the parent widget of this widget
|
||||||
|
*/
|
||||||
|
IndiTextPropertiesWidget::IndiTextPropertiesWidget(QList<IndependentTextItem *> text_list, QWidget *parent) :
|
||||||
|
PropertiesEditorWidget (parent),
|
||||||
|
ui(new Ui::IndiTextPropertiesWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
setText(text_list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief IndiTextPropertiesWidget::~IndiTextPropertiesWidget
|
* @brief IndiTextPropertiesWidget::~IndiTextPropertiesWidget
|
||||||
*/
|
*/
|
||||||
@@ -69,6 +82,32 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text)
|
|||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IndiTextPropertiesWidget::setText(QList<IndependentTextItem *> text_list)
|
||||||
|
{
|
||||||
|
for (QMetaObject::Connection c : m_connect_list) {
|
||||||
|
disconnect(c);
|
||||||
|
}
|
||||||
|
m_connect_list.clear();
|
||||||
|
m_text_list.clear();
|
||||||
|
m_text = nullptr;
|
||||||
|
|
||||||
|
if (text_list.size() == 0) {
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
else if (text_list.size() == 1)
|
||||||
|
{
|
||||||
|
setText(text_list.first());
|
||||||
|
m_text_list.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (IndependentTextItem *iti : text_list) {
|
||||||
|
m_text_list.append(QPointer<IndependentTextItem>(iti));
|
||||||
|
}
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief IndiTextPropertiesWidget::apply
|
* @brief IndiTextPropertiesWidget::apply
|
||||||
* Apply the current edition through a QUndoCommand pushed
|
* Apply the current edition through a QUndoCommand pushed
|
||||||
@@ -76,11 +115,24 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text)
|
|||||||
*/
|
*/
|
||||||
void IndiTextPropertiesWidget::apply()
|
void IndiTextPropertiesWidget::apply()
|
||||||
{
|
{
|
||||||
if (m_text && m_text->diagram())
|
Diagram *d = nullptr;
|
||||||
|
|
||||||
|
if (m_text && m_text->diagram()) {
|
||||||
|
d = m_text->diagram();
|
||||||
|
} else if (!m_text_list.isEmpty()) {
|
||||||
|
for (QPointer<IndependentTextItem> piti : m_text_list) {
|
||||||
|
if (piti->diagram()) {
|
||||||
|
d = piti->diagram();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d)
|
||||||
{
|
{
|
||||||
QUndoCommand *undo = associatedUndo();
|
QUndoCommand *undo = associatedUndo();
|
||||||
if (undo) {
|
if (undo) {
|
||||||
m_text->diagram()->undoStack().push(undo);
|
d->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,34 +170,88 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
|||||||
if (m_live_edit)
|
if (m_live_edit)
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = nullptr;
|
QPropertyUndoCommand *undo = nullptr;
|
||||||
if(ui->m_x_sb->value() != m_text->pos().x()) {
|
//One text is edited
|
||||||
undo = new QPropertyUndoCommand(m_text.data(), "x", QVariant(m_text->pos().x()), QVariant(ui->m_x_sb->value()));
|
if (m_text_list.isEmpty())
|
||||||
undo->setAnimated(true, false);
|
{
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
if(ui->m_x_sb->value() != m_text->pos().x()) {
|
||||||
|
undo = new QPropertyUndoCommand(m_text.data(), "x", QVariant(m_text->pos().x()), QVariant(ui->m_x_sb->value()));
|
||||||
|
undo->setAnimated(true, false);
|
||||||
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
|
}
|
||||||
|
if(ui->m_y_sb->value() != m_text->pos().y()) {
|
||||||
|
undo = new QPropertyUndoCommand(m_text.data(), "y", QVariant(m_text->pos().y()), QVariant(ui->m_y_sb->value()));
|
||||||
|
undo->setAnimated(true, false);
|
||||||
|
undo->setText(tr("Déplacer un champ texte"));
|
||||||
|
}
|
||||||
|
if(ui->m_angle_sb->value() != m_text->rotation()) {
|
||||||
|
undo = new QPropertyUndoCommand(m_text.data(), "rotation", QVariant(m_text->rotation()), QVariant(ui->m_angle_sb->value()));
|
||||||
|
undo->setAnimated(true, false);
|
||||||
|
undo->setText(tr("Pivoter un champ texte"));
|
||||||
|
}
|
||||||
|
if (ui->m_line_edit->text() != m_text->toPlainText()) {
|
||||||
|
undo = new QPropertyUndoCommand(m_text.data(), "plainText", m_text->toPlainText(), ui->m_line_edit->text());
|
||||||
|
undo->setText(tr("Modifier un champ texte"));
|
||||||
|
}
|
||||||
|
if (ui->m_size_sb->value() != m_text->fontSize()) {
|
||||||
|
undo = new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value());
|
||||||
|
undo->setAnimated(true, false);
|
||||||
|
undo->setText(tr("Modifier la taille d'un champ texte"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return undo;
|
||||||
}
|
}
|
||||||
if(ui->m_y_sb->value() != m_text->pos().y()) {
|
else //several text are edited, only size and rotation is available for edition
|
||||||
undo = new QPropertyUndoCommand(m_text.data(), "y", QVariant(m_text->pos().y()), QVariant(ui->m_y_sb->value()));
|
{
|
||||||
undo->setAnimated(true, false);
|
QUndoCommand *parent_undo = nullptr;
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
bool size_equal = true;
|
||||||
|
bool angle_equal = true;
|
||||||
|
qreal rotation_ = m_text_list.first()->rotation();
|
||||||
|
int size_ = m_text_list.first()->fontSize();
|
||||||
|
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||||
|
{
|
||||||
|
if (piti->rotation() != rotation_) {
|
||||||
|
angle_equal = false;
|
||||||
|
}
|
||||||
|
if (piti->fontSize() != size_) {
|
||||||
|
size_equal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((angle_equal && (ui->m_angle_sb->value() != rotation_)) ||
|
||||||
|
(!angle_equal && (ui->m_angle_sb->value() != ui->m_angle_sb->minimum())))
|
||||||
|
{
|
||||||
|
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||||
|
{
|
||||||
|
if (piti)
|
||||||
|
{
|
||||||
|
if (!parent_undo) {
|
||||||
|
parent_undo = new QUndoCommand(tr("Pivoter plusieurs champs texte"));
|
||||||
|
}
|
||||||
|
QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "rotation", QVariant(m_text->rotation()), QVariant(ui->m_angle_sb->value()), parent_undo);
|
||||||
|
qpuc->setAnimated(true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((size_equal && (ui->m_size_sb->value() != size_)) ||
|
||||||
|
(!size_equal && (ui->m_size_sb->value() != ui->m_size_sb->minimum())))
|
||||||
|
{
|
||||||
|
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||||
|
{
|
||||||
|
if (piti)
|
||||||
|
{
|
||||||
|
if (!parent_undo) {
|
||||||
|
parent_undo = new QUndoCommand(tr("Modifier la taille de plusieurs champs texte"));
|
||||||
|
}
|
||||||
|
QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value(), parent_undo);
|
||||||
|
qpuc->setAnimated(true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent_undo;
|
||||||
}
|
}
|
||||||
if(ui->m_angle_sb->value() != m_text->rotation()) {
|
|
||||||
undo = new QPropertyUndoCommand(m_text.data(), "rotation", QVariant(m_text->rotation()), QVariant(ui->m_angle_sb->value()));
|
|
||||||
undo->setAnimated(true, false);
|
|
||||||
undo->setText(tr("Pivoter un champ texte"));
|
|
||||||
}
|
|
||||||
if (ui->m_line_edit->text() != m_text->toPlainText()) {
|
|
||||||
undo = new QPropertyUndoCommand(m_text.data(), "plainText", m_text->toPlainText(), ui->m_line_edit->text());
|
|
||||||
undo->setText(tr("Modifier un champ texte"));
|
|
||||||
}
|
|
||||||
if (ui->m_size_sb->value() != m_text->fontSize()) {
|
|
||||||
undo = new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value());
|
|
||||||
undo->setAnimated(true, false);
|
|
||||||
undo->setText(tr("Modifier la taille d'un champ texte"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return undo;
|
|
||||||
}
|
}
|
||||||
else
|
//In mode not live edit, only one text can be edited
|
||||||
|
else if (m_text_list.isEmpty())
|
||||||
{
|
{
|
||||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétées d'un texte"));
|
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétées d'un texte"));
|
||||||
if(ui->m_x_sb->value() != m_text->pos().x()) {
|
if(ui->m_x_sb->value() != m_text->pos().x()) {
|
||||||
@@ -170,11 +276,14 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief IndiTextPropertiesWidget::setUpEditConnection
|
* @brief IndiTextPropertiesWidget::setUpEditConnection
|
||||||
* Disconnect the previous connection, and reconnect the connection between the editors widgets and apply function
|
* Disconnect the previous connection, and reconnect the connection between the editors widgets and void IndiTextPropertiesWidget::apply function
|
||||||
*/
|
*/
|
||||||
void IndiTextPropertiesWidget::setUpEditConnection()
|
void IndiTextPropertiesWidget::setUpEditConnection()
|
||||||
{
|
{
|
||||||
@@ -182,10 +291,14 @@ void IndiTextPropertiesWidget::setUpEditConnection()
|
|||||||
disconnect(c);
|
disconnect(c);
|
||||||
}
|
}
|
||||||
m_edit_connection.clear();
|
m_edit_connection.clear();
|
||||||
m_edit_connection << connect(ui->m_x_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
|
||||||
m_edit_connection << connect(ui->m_y_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
if (m_text_list.isEmpty())
|
||||||
|
{
|
||||||
|
m_edit_connection << connect(ui->m_x_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
||||||
|
m_edit_connection << connect(ui->m_y_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
||||||
|
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, this, &IndiTextPropertiesWidget::apply);
|
||||||
|
}
|
||||||
m_edit_connection << connect(ui->m_angle_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
m_edit_connection << connect(ui->m_angle_sb, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
||||||
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, this, &IndiTextPropertiesWidget::apply);
|
|
||||||
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &IndiTextPropertiesWidget::apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +307,7 @@ void IndiTextPropertiesWidget::setUpEditConnection()
|
|||||||
*/
|
*/
|
||||||
void IndiTextPropertiesWidget::updateUi()
|
void IndiTextPropertiesWidget::updateUi()
|
||||||
{
|
{
|
||||||
if (!m_text) {
|
if (!m_text && m_text_list.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,14 +318,45 @@ void IndiTextPropertiesWidget::updateUi()
|
|||||||
}
|
}
|
||||||
m_edit_connection.clear();
|
m_edit_connection.clear();
|
||||||
|
|
||||||
ui->m_x_sb->setValue(m_text->pos().x());
|
ui->m_x_sb->setEnabled(m_text_list.isEmpty() ? true : false);
|
||||||
ui->m_y_sb->setValue(m_text->pos().y());
|
ui->m_y_sb->setEnabled(m_text_list.isEmpty() ? true : false);
|
||||||
ui->m_angle_sb->setValue(m_text->rotation());
|
ui->m_line_edit->setEnabled(m_text_list.isEmpty() ? true : false);
|
||||||
ui->m_line_edit->setText(m_text->toPlainText());
|
ui->m_advanced_editor_pb->setEnabled(m_text_list.isEmpty() ? true : false);
|
||||||
ui->m_size_sb->setValue(m_text->fontSize());
|
|
||||||
|
|
||||||
ui->m_line_edit->setDisabled(m_text->isHtml() ? true : false);
|
if (m_text_list.isEmpty())
|
||||||
ui->m_size_sb->setDisabled(m_text->isHtml() ? true : false);
|
{
|
||||||
|
ui->m_x_sb->setValue(m_text->pos().x());
|
||||||
|
ui->m_y_sb->setValue(m_text->pos().y());
|
||||||
|
ui->m_line_edit->setText(m_text->toPlainText());
|
||||||
|
ui->m_angle_sb->setValue(m_text->rotation());
|
||||||
|
ui->m_size_sb->setValue(m_text->fontSize());
|
||||||
|
|
||||||
|
ui->m_line_edit->setDisabled(m_text->isHtml() ? true : false);
|
||||||
|
ui->m_size_sb->setDisabled(m_text->isHtml() ? true : false);
|
||||||
|
ui->m_label->setVisible(m_text->isHtml() ? true : false);
|
||||||
|
ui->m_break_html_pb->setVisible(m_text->isHtml() ? true : false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool size_equal = true;
|
||||||
|
bool angle_equal = true;
|
||||||
|
qreal rotation_ = m_text_list.first()->rotation();
|
||||||
|
int size_ = m_text_list.first()->fontSize();
|
||||||
|
for (QPointer<IndependentTextItem> piti : m_text_list)
|
||||||
|
{
|
||||||
|
if (piti->rotation() != rotation_) {
|
||||||
|
angle_equal = false;
|
||||||
|
}
|
||||||
|
if (piti->fontSize() != size_) {
|
||||||
|
size_equal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->m_angle_sb->setValue(angle_equal ? rotation_ : 0);
|
||||||
|
ui->m_size_sb->setValue(size_equal ? size_ : 0);
|
||||||
|
ui->m_label->setVisible(false);
|
||||||
|
ui->m_break_html_pb->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Set the connection now
|
//Set the connection now
|
||||||
setUpEditConnection();
|
setUpEditConnection();
|
||||||
@@ -226,3 +370,12 @@ void IndiTextPropertiesWidget::on_m_advanced_editor_pb_clicked() {
|
|||||||
m_text->edit();
|
m_text->edit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IndiTextPropertiesWidget::on_m_break_html_pb_clicked()
|
||||||
|
{
|
||||||
|
if (m_text)
|
||||||
|
{
|
||||||
|
m_text->setPlainText(m_text->toPlainText());
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2019 The QElectroTech Team
|
Copyright 2006-2019 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ namespace Ui {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The IndiTextPropertiesWidget class
|
* @brief The IndiTextPropertiesWidget class
|
||||||
* This widget is used to edit the properties of an independent text item
|
* This widget is used to edit the properties of one or several independent text item
|
||||||
*/
|
*/
|
||||||
class IndiTextPropertiesWidget : public PropertiesEditorWidget
|
class IndiTextPropertiesWidget : public PropertiesEditorWidget
|
||||||
{
|
{
|
||||||
@@ -36,15 +36,18 @@ class IndiTextPropertiesWidget : public PropertiesEditorWidget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
IndiTextPropertiesWidget(IndependentTextItem *text = nullptr, QWidget *parent = nullptr);
|
IndiTextPropertiesWidget(IndependentTextItem *text = nullptr, QWidget *parent = nullptr);
|
||||||
|
IndiTextPropertiesWidget(QList <IndependentTextItem *> text_list, QWidget *parent = nullptr);
|
||||||
~IndiTextPropertiesWidget() override;
|
~IndiTextPropertiesWidget() override;
|
||||||
void setText (IndependentTextItem *text);
|
void setText (IndependentTextItem *text);
|
||||||
|
void setText (QList<IndependentTextItem *> text_list);
|
||||||
|
|
||||||
void apply() override;
|
void apply() override;
|
||||||
bool setLiveEdit(bool live_edit) override;
|
bool setLiveEdit(bool live_edit) override;
|
||||||
QUndoCommand* associatedUndo() const override;
|
QUndoCommand* associatedUndo() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_advanced_editor_pb_clicked();
|
void on_m_advanced_editor_pb_clicked();
|
||||||
|
void on_m_break_html_pb_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpEditConnection();
|
void setUpEditConnection();
|
||||||
@@ -53,6 +56,7 @@ class IndiTextPropertiesWidget : public PropertiesEditorWidget
|
|||||||
private:
|
private:
|
||||||
Ui::IndiTextPropertiesWidget *ui;
|
Ui::IndiTextPropertiesWidget *ui;
|
||||||
QPointer <IndependentTextItem> m_text;
|
QPointer <IndependentTextItem> m_text;
|
||||||
|
QList <QPointer<IndependentTextItem>> m_text_list;
|
||||||
QList <QMetaObject::Connection> m_connect_list,
|
QList <QMetaObject::Connection> m_connect_list,
|
||||||
m_edit_connection;
|
m_edit_connection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,14 +6,51 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>299</width>
|
<width>288</width>
|
||||||
<height>237</height>
|
<height>251</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>X :</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="4">
|
||||||
|
<widget class="QPushButton" name="m_advanced_editor_pb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Éditeur avancé</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Taille :</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Angle :</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="m_x_sb">
|
<widget class="QDoubleSpinBox" name="m_x_sb">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
@@ -27,20 +64,39 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="4">
|
<item row="6" column="0">
|
||||||
<widget class="QPushButton" name="m_advanced_editor_pb">
|
<spacer name="verticalSpacer">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>Éditeur avancé</string>
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QSpinBox" name="m_size_sb">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>50</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="2" column="3">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QDoubleSpinBox" name="m_y_sb">
|
||||||
<property name="text">
|
<property name="suffix">
|
||||||
<string>Angle :</string>
|
<string>px</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="decimals">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>10000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -60,49 +116,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="4">
|
|
||||||
<widget class="QLineEdit" name="m_line_edit">
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>Texte</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<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 row="2" column="3">
|
|
||||||
<widget class="QDoubleSpinBox" name="m_y_sb">
|
|
||||||
<property name="suffix">
|
|
||||||
<string>px</string>
|
|
||||||
</property>
|
|
||||||
<property name="decimals">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>10000.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>X :</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -113,23 +126,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="0" column="0" colspan="4">
|
||||||
<widget class="QSpinBox" name="m_size_sb">
|
<widget class="QLineEdit" name="m_line_edit">
|
||||||
<property name="minimum">
|
<property name="placeholderText">
|
||||||
<number>4</number>
|
<string>Texte</string>
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>50</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="4" column="0" colspan="4">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="m_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Taille :</string>
|
<string>Le contenu et la taille du texte ne peuvent être modifié car formaté en html.
|
||||||
|
Veuillez utiliser l'éditeur avancé pour cela.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="scaledContents">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="4">
|
||||||
|
<widget class="QPushButton" name="m_break_html_pb">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cliquez ici pour annuler le formatage html</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user