From 35896d57713ad2c8ebca5ff96848e983aaf9381c Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 28 May 2020 19:05:44 +0200 Subject: [PATCH] solves #7 --- sources/editor/terminaleditor.cpp | 10 +++++---- sources/editor/ui/texteditor.cpp | 37 +++++-------------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/sources/editor/terminaleditor.cpp b/sources/editor/terminaleditor.cpp index 5b68f80a7..76f516202 100644 --- a/sources/editor/terminaleditor.cpp +++ b/sources/editor/terminaleditor.cpp @@ -160,7 +160,8 @@ void TerminalEditor::updateTerminalO() m_locked = true; QVariant var(orientation -> itemData(orientation -> currentIndex())); - for (auto term: m_terminals) { + for (int i=0; i < m_terminals.length(); i++) { + PartTerminal* term = m_terminals[i]; if (var != term->property("orientation")) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var); @@ -176,8 +177,8 @@ void TerminalEditor::updateXPos() { m_locked = true; QPointF new_pos(qle_x->value(), 0); - int i=0; - for (PartTerminal* term: m_terminals) { + for (int i=0; i < m_terminals.length(); i++) { + PartTerminal* term = m_terminals[i]; new_pos.setY(term->pos().y()); // change only x value if (term->pos() != new_pos) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos); @@ -194,7 +195,8 @@ void TerminalEditor::updateYPos() { m_locked = true; QPointF new_pos(0, qle_y->value()); // change only y value - for (auto term: m_terminals) { + for (int i=0; i < m_terminals.length(); i++) { + PartTerminal* term = m_terminals[i]; new_pos.setX(term->pos().x()); if (term->pos() != new_pos) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos); diff --git a/sources/editor/ui/texteditor.cpp b/sources/editor/ui/texteditor.cpp index 97b5df52b..2c6dc2c65 100644 --- a/sources/editor/ui/texteditor.cpp +++ b/sources/editor/ui/texteditor.cpp @@ -176,7 +176,8 @@ void TextEditor::setUpEditConnection() m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]() { QString text_ = ui->m_line_edit->text(); - for (auto partText: m_parts) { + for (int i=0; i < m_parts.length(); i++) { + PartText* partText = m_parts[i]; if (text_ != partText->toPlainText()) { QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_); @@ -188,7 +189,8 @@ void TextEditor::setUpEditConnection() m_edit_connection << connect(ui->m_x_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { QPointF pos(ui->m_x_sb->value(), 0); - for (auto partText: m_parts) { + for (int i=0; i < m_parts.length(); i++) { + PartText* partText = m_parts[i]; pos.setY(partText->pos().y()); if (pos != partText->pos()) { @@ -202,7 +204,8 @@ void TextEditor::setUpEditConnection() m_edit_connection << connect(ui->m_y_sb, QOverload::of(&QSpinBox::valueChanged), [this]() { QPointF pos(0, ui->m_y_sb->value()); - for (auto partText: m_parts) { + for (int i=0; i < m_parts.length(); i++) { + PartText* partText = m_parts[i]; pos.setX(partText->pos().x()); if (pos != partText->pos()) { @@ -212,25 +215,11 @@ void TextEditor::setUpEditConnection() undoStack().push(undo); } } - }); - m_edit_connection << connect(ui->m_rotation_sb, QOverload::of(&QSpinBox::valueChanged), [this]() - { - for (auto partText: m_parts) { - if (ui->m_rotation_sb->value() != partText->rotation()) - { - QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value()); undo->setText(tr("Pivoter un champ texte")); undo->setAnimated(true, false); undoStack().push(undo); } } - }); - m_edit_connection << connect(ui->m_size_sb, QOverload::of(&QSpinBox::valueChanged), [this]() - { - for (auto partText: m_parts) { - if (partText->font().pointSize() != ui->m_size_sb->value()) - { - QFont font_ = partText->font(); font_.setPointSize(ui->m_size_sb->value()); QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_); undo->setText(tr("Modifier la police d'un texte")); @@ -253,13 +242,6 @@ void TextEditor::on_m_font_pb_clicked() ui->m_size_sb->setValue(font_.pointSize()); ui->m_size_sb->blockSignals(false); - ui->m_font_pb->setText(font_.family()); - } - - for (auto partText: m_parts) { - if (ok && font_ != partText->font()) - { - QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_); undo->setText(tr("Modifier la police d'un texte")); undoStack().push(undo); } @@ -269,13 +251,6 @@ void TextEditor::on_m_font_pb_clicked() /** * @brief TextEditor::on_m_color_pb_changed * @param newColor - */ -void TextEditor::on_m_color_pb_changed(const QColor &newColor) -{ - for (auto partText: m_parts) { - if (newColor != partText->defaultTextColor()) - { - QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor); undo->setText(tr("Modifier la couleur d'un texte")); undoStack().push(undo); }