From f220274f4dbbd02cac8aae71512ea0c03b9155be Mon Sep 17 00:00:00 2001 From: Flavio Date: Sun, 1 Jan 2012 17:05:01 +0100 Subject: [PATCH] Minor autocomplete fixes --- src/Suggester.h | 2 +- src/autocomplete.cpp | 10 +++++++--- src/autocomplete.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Suggester.h b/src/Suggester.h index dc30bd8..d95d026 100644 --- a/src/Suggester.h +++ b/src/Suggester.h @@ -1,7 +1,7 @@ #ifndef SUGGESTER_H #define SUGGESTER_H -#include +#include class Suggester : public QObject { diff --git a/src/autocomplete.cpp b/src/autocomplete.cpp index a50fe38..33f475a 100644 --- a/src/autocomplete.cpp +++ b/src/autocomplete.cpp @@ -26,9 +26,13 @@ AutoComplete::AutoComplete(QWidget *parent, QLineEdit *editor): timer = new QTimer(this); timer->setSingleShot(true); - timer->setInterval(300); + timer->setInterval(600); connect(timer, SIGNAL(timeout()), SLOT(autoSuggest())); +#ifdef APP_MAC connect(parent, SIGNAL(textChanged(QString)), timer, SLOT(start())); +#else + connect(editor, SIGNAL(textEdited(QString)), timer, SLOT(start())); +#endif } @@ -112,12 +116,12 @@ void AutoComplete::showCompletion(const QStringList &choices) { popup->adjustSize(); popup->setUpdatesEnabled(true); - int h = popup->sizeHintForRow(0) * choices.count(); + int h = popup->sizeHintForRow(0) * choices.count() + 4; popup->resize(buddy->width(), h); popup->move(buddy->mapToGlobal(QPoint(0, buddy->height()))); - popup->setFocus(); + // popup->setFocus(); popup->show(); } diff --git a/src/autocomplete.h b/src/autocomplete.h index 46e4525..0962770 100644 --- a/src/autocomplete.h +++ b/src/autocomplete.h @@ -25,7 +25,7 @@ public slots: void suggestionsReady(QStringList suggestions); signals: - void suggestionAccepted(QString suggestion); + void suggestionAccepted(const QString &suggestion); private: QWidget *buddy; -- 2.39.5