Hello,
here another small patch using a QTimer() for displaying suggestion...
I think it make ui smoother, what do you think of ?
--
Cédric Bellegarde
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
index 1bb0178..8ed264d 100644
--- a/src/urlbar/completionwidget.cpp
+++ b/src/urlbar/completionwidget.cpp
@@ -257,24 +257,37 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button)
}
-void CompletionWidget::suggestUrls(const QString &text)
+void CompletionWidget::suggestUrlsTimer(const QString &text)
+{
+ // use a timer to make ui more fluid
+ static QTimer *timer = new QTimer ();
+ timer->setSingleShot(true);
+ connect(timer, SIGNAL(timeout()), this, SLOT(suggestUrls()));
+ currentUrl = text;
+ if (timer->isActive())
+ timer->stop();
+ timer->start(300);
+}
+
+void CompletionWidget::suggestUrls()
{
QWidget *w = qobject_cast<QWidget *>(parent());
+
if (!w->hasFocus())
return;
- if (text.isEmpty())
+ if (currentUrl.isEmpty())
{
hide();
return;
}
- UrlResolver res(text);
+ UrlResolver res(currentUrl);
UrlSearchList list = res.orderedSearchItems();
if (list.count() > 0)
{
clear();
- insertSearchList(list, text);
+ insertSearchList(list, currentUrl);
popup();
}
}
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
index fc0798e..6073a2f 100644
--- a/src/urlbar/completionwidget.h
+++ b/src/urlbar/completionwidget.h
@@ -63,7 +63,8 @@ public:
private slots:
void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton);
- void suggestUrls(const QString &text);
+ void suggestUrlsTimer(const QString &text);
+ void suggestUrls();
signals:
void chosenUrl(const KUrl &, Rekonq::OpenType);
@@ -83,6 +84,8 @@ private:
UrlSearchList _list;
int _currentIndex;
+ QString currentUrl;
+
KService::Ptr _searchEngine;
};
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index ad0f34a..0e93d68 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -316,7 +316,7 @@ 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 &)), _box.data(), SLOT(suggestUrlsTimer(const QString &)));
}
}
else
_______________________________________________
rekonq mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/rekonq