19 #include "ui_texteditor.h" 65 ui->m_line_edit->setText(
m_text->toPlainText());
66 ui->m_x_sb->setValue(
m_text->pos().x());
67 ui->m_y_sb->setValue(
m_text->pos().y());
68 ui->m_rotation_sb->setValue(
m_text->rotation());
69 ui->m_size_sb->setValue(
m_text->font().pointSize());
70 ui->m_font_pb->setText(
m_text->font().family());
71 ui->m_color_pb->setColor(
m_text->defaultTextColor());
95 if (
PartText *part_text = dynamic_cast<PartText *>(part))
138 QString text_ = ui->m_line_edit->text();
139 if (text_ != m_text->toPlainText())
141 QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text,
"text", m_text->toPlainText(), text_);
142 undo->setText(tr(
"Modifier le contenu d'un champ texte"));
143 undoStack().push(undo);
146 m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [
this]()
148 QPointF pos(ui->m_x_sb->value(), ui->m_y_sb->value());
149 if (pos != m_text->pos())
151 QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text,
"pos", m_text->pos(), pos);
152 undo->setText(tr(
"Déplacer un champ texte"));
153 undo->setAnimated(true, false);
154 undoStack().push(undo);
157 m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [
this]()
159 QPointF pos(ui->m_x_sb->value(), ui->m_y_sb->value());
160 if (pos != m_text->pos())
162 QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text,
"pos", m_text->pos(), pos);
163 undo->setText(tr(
"Déplacer un champ texte"));
164 undo->setAnimated(true, false);
165 undoStack().push(undo);
168 m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [
this]()
170 if (ui->m_rotation_sb->value() != m_text->rotation())
172 QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text,
"rotation", m_text->rotation(), ui->m_rotation_sb->value());
173 undo->setText(tr(
"Pivoter un champ texte"));
174 undo->setAnimated(true, false);
175 undoStack().push(undo);
178 m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [
this]()
180 if (m_text->font().pointSize() != ui->m_size_sb->value())
182 QFont font_ = m_text->font();
183 font_.setPointSize(ui->m_size_sb->value());
184 QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text,
"font", m_text->font(), font_);
185 undo->setText(tr(
"Modifier la police d'un texte"));
186 undoStack().push(undo);
197 QFont font_ = QFontDialog::getFont(&ok,
m_text->font(),
this);
199 if (ok && font_ !=
m_text->font())
201 ui->m_size_sb->blockSignals(
true);
202 ui->m_size_sb->setValue(font_.pointSize());
203 ui->m_size_sb->blockSignals(
false);
205 ui->m_font_pb->setText(font_.family());
207 undo->setText(
tr(
"Modifier la police d'un texte"));
218 if (newColor !=
m_text->defaultTextColor())
221 undo->setText(
tr(
"Modifier la couleur d'un texte"));
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
QList< QMetaObject::Connection > m_edit_connection
void plainTextChanged(const QString &text)
void on_m_color_pb_changed(const QColor &newColor)
TextEditor::on_m_color_pb_changed.
void colorChanged(const QColor &color)
QPointer< PartText > m_text
bool setPart(CustomElementPart *part) override
TextEditor::setPart Set the current text to edit. Set to nullptr to clear the current text...
~TextEditor() override
TextEditor::~TextEditor.
TextEditor(QETElementEditor *editor, PartText *text=nullptr, QWidget *parent=nullptr)
TextEditor::TextEditor Default constructor.
void on_m_font_pb_clicked()
TextEditor::on_m_font_pb_clicked.
void updateForm() override
TextEditor::updateForm Update the gui.
void fontChanged(const QFont &font)
CustomElementPart * currentPart() const override
TextEditor::currentPart.
virtual QUndoStack & undoStack() const
void setUpEditConnection()
TextEditor::setUpEditConnection Setup the connection between the widgets of this editor and the undo ...
QList< QMetaObject::Connection > m_change_connection