summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-04 17:14:44 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-07-22 21:05:46 +0000
commit35b1ded572615a5fb247f92dac928eda906f715e (patch)
treeee82748ac79bbf26b481ba4547c0e5ea4470106a /examples
parent1043c0507981c35047832c3d8e942c3840484b9a (diff)
Fixup Back/Forward short-cuts
Remove backspace short-cut, Chromium will already handle that if it is standard on the platform. Also we were not triggering on Back/Forward buttons due to those being mapped to prev/next tab item in Qt. Task-number: QTBUG-54546 Change-Id: I9a4f48c718c5685ca9ca1b032d8b04409ac622ca Reviewed-by: Jesus Fernandez <jesus.fernandez@theqtcompany.com> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginewidgets/demobrowser/browsermainwindow.cpp22
-rw-r--r--examples/webenginewidgets/simplebrowser/browserwindow.cpp22
2 files changed, 40 insertions, 4 deletions
diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
index 5d3fa47e5..6b64653b6 100644
--- a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
+++ b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
@@ -406,13 +406,31 @@ void BrowserMainWindow::setupMenu()
m_historyBack = new QAction(tr("Back"), this);
m_tabWidget->addWebAction(m_historyBack, QWebEnginePage::Back);
- m_historyBack->setShortcuts(QKeySequence::Back);
+ QList<QKeySequence> backShortcuts = QKeySequence::keyBindings(QKeySequence::Back);
+ for (auto it = backShortcuts.begin(); it != backShortcuts.end();) {
+ // Chromium already handles navigate on backspace when appropriate.
+ if ((*it)[0] == Qt::Key_Backspace)
+ it = backShortcuts.erase(it);
+ else
+ ++it;
+ }
+ // For some reason Qt doesn't bind the dedicated Back key to Back.
+ backShortcuts.append(QKeySequence(Qt::Key_Back));
+ m_historyBack->setShortcuts(backShortcuts);
m_historyBack->setIconVisibleInMenu(false);
historyActions.append(m_historyBack);
m_historyForward = new QAction(tr("Forward"), this);
m_tabWidget->addWebAction(m_historyForward, QWebEnginePage::Forward);
- m_historyForward->setShortcuts(QKeySequence::Forward);
+ QList<QKeySequence> fwdShortcuts = QKeySequence::keyBindings(QKeySequence::Forward);
+ for (auto it = fwdShortcuts.begin(); it != fwdShortcuts.end();) {
+ if (((*it)[0] & Qt::Key_unknown) == Qt::Key_Backspace)
+ it = fwdShortcuts.erase(it);
+ else
+ ++it;
+ }
+ fwdShortcuts.append(QKeySequence(Qt::Key_Forward));
+ m_historyForward->setShortcuts(fwdShortcuts);
m_historyForward->setIconVisibleInMenu(false);
historyActions.append(m_historyForward);
diff --git a/examples/webenginewidgets/simplebrowser/browserwindow.cpp b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
index e7d5fd129..c01f912d3 100644
--- a/examples/webenginewidgets/simplebrowser/browserwindow.cpp
+++ b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
@@ -280,7 +280,17 @@ QToolBar *BrowserWindow::createToolBar()
navigationBar->toggleViewAction()->setEnabled(false);
m_historyBackAction = new QAction(this);
- m_historyBackAction->setShortcuts(QKeySequence::Back);
+ QList<QKeySequence> backShortcuts = QKeySequence::keyBindings(QKeySequence::Back);
+ for (auto it = backShortcuts.begin(); it != backShortcuts.end();) {
+ // Chromium already handles navigate on backspace when appropriate.
+ if ((*it)[0] == Qt::Key_Backspace)
+ it = backShortcuts.erase(it);
+ else
+ ++it;
+ }
+ // For some reason Qt doesn't bind the dedicated Back key to Back.
+ backShortcuts.append(QKeySequence(Qt::Key_Back));
+ m_historyBackAction->setShortcuts(backShortcuts);
m_historyBackAction->setIconVisibleInMenu(false);
m_historyBackAction->setIcon(QIcon(QStringLiteral(":go-previous.png")));
connect(m_historyBackAction, &QAction::triggered, [this]() {
@@ -289,7 +299,15 @@ QToolBar *BrowserWindow::createToolBar()
navigationBar->addAction(m_historyBackAction);
m_historyForwardAction = new QAction(this);
- m_historyForwardAction->setShortcuts(QKeySequence::Forward);
+ QList<QKeySequence> fwdShortcuts = QKeySequence::keyBindings(QKeySequence::Forward);
+ for (auto it = fwdShortcuts.begin(); it != fwdShortcuts.end();) {
+ if (((*it)[0] & Qt::Key_unknown) == Qt::Key_Backspace)
+ it = fwdShortcuts.erase(it);
+ else
+ ++it;
+ }
+ fwdShortcuts.append(QKeySequence(Qt::Key_Forward));
+ m_historyForwardAction->setShortcuts(fwdShortcuts);
m_historyForwardAction->setIconVisibleInMenu(false);
m_historyForwardAction->setIcon(QIcon(QStringLiteral(":go-next.png")));
connect(m_historyForwardAction, &QAction::triggered, [this]() {