From cc2369c5f9dbaebb8fae2e652e27f189d0454fc1 Mon Sep 17 00:00:00 2001 From: Gehad Date: Thu, 20 Mar 2014 17:04:29 +0200 Subject: Make esc-key discard the new tag selection Signed-off-by: Gehad elrobey Signed-off-by: Dirk Hohndel --- qt-ui/tagwidget.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'qt-ui/tagwidget.cpp') 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 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(); } -- cgit v1.2.3-70-g09d2