From 9ff3f6810ae3238e791f15cdf765eaffae0b6b9b Mon Sep 17 00:00:00 2001 From: knaggita Date: Thu, 8 Sep 2016 08:22:58 +0300 Subject: [PATCH 1/3] Remove --qt-* arguments --- qutebrowser/qutebrowser.py | 24 ++++-------------------- qutebrowser/utils/qtutils.py | 16 +++++----------- tests/unit/utils/test_qtutils.py | 8 +++++--- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 51e01d47c..46eed65c4 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -112,26 +112,10 @@ def get_argparser(): "temporary basedir.") debug.add_argument('--no-err-windows', action='store_true', help="Don't " "show any error windows (used for tests/smoke.py).") - # For the Qt args, we use store_const with const=True rather than - # store_true because we want the default to be None, to make - # utils.qt:get_args easier. - debug.add_argument('--qt-name', help="Set the window name.", - metavar='NAME') - debug.add_argument('--qt-style', help="Set the Qt GUI style to use.", - metavar='STYLE') - debug.add_argument('--qt-stylesheet', help="Override the Qt application " - "stylesheet.", metavar='STYLESHEET') - debug.add_argument('--qt-widgetcount', help="Print debug message at the " - "end about number of widgets left undestroyed and " - "maximum number of widgets existed at the same time.", - action='store_const', const=True) - debug.add_argument('--qt-reverse', help="Set the application's layout " - "direction to right-to-left.", action='store_const', - const=True) - debug.add_argument('--qt-qmljsdebugger', help="Activate the QML/JS " - "debugger with a specified port. 'block' is optional " - "and will make the application wait until a debugger " - "connects to it.", metavar='port:PORT[,block]') + debug.add_argument('--qt-arg', help="Pass an argument with a value to Qt.", + nargs=2) + debug.add_argument('--qt-flag', help="Pass a argument to Qt as flag.", + nargs=1) parser.add_argument('command', nargs='*', help="Commands to execute on " "startup.", metavar=':command') # URLs will actually be in command diff --git a/qutebrowser/utils/qtutils.py b/qutebrowser/utils/qtutils.py index 841fc714a..f8509ae96 100644 --- a/qutebrowser/utils/qtutils.py +++ b/qutebrowser/utils/qtutils.py @@ -129,17 +129,11 @@ def get_args(namespace): The argv list to be passed to Qt. """ argv = [sys.argv[0]] - for argname, val in vars(namespace).items(): - if not argname.startswith('qt_'): - continue - elif val is None: - # flag/argument not given - continue - elif val is True: - argv.append('-' + argname[3:]) - else: - argv.append('-' + argname[3:]) - argv.append(val) + if namespace.qt_flag is not None: + argv.append('-' + namespace.qt_flag[0]) + if namespace.qt_arg is not None: + argv.append('-' + namespace.qt_arg[0]) + argv.append(namespace.qt_arg[1]) return argv diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index 6b3a8645e..fed0564ba 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -108,9 +108,10 @@ class TestGetQtArgs: # No Qt arguments (['--debug'], [sys.argv[0]]), # Qt flag - (['--debug', '--qt-reverse', '--nocolor'], [sys.argv[0], '-reverse']), + (['--debug', '--qt-flag', 'reverse'], [sys.argv[0], '-reverse']), # Qt argument with value - (['--qt-stylesheet', 'foo'], [sys.argv[0], '-stylesheet', 'foo']), + (['--qt-arg', 'stylesheet', 'foo'], + [sys.argv[0], '-stylesheet', 'foo']), ]) def test_qt_args(self, args, expected, parser): """Test commandline with no Qt arguments given.""" @@ -119,7 +120,8 @@ class TestGetQtArgs: def test_qt_both(self, parser): """Test commandline with a Qt argument and flag.""" - args = parser.parse_args(['--qt-stylesheet', 'foobar', '--qt-reverse']) + 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 From 864ec94cdea70f4969ff3ea0c85e67ce6dddcc4c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Sep 2016 17:56:58 +0200 Subject: [PATCH 2/3] Fix lint --- qutebrowser/qutebrowser.py | 2 +- tests/unit/utils/test_qtutils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 46eed65c4..5a6d7e259 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -114,7 +114,7 @@ def get_argparser(): "show any error windows (used for tests/smoke.py).") debug.add_argument('--qt-arg', help="Pass an argument with a value to Qt.", nargs=2) - debug.add_argument('--qt-flag', help="Pass a argument to Qt as flag.", + debug.add_argument('--qt-flag', help="Pass an argument to Qt as flag.", nargs=1) parser.add_argument('command', nargs='*', help="Commands to execute on " "startup.", metavar=':command') diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py index fed0564ba..b3d3dd2dc 100644 --- a/tests/unit/utils/test_qtutils.py +++ b/tests/unit/utils/test_qtutils.py @@ -111,7 +111,7 @@ class TestGetQtArgs: (['--debug', '--qt-flag', 'reverse'], [sys.argv[0], '-reverse']), # Qt argument with value (['--qt-arg', 'stylesheet', 'foo'], - [sys.argv[0], '-stylesheet', 'foo']), + [sys.argv[0], '-stylesheet', 'foo']), ]) def test_qt_args(self, args, expected, parser): """Test commandline with no Qt arguments given.""" @@ -120,8 +120,8 @@ class TestGetQtArgs: 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']) + 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 From 984e1cf3c574ad6eb22f3d36a9f79c934850888b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Sep 2016 17:58:35 +0200 Subject: [PATCH 3/3] Update docs --- CHANGELOG.asciidoc | 4 ++++ README.asciidoc | 2 +- doc/qutebrowser.1.asciidoc | 20 ++++---------------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index efb85c0d1..6c40f68bb 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -114,6 +114,8 @@ Changed - `:prompt-accept` now optionally accepts a value which overrides the one entered in the input box. `yes` and `no` can be used as values for yes/no questions. +- The new `--qt-arg` and `--qt-flag` arguments can be used to pass + arguments/flags to Qt's commandline. Deprecated ~~~~~~~~~~ @@ -137,6 +139,8 @@ Removed - The `hints -> opacity` setting - see the "Changed" section for details. - The `completion -> auto-open` setting got merged into `completion -> show` and thus removed. +- All `--qt-*` arguments got replaced by `--qt-arg` and `--qt-flag` and thus + removed. Fixed ~~~~~ diff --git a/README.asciidoc b/README.asciidoc index 53796e412..049e23306 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -175,9 +175,9 @@ Contributors, sorted by the number of commits in descending order: * John ShaggyTwoDope Jenkins * Peter Vilim * Clayton Craft +* knaggita * Oliver Caldwell * Julian Weigt -* knaggita * Jonas Schürmann * error800 * Michael Hoang diff --git a/doc/qutebrowser.1.asciidoc b/doc/qutebrowser.1.asciidoc index 7fa6198c6..1da675498 100644 --- a/doc/qutebrowser.1.asciidoc +++ b/doc/qutebrowser.1.asciidoc @@ -111,23 +111,11 @@ show it. *--no-err-windows*:: Don't show any error windows (used for tests/smoke.py). -*--qt-name* 'NAME':: - Set the window name. +*--qt-arg* 'QT_ARG':: + Pass an argument with a value to Qt. -*--qt-style* 'STYLE':: - Set the Qt GUI style to use. - -*--qt-stylesheet* 'STYLESHEET':: - Override the Qt application stylesheet. - -*--qt-widgetcount*:: - Print debug message at the end about number of widgets left undestroyed and maximum number of widgets existed at the same time. - -*--qt-reverse*:: - Set the application's layout direction to right-to-left. - -*--qt-qmljsdebugger* 'port:PORT[,block]':: - Activate the QML/JS debugger with a specified port. 'block' is optional and will make the application wait until a debugger connects to it. +*--qt-flag* 'QT_FLAG':: + Pass an argument to Qt as flag. // QUTE_OPTIONS_END == FILES