mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make the accelerator on &Show work.
I am a bit concerned about why shift-tab works differently from tab. It clearly does, but perhaps because of a bug in Qt? In any event, without the code one gets stuck in the group box.
This commit is contained in:
parent
0e9e771d1b
commit
8d3d28da09
@ -13,7 +13,7 @@ from functools import partial
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, Qt, QColor, QIcon, QVBoxLayout, QLabel, QGridLayout,
|
QDialog, Qt, QColor, QIcon, QVBoxLayout, QLabel, QGridLayout,
|
||||||
QDialogButtonBox, QWidget, QLineEdit, QHBoxLayout, QComboBox,
|
QDialogButtonBox, QWidget, QLineEdit, QHBoxLayout, QComboBox,
|
||||||
QCheckBox, QSpinBox, QRadioButton, QGroupBox
|
QCheckBox, QSpinBox, QRadioButton, QGroupBox, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
@ -22,6 +22,22 @@ from calibre.utils.date import parse_date, UNDEFINED_DATE
|
|||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
class GroupBox(QGroupBox):
|
||||||
|
# A group box for radio buttons that acts passes along focus events so the
|
||||||
|
# correct child button is given the focus
|
||||||
|
|
||||||
|
got_focus = pyqtSignal()
|
||||||
|
|
||||||
|
def focusInEvent(self, ev):
|
||||||
|
# We need this backtab focus stuff because a backtab from a radio button
|
||||||
|
# gives the focus back to the group box instead of the next widget in the
|
||||||
|
# focus chain. For some reason a tab doesn't do that.
|
||||||
|
if ev.reason() != Qt.FocusReason.BacktabFocusReason:
|
||||||
|
self.got_focus.emit()
|
||||||
|
else:
|
||||||
|
self.focusNextPrevChild(False)
|
||||||
|
|
||||||
|
|
||||||
class CreateCustomColumn(QDialog):
|
class CreateCustomColumn(QDialog):
|
||||||
|
|
||||||
# Note: in this class, we are treating is_multiple as the boolean that
|
# Note: in this class, we are treating is_multiple as the boolean that
|
||||||
@ -332,7 +348,9 @@ class CreateCustomColumn(QDialog):
|
|||||||
h1.addWidget(self.bool_show_text_button)
|
h1.addWidget(self.bool_show_text_button)
|
||||||
self.bool_show_both_button = QRadioButton(_('&Both'))
|
self.bool_show_both_button = QRadioButton(_('&Both'))
|
||||||
h1.addWidget(self.bool_show_both_button)
|
h1.addWidget(self.bool_show_both_button)
|
||||||
self.bool_button_group = QGroupBox()
|
self.bool_button_group = GroupBox()
|
||||||
|
self.bool_button_group.setFocusPolicy(Qt.StrongFocus)
|
||||||
|
self.bool_button_group.got_focus.connect(self.bool_groupbox_focused)
|
||||||
self.bool_button_group.setLayout(h1)
|
self.bool_button_group.setLayout(h1)
|
||||||
h = QHBoxLayout()
|
h = QHBoxLayout()
|
||||||
h.addWidget(self.bool_button_group)
|
h.addWidget(self.bool_button_group)
|
||||||
@ -452,6 +470,14 @@ class CreateCustomColumn(QDialog):
|
|||||||
self.resize(self.sizeHint())
|
self.resize(self.sizeHint())
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
def bool_groupbox_focused(self):
|
||||||
|
if self.bool_show_icon_button.isChecked():
|
||||||
|
self.bool_show_icon_button.setFocus()
|
||||||
|
elif self.bool_show_text_button.isChecked():
|
||||||
|
self.bool_show_text_button.setFocus()
|
||||||
|
else:
|
||||||
|
self.bool_show_both_button.setFocus()
|
||||||
|
|
||||||
def datatype_changed(self, *args):
|
def datatype_changed(self, *args):
|
||||||
try:
|
try:
|
||||||
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
col_type = self.column_types[self.column_type_box.currentIndex()]['datatype']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user