summary refs log tree commit diff
path: root/src/TextInputWidget.cpp
diff options
context:
space:
mode:
authorJussi Kuokkanen <jussi.kuokkanen@protonmail.com>2020-08-29 23:05:40 +0300
committerJussi Kuokkanen <jussi.kuokkanen@protonmail.com>2020-08-29 23:05:40 +0300
commitaed8d23aca2434a70f09d01aea5d89c363de0f79 (patch)
tree012b65c30e34e24e2cb6549792af6e041db4abb0 /src/TextInputWidget.cpp
parentundo changes to emoji_codegen.py (diff)
downloadnheko-aed8d23aca2434a70f09d01aea5d89c363de0f79.tar.xz
don't select emoji completion by default and add minimum string length before showing completions
Diffstat (limited to '')
-rw-r--r--src/TextInputWidget.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp
index 08883cca..770aaca1 100644
--- a/src/TextInputWidget.cpp
+++ b/src/TextInputWidget.cpp
@@ -250,15 +250,18 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
                 QTextEdit::keyPressEvent(event);
                 emoji_popup_open_ = true;
                 emoji_completion_model_->setFilterRegExp(wordUnderCursor());
-                completer_->popup()->setCurrentIndex(completer_->completionModel()->index(0, 0));
-                completer_->complete(completerRect());
                 break;
         }
         case Qt::Key_Return:
         case Qt::Key_Enter:
                 if (emoji_popup_open_) {
-                        event->ignore();
-                        return;
+                        if (!completer_->popup()->currentIndex().isValid()) {
+                        	// No completion to select, do normal behavior
+                        	completer_->popup()->hide();
+                        	emoji_popup_open_ = false;
+                        } 
+                    	else
+                    		event->ignore(); 
                 }
 
                 if (!(event->modifiers() & Qt::ShiftModifier)) {
@@ -307,11 +310,9 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
                 if (isModifier)
                         return;
 
-                if (emoji_popup_open_) {
+                if (emoji_popup_open_ && wordUnderCursor().length() > 2) {
                         // Update completion
                         emoji_completion_model_->setFilterRegExp(wordUnderCursor());
-                        completer_->popup()->setCurrentIndex(
-                          completer_->completionModel()->index(0, 0));
                         completer_->complete(completerRect());
                 }