diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/tagwidget.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp index 891b66425..a33bd5516 100644 --- a/qt-ui/tagwidget.cpp +++ b/qt-ui/tagwidget.cpp @@ -179,7 +179,19 @@ void TagWidget::clear() void TagWidget::keyPressEvent(QKeyEvent *e) { + QPair<int, int> pos; + QAbstractItemView *popup; switch (e->key()) { + case Qt::Key_Escape: + pos = getCursorTagPosition(); + if (pos.first >= 0 && pos.second > 0) { + setText(text().remove(pos.first, pos.second - pos.first)); + setCursorPosition(pos.first); + } + popup= m_completer->popup(); + if (popup) + popup->hide(); + return; case Qt::Key_Return: case Qt::Key_Enter: case Qt::Key_Tab: @@ -188,7 +200,7 @@ void TagWidget::keyPressEvent(QKeyEvent *e) * closing the QAbstractViewitem */ if (m_completer) { - QAbstractItemView *popup = m_completer->popup(); + popup = m_completer->popup(); if (popup) popup->hide(); } |