X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Ftabcompleter.cpp;h=5d2bf027b680dc0129c30035bac06656c85e72db;hp=7426ed4de3dd616e41ab7454762eb4cd74e49f96;hb=18931d024940d902ed8b1e241fbdeb98d2f1b424;hpb=49813fa53b34ffa35837d30fd022e2fc72f57eb5 diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 7426ed4d..5d2bf027 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -28,6 +28,9 @@ #include "network.h" #include "networkmodel.h" #include "uisettings.h" +#include "action.h" +#include "actioncollection.h" +#include "graphicalui.h" #include @@ -42,7 +45,16 @@ TabCompleter::TabCompleter(MultiLineEdit *_lineEdit) _enabled(false), _nickSuffix(": ") { + // use both an Action and generic eventFilter, to make the shortcut configurable + // yet still be able to reset() when required _lineEdit->installEventFilter(this); + ActionCollection *coll = GraphicalUi::actionCollection("General"); + coll->addAction("TabCompletionKey", new Action(tr("Tab completion"), coll, + this, SLOT(onTabCompletionKey()), QKeySequence(Qt::Key_Tab))); +} + +void TabCompleter::onTabCompletionKey() { + complete(); } void TabCompleter::buildCompletionList() { @@ -130,6 +142,9 @@ void TabCompleter::complete() { if(_completionType == UserTab && _lineEdit->cursorPosition() == _lastCompletionLength) { _lineEdit->insert(_nickSuffix); _lastCompletionLength += _nickSuffix.length(); + } else if (s.addSpaceMidSentence()) { + _lineEdit->insert(" "); + _lastCompletionLength++; } // we're at the end of the list -> start over again @@ -151,13 +166,10 @@ bool TabCompleter::eventFilter(QObject *obj, QEvent *event) { QKeyEvent *keyEvent = static_cast(event); - if(keyEvent->key() == Qt::Key_Tab) { - complete(); - return true; - } else { + if(keyEvent->key() != GraphicalUi::actionCollection("General")->action("TabCompletionKey")->shortcut()) { reset(); - return false; } + return false; } // this determines the sort order