More stupid PyQt enums

This commit is contained in:
Kovid Goyal 2020-12-20 12:12:49 +05:30
parent 7709deb8d5
commit 252431b903
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
5 changed files with 13 additions and 13 deletions

View file

@ -379,7 +379,7 @@ def clone_changed(self):
if self.clone_shortcuts:
sc = self.clone.shortcut()
if sc and not sc.isEmpty():
self.setText(self.text() + '\t' + sc.toString(sc.NativeText))
self.setText(self.text() + '\t' + sc.toString(QKeySequence.SequenceFormat.NativeText))
if self.clone.menu() is None:
if not self.is_top_level:
self.setMenu(None)

View file

@ -303,7 +303,7 @@ def commit(self):
if sc['persist_shortcut']:
options_map[un] = options_map.get(un, {})
options_map[un]['persist_shortcut'] = sc['persist_shortcut']
keys = [unicode_type(k.toString(k.PortableText)) for k in sc['keys']]
keys = [unicode_type(k.toString(QKeySequence.SequenceFormat.PortableText)) for k in sc['keys']]
kmap[un] = keys
with self.keyboard.config:
self.keyboard.config['map'] = kmap
@ -451,11 +451,11 @@ def initialize(self, shortcut, all_shortcuts):
self.default_keys = [QKeySequence(k, QKeySequence.SequenceFormat.PortableText) for k
in shortcut['default_keys']]
self.current_keys = list(shortcut['keys'])
default = ', '.join([unicode_type(k.toString(k.NativeText)) for k in
default = ', '.join([unicode_type(k.toString(QKeySequence.SequenceFormat.NativeText)) for k in
self.default_keys])
if not default:
default = _('None')
current = ', '.join([unicode_type(k.toString(k.NativeText)) for k in
current = ', '.join([unicode_type(k.toString(QKeySequence.SequenceFormat.NativeText)) for k in
self.current_keys])
if not current:
current = _('None')
@ -469,7 +469,7 @@ def initialize(self, shortcut, all_shortcuts):
self.use_custom.setChecked(True)
for key, which in zip(self.current_keys, [1,2]):
button = getattr(self, 'button%d'%which)
button.setText(key.toString(key.NativeText))
button.setText(key.toString(QKeySequence.SequenceFormat.NativeText))
def custom_toggled(self, checked):
for w in ('1', '2'):
@ -559,7 +559,7 @@ def to_doc(self, index):
elif data.is_shortcut:
shortcut = data.data
# Shortcut
keys = [unicode_type(k.toString(k.NativeText)) for k in shortcut['keys']]
keys = [unicode_type(k.toString(QKeySequence.SequenceFormat.NativeText)) for k in shortcut['keys']]
if not keys:
keys = _('None')
else:

View file

@ -7,7 +7,7 @@
import sys, gc, weakref
from PyQt5.Qt import (QMainWindow, QTimer, QAction, QMenu, QMenuBar, QIcon,
QObject)
QObject, QKeySequence)
from calibre.utils.config import OptionParser
from calibre.gui2 import error_dialog
from calibre import prints, as_unicode, prepare_string_for_xml
@ -165,7 +165,7 @@ def clone_action(ac, parent):
ans.setSeparator(True)
return ans
sc = ac.shortcut()
sc = '' if sc.isEmpty() else sc.toString(sc.NativeText)
sc = '' if sc.isEmpty() else sc.toString(QKeySequence.SequenceFormat.NativeText)
text = ac.text()
if '\t' not in text:
text += '\t' + sc

View file

@ -170,7 +170,7 @@ def createEditor(self, parent, option, index):
def setEditorData(self, editor, index):
defs = index.data(DEFAULTS)
defs = _(' or ').join([unicode_type(x.toString(x.NativeText)) for x in defs])
defs = _(' or ').join([unicode_type(x.toString(QKeySequence.SequenceFormat.NativeText)) for x in defs])
editor.key = unicode_type(index.data(KEY))
editor.default_shortcuts.setText(_('&Default') + ': %s' % defs)
editor.default_shortcuts.setChecked(True)
@ -183,7 +183,7 @@ def setEditorData(self, editor, index):
button = getattr(editor, 'button%d'%(x+1))
if len(custom) > x:
seq = QKeySequence(custom[x])
button.setText(seq.toString(seq.NativeText))
button.setText(seq.toString(QKeySequence.SequenceFormat.NativeText))
setattr(editor, 'shortcut%d'%(x+1), seq)
def setModelData(self, editor, model, index):
@ -251,7 +251,7 @@ def duplicate_check(self, seq, ignore):
return self.descriptions[key]
def get_shortcuts(self, key):
return [unicode_type(x.toString(x.NativeText)) for x in
return [unicode_type(x.toString(QKeySequence.SequenceFormat.NativeText)) for x in
self.get_sequences(key)]
def data(self, index, role):

View file

@ -11,7 +11,7 @@
QListWidgetItem, QTextCharFormat, QApplication, QSyntaxHighlighter,
QCursor, QColor, QWidget, QPixmap, QSplitterHandle, QToolButton,
Qt, pyqtSignal, QRegExp, QSize, QSplitter, QPainter, QPageSize, QPrinter,
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel,
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel, QKeySequence,
QCompleter, QTimer, QRect, QGraphicsView, QPagedPaintDevice, QPalette)
from calibre.constants import iswindows, ismacos
@ -1009,7 +1009,7 @@ def __init__(self, icon, text, splitter=None, parent=None, shortcut=None):
def update_shortcut(self, action_toggle=None):
action_toggle = action_toggle or getattr(self, 'action_toggle', None)
if action_toggle:
sc = ', '.join(sc.toString(sc.NativeText)
sc = ', '.join(sc.toString(QKeySequence.SequenceFormat.NativeText)
for sc in action_toggle.shortcuts())
self.shortcut = sc or ''
self.update_text()