Avoid DownloadView being focused when pressing tab
The previous fix didn't work in situations where the web view was actually focused, but had no focused element (like about:blank). The new fix always works, and even is a lot simpler! Fixes #504.
This commit is contained in:
parent
123fd18af5
commit
27b31b7ded
@ -72,6 +72,8 @@ Fixed
|
|||||||
- Fixed some directory browser issues on Windows
|
- Fixed some directory browser issues on Windows
|
||||||
- Fixed crash when closing a window with a finished download and delayed
|
- Fixed crash when closing a window with a finished download and delayed
|
||||||
`remove-finished-downloads` setting.
|
`remove-finished-downloads` setting.
|
||||||
|
- Fixed crash when hitting `<Tab>` then `<Ctrl-C>` on pages without keyboard
|
||||||
|
focus.
|
||||||
|
|
||||||
Removed
|
Removed
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -79,6 +79,7 @@ class DownloadView(QListView):
|
|||||||
self.setResizeMode(QListView.Adjust)
|
self.setResizeMode(QListView.Adjust)
|
||||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
|
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
|
||||||
|
self.setFocusPolicy(Qt.NoFocus)
|
||||||
self.setFlow(QListView.LeftToRight)
|
self.setFlow(QListView.LeftToRight)
|
||||||
self.setSpacing(1)
|
self.setSpacing(1)
|
||||||
self._menu = None
|
self._menu = None
|
||||||
|
@ -23,7 +23,6 @@ import functools
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, Qt, QObject, QEvent
|
from PyQt5.QtCore import pyqtSignal, Qt, QObject, QEvent
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtWebKitWidgets import QWebView
|
|
||||||
|
|
||||||
from qutebrowser.keyinput import modeparsers, keyparser
|
from qutebrowser.keyinput import modeparsers, keyparser
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
@ -171,13 +170,9 @@ class ModeManager(QObject):
|
|||||||
is_non_alnum = (
|
is_non_alnum = (
|
||||||
event.modifiers() not in (Qt.NoModifier, Qt.ShiftModifier) or
|
event.modifiers() not in (Qt.NoModifier, Qt.ShiftModifier) or
|
||||||
not event.text().strip())
|
not event.text().strip())
|
||||||
focus_widget = QApplication.instance().focusWidget()
|
|
||||||
is_tab = event.key() in (Qt.Key_Tab, Qt.Key_Backtab)
|
|
||||||
|
|
||||||
if handled:
|
if handled:
|
||||||
filter_this = True
|
filter_this = True
|
||||||
elif is_tab and not isinstance(focus_widget, QWebView):
|
|
||||||
filter_this = True
|
|
||||||
elif (parser.passthrough or
|
elif (parser.passthrough or
|
||||||
self._forward_unbound_keys == 'all' or
|
self._forward_unbound_keys == 'all' or
|
||||||
(self._forward_unbound_keys == 'auto' and is_non_alnum)):
|
(self._forward_unbound_keys == 'auto' and is_non_alnum)):
|
||||||
@ -189,11 +184,12 @@ class ModeManager(QObject):
|
|||||||
self._releaseevents_to_pass.add(KeyEvent(event))
|
self._releaseevents_to_pass.add(KeyEvent(event))
|
||||||
|
|
||||||
if curmode != usertypes.KeyMode.insert:
|
if curmode != usertypes.KeyMode.insert:
|
||||||
|
focus_widget = QApplication.instance().focusWidget()
|
||||||
log.modes.debug("handled: {}, forward-unbound-keys: {}, "
|
log.modes.debug("handled: {}, forward-unbound-keys: {}, "
|
||||||
"passthrough: {}, is_non_alnum: {}, is_tab {} --> "
|
"passthrough: {}, is_non_alnum: {} --> "
|
||||||
"filter: {} (focused: {!r})".format(
|
"filter: {} (focused: {!r})".format(
|
||||||
handled, self._forward_unbound_keys,
|
handled, self._forward_unbound_keys,
|
||||||
parser.passthrough, is_non_alnum, is_tab,
|
parser.passthrough, is_non_alnum,
|
||||||
filter_this, focus_widget))
|
filter_this, focus_widget))
|
||||||
return filter_this
|
return filter_this
|
||||||
|
|
||||||
|
@ -344,3 +344,20 @@ Feature: Various utility commands.
|
|||||||
Scenario: Running :pyeval with --quiet
|
Scenario: Running :pyeval with --quiet
|
||||||
When I run :debug-pyeval --quiet 1+1
|
When I run :debug-pyeval --quiet 1+1
|
||||||
Then "pyeval output: 2" should be logged
|
Then "pyeval output: 2" should be logged
|
||||||
|
|
||||||
|
## https://github.com/The-Compiler/qutebrowser/issues/504
|
||||||
|
|
||||||
|
Scenario: Focusing download widget via Tab
|
||||||
|
When I open about:blank
|
||||||
|
And I press the key "<Tab>"
|
||||||
|
And I press the key "<Ctrl-C>"
|
||||||
|
Then no crash should happen
|
||||||
|
|
||||||
|
Scenario: Focusing download widget via Tab (original issue)
|
||||||
|
When I open data/prompt/jsprompt.html
|
||||||
|
And I run :hint
|
||||||
|
And I run :follow-hint a
|
||||||
|
And I wait for "Entering mode KeyMode.prompt *" in the log
|
||||||
|
And I press the key "<Tab>"
|
||||||
|
And I press the key "<Ctrl-C>"
|
||||||
|
Then no crash should happen
|
||||||
|
Loading…
Reference in New Issue
Block a user