X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Ftabcompleter.cpp;h=527eb79540a01a953355fd89e3ec64bb18ce5d68;hp=5f7b0837bf21ee5a8a16ef9668d7281d0c72b611;hb=d650a89ba2410eea2b6b9a9be4644a7847d16d48;hpb=ed178d5c517ad031444fc64f1f85f9ea7a926e15;ds=inline diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 5f7b0837..527eb795 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 "qtui.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 = QtUi::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() { @@ -153,13 +165,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() != QtUi::actionCollection("General")->action("TabCompletionKey")->shortcut()) { reset(); - return false; } + return false; } // this determines the sort order