Merge branch 'blyxxyz-style-in-lists'
This commit is contained in:
commit
e35dfe7aa3
@ -163,7 +163,7 @@ def _init_icon():
|
|||||||
"""Initialize the icon of qutebrowser."""
|
"""Initialize the icon of qutebrowser."""
|
||||||
icon = QIcon()
|
icon = QIcon()
|
||||||
fallback_icon = QIcon()
|
fallback_icon = QIcon()
|
||||||
for size in (16, 24, 32, 48, 64, 96, 128, 256, 512):
|
for size in [16, 24, 32, 48, 64, 96, 128, 256, 512]:
|
||||||
filename = ':/icons/qutebrowser-{}x{}.png'.format(size, size)
|
filename = ':/icons/qutebrowser-{}x{}.png'.format(size, size)
|
||||||
pixmap = QPixmap(filename)
|
pixmap = QPixmap(filename)
|
||||||
qtutils.ensure_not_null(pixmap)
|
qtutils.ensure_not_null(pixmap)
|
||||||
@ -275,7 +275,7 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
|
|||||||
message.error('current', "Error in startup argument '{}': "
|
message.error('current', "Error in startup argument '{}': "
|
||||||
"{}".format(cmd, e))
|
"{}".format(cmd, e))
|
||||||
else:
|
else:
|
||||||
background = open_target in ('tab-bg', 'tab-bg-silent')
|
background = open_target in ['tab-bg', 'tab-bg-silent']
|
||||||
tabbed_browser.tabopen(url, background=background,
|
tabbed_browser.tabopen(url, background=background,
|
||||||
explicit=True)
|
explicit=True)
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ class AbstractZoom(QObject):
|
|||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def _on_config_changed(self, section, option):
|
def _on_config_changed(self, section, option):
|
||||||
if section == 'ui' and option in ('zoom-levels', 'default-zoom'):
|
if section == 'ui' and option in ['zoom-levels', 'default-zoom']:
|
||||||
if not self._default_zoom_changed:
|
if not self._default_zoom_changed:
|
||||||
factor = float(config.get('ui', 'default-zoom')) / 100
|
factor = float(config.get('ui', 'default-zoom')) / 100
|
||||||
self._set_factor_internal(factor)
|
self._set_factor_internal(factor)
|
||||||
|
@ -521,7 +521,7 @@ class CommandDispatcher:
|
|||||||
background=bg, window=window)
|
background=bg, window=window)
|
||||||
elif where == 'up':
|
elif where == 'up':
|
||||||
self._navigate_up(url, tab, bg, window)
|
self._navigate_up(url, tab, bg, window)
|
||||||
elif where in ('decrement', 'increment'):
|
elif where in ['decrement', 'increment']:
|
||||||
self._navigate_incdec(url, where, tab, bg, window)
|
self._navigate_incdec(url, where, tab, bg, window)
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
raise ValueError("Got called with invalid value {} for "
|
raise ValueError("Got called with invalid value {} for "
|
||||||
@ -574,7 +574,7 @@ class CommandDispatcher:
|
|||||||
"expected one of: {}".format(
|
"expected one of: {}".format(
|
||||||
direction, expected_values))
|
direction, expected_values))
|
||||||
|
|
||||||
if direction in ('top', 'bottom'):
|
if direction in ['top', 'bottom']:
|
||||||
func()
|
func()
|
||||||
else:
|
else:
|
||||||
func(count=count)
|
func(count=count)
|
||||||
|
@ -608,7 +608,7 @@ class HintManager(QObject):
|
|||||||
Return:
|
Return:
|
||||||
A QUrl with the absolute URL, or None.
|
A QUrl with the absolute URL, or None.
|
||||||
"""
|
"""
|
||||||
for attr in ('href', 'src'):
|
for attr in ['href', 'src']:
|
||||||
if attr in elem:
|
if attr in elem:
|
||||||
text = elem[attr].strip()
|
text = elem[attr].strip()
|
||||||
break
|
break
|
||||||
@ -677,8 +677,8 @@ class HintManager(QObject):
|
|||||||
"""
|
"""
|
||||||
if not isinstance(target, Target):
|
if not isinstance(target, Target):
|
||||||
raise TypeError("Target {} is no Target member!".format(target))
|
raise TypeError("Target {} is no Target member!".format(target))
|
||||||
if target in (Target.userscript, Target.spawn, Target.run,
|
if target in [Target.userscript, Target.spawn, Target.run,
|
||||||
Target.fill):
|
Target.fill]:
|
||||||
if not args:
|
if not args:
|
||||||
raise cmdexc.CommandError(
|
raise cmdexc.CommandError(
|
||||||
"'args' is required with target userscript/spawn/run/"
|
"'args' is required with target userscript/spawn/run/"
|
||||||
|
@ -345,7 +345,7 @@ class DownloadItem(QObject):
|
|||||||
errmsg = ""
|
errmsg = ""
|
||||||
else:
|
else:
|
||||||
errmsg = " - {}".format(self.error_msg)
|
errmsg = " - {}".format(self.error_msg)
|
||||||
if all(e is None for e in (perc, remaining, self.stats.total)):
|
if all(e is None for e in [perc, remaining, self.stats.total]):
|
||||||
return ('{index}: {name} [{speed:>10}|{down}]{errmsg}'.format(
|
return ('{index}: {name} [{speed:>10}|{down}]{errmsg}'.format(
|
||||||
index=self.index, name=self.basename, speed=speed,
|
index=self.index, name=self.basename, speed=speed,
|
||||||
down=down, errmsg=errmsg))
|
down=down, errmsg=errmsg))
|
||||||
@ -451,7 +451,7 @@ class DownloadItem(QObject):
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=bad-config-call
|
# pylint: disable=bad-config-call
|
||||||
# WORKAROUND for https://bitbucket.org/logilab/astroid/issue/104/
|
# WORKAROUND for https://bitbucket.org/logilab/astroid/issue/104/
|
||||||
assert position in ("fg", "bg")
|
assert position in ["fg", "bg"]
|
||||||
start = config.get('colors', 'downloads.{}.start'.format(position))
|
start = config.get('colors', 'downloads.{}.start'.format(position))
|
||||||
stop = config.get('colors', 'downloads.{}.stop'.format(position))
|
stop = config.get('colors', 'downloads.{}.stop'.format(position))
|
||||||
system = config.get('colors', 'downloads.{}.system'.format(position))
|
system = config.get('colors', 'downloads.{}.system'.format(position))
|
||||||
|
@ -319,7 +319,7 @@ class _Downloader:
|
|||||||
Args:
|
Args:
|
||||||
url: The file to download as QUrl.
|
url: The file to download as QUrl.
|
||||||
"""
|
"""
|
||||||
if url.scheme() not in {'http', 'https'}:
|
if url.scheme() not in ['http', 'https']:
|
||||||
return
|
return
|
||||||
# Prevent loading an asset twice
|
# Prevent loading an asset twice
|
||||||
if url in self.loaded_urls:
|
if url in self.loaded_urls:
|
||||||
|
@ -83,7 +83,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
|||||||
if elem.isNull():
|
if elem.isNull():
|
||||||
raise IsNullError('{} is a null element!'.format(elem))
|
raise IsNullError('{} is a null element!'.format(elem))
|
||||||
self._elem = elem
|
self._elem = elem
|
||||||
for name in ('addClass', 'appendInside', 'appendOutside',
|
for name in ['addClass', 'appendInside', 'appendOutside',
|
||||||
'attributeNS', 'classes', 'clone', 'document',
|
'attributeNS', 'classes', 'clone', 'document',
|
||||||
'encloseContentsWith', 'encloseWith',
|
'encloseContentsWith', 'encloseWith',
|
||||||
'evaluateJavaScript', 'findAll', 'findFirst',
|
'evaluateJavaScript', 'findAll', 'findFirst',
|
||||||
@ -97,7 +97,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
|||||||
'setInnerXml', 'setOuterXml', 'setPlainText',
|
'setInnerXml', 'setOuterXml', 'setPlainText',
|
||||||
'setStyleProperty', 'styleProperty', 'tagName',
|
'setStyleProperty', 'styleProperty', 'tagName',
|
||||||
'takeFromDocument', 'toInnerXml', 'toOuterXml',
|
'takeFromDocument', 'toInnerXml', 'toOuterXml',
|
||||||
'toggleClass', 'webFrame', '__eq__', '__ne__'):
|
'toggleClass', 'webFrame', '__eq__', '__ne__']:
|
||||||
# We don't wrap some methods for which we have better alternatives:
|
# We don't wrap some methods for which we have better alternatives:
|
||||||
# - Mapping access for attributeNames/hasAttribute/setAttribute/
|
# - Mapping access for attributeNames/hasAttribute/setAttribute/
|
||||||
# attribute/removeAttribute.
|
# attribute/removeAttribute.
|
||||||
@ -194,7 +194,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
|||||||
"""
|
"""
|
||||||
self._check_vanished()
|
self._check_vanished()
|
||||||
try:
|
try:
|
||||||
return self['contenteditable'].lower() not in ('false', 'inherit')
|
return self['contenteditable'].lower() not in ['false', 'inherit']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
|||||||
return self._is_editable_input()
|
return self._is_editable_input()
|
||||||
elif tag == 'textarea':
|
elif tag == 'textarea':
|
||||||
return self.is_writable()
|
return self.is_writable()
|
||||||
elif tag in ('embed', 'applet'):
|
elif tag in ['embed', 'applet']:
|
||||||
# Flash/Java/...
|
# Flash/Java/...
|
||||||
return config.get('input', 'insert-mode-on-plugins') and not strict
|
return config.get('input', 'insert-mode-on-plugins') and not strict
|
||||||
elif tag == 'object':
|
elif tag == 'object':
|
||||||
@ -284,7 +284,7 @@ class WebElementWrapper(collections.abc.MutableMapping):
|
|||||||
self._check_vanished()
|
self._check_vanished()
|
||||||
roles = ('combobox', 'textbox')
|
roles = ('combobox', 'textbox')
|
||||||
tag = self._elem.tagName().lower()
|
tag = self._elem.tagName().lower()
|
||||||
return self.get('role', None) in roles or tag in ('input', 'textarea')
|
return self.get('role', None) in roles or tag in ['input', 'textarea']
|
||||||
|
|
||||||
def remove_blank_target(self):
|
def remove_blank_target(self):
|
||||||
"""Remove target from link."""
|
"""Remove target from link."""
|
||||||
|
@ -300,7 +300,7 @@ class BrowserPage(QWebPage):
|
|||||||
else:
|
else:
|
||||||
reply.finished.connect(functools.partial(
|
reply.finished.connect(functools.partial(
|
||||||
self.display_content, reply, 'image/jpeg'))
|
self.display_content, reply, 'image/jpeg'))
|
||||||
elif (mimetype in {'application/pdf', 'application/x-pdf'} and
|
elif (mimetype in ['application/pdf', 'application/x-pdf'] and
|
||||||
config.get('content', 'enable-pdfjs')):
|
config.get('content', 'enable-pdfjs')):
|
||||||
# Use pdf.js to display the page
|
# Use pdf.js to display the page
|
||||||
self._show_pdfjs(reply)
|
self._show_pdfjs(reply)
|
||||||
|
@ -159,14 +159,14 @@ class WebView(QWebView):
|
|||||||
Args:
|
Args:
|
||||||
e: The QMouseEvent.
|
e: The QMouseEvent.
|
||||||
"""
|
"""
|
||||||
if e.button() in (Qt.XButton1, Qt.LeftButton):
|
if e.button() in [Qt.XButton1, Qt.LeftButton]:
|
||||||
# Back button on mice which have it, or rocker gesture
|
# Back button on mice which have it, or rocker gesture
|
||||||
if self.page().history().canGoBack():
|
if self.page().history().canGoBack():
|
||||||
self.back()
|
self.back()
|
||||||
else:
|
else:
|
||||||
message.error(self.win_id, "At beginning of history.",
|
message.error(self.win_id, "At beginning of history.",
|
||||||
immediately=True)
|
immediately=True)
|
||||||
elif e.button() in (Qt.XButton2, Qt.RightButton):
|
elif e.button() in [Qt.XButton2, Qt.RightButton]:
|
||||||
# Forward button on mice which have it, or rocker gesture
|
# Forward button on mice which have it, or rocker gesture
|
||||||
if self.page().history().canGoForward():
|
if self.page().history().canGoForward():
|
||||||
self.forward()
|
self.forward()
|
||||||
@ -337,8 +337,8 @@ class WebView(QWebView):
|
|||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_entered(self, mode):
|
def on_mode_entered(self, mode):
|
||||||
"""Ignore attempts to focus the widget if in any status-input mode."""
|
"""Ignore attempts to focus the widget if in any status-input mode."""
|
||||||
if mode in (usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
if mode in [usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
||||||
usertypes.KeyMode.yesno):
|
usertypes.KeyMode.yesno]:
|
||||||
log.webview.debug("Ignoring focus because mode {} was "
|
log.webview.debug("Ignoring focus because mode {} was "
|
||||||
"entered.".format(mode))
|
"entered.".format(mode))
|
||||||
self.setFocusPolicy(Qt.NoFocus)
|
self.setFocusPolicy(Qt.NoFocus)
|
||||||
@ -346,8 +346,8 @@ class WebView(QWebView):
|
|||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Restore focus policy if status-input modes were left."""
|
"""Restore focus policy if status-input modes were left."""
|
||||||
if mode in (usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
if mode in [usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
||||||
usertypes.KeyMode.yesno):
|
usertypes.KeyMode.yesno]:
|
||||||
log.webview.debug("Restoring focus policy because mode {} was "
|
log.webview.debug("Restoring focus policy because mode {} was "
|
||||||
"left.".format(mode))
|
"left.".format(mode))
|
||||||
self.setFocusPolicy(Qt.WheelFocus)
|
self.setFocusPolicy(Qt.WheelFocus)
|
||||||
@ -424,7 +424,7 @@ class WebView(QWebView):
|
|||||||
is_rocker_gesture = (config.get('input', 'rocker-gestures') and
|
is_rocker_gesture = (config.get('input', 'rocker-gestures') and
|
||||||
e.buttons() == Qt.LeftButton | Qt.RightButton)
|
e.buttons() == Qt.LeftButton | Qt.RightButton)
|
||||||
|
|
||||||
if e.button() in (Qt.XButton1, Qt.XButton2) or is_rocker_gesture:
|
if e.button() in [Qt.XButton1, Qt.XButton2] or is_rocker_gesture:
|
||||||
self._mousepress_backforward(e)
|
self._mousepress_backforward(e)
|
||||||
super().mousePressEvent(e)
|
super().mousePressEvent(e)
|
||||||
return
|
return
|
||||||
|
@ -211,7 +211,7 @@ def _init_misc():
|
|||||||
"""Initialize misc. config-related files."""
|
"""Initialize misc. config-related files."""
|
||||||
save_manager = objreg.get('save-manager')
|
save_manager = objreg.get('save-manager')
|
||||||
state_config = ini.ReadWriteConfigParser(standarddir.data(), 'state')
|
state_config = ini.ReadWriteConfigParser(standarddir.data(), 'state')
|
||||||
for sect in ('general', 'geometry'):
|
for sect in ['general', 'geometry']:
|
||||||
try:
|
try:
|
||||||
state_config.add_section(sect)
|
state_config.add_section(sect)
|
||||||
except configparser.DuplicateSectionError:
|
except configparser.DuplicateSectionError:
|
||||||
@ -242,7 +242,7 @@ def _init_misc():
|
|||||||
path = os.devnull
|
path = os.devnull
|
||||||
else:
|
else:
|
||||||
path = os.path.join(standarddir.config(), 'qsettings')
|
path = os.path.join(standarddir.config(), 'qsettings')
|
||||||
for fmt in (QSettings.NativeFormat, QSettings.IniFormat):
|
for fmt in [QSettings.NativeFormat, QSettings.IniFormat]:
|
||||||
QSettings.setPath(fmt, QSettings.UserScope, path)
|
QSettings.setPath(fmt, QSettings.UserScope, path)
|
||||||
|
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ class ConfigManager(QObject):
|
|||||||
"""Notify other objects the config has changed."""
|
"""Notify other objects the config has changed."""
|
||||||
log.config.debug("Config option changed: {} -> {}".format(
|
log.config.debug("Config option changed: {} -> {}".format(
|
||||||
sectname, optname))
|
sectname, optname))
|
||||||
if sectname in ('colors', 'fonts'):
|
if sectname in ['colors', 'fonts']:
|
||||||
self.style_changed.emit(sectname, optname)
|
self.style_changed.emit(sectname, optname)
|
||||||
self.changed.emit(sectname, optname)
|
self.changed.emit(sectname, optname)
|
||||||
|
|
||||||
|
@ -1342,7 +1342,7 @@ class AutoSearch(BaseType):
|
|||||||
self._basic_validation(value)
|
self._basic_validation(value)
|
||||||
if not value:
|
if not value:
|
||||||
return
|
return
|
||||||
elif value.lower() in ('naive', 'dns'):
|
elif value.lower() in ['naive', 'dns']:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.booltype.validate(value)
|
self.booltype.validate(value)
|
||||||
@ -1350,7 +1350,7 @@ class AutoSearch(BaseType):
|
|||||||
def transform(self, value):
|
def transform(self, value):
|
||||||
if not value:
|
if not value:
|
||||||
return None
|
return None
|
||||||
elif value.lower() in ('naive', 'dns'):
|
elif value.lower() in ['naive', 'dns']:
|
||||||
return value.lower()
|
return value.lower()
|
||||||
elif self.booltype.transform(value):
|
elif self.booltype.transform(value):
|
||||||
# boolean true is an alias for naive matching
|
# boolean true is an alias for naive matching
|
||||||
|
@ -170,7 +170,7 @@ class ModeManager(QObject):
|
|||||||
handled = parser.handle(event)
|
handled = parser.handle(event)
|
||||||
|
|
||||||
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())
|
||||||
|
|
||||||
if handled:
|
if handled:
|
||||||
|
@ -77,7 +77,7 @@ def get_window(via_ipc, force_window=False, force_tab=False,
|
|||||||
win_id = window.win_id
|
win_id = window.win_id
|
||||||
window_to_raise = window
|
window_to_raise = window
|
||||||
win_id = window.win_id
|
win_id = window.win_id
|
||||||
if open_target not in ('tab-silent', 'tab-bg-silent'):
|
if open_target not in ['tab-silent', 'tab-bg-silent']:
|
||||||
window_to_raise = window
|
window_to_raise = window
|
||||||
if window_to_raise is not None:
|
if window_to_raise is not None:
|
||||||
window_to_raise.setWindowState(
|
window_to_raise.setWindowState(
|
||||||
@ -196,7 +196,7 @@ class MainWindow(QWidget):
|
|||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def on_config_changed(self, section, option):
|
def on_config_changed(self, section, option):
|
||||||
"""Resize the completion if related config options changed."""
|
"""Resize the completion if related config options changed."""
|
||||||
if section == 'completion' and option in ('height', 'shrink'):
|
if section == 'completion' and option in ['height', 'shrink']:
|
||||||
self.resize_completion()
|
self.resize_completion()
|
||||||
elif section == 'ui' and option == 'statusbar-padding':
|
elif section == 'ui' and option == 'statusbar-padding':
|
||||||
self.resize_completion()
|
self.resize_completion()
|
||||||
|
@ -519,9 +519,9 @@ class StatusBar(QWidget):
|
|||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
if keyparsers[mode].passthrough:
|
if keyparsers[mode].passthrough:
|
||||||
self._set_mode_text(mode.name)
|
self._set_mode_text(mode.name)
|
||||||
if mode in (usertypes.KeyMode.insert,
|
if mode in [usertypes.KeyMode.insert,
|
||||||
usertypes.KeyMode.command,
|
usertypes.KeyMode.command,
|
||||||
usertypes.KeyMode.caret):
|
usertypes.KeyMode.caret]:
|
||||||
self.set_mode_active(mode, True)
|
self.set_mode_active(mode, True)
|
||||||
|
|
||||||
@pyqtSlot(usertypes.KeyMode, usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode, usertypes.KeyMode)
|
||||||
@ -534,9 +534,9 @@ class StatusBar(QWidget):
|
|||||||
self._set_mode_text(new_mode.name)
|
self._set_mode_text(new_mode.name)
|
||||||
else:
|
else:
|
||||||
self.txt.set_text(self.txt.Text.normal, '')
|
self.txt.set_text(self.txt.Text.normal, '')
|
||||||
if old_mode in (usertypes.KeyMode.insert,
|
if old_mode in [usertypes.KeyMode.insert,
|
||||||
usertypes.KeyMode.command,
|
usertypes.KeyMode.command,
|
||||||
usertypes.KeyMode.caret):
|
usertypes.KeyMode.caret]:
|
||||||
self.set_mode_active(old_mode, False)
|
self.set_mode_active(old_mode, False)
|
||||||
|
|
||||||
@config.change_filter('ui', 'message-timeout')
|
@config.change_filter('ui', 'message-timeout')
|
||||||
|
@ -207,7 +207,7 @@ class Prompter(QObject):
|
|||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Clear and reset input when the mode was left."""
|
"""Clear and reset input when the mode was left."""
|
||||||
prompt = objreg.get('prompt', scope='window', window=self._win_id)
|
prompt = objreg.get('prompt', scope='window', window=self._win_id)
|
||||||
if mode in (usertypes.KeyMode.prompt, usertypes.KeyMode.yesno):
|
if mode in [usertypes.KeyMode.prompt, usertypes.KeyMode.yesno]:
|
||||||
prompt.txt.setText('')
|
prompt.txt.setText('')
|
||||||
prompt.lineedit.clear()
|
prompt.lineedit.clear()
|
||||||
prompt.lineedit.setEchoMode(QLineEdit.Normal)
|
prompt.lineedit.setEchoMode(QLineEdit.Normal)
|
||||||
|
@ -120,10 +120,10 @@ class UrlText(textbase.TextBase):
|
|||||||
status_str: The LoadStatus as string.
|
status_str: The LoadStatus as string.
|
||||||
"""
|
"""
|
||||||
status = usertypes.LoadStatus[status_str]
|
status = usertypes.LoadStatus[status_str]
|
||||||
if status in (usertypes.LoadStatus.success,
|
if status in [usertypes.LoadStatus.success,
|
||||||
usertypes.LoadStatus.success_https,
|
usertypes.LoadStatus.success_https,
|
||||||
usertypes.LoadStatus.error,
|
usertypes.LoadStatus.error,
|
||||||
usertypes.LoadStatus.warn):
|
usertypes.LoadStatus.warn]:
|
||||||
self._normal_url_type = UrlType[status_str]
|
self._normal_url_type = UrlType[status_str]
|
||||||
else:
|
else:
|
||||||
self._normal_url_type = UrlType.normal
|
self._normal_url_type = UrlType.normal
|
||||||
|
@ -536,8 +536,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
@pyqtSlot(usertypes.KeyMode)
|
@pyqtSlot(usertypes.KeyMode)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Give focus to current tab if command mode was left."""
|
"""Give focus to current tab if command mode was left."""
|
||||||
if mode in (usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
if mode in [usertypes.KeyMode.command, usertypes.KeyMode.prompt,
|
||||||
usertypes.KeyMode.yesno):
|
usertypes.KeyMode.yesno]:
|
||||||
widget = self.currentWidget()
|
widget = self.currentWidget()
|
||||||
log.modes.debug("Left status-input mode, focusing {!r}".format(
|
log.modes.debug("Left status-input mode, focusing {!r}".format(
|
||||||
widget))
|
widget))
|
||||||
@ -554,8 +554,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
tab = self.widget(idx)
|
tab = self.widget(idx)
|
||||||
log.modes.debug("Current tab changed, focusing {!r}".format(tab))
|
log.modes.debug("Current tab changed, focusing {!r}".format(tab))
|
||||||
tab.setFocus()
|
tab.setFocus()
|
||||||
for mode in (usertypes.KeyMode.hint, usertypes.KeyMode.insert,
|
for mode in [usertypes.KeyMode.hint, usertypes.KeyMode.insert,
|
||||||
usertypes.KeyMode.caret, usertypes.KeyMode.passthrough):
|
usertypes.KeyMode.caret, usertypes.KeyMode.passthrough]:
|
||||||
modeman.maybe_leave(self._win_id, mode, 'tab changed')
|
modeman.maybe_leave(self._win_id, mode, 'tab changed')
|
||||||
if self._now_focused is not None:
|
if self._now_focused is not None:
|
||||||
objreg.register('last-focused-tab', self._now_focused, update=True,
|
objreg.register('last-focused-tab', self._now_focused, update=True,
|
||||||
|
@ -72,7 +72,7 @@ class TabWidget(QTabWidget):
|
|||||||
position = config.get('tabs', 'position')
|
position = config.get('tabs', 'position')
|
||||||
selection_behavior = config.get('tabs', 'select-on-remove')
|
selection_behavior = config.get('tabs', 'select-on-remove')
|
||||||
self.setTabPosition(position)
|
self.setTabPosition(position)
|
||||||
tabbar.vertical = position in (QTabWidget.West, QTabWidget.East)
|
tabbar.vertical = position in [QTabWidget.West, QTabWidget.East]
|
||||||
tabbar.setSelectionBehaviorOnRemove(selection_behavior)
|
tabbar.setSelectionBehaviorOnRemove(selection_behavior)
|
||||||
tabbar.refresh()
|
tabbar.refresh()
|
||||||
|
|
||||||
@ -542,11 +542,11 @@ class TabBarStyle(QCommonStyle):
|
|||||||
style: The base/"parent" style.
|
style: The base/"parent" style.
|
||||||
"""
|
"""
|
||||||
self._style = style
|
self._style = style
|
||||||
for method in ('drawComplexControl', 'drawItemPixmap',
|
for method in ['drawComplexControl', 'drawItemPixmap',
|
||||||
'generatedIconPixmap', 'hitTestComplexControl',
|
'generatedIconPixmap', 'hitTestComplexControl',
|
||||||
'itemPixmapRect', 'itemTextRect', 'polish', 'styleHint',
|
'itemPixmapRect', 'itemTextRect', 'polish', 'styleHint',
|
||||||
'subControlRect', 'unpolish', 'drawItemText',
|
'subControlRect', 'unpolish', 'drawItemText',
|
||||||
'sizeFromContents', 'drawPrimitive'):
|
'sizeFromContents', 'drawPrimitive']:
|
||||||
target = getattr(self._style, method)
|
target = getattr(self._style, method)
|
||||||
setattr(self, method, functools.partial(target))
|
setattr(self, method, functools.partial(target))
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -311,7 +311,7 @@ class SignalHandler(QObject):
|
|||||||
# pylint: disable=import-error,no-member,useless-suppression
|
# pylint: disable=import-error,no-member,useless-suppression
|
||||||
import fcntl
|
import fcntl
|
||||||
read_fd, write_fd = os.pipe()
|
read_fd, write_fd = os.pipe()
|
||||||
for fd in (read_fd, write_fd):
|
for fd in [read_fd, write_fd]:
|
||||||
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
|
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
|
||||||
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||||
self._notifier = QSocketNotifier(read_fd, QSocketNotifier.Read,
|
self._notifier = QSocketNotifier(read_fd, QSocketNotifier.Read,
|
||||||
|
@ -175,7 +175,7 @@ def fix_harfbuzz(args):
|
|||||||
else:
|
else:
|
||||||
log.init.debug("Using old harfbuzz engine (auto)")
|
log.init.debug("Using old harfbuzz engine (auto)")
|
||||||
os.environ['QT_HARFBUZZ'] = 'old'
|
os.environ['QT_HARFBUZZ'] = 'old'
|
||||||
elif args.harfbuzz in ('old', 'new'):
|
elif args.harfbuzz in ['old', 'new']:
|
||||||
# forced harfbuzz variant
|
# forced harfbuzz variant
|
||||||
# FIXME looking at the Qt code, 'new' isn't a valid value, but leaving
|
# FIXME looking at the Qt code, 'new' isn't a valid value, but leaving
|
||||||
# it empty and using new yields different behavior...
|
# it empty and using new yields different behavior...
|
||||||
|
@ -263,8 +263,8 @@ class IPCServer(QObject):
|
|||||||
log.ipc.debug("We can read a line immediately.")
|
log.ipc.debug("We can read a line immediately.")
|
||||||
self.on_ready_read()
|
self.on_ready_read()
|
||||||
socket.error.connect(self.on_error)
|
socket.error.connect(self.on_error)
|
||||||
if socket.error() not in (QLocalSocket.UnknownSocketError,
|
if socket.error() not in [QLocalSocket.UnknownSocketError,
|
||||||
QLocalSocket.PeerClosedError):
|
QLocalSocket.PeerClosedError]:
|
||||||
log.ipc.debug("We got an error immediately.")
|
log.ipc.debug("We got an error immediately.")
|
||||||
self.on_error(socket.error())
|
self.on_error(socket.error())
|
||||||
socket.disconnected.connect(self.on_disconnected)
|
socket.disconnected.connect(self.on_disconnected)
|
||||||
@ -311,7 +311,7 @@ class IPCServer(QObject):
|
|||||||
self._handle_invalid_data()
|
self._handle_invalid_data()
|
||||||
return
|
return
|
||||||
|
|
||||||
for name in ('args', 'target_arg'):
|
for name in ['args', 'target_arg']:
|
||||||
if name not in json_data:
|
if name not in json_data:
|
||||||
log.ipc.error("Missing {}: {}".format(name, decoded.strip()))
|
log.ipc.error("Missing {}: {}".format(name, decoded.strip()))
|
||||||
self._handle_invalid_data()
|
self._handle_invalid_data()
|
||||||
@ -493,8 +493,8 @@ def send_to_running_instance(socketname, command, target_arg, *,
|
|||||||
socket.waitForDisconnected(CONNECT_TIMEOUT)
|
socket.waitForDisconnected(CONNECT_TIMEOUT)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if socket.error() not in (QLocalSocket.ConnectionRefusedError,
|
if socket.error() not in [QLocalSocket.ConnectionRefusedError,
|
||||||
QLocalSocket.ServerNotFoundError):
|
QLocalSocket.ServerNotFoundError]:
|
||||||
raise SocketError("connecting to running instance", socket)
|
raise SocketError("connecting to running instance", socket)
|
||||||
else:
|
else:
|
||||||
log.ipc.debug("No existing instance present (error {})".format(
|
log.ipc.debug("No existing instance present (error {})".format(
|
||||||
|
@ -61,7 +61,7 @@ def _guess_autoescape(template_name):
|
|||||||
if template_name is None or '.' not in template_name:
|
if template_name is None or '.' not in template_name:
|
||||||
return False
|
return False
|
||||||
ext = template_name.rsplit('.', 1)[1]
|
ext = template_name.rsplit('.', 1)[1]
|
||||||
return ext in ('html', 'htm', 'xml')
|
return ext in ['html', 'htm', 'xml']
|
||||||
|
|
||||||
|
|
||||||
def resource_url(path):
|
def resource_url(path):
|
||||||
|
@ -86,7 +86,7 @@ def _wrapper(win_id, method_name, text, *args, **kwargs):
|
|||||||
win in objreg.window_registry.values() and
|
win in objreg.window_registry.values() and
|
||||||
win.win_id == win_id)
|
win.win_id == win_id)
|
||||||
if (config.get('ui', 'message-unfocused') or
|
if (config.get('ui', 'message-unfocused') or
|
||||||
method_name not in ('error', 'warning', 'info') or
|
method_name not in ['error', 'warning', 'info'] or
|
||||||
window_focused):
|
window_focused):
|
||||||
getattr(bridge, method_name)(text, *args, **kwargs)
|
getattr(bridge, method_name)(text, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
@ -194,7 +194,7 @@ def _get_window_registry(window):
|
|||||||
|
|
||||||
def _get_registry(scope, window=None, tab=None):
|
def _get_registry(scope, window=None, tab=None):
|
||||||
"""Get the correct registry for a given scope."""
|
"""Get the correct registry for a given scope."""
|
||||||
if window is not None and scope not in ('window', 'tab'):
|
if window is not None and scope not in ['window', 'tab']:
|
||||||
raise TypeError("window is set with scope {}".format(scope))
|
raise TypeError("window is set with scope {}".format(scope))
|
||||||
if tab is not None and scope != 'tab':
|
if tab is not None and scope != 'tab':
|
||||||
raise TypeError("tab is set with scope {}".format(scope))
|
raise TypeError("tab is set with scope {}".format(scope))
|
||||||
|
@ -263,7 +263,7 @@ def is_url(urlstr):
|
|||||||
# URLs with explicit schemes are always URLs
|
# URLs with explicit schemes are always URLs
|
||||||
log.url.debug("Contains explicit scheme")
|
log.url.debug("Contains explicit scheme")
|
||||||
url = True
|
url = True
|
||||||
elif qurl_userinput.host() in ('localhost', '127.0.0.1', '::1'):
|
elif qurl_userinput.host() in ['localhost', '127.0.0.1', '::1']:
|
||||||
log.url.debug("Is localhost.")
|
log.url.debug("Is localhost.")
|
||||||
url = True
|
url = True
|
||||||
elif is_special_url(qurl):
|
elif is_special_url(qurl):
|
||||||
|
@ -518,7 +518,7 @@ def normalize_keystr(keystr):
|
|||||||
)
|
)
|
||||||
for (orig, repl) in replacements:
|
for (orig, repl) in replacements:
|
||||||
keystr = keystr.replace(orig, repl)
|
keystr = keystr.replace(orig, repl)
|
||||||
for mod in ('ctrl', 'meta', 'alt', 'shift'):
|
for mod in ['ctrl', 'meta', 'alt', 'shift']:
|
||||||
keystr = keystr.replace(mod + '-', mod + '+')
|
keystr = keystr.replace(mod + '-', mod + '+')
|
||||||
return keystr
|
return keystr
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ def _os_info():
|
|||||||
versioninfo = ''
|
versioninfo = ''
|
||||||
else:
|
else:
|
||||||
versioninfo = '.'.join(versioninfo)
|
versioninfo = '.'.join(versioninfo)
|
||||||
osver = ', '.join([e for e in (release, versioninfo, machine) if e])
|
osver = ', '.join([e for e in [release, versioninfo, machine] if e])
|
||||||
else:
|
else:
|
||||||
osver = '?'
|
osver = '?'
|
||||||
lines.append('OS Version: {}'.format(osver))
|
lines.append('OS Version: {}'.format(osver))
|
||||||
|
@ -197,7 +197,7 @@ class AsciiDoc:
|
|||||||
for filename in files:
|
for filename in files:
|
||||||
basename, ext = os.path.splitext(filename)
|
basename, ext = os.path.splitext(filename)
|
||||||
if (ext != '.asciidoc' or
|
if (ext != '.asciidoc' or
|
||||||
basename in ('header', 'OpenSans-License')):
|
basename in ['header', 'OpenSans-License']):
|
||||||
continue
|
continue
|
||||||
self._build_website_file(root, filename)
|
self._build_website_file(root, filename)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class ConfigChecker(checkers.BaseChecker):
|
|||||||
if hasattr(node, 'func'):
|
if hasattr(node, 'func'):
|
||||||
infer = utils.safe_infer(node.func)
|
infer = utils.safe_infer(node.func)
|
||||||
if infer and infer.root().name == 'qutebrowser.config.config':
|
if infer and infer.root().name == 'qutebrowser.config.config':
|
||||||
if getattr(node.func, 'attrname', None) in ('get', 'set'):
|
if getattr(node.func, 'attrname', None) in ['get', 'set']:
|
||||||
self._check_config(node)
|
self._check_config(node)
|
||||||
|
|
||||||
def _check_config(self, node):
|
def _check_config(self, node):
|
||||||
|
@ -42,7 +42,7 @@ class OpenEncodingChecker(checkers.BaseChecker):
|
|||||||
if hasattr(node, 'func'):
|
if hasattr(node, 'func'):
|
||||||
infer = utils.safe_infer(node.func)
|
infer = utils.safe_infer(node.func)
|
||||||
if infer and infer.root().name == '_io':
|
if infer and infer.root().name == '_io':
|
||||||
if getattr(node.func, 'name', None) in ('open', 'file'):
|
if getattr(node.func, 'name', None) in ['open', 'file']:
|
||||||
self._check_open_encoding(node)
|
self._check_open_encoding(node)
|
||||||
|
|
||||||
def _check_open_encoding(self, node):
|
def _check_open_encoding(self, node):
|
||||||
|
@ -44,14 +44,14 @@ def whitelist_generator():
|
|||||||
|
|
||||||
# pyPEG2 classes
|
# pyPEG2 classes
|
||||||
for name, member in inspect.getmembers(rfc6266, inspect.isclass):
|
for name, member in inspect.getmembers(rfc6266, inspect.isclass):
|
||||||
for attr in ('grammar', 'regex'):
|
for attr in ['grammar', 'regex']:
|
||||||
if hasattr(member, attr):
|
if hasattr(member, attr):
|
||||||
yield 'qutebrowser.browser.webkit.rfc6266.{}.{}'.format(name,
|
yield 'qutebrowser.browser.webkit.rfc6266.{}.{}'.format(name,
|
||||||
attr)
|
attr)
|
||||||
|
|
||||||
# PyQt properties
|
# PyQt properties
|
||||||
for attr in ('prompt_active', 'command_active', 'insert_active',
|
for attr in ['prompt_active', 'command_active', 'insert_active',
|
||||||
'caret_mode'):
|
'caret_mode']:
|
||||||
yield 'qutebrowser.mainwindow.statusbar.bar.StatusBar.' + attr
|
yield 'qutebrowser.mainwindow.statusbar.bar.StatusBar.' + attr
|
||||||
yield 'qutebrowser.mainwindow.statusbar.url.UrlText.urltype'
|
yield 'qutebrowser.mainwindow.statusbar.url.UrlText.urltype'
|
||||||
|
|
||||||
@ -89,16 +89,16 @@ def whitelist_generator():
|
|||||||
# in NetworkManager.on_authentication_required
|
# in NetworkManager.on_authentication_required
|
||||||
yield 'PyQt5.QtNetwork.QNetworkReply.netrc_used'
|
yield 'PyQt5.QtNetwork.QNetworkReply.netrc_used'
|
||||||
|
|
||||||
for attr in ('fileno', 'truncate', 'closed', 'readable'):
|
for attr in ['fileno', 'truncate', 'closed', 'readable']:
|
||||||
yield 'qutebrowser.utils.qtutils.PyQIODevice.' + attr
|
yield 'qutebrowser.utils.qtutils.PyQIODevice.' + attr
|
||||||
|
|
||||||
for attr in ('priority', 'visit_call'):
|
for attr in ['priority', 'visit_call']:
|
||||||
yield 'scripts.dev.pylint_checkers.config.' + attr
|
yield 'scripts.dev.pylint_checkers.config.' + attr
|
||||||
|
|
||||||
yield 'scripts.dev.pylint_checkers.modeline.process_module'
|
yield 'scripts.dev.pylint_checkers.modeline.process_module'
|
||||||
|
|
||||||
for attr in ('_get_default_metavar_for_optional',
|
for attr in ['_get_default_metavar_for_optional',
|
||||||
'_get_default_metavar_for_positional', '_metavar_formatter'):
|
'_get_default_metavar_for_positional', '_metavar_formatter']:
|
||||||
yield 'scripts.dev.src2asciidoc.UsageFormatter.' + attr
|
yield 'scripts.dev.src2asciidoc.UsageFormatter.' + attr
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class TestStandardDir:
|
|||||||
def test_linux_normal(self, monkeypatch, tmpdir, func, subdirs):
|
def test_linux_normal(self, monkeypatch, tmpdir, func, subdirs):
|
||||||
"""Test dirs with XDG_*_HOME not set."""
|
"""Test dirs with XDG_*_HOME not set."""
|
||||||
monkeypatch.setenv('HOME', str(tmpdir))
|
monkeypatch.setenv('HOME', str(tmpdir))
|
||||||
for var in ('DATA', 'CONFIG', 'CACHE'):
|
for var in ['DATA', 'CONFIG', 'CACHE']:
|
||||||
monkeypatch.delenv('XDG_{}_HOME'.format(var), raising=False)
|
monkeypatch.delenv('XDG_{}_HOME'.format(var), raising=False)
|
||||||
assert func() == str(tmpdir.join(*subdirs))
|
assert func() == str(tmpdir.join(*subdirs))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user