From 84381d6b74a31c8b1b6468fa490621f8a7a32c23 Mon Sep 17 00:00:00 2001 From: Bas Pape Date: Thu, 4 Aug 2011 16:16:06 +0200 Subject: [PATCH] Add support for adding a space when tab-completing mid-sentence --- src/client/clientsettings.cpp | 8 +++++ src/client/clientsettings.h | 3 ++ .../settingspages/inputwidgetsettingspage.ui | 33 +++++++++++++++++++ src/uisupport/tabcompleter.cpp | 2 ++ 4 files changed, 46 insertions(+) diff --git a/src/client/clientsettings.cpp b/src/client/clientsettings.cpp index a7d42b5d..dfed519f 100644 --- a/src/client/clientsettings.cpp +++ b/src/client/clientsettings.cpp @@ -281,6 +281,14 @@ QString TabCompletionSettings::completionSuffix() { return localValue("CompletionSuffix", ": ").toString(); } +void TabCompletionSettings::setAddSpaceMidSentence(const bool &space) { + setLocalValue("AddSpaceMidSentence", space); +} + +bool TabCompletionSettings::addSpaceMidSentence() { + return localValue("AddSpaceMidSentence", false).toBool(); +} + void TabCompletionSettings::setSortMode(SortMode mode) { setLocalValue("SortMode", mode); } diff --git a/src/client/clientsettings.h b/src/client/clientsettings.h index 40e890db..be3fb102 100644 --- a/src/client/clientsettings.h +++ b/src/client/clientsettings.h @@ -153,6 +153,9 @@ public: void setCompletionSuffix(const QString &); QString completionSuffix(); + void setAddSpaceMidSentence(const bool &); + bool addSpaceMidSentence(); + void setSortMode(SortMode); SortMode sortMode(); diff --git a/src/qtui/settingspages/inputwidgetsettingspage.ui b/src/qtui/settingspages/inputwidgetsettingspage.ui index 078745fe..41b2d05b 100644 --- a/src/qtui/settingspages/inputwidgetsettingspage.ui +++ b/src/qtui/settingspages/inputwidgetsettingspage.ui @@ -254,6 +254,39 @@ + + + + + + Add space after nick when completing mid-sentence + + + false + + + /TabCompletion/AddSpaceMidSentence + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 7426ed4d..5f7b0837 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -130,6 +130,8 @@ void TabCompleter::complete() { if(_completionType == UserTab && _lineEdit->cursorPosition() == _lastCompletionLength) { _lineEdit->insert(_nickSuffix); _lastCompletionLength += _nickSuffix.length(); + } else if (s.addSpaceMidSentence()) { + _lineEdit->insert(" "); } // we're at the end of the list -> start over again -- 2.20.1