ElementEditor: texteditor.cpp surround arrows and more braces

This commit is contained in:
damianCaceres
2020-08-05 09:27:19 +01:00
committed by Laurent Trinques
parent 216374d27c
commit b3a74a8315

View File

@@ -100,17 +100,14 @@ void TextEditor::disconnectEditConnection() {
* @param part : part to edit
* @return : return if @part is a partext or nullptr, else return false
*/
bool TextEditor::setPart(CustomElementPart *part)
{
if (!part)
{
bool TextEditor::setPart(CustomElementPart *part) {
if (!part) {
m_text = nullptr;
disconnectChangeConnection();
return true;
}
if (PartText *part_text = static_cast<PartText *>(part))
{
if (PartText *part_text = static_cast<PartText *>(part)) {
if (part_text == m_text) {
return true;
}
@@ -139,8 +136,9 @@ bool TextEditor::setParts(QList <CustomElementPart *> parts) {
m_text = part;
m_parts.clear();
m_parts.append(part);
for (int i=1; i < parts.length(); i++)
for (int i=1; i < parts.length(); i++) {
m_parts.append(static_cast<PartText*>(parts[i]));
}
setUpChangeConnection(m_text);
updateForm();
return true;
@@ -169,8 +167,7 @@ QList<CustomElementPart*> TextEditor::currentParts() const {
* Setup the connection between the widgets of this editor and the undo command
* use to apply the change to the edited text.
*/
void TextEditor::setUpEditConnection()
{
void TextEditor::setUpEditConnection() {
disconnectEditConnection();
m_edit_connection << connect(ui -> m_line_edit, &QLineEdit::textEdited, [this]() {
@@ -214,7 +211,8 @@ void TextEditor::setUpEditConnection()
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (ui -> m_rotation_sb -> value() != partText -> rotation()) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
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);
@@ -268,7 +266,8 @@ void TextEditor::on_m_color_pb_changed(const QColor &newColor) {
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
if (newColor != partText -> defaultTextColor()) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
QPropertyUndoCommand *undo = new QPropertyUndoCommand(
partText, "color", partText -> defaultTextColor(), newColor);
undo -> setText(tr("Modifier la couleur d'un texte"));
undoStack().push(undo);
}