Merge branch 'knaggita-issue1703'

This commit is contained in:
Florian Bruhin 2016-09-09 17:58:59 +02:00
commit 0053548036
6 changed files with 23 additions and 51 deletions

View File

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

View File

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

View File

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

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