Add keyboard shorcuts to focus and unfocus chat (#3898)

* Added keyboard shorcuts to focus and unfocus chat

* Fixed format

* Changed the Esc behavior to work on any QLineEdit in the main Window and ignore shortcut conflicts

* Fixed a conflict with shortcuts

* Configurable unfocus shortcut and format fixes

* minor style fix
This commit is contained in:
Xenos6666 2020-03-17 02:48:05 +01:00 committed by GitHub
parent 7285f24a29
commit 63b4f9b2f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 235 additions and 107 deletions

View file

@ -1,21 +1,21 @@
#include "lineeditcompleter.h"
#include <QAbstractItemView>
#include <QCompleter>
#include <QFocusEvent>
#include <QKeyEvent>
#include <QLineEdit>
#include <QScrollBar>
#include <QStringListModel>
#include <QTextCursor>
#include <QWidget>
LineEditCompleter::LineEditCompleter(QWidget *parent) : QLineEdit(parent), c(nullptr)
LineEditCompleter::LineEditCompleter(QWidget *parent) : LineEditUnfocusable(parent), c(nullptr)
{
}
void LineEditCompleter::focusOutEvent(QFocusEvent *e)
{
QLineEdit::focusOutEvent(e);
LineEditUnfocusable::focusOutEvent(e);
if (c->popup()->isVisible()) {
// Remove Popup
c->popup()->hide();
@ -73,7 +73,7 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event)
break;
}
QLineEdit::keyPressEvent(event);
LineEditUnfocusable::keyPressEvent(event);
// return if the completer is null or if the most recently typed char was '@'.
// Only want the popup AFTER typing the first char of the mention.
if (!c || text().right(1).contains("@")) {
@ -130,4 +130,4 @@ void LineEditCompleter::setCompletionList(QStringList completionList)
if (model == NULL)
model = new QStringListModel();
model->setStringList(completionList);
}
}