Commit Graph

15316 Commits

Author SHA1 Message Date
Florian Bruhin
910bbc8521 Refactor keyutils._parse_keystring 2018-03-04 20:40:05 +01:00
Florian Bruhin
c9c0bc0bbd Update docs 2018-03-04 20:28:46 +01:00
Florian Bruhin
d8bfe23c0d Fix lint 2018-03-04 20:21:58 +01:00
Florian Bruhin
58b7599152 Remove old fixme 2018-03-04 20:21:58 +01:00
Florian Bruhin
f85e69ec77 Refactor other keyinput tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
2be7db29ed 100% coverage for keyinput.keyutils 2018-03-04 20:21:58 +01:00
Florian Bruhin
8da878c77c Make KeySequence.matchs() work correctly 2018-03-04 20:21:58 +01:00
Florian Bruhin
866c758660 Add more KeySequence tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
68db8d04ad KeySequence: Make sure we got valid key codes 2018-03-04 20:21:58 +01:00
Florian Bruhin
3649a36869 KeySequence: Add __le__/__ge__ 2018-03-04 20:21:58 +01:00
Florian Bruhin
fb7c75a090 Improve keyutils tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
3c9e8ff9ab Test and fix keyutils._parse_keystring 2018-03-04 20:21:58 +01:00
Florian Bruhin
7f8508a367 Change the way Space keybindings are handled
Using it as " " in a keystring won't work anymore, but instead <Space> and
<Shift-Space> does.
2018-03-04 20:21:58 +01:00
Florian Bruhin
da60d11b24 Refactor keyutils tests 2018-03-04 20:21:58 +01:00
Florian Bruhin
b3834835ed Bring back keyutils.is_modifier() and modifier handling
Turns out when we press yY, we get three events:

Qt.Key_Y, Qt.NoModifier
Qt.Key_Shift, Qt.ShiftModifier
Qt.Key_Y, Qt.ShiftModifier

If we don't ignore the second one, our keychain will be interrupted by the Shift
keypress.
2018-03-04 20:21:58 +01:00
Florian Bruhin
e306e2dadb Improve and fix test_is_printable 2018-03-04 20:21:58 +01:00
Fritz Reichwald
d9a88e139c Test for modifiers and corner case 0xFF 2018-03-04 20:21:58 +01:00
Florian Bruhin
3a11a24be0 Fix modifier handling
We don't want to show <Shift-Shift>, but <Ctrl-Shift> should still work
correctly.
2018-03-04 20:21:58 +01:00
Florian Bruhin
7cb781cc92 Simplify handling of modifier-only keys
Now that we don't rely on str(KeyInfo) being empty anywhere, there's no reason
to return an empty string for only-modifier keypresses anymore.

While those keys can't be bound (QKeySequence('Shift') == Qt.Key_unknown)
there's also no reason to explicitly ignore them.
2018-03-04 20:21:57 +01:00
Florian Bruhin
693178c8ee Refactor KeyInfo.__str__
This removes the special handling for macOS, but this is hopefully not needed
anymore as we don't compare strings.
2018-03-04 20:21:57 +01:00
Florian Bruhin
af6e5b1838 Fix lint 2018-03-04 20:21:57 +01:00
Florian Bruhin
fac8d72d8c Capitalize Escape in TestFullscreenNotification 2018-03-04 20:21:57 +01:00
Florian Bruhin
a57fc5c746 Refactor keyutils tests involving all keys 2018-03-04 20:21:57 +01:00
Florian Bruhin
50d2ef3b90 Fix handling of printable control keys in KeyInfo.text() 2018-03-04 20:21:57 +01:00
Florian Bruhin
4223e2f85d Check all keys against QTest::keyToAscii 2018-03-04 20:21:57 +01:00
Fritz Reichwald
d28c323074 Add printable and ismodifier test 2018-03-04 20:21:57 +01:00
Florian Bruhin
934d586286 Fix handling of Shift-Tab aka. Backtab 2018-03-04 20:21:57 +01:00
Florian Bruhin
65a05f334e Fix KeyInfo.__str__ for <Shift-Tab> 2018-03-04 20:21:57 +01:00
Florian Bruhin
4e505d52df Regenerate docs 2018-03-04 20:21:57 +01:00
Florian Bruhin
0aa17bfa33 Simplify unicodedata.category calls 2018-03-04 20:21:57 +01:00
Florian Bruhin
63e05e12ba Fix lint and tests 2018-03-04 20:21:57 +01:00
Florian Bruhin
e26eaaddc2 Add keyutils.is_modifier_key() 2018-03-04 20:21:57 +01:00
Florian Bruhin
1cd86d79d9 Add keyutils.is_printable() 2018-03-04 20:21:57 +01:00
Florian Bruhin
b4d232badd Simplify KeyInfo.text() 2018-03-04 20:20:31 +01:00
Florian Bruhin
2ca15d7667 Add tests for lower-/uppercase text 2018-03-04 20:20:31 +01:00
Florian Bruhin
8c87040cb6 Improve IDs for qt_key fixture 2018-03-04 20:20:31 +01:00
Florian Bruhin
0b6d2c2b0a Make all key names work 2018-03-04 20:20:30 +01:00
Florian Bruhin
601e56d2fa Make test_keyutils work 2018-03-04 20:20:30 +01:00
Florian Bruhin
8f479407a0 key_data: Update key names to reflect reality
Generated by:

