summaryrefslogtreecommitdiff
path: root/src/urlbar.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-10-28 00:18:01 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-10-28 00:18:01 +0100
commite1bfbc42e49b03504e9e8c2ad2afb6ac180e3659 (patch)
tree05563e087356f0b3d75c6d990c609c1a940ae76c /src/urlbar.cpp
parentFixing (?) close tab action (diff)
parentShortcut in the URL bar to automatically add www. .com/.net/.org around a word (diff)
downloadrekonq-e1bfbc42e49b03504e9e8c2ad2afb6ac180e3659.tar.xz
Merge commit 'refs/merge-requests/1936' of git://gitorious.org/rekonq/mainline into mr1936
Diffstat (limited to 'src/urlbar.cpp')
-rw-r--r--src/urlbar.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/urlbar.cpp b/src/urlbar.cpp
index b6340fe7..d587fd80 100644
--- a/src/urlbar.cpp
+++ b/src/urlbar.cpp
@@ -140,7 +140,7 @@ void UrlBar::setUrl(const QUrl& url)
}
else
m_currentUrl = url;
-
+
slotUpdateUrl();
}
@@ -303,3 +303,36 @@ bool UrlBar::isLoading()
}
return true;
}
+
+void UrlBar::keyPressEvent(QKeyEvent *event)
+{
+ QString currentText = m_lineEdit->text().trimmed();
+ if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
+ && !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive))
+ {
+ QString append;
+ if (event->modifiers() == Qt::ControlModifier)
+ {
+ append = QLatin1String(".com");
+ }
+ else if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
+ {
+ append = QLatin1String(".org");
+ }
+ else if (event->modifiers() == Qt::ShiftModifier)
+ {
+ append = QLatin1String(".net");
+ }
+
+ QUrl url(QLatin1String("http://www.") + currentText);
+ QString host = url.host();
+ if (!host.endsWith(append, Qt::CaseInsensitive))
+ {
+ host += append;
+ url.setHost(host);
+ m_lineEdit->setText(url.toString());
+ }
+ }
+
+ KHistoryComboBox::keyPressEvent(event);
+} \ No newline at end of file