Fixes #326 Shift + EMOTE TAB doesnt work

This commit is contained in:
fourtf 2018-04-10 01:54:30 +02:00
parent b23b583cb3
commit efdcc64f89

View file

@ -75,13 +75,8 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
this->keyPressed.invoke(event); this->keyPressed.invoke(event);
if (event->key() == Qt::Key_Backtab) { bool doComplete = (event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) &&
// Ignore for now. We want to use it for autocomplete later (event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
return;
}
bool doComplete =
event->key() == Qt::Key_Tab && (event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
if (doComplete) { if (doComplete) {
// check if there is a completer // check if there is a completer
@ -110,10 +105,17 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
} }
// scrolling through selections // scrolling through selections
if (event->key() == Qt::Key_Tab) {
if (!this->completer->setCurrentRow(this->completer->currentRow() + 1)) { if (!this->completer->setCurrentRow(this->completer->currentRow() + 1)) {
// wrap over and start again // wrap over and start again
this->completer->setCurrentRow(0); this->completer->setCurrentRow(0);
} }
} else {
if (!this->completer->setCurrentRow(this->completer->currentRow() - 1)) {
// wrap over and start again
this->completer->setCurrentRow(this->completer->completionCount() - 1);
}
}
this->completer->complete(); this->completer->complete();
return; return;
@ -122,7 +124,13 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
// (hemirt) // (hemirt)
// this resets the selection in the completion list, it should probably only trigger on actual // this resets the selection in the completion list, it should probably only trigger on actual
// chat input (space, character) and not on every key input (pressing alt for example) // chat input (space, character) and not on every key input (pressing alt for example)
// (fourtf)
// fixed for shift+tab, there might be a better solution but nobody is gonna bother anyways
if (event->key() != Qt::Key_Shift && event->key() != Qt::Key_Control &&
event->key() != Qt::Key_Alt && event->key() != Qt::Key_Super_L &&
event->key() != Qt::Key_Super_R) {
this->completionInProgress = false; this->completionInProgress = false;
}
if (!event->isAccepted()) { if (!event->isAccepted()) {
QTextEdit::keyPressEvent(event); QTextEdit::keyPressEvent(event);