mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix shortcut editing widget when Qt is using a theme that inserts accelerators into push button labels automatically
This commit is contained in:
parent
30decaadeb
commit
de55056f20
@ -447,6 +447,7 @@ class Editor(QFrame): # {{{
|
|||||||
l.addWidget(la, off+which, 0, 1, 3)
|
l.addWidget(la, off+which, 0, 1, 3)
|
||||||
setattr(self, 'label%d'%which, la)
|
setattr(self, 'label%d'%which, la)
|
||||||
button = QPushButton(_('None'), self)
|
button = QPushButton(_('None'), self)
|
||||||
|
button.setObjectName(_('None'))
|
||||||
button.clicked.connect(partial(self.capture_clicked, which=which))
|
button.clicked.connect(partial(self.capture_clicked, which=which))
|
||||||
button.installEventFilter(self)
|
button.installEventFilter(self)
|
||||||
setattr(self, 'button%d'%which, button)
|
setattr(self, 'button%d'%which, button)
|
||||||
@ -491,7 +492,9 @@ class Editor(QFrame): # {{{
|
|||||||
self.use_custom.setChecked(True)
|
self.use_custom.setChecked(True)
|
||||||
for key, which in zip(self.current_keys, [1,2]):
|
for key, which in zip(self.current_keys, [1,2]):
|
||||||
button = getattr(self, 'button%d'%which)
|
button = getattr(self, 'button%d'%which)
|
||||||
button.setText(key.toString(QKeySequence.SequenceFormat.NativeText))
|
ns = key.toString(QKeySequence.SequenceFormat.NativeText)
|
||||||
|
button.setText(ns.replace('&', '&&'))
|
||||||
|
button.setObjectName(ns)
|
||||||
|
|
||||||
def custom_toggled(self, checked):
|
def custom_toggled(self, checked):
|
||||||
for w in ('1', '2'):
|
for w in ('1', '2'):
|
||||||
@ -508,6 +511,7 @@ class Editor(QFrame): # {{{
|
|||||||
def clear_clicked(self, which=0):
|
def clear_clicked(self, which=0):
|
||||||
button = getattr(self, 'button%d'%which)
|
button = getattr(self, 'button%d'%which)
|
||||||
button.setText(_('None'))
|
button.setText(_('None'))
|
||||||
|
button.setObjectName(_('None'))
|
||||||
|
|
||||||
def eventFilter(self, obj, event):
|
def eventFilter(self, obj, event):
|
||||||
if self.capture and obj in (self.button1, self.button2):
|
if self.capture and obj in (self.button1, self.button2):
|
||||||
@ -530,7 +534,9 @@ class Editor(QFrame): # {{{
|
|||||||
|
|
||||||
button = getattr(self, 'button%d'%which)
|
button = getattr(self, 'button%d'%which)
|
||||||
button.setStyleSheet('QPushButton { font-weight: normal}')
|
button.setStyleSheet('QPushButton { font-weight: normal}')
|
||||||
button.setText(sequence.toString(QKeySequence.SequenceFormat.NativeText))
|
ns = sequence.toString(QKeySequence.SequenceFormat.NativeText)
|
||||||
|
button.setText(ns.replace('&', '&&'))
|
||||||
|
button.setObjectName(ns)
|
||||||
self.capture = 0
|
self.capture = 0
|
||||||
dup_desc = self.dup_check(sequence)
|
dup_desc = self.dup_check(sequence)
|
||||||
if dup_desc is not None:
|
if dup_desc is not None:
|
||||||
@ -554,8 +560,8 @@ class Editor(QFrame): # {{{
|
|||||||
ans = []
|
ans = []
|
||||||
for which in (1, 2):
|
for which in (1, 2):
|
||||||
button = getattr(self, 'button%d'%which)
|
button = getattr(self, 'button%d'%which)
|
||||||
t = str(button.text())
|
t = button.objectName()
|
||||||
if t == _('None'):
|
if not t or t == _('None'):
|
||||||
continue
|
continue
|
||||||
ks = QKeySequence(t, QKeySequence.SequenceFormat.NativeText)
|
ks = QKeySequence(t, QKeySequence.SequenceFormat.NativeText)
|
||||||
if not ks.isEmpty():
|
if not ks.isEmpty():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user