pyqt6: More keyboard modifiers nonsense and another py310 float->int

This commit is contained in:
Kovid Goyal 2022-01-03 08:52:52 +05:30
parent 749d0351e8
commit cfb011c3ff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 3 deletions

View File

@ -405,7 +405,7 @@ class NotesDisplay(Details):
self.setHtml('<div><a href="edit://moo">{}</a></div>{}'.format(_('Edit notes'), html)) self.setHtml('<div><a href="edit://moo">{}</a></div>{}'.format(_('Edit notes'), html))
self.document().setDefaultStyleSheet('a[href] { text-decoration: none }') self.document().setDefaultStyleSheet('a[href] { text-decoration: none }')
h = self.document().size().height() + 2 h = self.document().size().height() + 2
self.setMaximumHeight(h) self.setMaximumHeight(int(h))
def anchor_clicked(self, qurl): def anchor_clicked(self, qurl):
if qurl.scheme() == 'edit': if qurl.scheme() == 'edit':

View File

@ -41,8 +41,10 @@ def key_to_text(key):
def ev_to_index(ev): def ev_to_index(ev):
m = ev.modifiers() m = ev.modifiers()
mods = [] mods = []
for x in ('ALT', 'CTRL', 'META', 'SHIFT'): for x in (
mods.append('y' if m & getattr(Qt, x) else 'n') Qt.KeyboardModifier.AltModifier, Qt.KeyboardModifier.ControlModifier,
Qt.KeyboardModifier.MetaModifier, Qt.KeyboardModifier.ShiftModifier):
mods.append('y' if m & x else 'n')
return ''.join(mods) + key_to_text(ev.key()) return ''.join(mods) + key_to_text(ev.key())