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
=== modified file 'src/app/webbrowser/Browser.qml'
--- src/app/webbrowser/Browser.qml 2015-09-28 08:15:10 +0000
+++ src/app/webbrowser/Browser.qml 2015-10-06 15:46:27 +0000
@@ -1273,6 +1273,24 @@
1273 }1273 }
1274 }1274 }
12751275
1276 function switchToPreviousTab() {
1277 if (browser.wide) {
1278 internal.switchToTab((tabsModel.currentIndex - 1 + tabsModel.count) % tabsModel.count)
1279 } else {
1280 internal.switchToTab(tabsModel.count - 1)
1281 }
1282 if (recentView.visible) recentView.focus = true
1283 }
1284
1285 function switchToNextTab() {
1286 if (browser.wide) {
1287 internal.switchToTab((tabsModel.currentIndex + 1) % tabsModel.count)
1288 } else {
1289 internal.switchToTab(tabsModel.count - 1)
1290 }
1291 if (recentView.visible) recentView.focus = true
1292 }
1293
1276 function switchToTab(index) {1294 function switchToTab(index) {
1277 tabsModel.currentIndex = index1295 tabsModel.currentIndex = index
1278 var tab = tabsModel.currentTab1296 var tab = tabsModel.currentTab
@@ -1581,34 +1599,32 @@
1581 KeyboardShortcuts {1599 KeyboardShortcuts {
1582 id: shortcuts1600 id: shortcuts
15831601
1584 // Ctrl+Tab: cycle through open tabs1602 // Ctrl+Tab or Ctrl+PageDown: cycle through open tabs
1585 KeyboardShortcut {1603 KeyboardShortcut {
1586 modifiers: Qt.ControlModifier1604 modifiers: Qt.ControlModifier
1587 key: Qt.Key_Tab1605 key: Qt.Key_Tab
1588 enabled: chrome.visible || recentView.visible1606 enabled: chrome.visible || recentView.visible
1589 onTriggered: {1607 onTriggered: internal.switchToNextTab()
1590 if (browser.wide) {1608 }
1591 internal.switchToTab((tabsModel.currentIndex + 1) % tabsModel.count)1609 KeyboardShortcut {
1592 } else {1610 modifiers: Qt.ControlModifier
1593 internal.switchToTab(tabsModel.count - 1)1611 key: Qt.Key_PageDown
1594 }1612 enabled: chrome.visible || recentView.visible
1595 if (recentView.visible) recentView.focus = true1613 onTriggered: internal.switchToNextTab()
1596 }
1597 }1614 }
15981615
1599 // Ctrl+Shift+Tab: cycle through open tabs in reverse order1616 // Ctrl+Shift+Tab or Ctrl+PageUp: cycle through open tabs in reverse order
1600 KeyboardShortcut {1617 KeyboardShortcut {
1601 modifiers: Qt.ControlModifier1618 modifiers: Qt.ControlModifier
1602 key: Qt.Key_Backtab1619 key: Qt.Key_Backtab
1603 enabled: chrome.visible || recentView.visible1620 enabled: chrome.visible || recentView.visible
1604 onTriggered: {1621 onTriggered: internal.switchToPreviousTab()
1605 if (browser.wide) {1622 }
1606 internal.switchToTab((tabsModel.currentIndex - 1 + tabsModel.count) % tabsModel.count)1623 KeyboardShortcut {
1607 } else {1624 modifiers: Qt.ControlModifier
1608 internal.switchToTab(tabsModel.count - 1)1625 key: Qt.Key_PageUp
1609 }1626 enabled: chrome.visible || recentView.visible
1610 if (recentView.visible) recentView.focus = true1627 onTriggered: internal.switchToPreviousTab()
1611 }
1612 }1628 }
16131629
1614 // Ctrl+W or Ctrl+F4: Close the current tab1630 // Ctrl+W or Ctrl+F4: Close the current tab
16151631
=== modified file 'tests/autopilot/webbrowser_app/tests/test_keyboard.py'
--- tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-08-14 09:25:38 +0000
+++ tests/autopilot/webbrowser_app/tests/test_keyboard.py 2015-10-06 15:46:27 +0000
@@ -102,6 +102,12 @@
102 self.check_tab_number(1)102 self.check_tab_number(1)
103 self.main_window.press_key('Ctrl+Tab')103 self.main_window.press_key('Ctrl+Tab')
104 self.check_tab_number(2)104 self.check_tab_number(2)
105 self.main_window.press_key('Ctrl+Page_Down')
106 self.check_tab_number(0)
107 self.main_window.press_key('Shift+Ctrl+Tab')
108 self.check_tab_number(2)
109 self.main_window.press_key('Ctrl+Page_Up')
110 self.check_tab_number(1)
105111
106 def test_can_switch_tabs_after_suggestions_escape(self):112 def test_can_switch_tabs_after_suggestions_escape(self):
107 self.open_tabs(1)113 self.open_tabs(1)

Subscribers

People subscribed via source and target branches

to status/vote changes: