From 51027ff78242fbb593e76cabc1521bb59c89fbc3 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 23 Dec 2011 11:11:14 +0100 Subject: [PATCH] Ctrl+Enter shortcut in locationbar for append .com and go. --- src/navigation/locationbar.cpp | 39 ++++++++++++++++++++++++---------- src/navigation/locationbar.h | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/navigation/locationbar.cpp b/src/navigation/locationbar.cpp index ee3bbb786..c5babe7a1 100644 --- a/src/navigation/locationbar.cpp +++ b/src/navigation/locationbar.cpp @@ -75,7 +75,7 @@ LocationBar::LocationBar(QupZilla* mainClass) connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit())); connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString))); - connect(this, SIGNAL(returnPressed()), this, SLOT(urlEnter())); +// connect(this, SIGNAL(returnPressed()), this, SLOT(urlEnter())); connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), p_QupZilla, SLOT(urlEnter())); connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo())); connect(m_goButton, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter())); @@ -303,19 +303,36 @@ void LocationBar::mousePressEvent(QMouseEvent* event) void LocationBar::keyPressEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_Escape) { + static QString localDomain = tr(".co.uk", "Append domain name on ALT + Enter = Should be different for every country"); + + switch (event->key()) { + case Qt::Key_Escape: setText(m_webView->url().toEncoded()); event->accept(); - return; + break; + + case Qt::Key_Alt: + if (event->key() == Qt::Key_Alt && m_locationBarSettings->addCountryWithAlt && !text().endsWith(localDomain) && !text().endsWith("/")) { + setText(text().append(localDomain)); + } + + LineEdit::keyPressEvent(event); + break; + + case Qt::Key_Return: + case Qt::Key_Enter: + if (event->modifiers() == Qt::ControlModifier) { + setText(text().append(".com")); + urlEnter(); + } + else { + urlEnter(); + } + break; + + default: + LineEdit::keyPressEvent(event); } - - QString localDomain = tr(".co.uk", "Append domain name on ALT + Enter = Should be different for every country"); - - if (event->key() == Qt::Key_Alt && m_locationBarSettings->addCountryWithAlt && !text().endsWith(localDomain) && !text().endsWith("/")) { - setText(text().append(localDomain)); - } - - QLineEdit::keyPressEvent(event); } LocationBar::~LocationBar() diff --git a/src/navigation/locationbar.h b/src/navigation/locationbar.h index d33abaaa0..c04220c64 100644 --- a/src/navigation/locationbar.h +++ b/src/navigation/locationbar.h @@ -30,6 +30,8 @@ #include #include #include +#include + #include "lineedit.h" class QupZilla;