diff options
author | Panagiotis Papadopoulos <pano_90@gmx.net> | 2010-02-02 23:08:40 +0100 |
---|---|---|
committer | Panagiotis Papadopoulos <pano_90@gmx.net> | 2010-02-02 23:08:40 +0100 |
commit | 5efd06bc3dd4c494aa799f5e774a9475a4fa717a (patch) | |
tree | 9540281ba60e520c5edb8949dc38766aae1b72ad /src/urlbar | |
parent | i18n fixes (diff) | |
parent | rekonq 0.3.34 (diff) | |
download | rekonq-5efd06bc3dd4c494aa799f5e774a9475a4fa717a.tar.xz |
Merge branch 'master' of git://gitorious.org/rekonq/mainline into i18n
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/urlbar.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index be19dae4..adeba6ae 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -140,13 +140,15 @@ void UrlBar::setUrl(const QUrl& url) if(url.scheme() == "about") { m_currentUrl = KUrl(); + updateUrl(); // updateUrl before setFocus setFocus(); } else { m_currentUrl = KUrl(url); + updateUrl(); } - updateUrl(); + } @@ -302,36 +304,43 @@ 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)) + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { - QString append; - if (event->modifiers() == Qt::ControlModifier) + if( !currentText.startsWith(QLatin1String("http://"), Qt::CaseInsensitive) ) { - append = QLatin1String(".com"); + 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()); + } } - 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)) + else { - host += append; - url.setHost(host); - m_lineEdit->setText(url.toString()); + // fill lineEdit with its stripped contents to remove trailing spaces + m_lineEdit->setText(currentText); } } KHistoryComboBox::keyPressEvent(event); } - |