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 - `: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 entered in the input box. `yes` and `no` can be used as values for yes/no
questions. questions.
- The new `--qt-arg` and `--qt-flag` arguments can be used to pass
arguments/flags to Qt's commandline.
Deprecated Deprecated
~~~~~~~~~~ ~~~~~~~~~~
@ -137,6 +139,8 @@ Removed
- The `hints -> opacity` setting - see the "Changed" section for details. - The `hints -> opacity` setting - see the "Changed" section for details.
- The `completion -> auto-open` setting got merged into `completion -> show` and - The `completion -> auto-open` setting got merged into `completion -> show` and
thus removed. thus removed.
- All `--qt-*` arguments got replaced by `--qt-arg` and `--qt-flag` and thus
removed.
Fixed Fixed
~~~~~ ~~~~~

View File

@ -175,9 +175,9 @@ Contributors, sorted by the number of commits in descending order:
* John ShaggyTwoDope Jenkins * John ShaggyTwoDope Jenkins
* Peter Vilim * Peter Vilim
* Clayton Craft * Clayton Craft
* knaggita
* Oliver Caldwell * Oliver Caldwell
* Julian Weigt * Julian Weigt
* knaggita
* Jonas Schürmann * Jonas Schürmann
* error800 * error800
* Michael Hoang * Michael Hoang

View File

@ -111,23 +111,11 @@ show it.
*--no-err-windows*:: *--no-err-windows*::
Don't show any error windows (used for tests/smoke.py). Don't show any error windows (used for tests/smoke.py).
*--qt-name* 'NAME':: *--qt-arg* 'QT_ARG'::
Set the window name. Pass an argument with a value to Qt.
*--qt-style* 'STYLE':: *--qt-flag* 'QT_FLAG'::
Set the Qt GUI style to use. Pass an argument to Qt as flag.
*--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.
// QUTE_OPTIONS_END // QUTE_OPTIONS_END
== FILES == FILES

View File

@ -112,26 +112,10 @@ def get_argparser():
"temporary basedir.") "temporary basedir.")
debug.add_argument('--no-err-windows', action='store_true', help="Don't " debug.add_argument('--no-err-windows', action='store_true', help="Don't "
"show any error windows (used for tests/smoke.py).") "show any error windows (used for tests/smoke.py).")
# For the Qt args, we use store_const with const=True rather than debug.add_argument('--qt-arg', help="Pass an argument with a value to Qt.",
# store_true because we want the default to be None, to make nargs=2)
# utils.qt:get_args easier. debug.add_argument('--qt-flag', help="Pass an argument to Qt as flag.",
debug.add_argument('--qt-name', help="Set the window name.", nargs=1)
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]')
parser.add_argument('command', nargs='*', help="Commands to execute on " parser.add_argument('command', nargs='*', help="Commands to execute on "
"startup.", metavar=':command') "startup.", metavar=':command')
# URLs will actually be in 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. The argv list to be passed to Qt.
""" """
argv = [sys.argv[0]] argv = [sys.argv[0]]
for argname, val in vars(namespace).items(): if namespace.qt_flag is not None:
if not argname.startswith('qt_'): argv.append('-' + namespace.qt_flag[0])
continue if namespace.qt_arg is not None:
elif val is None: argv.append('-' + namespace.qt_arg[0])
# flag/argument not given argv.append(namespace.qt_arg[1])
continue
elif val is True:
argv.append('-' + argname[3:])
else:
argv.append('-' + argname[3:])
argv.append(val)
return argv return argv

View File

@ -108,9 +108,10 @@ class TestGetQtArgs:
# No Qt arguments # No Qt arguments
(['--debug'], [sys.argv[0]]), (['--debug'], [sys.argv[0]]),
# Qt flag # Qt flag
(['--debug', '--qt-reverse', '--nocolor'], [sys.argv[0], '-reverse']), (['--debug', '--qt-flag', 'reverse'], [sys.argv[0], '-reverse']),
# Qt argument with value # 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): def test_qt_args(self, args, expected, parser):
"""Test commandline with no Qt arguments given.""" """Test commandline with no Qt arguments given."""
@ -119,7 +120,8 @@ class TestGetQtArgs:
def test_qt_both(self, parser): def test_qt_both(self, parser):
"""Test commandline with a Qt argument and flag.""" """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) qt_args = qtutils.get_args(args)
assert qt_args[0] == sys.argv[0] assert qt_args[0] == sys.argv[0]
assert '-reverse' in qt_args assert '-reverse' in qt_args