parent
34042522f1
commit
fe05947b54
@ -208,6 +208,7 @@
|
|||||||
|<<new_instance_open_target_window,new_instance_open_target_window>>|Which window to choose when opening links as new tabs.
|
|<<new_instance_open_target_window,new_instance_open_target_window>>|Which window to choose when opening links as new tabs.
|
||||||
|<<prompt.filebrowser,prompt.filebrowser>>|Show a filebrowser in upload/download prompts.
|
|<<prompt.filebrowser,prompt.filebrowser>>|Show a filebrowser in upload/download prompts.
|
||||||
|<<prompt.radius,prompt.radius>>|The rounding radius for the edges of prompts.
|
|<<prompt.radius,prompt.radius>>|The rounding radius for the edges of prompts.
|
||||||
|
|<<qt_args,qt_args>>|Additional arguments to pass to Qt, without leading `--`.
|
||||||
|<<scrolling.bar,scrolling.bar>>|Show a scrollbar.
|
|<<scrolling.bar,scrolling.bar>>|Show a scrollbar.
|
||||||
|<<scrolling.smooth,scrolling.smooth>>|Enable smooth scrolling for web pages.
|
|<<scrolling.smooth,scrolling.smooth>>|Enable smooth scrolling for web pages.
|
||||||
|<<session_default_name,session_default_name>>|The name of the session to save by default.
|
|<<session_default_name,session_default_name>>|The name of the session to save by default.
|
||||||
@ -2604,6 +2605,15 @@ Type: <<types,Int>>
|
|||||||
|
|
||||||
Default: +pass:[8]+
|
Default: +pass:[8]+
|
||||||
|
|
||||||
|
[[qt_args]]
|
||||||
|
=== qt_args
|
||||||
|
Additional arguments to pass to Qt, without leading `--`.
|
||||||
|
With QtWebEngine, some Chromium arguments (see https://peter.sh/experiments/chromium-command-line-switches/ for a list) will work.
|
||||||
|
|
||||||
|
Type: <<types,List>>
|
||||||
|
|
||||||
|
Default: empty
|
||||||
|
|
||||||
[[scrolling.bar]]
|
[[scrolling.bar]]
|
||||||
=== scrolling.bar
|
=== scrolling.bar
|
||||||
Show a scrollbar.
|
Show a scrollbar.
|
||||||
|
@ -770,7 +770,7 @@ class Application(QApplication):
|
|||||||
"""
|
"""
|
||||||
self._last_focus_object = None
|
self._last_focus_object = None
|
||||||
|
|
||||||
qt_args = qtutils.get_args(args)
|
qt_args = config.qt_args(args)
|
||||||
log.init.debug("Qt arguments: {}, based on {}".format(qt_args, args))
|
log.init.debug("Qt arguments: {}, based on {}".format(qt_args, args))
|
||||||
super().__init__(qt_args)
|
super().__init__(qt_args)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"""Configuration storage and config-related utilities."""
|
"""Configuration storage and config-related utilities."""
|
||||||
|
|
||||||
|
import sys
|
||||||
import copy
|
import copy
|
||||||
import contextlib
|
import contextlib
|
||||||
import functools
|
import functools
|
||||||
@ -704,3 +705,25 @@ def late_init(save_manager):
|
|||||||
|
|
||||||
instance.init_save_manager(save_manager)
|
instance.init_save_manager(save_manager)
|
||||||
configfiles.state.init_save_manager(save_manager)
|
configfiles.state.init_save_manager(save_manager)
|
||||||
|
|
||||||
|
|
||||||
|
def qt_args(namespace):
|
||||||
|
"""Get the Qt QApplication arguments based on an argparse namespace.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
namespace: The argparse namespace.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
The argv list to be passed to Qt.
|
||||||
|
"""
|
||||||
|
argv = [sys.argv[0]]
|
||||||
|
|
||||||
|
if namespace.qt_flag is not None:
|
||||||
|
argv += ['--' + flag[0] for flag in namespace.qt_flag]
|
||||||
|
|
||||||
|
if namespace.qt_arg is not None:
|
||||||
|
for name, value in namespace.qt_arg:
|
||||||
|
argv += ['--' + name, value]
|
||||||
|
|
||||||
|
argv += ['--' + arg for arg in val.qt_args]
|
||||||
|
return argv
|
||||||
|
@ -85,6 +85,19 @@ session_default_name:
|
|||||||
|
|
||||||
If this is set to null, the session which was last loaded is saved.
|
If this is set to null, the session which was last loaded is saved.
|
||||||
|
|
||||||
|
qt_args:
|
||||||
|
type:
|
||||||
|
name: List
|
||||||
|
valtype: String
|
||||||
|
none_ok: true
|
||||||
|
default: []
|
||||||
|
desc: >-
|
||||||
|
Additional arguments to pass to Qt, without leading `--`.
|
||||||
|
|
||||||
|
With QtWebEngine, some Chromium arguments (see
|
||||||
|
https://peter.sh/experiments/chromium-command-line-switches/ for a list)
|
||||||
|
will work.
|
||||||
|
|
||||||
## auto_save
|
## auto_save
|
||||||
|
|
||||||
auto_save.interval:
|
auto_save.interval:
|
||||||
|
@ -29,7 +29,6 @@ Module attributes:
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import operator
|
import operator
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
@ -138,27 +137,6 @@ def check_overflow(arg, ctype, fatal=True):
|
|||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
|
||||||
def get_args(namespace):
|
|
||||||
"""Get the Qt QApplication arguments based on an argparse namespace.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
namespace: The argparse namespace.
|
|
||||||
|
|
||||||
Return:
|
|
||||||
The argv list to be passed to Qt.
|
|
||||||
"""
|
|
||||||
argv = [sys.argv[0]]
|
|
||||||
|
|
||||||
if namespace.qt_flag is not None:
|
|
||||||
argv += ['--' + flag[0] for flag in namespace.qt_flag]
|
|
||||||
|
|
||||||
if namespace.qt_arg is not None:
|
|
||||||
for name, value in namespace.qt_arg:
|
|
||||||
argv += ['--' + name, value]
|
|
||||||
|
|
||||||
return argv
|
|
||||||
|
|
||||||
|
|
||||||
def check_print_compat():
|
def check_print_compat():
|
||||||
"""Check if printing should work in the given Qt version."""
|
"""Check if printing should work in the given Qt version."""
|
||||||
# WORKAROUND (remove this when we bump the requirements to 5.3.0)
|
# WORKAROUND (remove this when we bump the requirements to 5.3.0)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
"""Tests for qutebrowser.config.config."""
|
"""Tests for qutebrowser.config.config."""
|
||||||
|
|
||||||
|
import sys
|
||||||
import copy
|
import copy
|
||||||
import types
|
import types
|
||||||
import logging
|
import logging
|
||||||
@ -27,6 +28,7 @@ import pytest
|
|||||||
from PyQt5.QtCore import QObject, QUrl
|
from PyQt5.QtCore import QObject, QUrl
|
||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
|
|
||||||
|
from qutebrowser import qutebrowser
|
||||||
from qutebrowser.commands import cmdexc
|
from qutebrowser.commands import cmdexc
|
||||||
from qutebrowser.config import config, configdata, configexc, configfiles
|
from qutebrowser.config import config, configdata, configexc, configfiles
|
||||||
from qutebrowser.utils import objreg, usertypes
|
from qutebrowser.utils import objreg, usertypes
|
||||||
@ -982,3 +984,51 @@ def test_late_init(init_patch, monkeypatch, fake_save_manager, mocker, errors):
|
|||||||
assert '<b>Error text</b>: Exception' in text
|
assert '<b>Error text</b>: Exception' in text
|
||||||
else:
|
else:
|
||||||
assert not msgbox_mock.called
|
assert not msgbox_mock.called
|
||||||
|
|
||||||
|
|
||||||
|
class TestQtArgs:
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def parser(self, mocker):
|
||||||
|
"""Fixture to provide an argparser.
|
||||||
|
|
||||||
|
Monkey-patches .exit() of the argparser so it doesn't exit on errors.
|
||||||
|
"""
|
||||||
|
parser = qutebrowser.get_argparser()
|
||||||
|
mocker.patch.object(parser, 'exit', side_effect=Exception)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('args, expected', [
|
||||||
|
# No Qt arguments
|
||||||
|
(['--debug'], [sys.argv[0]]),
|
||||||
|
# Qt flag
|
||||||
|
(['--debug', '--qt-flag', 'reverse'], [sys.argv[0], '--reverse']),
|
||||||
|
# Qt argument with value
|
||||||
|
(['--qt-arg', 'stylesheet', 'foo'],
|
||||||
|
[sys.argv[0], '--stylesheet', 'foo']),
|
||||||
|
# --qt-arg given twice
|
||||||
|
(['--qt-arg', 'stylesheet', 'foo', '--qt-arg', 'geometry', 'bar'],
|
||||||
|
[sys.argv[0], '--stylesheet', 'foo', '--geometry', 'bar']),
|
||||||
|
# --qt-flag given twice
|
||||||
|
(['--qt-flag', 'foo', '--qt-flag', 'bar'],
|
||||||
|
[sys.argv[0], '--foo', '--bar']),
|
||||||
|
])
|
||||||
|
def test_qt_args(self, config_stub, args, expected, parser):
|
||||||
|
"""Test commandline with no Qt arguments given."""
|
||||||
|
parsed = parser.parse_args(args)
|
||||||
|
assert config.qt_args(parsed) == expected
|
||||||
|
|
||||||
|
def test_qt_both(self, config_stub, parser):
|
||||||
|
"""Test commandline with a Qt argument and flag."""
|
||||||
|
args = parser.parse_args(['--qt-arg', 'stylesheet', 'foobar',
|
||||||
|
'--qt-flag', 'reverse'])
|
||||||
|
qt_args = config.qt_args(args)
|
||||||
|
assert qt_args[0] == sys.argv[0]
|
||||||
|
assert '--reverse' in qt_args
|
||||||
|
assert '--stylesheet' in qt_args
|
||||||
|
assert 'foobar' in qt_args
|
||||||
|
|
||||||
|
def test_with_settings(self, config_stub, parser):
|
||||||
|
parsed = parser.parse_args(['--qt-flag', 'foo'])
|
||||||
|
config_stub.val.qt_args = ['bar']
|
||||||
|
assert config.qt_args(parsed) == [sys.argv[0], '--foo', '--bar']
|
||||||
|
@ -36,7 +36,6 @@ import pytest
|
|||||||
from PyQt5.QtCore import (QDataStream, QPoint, QUrl, QByteArray, QIODevice,
|
from PyQt5.QtCore import (QDataStream, QPoint, QUrl, QByteArray, QIODevice,
|
||||||
QTimer, QBuffer, QFile, QProcess, QFileDevice)
|
QTimer, QBuffer, QFile, QProcess, QFileDevice)
|
||||||
|
|
||||||
from qutebrowser import qutebrowser
|
|
||||||
from qutebrowser.utils import qtutils
|
from qutebrowser.utils import qtutils
|
||||||
import overflow_test_cases
|
import overflow_test_cases
|
||||||
|
|
||||||
@ -119,51 +118,6 @@ class TestCheckOverflow:
|
|||||||
assert newval == repl
|
assert newval == repl
|
||||||
|
|
||||||
|
|
||||||
class TestGetQtArgs:
|
|
||||||
|
|
||||||
"""Tests for get_args."""
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def parser(self, mocker):
|
|
||||||
"""Fixture to provide an argparser.
|
|
||||||
|
|
||||||
Monkey-patches .exit() of the argparser so it doesn't exit on errors.
|
|
||||||
"""
|
|
||||||
parser = qutebrowser.get_argparser()
|
|
||||||
mocker.patch.object(parser, 'exit', side_effect=Exception)
|
|
||||||
return parser
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('args, expected', [
|
|
||||||
# No Qt arguments
|
|
||||||
(['--debug'], [sys.argv[0]]),
|
|
||||||
# Qt flag
|
|
||||||
(['--debug', '--qt-flag', 'reverse'], [sys.argv[0], '--reverse']),
|
|
||||||
# Qt argument with value
|
|
||||||
(['--qt-arg', 'stylesheet', 'foo'],
|
|
||||||
[sys.argv[0], '--stylesheet', 'foo']),
|
|
||||||
# --qt-arg given twice
|
|
||||||
(['--qt-arg', 'stylesheet', 'foo', '--qt-arg', 'geometry', 'bar'],
|
|
||||||
[sys.argv[0], '--stylesheet', 'foo', '--geometry', 'bar']),
|
|
||||||
# --qt-flag given twice
|
|
||||||
(['--qt-flag', 'foo', '--qt-flag', 'bar'],
|
|
||||||
[sys.argv[0], '--foo', '--bar']),
|
|
||||||
])
|
|
||||||
def test_qt_args(self, args, expected, parser):
|
|
||||||
"""Test commandline with no Qt arguments given."""
|
|
||||||
parsed = parser.parse_args(args)
|
|
||||||
assert qtutils.get_args(parsed) == expected
|
|
||||||
|
|
||||||
def test_qt_both(self, parser):
|
|
||||||
"""Test commandline with a Qt argument and flag."""
|
|
||||||
args = parser.parse_args(['--qt-arg', 'stylesheet', 'foobar',
|
|
||||||
'--qt-flag', 'reverse'])
|
|
||||||
qt_args = qtutils.get_args(args)
|
|
||||||
assert qt_args[0] == sys.argv[0]
|
|
||||||
assert '--reverse' in qt_args
|
|
||||||
assert '--stylesheet' in qt_args
|
|
||||||
assert 'foobar' in qt_args
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('os_name, qversion, expected', [
|
@pytest.mark.parametrize('os_name, qversion, expected', [
|
||||||
('linux', '5.2.1', True), # unaffected OS
|
('linux', '5.2.1', True), # unaffected OS
|
||||||
('linux', '5.4.1', True), # unaffected OS
|
('linux', '5.4.1', True), # unaffected OS
|
||||||
|
Loading…
Reference in New Issue
Block a user