diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-05-12 11:47:02 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-05-12 11:47:02 +0200 |
commit | 1553bf6ba7614abaf09ef86f36407bc07c309bc8 (patch) | |
tree | 554e88556ef9af3041eb9b450e59b1a61a781da7 /src/urlbar/urlbar.cpp | |
parent | Fix UrlFilter Hangs (diff) | |
download | rekonq-1553bf6ba7614abaf09ef86f36407bc07c309bc8.tar.xz |
Add timer to UrlBar suggestions
This is based on the Cedric's patch about and I changed it to save a bit of work
to rekonq to not resolve urls that not will be displayed :)
Diffstat (limited to 'src/urlbar/urlbar.cpp')
-rw-r--r-- | src/urlbar/urlbar.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index ad0f34a1..e1e542b7 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -75,6 +75,7 @@ UrlBar::UrlBar(QWidget *parent) , _tab(0) , _privateMode(false) , _icon(new IconButton(this)) + , _suggestionTimer(new QTimer(this)) { // initial style setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width())); @@ -108,6 +109,9 @@ UrlBar::UrlBar(QWidget *parent) // load typed urls connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &))); + _suggestionTimer->setSingleShot(true); + connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest())); + activateSuggestions(true); } @@ -316,11 +320,12 @@ void UrlBar::activateSuggestions(bool b) connect(_box.data(), SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType))); // activate suggestions on edit text - connect(this, SIGNAL(textChanged(const QString &)), _box.data(), SLOT(suggestUrls(const QString &))); + connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(detectTypedString(const QString &))); } } else { + disconnect(this, SIGNAL(textChanged(const QString &)), this, SLOT(detectTypedString(const QString &))); removeEventFilter(_box.data()); _box.data()->deleteLater(); } @@ -389,3 +394,20 @@ void UrlBar::resizeEvent(QResizeEvent *event) KLineEdit::resizeEvent(event); } + + +void UrlBar::detectTypedString(const QString &typed) +{ + Q_UNUSED(typed); + + if(_suggestionTimer->isActive()) + _suggestionTimer->stop(); + _suggestionTimer->start(200); +} + + +void UrlBar::suggest() +{ + if(!_box.isNull()) + _box.data()->suggestUrls( text() ); +}
\ No newline at end of file |