Remove --qt-* arguments

This commit is contained in:
knaggita 2016-09-08 08:22:58 +03:00 committed by Florian Bruhin
parent f75f45addc
commit 9ff3f6810a
3 changed files with 14 additions and 34 deletions

View File

@ -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

View File

@ -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

View File

@ -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