import key_data
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QKeySequence

for key in key_data.KEYS:
    attr = key.attribute
    member = getattr(Qt, 'Key_' + attr, None)
    if member is None:
        continue
    name = QKeySequence(member).toString()
    if name != attr:
        try:
            print("    Key('{}', '{}')".format(attr, name))
        except UnicodeEncodeError:
            print("    Key('{}', '{}')  # FIXME".format(attr, name.encode('unicode-escape').decode('ascii')))
    else:
        print()
2018-03-04 20:20:30 +01:00
Florian Bruhin
f714be0ff7 Initial tests on all Qt keys 2018-03-04 20:20:30 +01:00
Florian Bruhin
19512e988b Expose less from keyutils publicly 2018-03-04 20:20:30 +01:00
Florian Bruhin
880da2d143 Add missing default=True for configmodel.bind 2018-03-04 20:20:30 +01:00
Florian Bruhin
2ed480b40a Refactor configmodel.bind 2018-03-04 20:20:30 +01:00
Florian Bruhin
fdc2458657 Fix test_split_count after _handle_key merge 2018-03-04 20:20:30 +01:00
Florian Bruhin
c3485821c7 Adjust copyright 2018-03-04 20:20:30 +01:00
Florian Bruhin
77e0b8983c Point to Debian repos for .deb downloads
[ci skip]
Fixes #3669
2018-03-04 18:51:16 +01:00
Jimmy
6d415b6653 Greasemonkey: don't inject JS into dead frames
Hopefully closes #3627

This feels like fixing the symptom instead of the problem but I am not
sure how such a situation would arise. Never the less, the crash logs
clearly show that `_inject_userjs()` is being called with a deleted
frame sometimes. It is being called from a closure that gets triggered
on frame.loadFinished so I am not sure how frame could be deleted at
that time unless:
* the error message is misleading and it is actually some reference to
  the object that is no longer valid
* the frame gets deleted from some other handler of loadFinished.
2018-03-03 15:10:44 +13:00
Jimmy
0adda22d3c Greasemonkey: add a way to register scripts directly.
Previously to add a greasemonkey script you had to write it to the
greasemonkey data directory and call load_scripts(). Now you can just
make a new GreasemonkeyScript and pass it to add_script(), yay.

There are no users of the method yet although I could have used it while
writing the tests.
2018-03-03 15:02:43 +13:00
Jimmy
7dab8335e2 Greasemonkey: handle downloads that complete fast
When `@require`ing local files (with the `file://` scheme) the
greasemonkey manager was not catching the DownloadItem.finished signal
because it was being emitted before it had managed to connect.

I didn't see this happening while testing with files that should have
been in cache but I wouldn't be surprised.

I had to change the download mock to be able to give it the appearance
of asynchronicity. Now when using it one must set download.successful
appropriately before firing download.finished. I also added a list of
downloads to the stub so a test could enumerate them in case the
unit-under-test didn't have a reference to them.
2018-03-03 15:02:43 +13:00
Jimmy
87a0c2a7a7 Greasemonkey: indent source of required scripts
This is for the case where a script uses `@require` to pull down another
greasemonkey script. Since QWebEngineScript doesn't support `@require`
we pass scripts to it with any required ones pre-pended. To avoid
QWebEngineScript parsing the first metadata block, the one from the
required script, we indent the whole lot. Because the greasemonkey spec
says that the //==UserScript== text must start in the first column.
2018-03-03 15:02:42 +13:00