19 #include "ui_inditextpropertieswidget.h" 94 if (text_list.size() == 0) {
97 else if (text_list.size() == 1)
105 m_text_list.append(QPointer<IndependentTextItem>(iti));
123 for (QPointer<IndependentTextItem> piti :
m_text_list) {
124 if (piti->diagram()) {
176 if(
ui->m_x_sb->value() !=
m_text->pos().x()) {
179 undo->setText(
tr(
"Déplacer un champ texte"));
181 if(
ui->m_y_sb->value() !=
m_text->pos().y()) {
184 undo->setText(
tr(
"Déplacer un champ texte"));
186 if(
ui->m_angle_sb->value() !=
m_text->rotation()) {
189 undo->setText(
tr(
"Pivoter un champ texte"));
191 if (
ui->m_line_edit->text() !=
m_text->toPlainText()) {
193 undo->setText(
tr(
"Modifier un champ texte"));
195 if (
ui->m_size_sb->value() !=
m_text->font().pointSize()) {
196 QFont font =
m_text->font();
197 font.setPointSize(
ui->m_size_sb->value());
199 undo->setText(
tr(
"Modifier la taille d'un champ texte"));
204 undo->setText(
tr(
"Modifier la police d'un champ texte"));
211 QUndoCommand *parent_undo =
nullptr;
212 bool size_equal =
true;
213 bool angle_equal =
true;
214 bool font_equal =
true;
216 int size_ =
m_text_list.first()->font().pointSize();
218 for (QPointer<IndependentTextItem> piti :
m_text_list)
220 if (piti->rotation() != rotation_) {
223 if (piti->font().pointSize() != size_) {
226 if (piti->font() != font_) {
231 if ((angle_equal && (
ui->m_angle_sb->value() != rotation_)) ||
232 (!angle_equal && (
ui->m_angle_sb->value() !=
ui->m_angle_sb->minimum())))
234 for (QPointer<IndependentTextItem> piti :
m_text_list)
239 parent_undo =
new QUndoCommand(
tr(
"Pivoter plusieurs champs texte"));
246 else if ((size_equal && (
ui->m_size_sb->value() != size_)) ||
247 (!size_equal && (
ui->m_size_sb->value() !=
ui->m_size_sb->minimum())))
249 for (QPointer<IndependentTextItem> piti :
m_text_list)
254 parent_undo =
new QUndoCommand(
tr(
"Modifier la taille de plusieurs champs texte"));
256 QFont font = piti->font();
257 font.setPointSize(
ui->m_size_sb->value());
258 new QPropertyUndoCommand(piti.data(),
"font", QVariant(piti->font()), QVariant(font), parent_undo);
265 for (QPointer<IndependentTextItem> piti :
m_text_list)
270 parent_undo =
new QUndoCommand(
tr(
"Modifier la police de plusieurs champs texte"));
282 QUndoCommand *undo =
new QUndoCommand(
tr(
"Modifier les propriétés d'un texte"));
283 if(
ui->m_x_sb->value() !=
m_text->pos().x()) {
286 if(
ui->m_y_sb->value() !=
m_text->pos().y()) {
289 if(
ui->m_angle_sb->value() !=
m_text->rotation()) {
292 if (
ui->m_line_edit->text() !=
m_text->toPlainText()) {
295 if (
ui->m_size_sb->value() !=
m_text->font().pointSize())
297 QFont font =
m_text->font();
298 font.setPointSize(
ui->m_size_sb->value());
305 if (undo->childCount()) {
334 m_edit_connection << connect(
ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [
this]()
336 this->m_selected_font.setPointSize(ui->m_size_sb->value());
357 ui->m_x_sb->setEnabled(
m_text_list.isEmpty() ? true :
false);
358 ui->m_y_sb->setEnabled(
m_text_list.isEmpty() ? true :
false);
359 ui->m_line_edit->setEnabled(
m_text_list.isEmpty() ? true :
false);
360 ui->m_advanced_editor_pb->setEnabled(
m_text_list.isEmpty() ? true :
false);
364 ui->m_x_sb->setValue(
m_text->pos().x());
365 ui->m_y_sb->setValue(
m_text->pos().y());
366 ui->m_line_edit->setText(
m_text->toPlainText());
367 ui->m_angle_sb->setValue(
m_text->rotation());
368 ui->m_size_sb->setValue(
m_text->font().pointSize());
370 ui->m_line_edit->setDisabled(
m_text->isHtml() ? true :
false);
371 ui->m_size_sb->setDisabled(
m_text->isHtml() ? true :
false);
372 ui->m_label->setVisible(
m_text->isHtml() ? true :
false);
373 ui->m_break_html_pb->setVisible(
m_text->isHtml() ? true :
false);
374 ui->m_font_pb->setDisabled(
m_text->isHtml() ? true :
false);
375 ui->m_font_pb->setText(
m_text->isHtml() ?
tr(
"Police") :
m_text->font().family());
379 bool size_equal =
true;
380 bool angle_equal =
true;
381 bool font_equal =
true;
383 int size_ =
m_text_list.first()->font().pointSize();
386 for (QPointer<IndependentTextItem> piti :
m_text_list)
388 if (piti->rotation() != rotation_) {
391 if (piti->font().pointSize() != size_) {
394 if (piti->font() != font_) {
398 ui->m_angle_sb->setValue(angle_equal ? rotation_ : 0);
401 for (QPointer<IndependentTextItem> piti :
m_text_list) {
402 if (piti->isHtml()) {
406 ui->m_font_pb->setEnabled(valid_);
407 ui->m_font_pb->setText(font_equal ? font_.family() :
tr(
"Police"));
408 ui->m_size_sb->setEnabled(valid_);
409 ui->m_size_sb->setValue(size_equal ? size_ : 0);
410 ui->m_label->setVisible(
false);
411 ui->m_break_html_pb->setVisible(
true);
433 for (QPointer<IndependentTextItem> piti :
m_text_list) {
434 piti->setPlainText(piti->toPlainText());
450 ui->m_font_pb->setText(font.family());
451 ui->m_size_sb->setValue(font.pointSize());
454 ui->m_font_pb->setText(
tr(
"Police"));
void on_m_break_html_pb_clicked()
void fontChanged(QFont font)
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
void textEdited(const QString &old_str, const QString &new_str)
QPointer< IndependentTextItem > m_text
void updateUi() override
IndiTextPropertiesWidget::updateUi.
bool setLiveEdit(bool live_edit) override
IndiTextPropertiesWidget::setLiveEdit.
Ui::IndiTextPropertiesWidget * ui
QList< QMetaObject::Connection > m_connect_list
void on_m_font_pb_clicked()
IndiTextPropertiesWidget(IndependentTextItem *text=nullptr, QWidget *parent=nullptr)
IndiTextPropertiesWidget::IndiTextPropertiesWidget.
void setUpEditConnection()
IndiTextPropertiesWidget::setUpEditConnection Disconnect the previous connection, and reconnect the c...
void setText(IndependentTextItem *text)
IndiTextPropertiesWidget::setText.
QList< QPointer< IndependentTextItem > > m_text_list
QList< QMetaObject::Connection > m_edit_connection
void apply() override
IndiTextPropertiesWidget::apply Apply the current edition through a QUndoCommand pushed to the undo s...
~IndiTextPropertiesWidget() override
IndiTextPropertiesWidget::~IndiTextPropertiesWidget.
void setAnimated(bool animate=true, bool first_time=true)
QPropertyUndoCommand::setAnimated.
The IndiTextPropertiesWidget class This widget is used to edit the properties of one or several indep...
QUndoCommand * associatedUndo() const override
IndiTextPropertiesWidget::associatedUndo.
void on_m_advanced_editor_pb_clicked()
IndiTextPropertiesWidget::on_m_advanced_editor_pb_clicked.