From bb82a616deeeb189f4220c2a6c31f557635d3a12 Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 21 Jan 2021 19:35:38 +0100 Subject: [PATCH] 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 --- sources/editor/ui/texteditor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sources/editor/ui/texteditor.cpp b/sources/editor/ui/texteditor.cpp index 1f3c0ff5e..1ba74ee39 100644 --- a/sources/editor/ui/texteditor.cpp +++ b/sources/editor/ui/texteditor.cpp @@ -187,6 +187,7 @@ void TextEditor::setUpEditConnection() } } }); + m_edit_connection << connect(m_x_sb, QOverload::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::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::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::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(); }); }