Minor fix : widget lose focus each time user tip

Each time a QUndoCommand is pushed to a QUndoStack, the current focused
widget lose focus.
So each time user change a value in a widget (for exemple a QSpinBox)
the widget lose focus and user will have to click again in the widget to
gain focus and continue to edit.
The workaround is to call the method focus of the current widget each
time we push a undo command
This commit is contained in:
joshua
2021-01-21 19:35:38 +01:00
parent da1fda6b03
commit bb82a616de

View File

@@ -187,6 +187,7 @@ void TextEditor::setUpEditConnection()
}
}
});
m_edit_connection << connect(m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(m_x_sb -> value(), 0);
for (int i=0; i < m_parts.length(); i++) {
@@ -199,7 +200,9 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_x_sb->setFocus();
});
m_edit_connection << connect(m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
QPointF pos(0, m_y_sb -> value());
for (int i=0; i < m_parts.length(); i++) {
@@ -212,7 +215,9 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_y_sb->setFocus();
});
m_edit_connection << connect(m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
@@ -224,7 +229,9 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_rotation_sb->setFocus();
});
m_edit_connection << connect(m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]() {
for (int i=0; i < m_parts.length(); i++) {
PartText* partText = m_parts[i];
@@ -236,6 +243,7 @@ void TextEditor::setUpEditConnection()
undoStack().push(undo);
}
}
m_size_sb->setFocus();
});
}