Files
UltraGrid/gui/QT/option/lineedit_ui.cpp
Martin Piatka 99888c6bf6 GUI: LineEdit: Fix cursor jumping to the end when editing
The issue was that editing the text triggers the change of the option,
which in turn triggers updateUiState which sets the content of the
LineEdit to the changed option causing the cursor to jump to the end.

As a workaround only set the LineEdit contet when it's not focused.
2023-11-06 10:13:03 +01:00

33 lines
662 B
C++

#include "lineedit_ui.hpp"
LineEditUi::LineEditUi(QLineEdit *line, Settings *settings, const std::string &opt) :
TextOptUi(settings, opt),
line(line)
{
updateUiState();
connectSignals();
}
void LineEditUi::connectSignals(){
connect(line, &QLineEdit::textEdited, this, &LineEditUi::textEdited);
}
void LineEditUi::updateUiState(const std::string &text){
if(!line->hasFocus())
line->setText(QString::fromStdString(text));
}
void LineEditUi::updateUiState(){
updateUiState(getOptValue());
}
void LineEditUi::setEnabled(bool enabled){
line->setEnabled(enabled);
}
void LineEditUi::setToolTip(const QString& toolTip){
line->setToolTip(toolTip);
}