summaryrefslogtreecommitdiff
path: root/src/urlbar/urlbar.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-10-14 21:52:46 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:05 +0100
commit35cdc4f30f167037ef25f8f0a2d134cff74a599a (patch)
tree7a086a30651ad84d3bcfcb7a0710ef6f2f35de54 /src/urlbar/urlbar.cpp
parentFix opening when there are no pinned tabs (diff)
downloadrekonq-35cdc4f30f167037ef25f8f0a2d134cff74a599a.tar.xz
clean up urlbar url loading. We really are lighter now :)
Diffstat (limited to 'src/urlbar/urlbar.cpp')
-rw-r--r--src/urlbar/urlbar.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 56d1370d..f10360b0 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -159,8 +159,6 @@ UrlBar::UrlBar(QWidget *parent)
_suggestionTimer->setSingleShot(true);
connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
-
- activateSuggestions(true);
}
@@ -200,10 +198,22 @@ void UrlBar::loadRequestedUrl(const KUrl& url, Rekonq::OpenType type)
}
-void UrlBar::loadDigitedUrl()
+void UrlBar::loadTypedUrl()
{
- KUrl u = UrlResolver::urlFromTextTyped(text());
- loadRequestedUrl(u);
+ KUrl urlToLoad;
+ if (!_box.isNull())
+ {
+ urlToLoad = _box.data()->activeSuggestion();
+ if (!urlToLoad.isEmpty())
+ {
+ loadRequestedUrl(urlToLoad);
+ return;
+ }
+ }
+
+ // fallback here
+ urlToLoad = UrlResolver::urlFromTextTyped(text());
+ loadRequestedUrl(urlToLoad);
}
@@ -333,11 +343,19 @@ void UrlBar::keyPressEvent(QKeyEvent *event)
void UrlBar::focusInEvent(QFocusEvent *event)
{
+ emit focusIn();
activateSuggestions(true);
KLineEdit::focusInEvent(event);
}
+void UrlBar::focusOutEvent(QFocusEvent *event)
+{
+ activateSuggestions(false);
+ KLineEdit::focusOutEvent(event);
+}
+
+
void UrlBar::dropEvent(QDropEvent *event)
{
// handles only plain-text with url format
@@ -429,7 +447,6 @@ void UrlBar::activateSuggestions(bool b)
if (_box.isNull())
{
_box = new CompletionWidget(this);
- installEventFilter(_box.data());
connect(_box.data(), SIGNAL(chosenUrl(KUrl, Rekonq::OpenType)), this, SLOT(loadRequestedUrl(KUrl, Rekonq::OpenType)));
// activate suggestions on edit text
@@ -439,9 +456,13 @@ void UrlBar::activateSuggestions(bool b)
else
{
disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(detectTypedString(QString)));
- removeEventFilter(_box.data());
+
if (!_box.isNull())
- _box.data()->deleteLater();
+ {
+ // This was just deleted later because of a crash in completionwidget...
+ delete _box.data();
+ _box.clear();
+ }
}
}
@@ -637,15 +658,16 @@ void UrlBar::detectTypedString(const QString &typed)
if (_suggestionTimer->isActive())
_suggestionTimer->stop();
- _suggestionTimer->start(50);
+ _suggestionTimer->start(100);
}
void UrlBar::suggest()
{
- kDebug() << "SUGGEST ABOUT DIGITED: " << text();
if (!_box.isNull())
+ {
_box.data()->suggestUrls(text());
+ }
}