summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-04-13 10:50:45 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2018-04-17 16:29:30 +0000
commit188e61a7e3eb6fe1e08a7c13bc2d514c0ec0be92 (patch)
tree00e25c78648d547bbf76ee3b563abd0a6b6fd86a
parent7c964ca5569cdbf0d1570d0328f73c4fe8c93758 (diff)
downloadqtwebengine-188e61a7e3eb6fe1e08a7c13bc2d514c0ec0be92.tar.gz
simplebrowser: Focus url bar for new tabs and windows
Change-Id: Ib13db55adc065dde3bc257f3acc243480c2d03b4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--examples/webenginewidgets/simplebrowser/browserwindow.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/webenginewidgets/simplebrowser/browserwindow.cpp b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
index c369a90fa..4351dfe71 100644
--- a/examples/webenginewidgets/simplebrowser/browserwindow.cpp
+++ b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
@@ -156,7 +156,10 @@ QMenu *BrowserWindow::createFileMenu(TabWidget *tabWidget)
QAction *newTabAction = new QAction(tr("New &Tab"), this);
newTabAction->setShortcuts(QKeySequence::AddTab);
- connect(newTabAction, &QAction::triggered, tabWidget, &TabWidget::createTab);
+ connect(newTabAction, &QAction::triggered, this, [this]() {
+ m_tabWidget->createTab();
+ m_urlLineEdit->setFocus();
+ });
fileMenu->addAction(newTabAction);
fileMenu->addAction(tr("&Open File..."), this, &BrowserWindow::handleFileOpenTriggered, QKeySequence::Open);
@@ -427,12 +430,14 @@ void BrowserWindow::handleWebViewTitleChanged(const QString &title)
void BrowserWindow::handleNewWindowTriggered()
{
- m_browser->createWindow();
+ BrowserWindow *window = m_browser->createWindow();
+ window->m_urlLineEdit->setFocus();
}
void BrowserWindow::handleNewIncognitoWindowTriggered()
{
- m_browser->createWindow(/* offTheRecord: */ true);
+ BrowserWindow *window = m_browser->createWindow(/* offTheRecord: */ true);
+ window->m_urlLineEdit->setFocus();
}
void BrowserWindow::handleFileOpenTriggered()