mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
Align the lines of a multi-line symbol text to its alignment
The lines of a wrapped or multi-line dynamic text were always centred, whatever horizontal alignment the user picked, on the folio and in the symbol editor alike. Follow the horizontal alignment instead. The alignment still also sets the anchor point, as before, and saved positions are unchanged. Existing multi-line texts set to the default left alignment are now drawn left-aligned instead of centred. Issue #1155 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,7 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
|
||||
//Option when text is displayed in multiple line
|
||||
QTextOption option = document() -> defaultTextOption();
|
||||
option.setAlignment(Qt::AlignHCenter);
|
||||
option.setAlignment(m_alignment & Qt::AlignHorizontal_Mask);
|
||||
option.setWrapMode(QTextOption::WordWrap);
|
||||
document() -> setDefaultTextOption(option);
|
||||
}
|
||||
@@ -462,6 +462,10 @@ void PartDynamicTextField::setPlainText(const QString &text) {
|
||||
|
||||
void PartDynamicTextField::setAlignment(Qt::Alignment alignment) {
|
||||
m_alignment = alignment;
|
||||
//Lines of a multi-line text follow the horizontal alignment
|
||||
QTextOption option = document() -> defaultTextOption();
|
||||
option.setAlignment(m_alignment & Qt::AlignHorizontal_Mask);
|
||||
document() -> setDefaultTextOption(option);
|
||||
emit alignmentChanged(m_alignment);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,9 +63,17 @@ DynamicElementTextItem::DynamicElementTextItem(Element *parent_element) :
|
||||
|
||||
//Option when text is displayed in multiple line
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
option.setAlignment(Qt::AlignHCenter);
|
||||
option.setAlignment(alignment() & Qt::AlignHorizontal_Mask);
|
||||
option.setWrapMode(QTextOption::WordWrap);
|
||||
document()->setDefaultTextOption(option);
|
||||
|
||||
//Lines of a multi-line text follow the horizontal alignment
|
||||
connect(this, &DiagramTextItem::alignmentChanged, [this](Qt::Alignment alignment)
|
||||
{
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
option.setAlignment(alignment & Qt::AlignHorizontal_Mask);
|
||||
document()->setDefaultTextOption(option);
|
||||
});
|
||||
}
|
||||
|
||||
DynamicElementTextItem::~DynamicElementTextItem()
|
||||
|
||||
Reference in New Issue
Block a user