mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More stupid PyQt enums
This commit is contained in:
parent
7709deb8d5
commit
252431b903
@ -379,7 +379,7 @@ if ismacos:
|
||||
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)
|
||||
|
@ -303,7 +303,7 @@ class ConfigModel(SearchQueryParser, QAbstractItemModel):
|
||||
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 @@ class Editor(QFrame): # {{{
|
||||
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 @@ class Editor(QFrame): # {{{
|
||||
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 @@ class Delegate(QStyledItemDelegate): # {{{
|
||||
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:
|
||||
|
@ -7,7 +7,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
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_menu(menu):
|
||||
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
|
||||
|
@ -170,7 +170,7 @@ class Delegate(QStyledItemDelegate):
|
||||
|
||||
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 @@ class Delegate(QStyledItemDelegate):
|
||||
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 @@ class Shortcuts(QAbstractListModel):
|
||||
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):
|
||||
|
@ -11,7 +11,7 @@ from PyQt5.Qt import (QIcon, QFont, QLabel, QListWidget, QAction, QEvent,
|
||||
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 @@ class LayoutButton(QToolButton):
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user