summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlionelc <lionelc@lionelc.(none)>2009-10-27 16:37:19 +0100
committerlionelc <lionelc@lionelc.(none)>2009-10-27 16:37:19 +0100
commit48d2c6edc6066fe979245600398d046ddaaffcd3 (patch)
tree7df135209407c81a70ca5b8c45eebd4768f24021 /src
parentMerge commit 'refs/merge-requests/1925' of git://gitorious.org/rekonq/mainlin... (diff)
downloadrekonq-48d2c6edc6066fe979245600398d046ddaaffcd3.tar.xz
Shortcut in the URL bar to automatically add www. .com/.net/.org around a word
Diffstat (limited to 'src')
-rw-r--r--src/urlbar.cpp35
-rw-r--r--src/urlbar.h1
2 files changed, 35 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
diff --git a/src/urlbar.h b/src/urlbar.h
index 28b1dc08..787032fb 100644
--- a/src/urlbar.h
+++ b/src/urlbar.h
@@ -80,6 +80,7 @@ private slots:
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
+ virtual void keyPressEvent(QKeyEvent *event);
private:
void setupLineEdit();