forked from qt-creator/qt-creator
Utils: Fix StringAspect ui connection
QLineEdit::textEdited is only called when the user types. It is not triggered if the text changes due to undo/redo. QLineEdit::textChanged is triggered for all changes. We also have to make sure that we don't call QLineEdit::setTextKeepingActiveCursor unnecessarily as that would clear the undo/redo stack of the QLineEdit. Change-Id: I19562d0804e6a34b11f19e86abd256a807e147d6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1165,7 +1165,7 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
handleGuiChanged();
|
handleGuiChanged();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
connect(lineEditDisplay, &QLineEdit::textEdited, this, [this, lineEditDisplay]() {
|
connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay]() {
|
||||||
d->undoable.set(undoStack(), lineEditDisplay->text());
|
d->undoable.set(undoStack(), lineEditDisplay->text());
|
||||||
handleGuiChanged();
|
handleGuiChanged();
|
||||||
});
|
});
|
||||||
@@ -1188,7 +1188,9 @@ void StringAspect::addToLayout(LayoutItem &parent)
|
|||||||
&UndoSignaller::changed,
|
&UndoSignaller::changed,
|
||||||
lineEditDisplay,
|
lineEditDisplay,
|
||||||
[this, lineEditDisplay] {
|
[this, lineEditDisplay] {
|
||||||
lineEditDisplay->setTextKeepingActiveCursor(d->undoable.get());
|
if (lineEditDisplay->text() != d->undoable.get())
|
||||||
|
lineEditDisplay->setTextKeepingActiveCursor(d->undoable.get());
|
||||||
|
|
||||||
lineEditDisplay->validate();
|
lineEditDisplay->validate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user