diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 110391d71..2a6d97fe5 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1515,7 +1515,9 @@ void Conductor::setProperties(const ConductorProperties &property) } m_text_item->setPlainText(m_properties.text); - m_text_item->setFontSize(m_properties.text_size); + QFont font = m_text_item->font(); + font.setPointSize(m_properties.text_size); + m_text_item->setFont(font); if (m_properties.type != ConductorProperties::Multi) m_text_item->setVisible(false); diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index d046d9a70..a821b0d6c 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -150,21 +150,6 @@ QPointF DiagramTextItem::mapMovementFromParent(const QPointF &movement) const { return(local_movement_point - local_origin); } -void DiagramTextItem::setFontSize(int s) -{ - prepareAlignment(); - QFont font_ = font(); - font_.setPointSize(s); - setFont(font_); - finishAlignment(); - emit fontSizeChanged(s); -} - -int DiagramTextItem::fontSize() const -{ - return font().pointSize(); -} - void DiagramTextItem::setFont(const QFont &font) { if (this->font() == font) { diff --git a/sources/qetgraphicsitem/diagramtextitem.h b/sources/qetgraphicsitem/diagramtextitem.h index 1c19f6628..61ff60851 100644 --- a/sources/qetgraphicsitem/diagramtextitem.h +++ b/sources/qetgraphicsitem/diagramtextitem.h @@ -34,7 +34,6 @@ class DiagramTextItem : public QGraphicsTextItem { Q_OBJECT - 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) Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText) @@ -42,7 +41,6 @@ class DiagramTextItem : public QGraphicsTextItem signals: - void fontSizeChanged(int size); void colorChanged(QColor color); void alignmentChanged(Qt::Alignment alignment); void textEdited(const QString &old_str, const QString &new_str); @@ -69,9 +67,6 @@ class DiagramTextItem : public QGraphicsTextItem QPointF mapMovementToParent (const QPointF &) const; QPointF mapMovementFromParent (const QPointF &) const; - void setFontSize(int s); - int fontSize()const; - void setFont(const QFont &font); void setColor(const QColor& color); diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 130ce0310..b057b86cf 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -511,7 +511,9 @@ bool Element::parseInput(const QDomElement &dom_element) { DynamicElementTextItem *deti = new DynamicElementTextItem(this); deti->setText(dom_element.attribute("text", "_")); - deti->setFontSize(dom_element.attribute("size", QString::number(9)).toInt()); + QFont font = deti->font(); + font.setPointSize(dom_element.attribute("size", QString::number(9)).toInt()); + deti->setFont(font); deti->setRotation(dom_element.attribute("rotation", QString::number(0)).toDouble()); if(dom_element.attribute("tagg", "none") != "none") @@ -903,7 +905,9 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool comment_text = new DynamicElementTextItem(this); comment_text->setTextFrom(DynamicElementTextItem::ElementInfo); comment_text->setInfoName("comment"); - comment_text->setFontSize(6); + QFont font = comment_text->font(); + font.setPointSize(6); + comment_text->setFont(font); comment_text->setFrame(true); if(comment_text->toPlainText().count() > 17) comment_text->setTextWidth(80); @@ -922,7 +926,9 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool location_text = new DynamicElementTextItem(this); location_text->setTextFrom(DynamicElementTextItem::ElementInfo); location_text->setInfoName("location"); - location_text->setFontSize(6); + QFont font = location_text->font(); + font.setPointSize(6); + location_text->setFont(font); if(location_text->toPlainText().count() > 17) location_text->setTextWidth(80); location_text->setPos(deti->x(), deti->y()+20); //+20 is arbitrary, location_text must be below deti and comment @@ -966,7 +972,9 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool comment_text = new DynamicElementTextItem(this); comment_text->setTextFrom(DynamicElementTextItem::ElementInfo); comment_text->setInfoName("comment"); - comment_text->setFontSize(6); + QFont font = comment_text->font(); + font.setPointSize(6); + comment_text->setFont(font); comment_text->setFrame(true); comment_text->setTextWidth(80); addDynamicTextItem(comment_text); @@ -978,7 +986,9 @@ bool Element::fromXml(QDomElement &e, QHash &table_id_adr, bool location_text = new DynamicElementTextItem(this); location_text->setTextFrom(DynamicElementTextItem::ElementInfo); location_text->setInfoName("location"); - location_text->setFontSize(6); + QFont font = location_text->font(); + font.setPointSize(6); + location_text->setFont(font); location_text->setTextWidth(80); if(comment_text) location_text->setPos(comment_text->x(), comment_text->y()+10); //+10 is arbitrary, location_text must be below the comment diff --git a/sources/qetgraphicsitem/elementtextitemgroup.cpp b/sources/qetgraphicsitem/elementtextitemgroup.cpp index ef3c3891b..468ab2a37 100644 --- a/sources/qetgraphicsitem/elementtextitemgroup.cpp +++ b/sources/qetgraphicsitem/elementtextitemgroup.cpp @@ -67,7 +67,7 @@ void ElementTextItemGroup::addToGroup(QGraphicsItem *item) updateAlignment(); DynamicElementTextItem *deti = qgraphicsitem_cast(item); - connect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment); + connect(deti, &DynamicElementTextItem::fontChanged, this, &ElementTextItemGroup::updateAlignment); connect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment); connect(deti, &DynamicElementTextItem::textFromChanged, this, &ElementTextItemGroup::updateAlignment); connect(deti, &DynamicElementTextItem::infoNameChanged, this, &ElementTextItemGroup::updateAlignment); @@ -98,7 +98,7 @@ void ElementTextItemGroup::removeFromGroup(QGraphicsItem *item) if(DynamicElementTextItem *deti = qgraphicsitem_cast(item)) { - disconnect(deti, &DynamicElementTextItem::fontSizeChanged, this, &ElementTextItemGroup::updateAlignment); + disconnect(deti, &DynamicElementTextItem::fontChanged, this, &ElementTextItemGroup::updateAlignment); disconnect(deti, &DynamicElementTextItem::textChanged, this, &ElementTextItemGroup::updateAlignment); disconnect(deti, &DynamicElementTextItem::textFromChanged, this, &ElementTextItemGroup::updateAlignment); disconnect(deti, &DynamicElementTextItem::infoNameChanged, this, &ElementTextItemGroup::updateAlignment); @@ -453,11 +453,11 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt } if(m_frame) { - int font_size = 1; + qreal font_size = 1; QRectF rect; for(DynamicElementTextItem *deti : this->texts()) { - font_size = std::max(font_size, deti->fontSize()); + font_size = std::max(font_size, deti->font().pointSizeF()); rect = rect.united(mapFromItem(deti, deti->frameRect()).boundingRect()); } @@ -465,7 +465,7 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt qreal w=0.3; if (font_size >= 5) { - w = (qreal)font_size*0.1; + w = font_size*0.1; if(w > 2.5) w = 2.5; } @@ -477,7 +477,7 @@ void ElementTextItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsIt painter->setRenderHint(QPainter::Antialiasing); //Adjust the rounding of the rectangle according to the size of the font - qreal ro = (qreal)font_size/3; + qreal ro = font_size/3; painter->drawRoundedRect(rect, ro, ro); painter->restore(); } diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index 2ac8b1791..6acf1afaa 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -488,8 +488,9 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt(); if (fs != deti->font().pointSize()) { - QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "fontSize", QVariant(deti->font().pointSize()), QVariant(fs), undo); - quc->setAnimated(true, false); + QFont font = deti->font(); + font.setPointSize(fs); + QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "font", QVariant(deti->font()), QVariant(font), undo); quc->setText(tr("Modifier la taille d'un texte d'élément")); } diff --git a/sources/ui/inditextpropertieswidget.cpp b/sources/ui/inditextpropertieswidget.cpp index d222c61f7..eb8cda9d6 100644 --- a/sources/ui/inditextpropertieswidget.cpp +++ b/sources/ui/inditextpropertieswidget.cpp @@ -76,7 +76,7 @@ void IndiTextPropertiesWidget::setText(IndependentTextItem *text) m_connect_list << connect(m_text.data(), &IndependentTextItem::xChanged, this, &IndiTextPropertiesWidget::updateUi); m_connect_list << connect(m_text.data(), &IndependentTextItem::yChanged, this, &IndiTextPropertiesWidget::updateUi); m_connect_list << connect(m_text.data(), &IndependentTextItem::rotationChanged, this, &IndiTextPropertiesWidget::updateUi); - m_connect_list << connect(m_text.data(), &IndependentTextItem::fontSizeChanged, this, &IndiTextPropertiesWidget::updateUi); + m_connect_list << connect(m_text.data(), &IndependentTextItem::fontChanged, this, &IndiTextPropertiesWidget::updateUi); m_connect_list << connect(m_text.data(), &IndependentTextItem::textEdited, this, &IndiTextPropertiesWidget::updateUi); updateUi(); @@ -192,9 +192,10 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const 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); + if (ui->m_size_sb->value() != m_text->font().pointSize()) { + QFont font = m_text->font(); + font.setPointSize(ui->m_size_sb->value()); + undo = new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font); undo->setText(tr("Modifier la taille d'un champ texte")); } @@ -206,13 +207,13 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const bool size_equal = true; bool angle_equal = true; qreal rotation_ = m_text_list.first()->rotation(); - int size_ = m_text_list.first()->fontSize(); + int size_ = m_text_list.first()->font().pointSize(); for (QPointer piti : m_text_list) { if (piti->rotation() != rotation_) { angle_equal = false; } - if (piti->fontSize() != size_) { + if (piti->font().pointSize() != size_) { size_equal = false; } } @@ -242,7 +243,9 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const if (!parent_undo) { parent_undo = new QUndoCommand(tr("Modifier la taille de plusieurs champs texte")); } - QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "fontSize", QVariant(piti->fontSize()), QVariant(ui->m_size_sb->value()), parent_undo); + QFont font = piti->font(); + font.setPointSize(ui->m_size_sb->value()); + QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(piti.data(), "font", QVariant(piti->font()), QVariant(font), parent_undo); qpuc->setAnimated(true, false); } } @@ -266,8 +269,11 @@ QUndoCommand *IndiTextPropertiesWidget::associatedUndo() const if (ui->m_line_edit->text() != m_text->toPlainText()) { new ChangeDiagramTextCommand(m_text.data(), m_text->toHtml(), ui->m_line_edit->text(), undo); } - if (ui->m_size_sb->value() != m_text->fontSize()) { - new QPropertyUndoCommand(m_text.data(), "fontSize", m_text->fontSize(), ui->m_size_sb->value(), undo); + if (ui->m_size_sb->value() != m_text->font().pointSize()) + { + QFont font = m_text->font(); + font.setPointSize(ui->m_size_sb->value()); + new QPropertyUndoCommand(m_text.data(), "font", m_text->font(), font, undo); } if (undo->childCount()) { @@ -329,7 +335,7 @@ void IndiTextPropertiesWidget::updateUi() 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_size_sb->setValue(m_text->font().pointSize()); ui->m_line_edit->setDisabled(m_text->isHtml() ? true : false); ui->m_size_sb->setDisabled(m_text->isHtml() ? true : false); @@ -341,13 +347,13 @@ void IndiTextPropertiesWidget::updateUi() bool size_equal = true; bool angle_equal = true; qreal rotation_ = m_text_list.first()->rotation(); - int size_ = m_text_list.first()->fontSize(); + int size_ = m_text_list.first()->font().pointSize(); for (QPointer piti : m_text_list) { if (piti->rotation() != rotation_) { angle_equal = false; } - if (piti->fontSize() != size_) { + if (piti->font().pointSize() != size_) { size_equal = false; } }