From: Bas Pape Date: Sun, 7 Aug 2011 14:55:40 +0000 (+0200) Subject: Make tabcompletion key configurable via shortcuts. fixes 1018 X-Git-Tag: 0.8-beta1~60 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=d650a89ba2410eea2b6b9a9be4644a7847d16d48;hp=ed178d5c517ad031444fc64f1f85f9ea7a926e15;ds=sidebyside Make tabcompletion key configurable via shortcuts. fixes 1018 --- diff --git a/src/uisupport/CMakeLists.txt b/src/uisupport/CMakeLists.txt index 5afab319..3d135d9e 100644 --- a/src/uisupport/CMakeLists.txt +++ b/src/uisupport/CMakeLists.txt @@ -86,7 +86,9 @@ endif(HAVE_KDE) qt4_wrap_cpp(MOC ${MOC_HDRS}) include_directories(${CMAKE_SOURCE_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/client) + ${CMAKE_SOURCE_DIR}/src/client + ${CMAKE_SOURCE_DIR}/src/qtui + ${CMAKE_SOURCE_DIR}/src/uisupport) add_library(mod_uisupport STATIC ${SOURCES} ${MOC} ${HEADERS}) add_dependencies(mod_uisupport mod_common mod_client) 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 diff --git a/src/uisupport/tabcompleter.h b/src/uisupport/tabcompleter.h index b8461ee7..47aebb09 100644 --- a/src/uisupport/tabcompleter.h +++ b/src/uisupport/tabcompleter.h @@ -47,6 +47,9 @@ public: virtual bool eventFilter(QObject *obj, QEvent *event); +public slots: + void onTabCompletionKey(); + private: struct CompletionKey {