1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
when losing focus circle gets renamed unless ESC is pressed
This commit is contained in:
Michał Šrajer 2016-02-28 18:09:53 +01:00
parent e5e4d561c9
commit 04b3276b0f

View File

@ -40,8 +40,10 @@ CroppingLabel::CroppingLabel(QWidget* parent)
protected:
void keyPressEvent(QKeyEvent* event) override
{
if (event->key() == Qt::Key_Escape)
if (event->key() == Qt::Key_Escape) {
undo();
clearFocus();
}
QLineEdit::keyPressEvent(event);
}
@ -53,8 +55,7 @@ CroppingLabel::CroppingLabel(QWidget* parent)
| Qt::ImhNoPredictiveText
| Qt::ImhPreferLatin);
connect(textEdit, &QLineEdit::returnPressed, this, &CroppingLabel::editingFinished);
connect(textEdit, &QLineEdit::editingFinished, this, &CroppingLabel::hideTextEdit);
connect(textEdit, &QLineEdit::editingFinished, this, &CroppingLabel::editingFinished);
}
void CroppingLabel::editBegin()
@ -162,6 +163,7 @@ void CroppingLabel::minimizeMaximumWidth()
void CroppingLabel::editingFinished()
{
hideTextEdit();
QString newText = textEdit->text().trimmed().remove(QRegExp("[\\t\\n\\v\\f\\r\\x0000]"));
if (origText != newText)