Merge lp:~mterry/webbrowser-app/switch-tab-keybinding into lp:webbrowser-app

Proposed by Michael Terry
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1205
Merged at revision: 1229
Proposed branch: lp:~mterry/webbrowser-app/switch-tab-keybinding
Merge into: lp:webbrowser-app
Diff against target: 96 lines (+40/-18)
2 files modified
src/app/webbrowser/Browser.qml (+34/-18)
tests/autopilot/webbrowser_app/tests/test_keyboard.py (+6/-0)
To merge this branch: bzr merge lp:~mterry/webbrowser-app/switch-tab-keybinding
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Olivier Tilloy Approve
Review via email: mp+272671@code.launchpad.net

Commit message

Add Ctrl+PageUp and Ctrl+PageDown as alternate keyboard shortcuts for cycling through tabs.

Description of the change

Add Ctrl+PageUp and Ctrl+PageDown as alternate keyboard shortcuts for cycling through tabs.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM, thanks for this useful contribution.

A couple of minor comments:

 - the call to focus recentView should probably be factored out to the implementation of internal.switchToTab()

 - can you update the autopilot tests in tests/autopilot/webbrowser_app/tests/test_keyboard.py to also test these new shortcuts (see test_switch_tabs)

1204. By Michael Terry

Add test and consolidate a little code

Revision history for this message
Michael Terry (mterry) wrote :

Test added and recentView.focus=true line consolidated.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

I assume those autopilot errors are typical, and not due to this branch?

Revision history for this message
Olivier Tilloy (osomon) wrote :

The autopilot tests are usually fairly stable, but it’s not uncommon to see one or two random failures. The failures here seem completely unrelated to your branch, but given there are 4 of them, which is higher than usual, I’ll trigger a new CI run.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

The following autopilot test is broken:

    webbrowser_app.tests.test_tabs.TestTabsManagement.test_selecting_tab_focuses_webview

I can reliably observe the failure on desktop by running the test in narrow mode: modify the width of the window to be 50GU instead of 100GU in src/app/BrowserWindow.qml, and then run the test locally:

    cd tests/autopilot
    autopilot3 run webbrowser_app.tests.test_tabs.TestTabsManagement.test_selecting_tab_focuses_webview

I’m guessing the change to switchToTab() is what introduced the regression: when selecting a tab from the tabs view (in narrow mode), the recent view is still visible, so we don’t want to focus back the recent view. My bad for suggesting to factor this out, can you please revert that change?

review: Needs Fixing
1205. By Michael Terry

Undo consolidation

Revision history for this message
Michael Terry (mterry) wrote :

OK, undid that change. :)

Revision history for this message
Olivier Tilloy (osomon) wrote :

LGTM, let’s see if the CI job passes now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webbrowser/Browser.qml'
2--- src/app/webbrowser/Browser.qml 2015-09-28 08:15:10 +0000
3+++ src/app/webbrowser/Browser.qml 2015-10-06 15:46:27 +0000
4@@ -1273,6 +1273,24 @@
5 }
6 }
7
8+ function switchToPreviousTab() {
9+ if (browser.wide) {
10+ internal.switchToTab((tabsModel.currentIndex - 1 + tabsModel.count) % tabsModel.count)
11+ } else {
12+ internal.switchToTab(tabsModel.count - 1)
13+ }
14+ if (recentView.visible) recentView.focus = true
15+ }
16+
17+ function switchToNextTab() {
18+ if (browser.wide) {
19+ internal.switchToTab((tabsModel.currentIndex + 1) % tabsModel.count)
20+ } else {
21+ internal.switchToTab(tabsModel.count - 1)
22+ }
23+ if (recentView.visible) recentView.focus = true
24+ }
25+
26 function switchToTab(index) {
27 tabsModel.currentIndex = index
28 var tab = tabsModel.currentTab
29@@ -1581,34 +1599,32 @@
30 KeyboardShortcuts {
31 id: shortcuts
32
33- // Ctrl+Tab: cycle through open tabs
34+ // Ctrl+Tab or Ctrl+PageDown: cycle through open tabs
35 KeyboardShortcut {
36 modifiers: Qt.ControlModifier
37 key: Qt.Key_Tab
38 enabled: chrome.visible || recentView.visible
39- onTriggered: {
40- if (browser.wide) {
41- internal.switchToTab((tabsModel.currentIndex + 1) % tabsModel.count)
42- } else {
43- internal.switchToTab(tabsModel.count - 1)
44- }
45- if (recentView.visible) recentView.focus = true
46- }
47+ onTriggered: internal.switchToNextTab()
48+ }
49+ KeyboardShortcut {
50+ modifiers: Qt.ControlModifier
51+ key: Qt.Key_PageDown
52+ enabled: chrome.visible || recentView.visible
53+ onTriggered: internal.switchToNextTab()
54 }
55
56- // Ctrl+Shift+Tab: cycle through open tabs in reverse order
57+ // Ctrl+Shift+Tab or Ctrl+PageUp: cycle through open tabs in reverse order
58 KeyboardShortcut {
59 modifiers: Qt.ControlModifier
60 key: Qt.Key_Backtab
61 enabled: chrome.visible || recentView.visible
62- onTriggered: {
63- if (browser.wide) {
64- internal.switchToTab((tabsModel.currentIndex - 1 + tabsModel.count) % tabsModel.count)
65- } else {
66- internal.switchToTab(tabsModel.count - 1)
67- }
68- if (recentView.visible) recentView.focus = true
69- }
70+ onTriggered: internal.switchToPreviousTab()
71+ }
72+ KeyboardShortcut {
73+ modifiers: Qt.ControlModifier
74+ key: Qt.Key_PageUp
75+ enabled: chrome.visible || recentView.visible
76+ onTriggered: internal.switchToPreviousTab()
77 }
78
79 // Ctrl+W or Ctrl+F4: Close the current tab
80
81=== modified file 'tests/autopilot/webbrowser_app/tests/test_keyboard.py'
82--- tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-08-14 09:25:38 +0000
83+++ tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-10-06 15:46:27 +0000
84@@ -102,6 +102,12 @@
85 self.check_tab_number(1)
86 self.main_window.press_key('Ctrl+Tab')
87 self.check_tab_number(2)
88+ self.main_window.press_key('Ctrl+Page_Down')
89+ self.check_tab_number(0)
90+ self.main_window.press_key('Shift+Ctrl+Tab')
91+ self.check_tab_number(2)
92+ self.main_window.press_key('Ctrl+Page_Up')
93+ self.check_tab_number(1)
94
95 def test_can_switch_tabs_after_suggestions_escape(self):
96 self.open_tabs(1)

Subscribers

People subscribed via source and target branches

to status/vote changes: