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
c857c89fbe
commit
168e58d704
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize,
|
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize, QAbstractItemView,
|
||||||
QDialogButtonBox, QTableWidget, QItemDelegate, QApplication,
|
QDialogButtonBox, QTableWidget, QItemDelegate, QApplication,
|
||||||
pyqtSignal, QAction, QFrame, QLabel, QTimer, QMenu, QColor)
|
pyqtSignal, QAction, QFrame, QLabel, QTimer, QMenu, QColor)
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
|
|||||||
ca.triggered.connect(partial(self.search_for_books, item))
|
ca.triggered.connect(partial(self.search_for_books, item))
|
||||||
if disable_copy_paste_search:
|
if disable_copy_paste_search:
|
||||||
ca.setEnabled(False)
|
ca.setEnabled(False)
|
||||||
if self.table.state() == self.table.EditingState:
|
if self.table.state() == QAbstractItemView.State.EditingState:
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
case_menu = QMenu(_('Change case'))
|
case_menu = QMenu(_('Change case'))
|
||||||
action_upper_case = case_menu.addAction(_('Upper case'))
|
action_upper_case = case_menu.addAction(_('Upper case'))
|
||||||
|
@ -10,7 +10,7 @@ from collections import OrderedDict
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, QItemSelectionModel,
|
from PyQt5.Qt import (QObject, QKeySequence, QAbstractItemModel, QModelIndex, QItemSelectionModel,
|
||||||
Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame,
|
Qt, QStyledItemDelegate, QTextDocument, QStyle, pyqtSignal, QFrame, QAbstractItemView,
|
||||||
QApplication, QSize, QRectF, QWidget, QTreeView, QHBoxLayout, QVBoxLayout,
|
QApplication, QSize, QRectF, QWidget, QTreeView, QHBoxLayout, QVBoxLayout,
|
||||||
QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon, QEvent)
|
QGridLayout, QLabel, QRadioButton, QPushButton, QToolButton, QIcon, QEvent)
|
||||||
try:
|
try:
|
||||||
@ -687,7 +687,7 @@ class ShortcutConfig(QWidget): # {{{
|
|||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if self.view.state() == self.view.EditingState:
|
if self.view.state() == QAbstractItemView.State.EditingState:
|
||||||
self.delegate.accept_changes()
|
self.delegate.accept_changes()
|
||||||
self._model.commit()
|
self._model.commit()
|
||||||
|
|
||||||
@ -700,7 +700,7 @@ class ShortcutConfig(QWidget): # {{{
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_editing(self):
|
def is_editing(self):
|
||||||
return self.view.state() == self.view.EditingState
|
return self.view.state() == QAbstractItemView.State.EditingState
|
||||||
|
|
||||||
def find(self, query):
|
def find(self, query):
|
||||||
if not query:
|
if not query:
|
||||||
|
@ -53,7 +53,7 @@ def handle_enter_press(self, ev, special_action=None, has_edit_cell=True):
|
|||||||
mods = ev.modifiers()
|
mods = ev.modifiers()
|
||||||
if mods & Qt.Modifier.CTRL or mods & Qt.Modifier.ALT or mods & Qt.Modifier.SHIFT or mods & Qt.Modifier.META:
|
if mods & Qt.Modifier.CTRL or mods & Qt.Modifier.ALT or mods & Qt.Modifier.SHIFT or mods & Qt.Modifier.META:
|
||||||
return
|
return
|
||||||
if self.state() != self.EditingState and self.hasFocus() and self.currentIndex().isValid():
|
if self.state() != QAbstractItemView.State.EditingState and self.hasFocus() and self.currentIndex().isValid():
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
ev.ignore()
|
ev.ignore()
|
||||||
tweak = tweaks['enter_key_behavior']
|
tweak = tweaks['enter_key_behavior']
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from PyQt5.Qt import QAbstractTableModel, QFont, Qt
|
from PyQt5.Qt import QAbstractTableModel, QFont, Qt, QAbstractItemView
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
||||||
@ -245,7 +245,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
# No defaults to restore to
|
# No defaults to restore to
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if self.email_view.state() == self.email_view.EditingState:
|
if self.email_view.state() == QAbstractItemView.State.EditingState:
|
||||||
# Ensure that the cell being edited is committed by switching focus
|
# Ensure that the cell being edited is committed by switching focus
|
||||||
# to some other widget, which automatically closes the open editor
|
# to some other widget, which automatically closes the open editor
|
||||||
self.send_email_widget.setFocus(Qt.FocusReason.OtherFocusReason)
|
self.send_email_widget.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QAbstractListModel, Qt, QKeySequence, QListView, QVBoxLayout, QLabel,
|
QAbstractListModel, Qt, QKeySequence, QListView, QVBoxLayout, QLabel, QAbstractItemView,
|
||||||
QHBoxLayout, QWidget, QApplication, QStyledItemDelegate, QStyle, QIcon,
|
QHBoxLayout, QWidget, QApplication, QStyledItemDelegate, QStyle, QIcon,
|
||||||
QTextDocument, QRectF, QFrame, QSize, QFont, QKeyEvent, QRadioButton, QPushButton, QToolButton, QEvent
|
QTextDocument, QRectF, QFrame, QSize, QFont, QKeyEvent, QRadioButton, QPushButton, QToolButton, QEvent
|
||||||
)
|
)
|
||||||
@ -309,7 +309,7 @@ class ShortcutConfig(QWidget):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_editing(self):
|
def is_editing(self):
|
||||||
return self.view.state() == self.view.EditingState
|
return self.view.state() == QAbstractItemView.State.EditingState
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -10,7 +10,7 @@ import os, re, traceback
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QStyledItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon, QApplication, QStyle,
|
QStyledItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon, QApplication, QStyle, QAbstractItemView,
|
||||||
QMenu, QPoint, QToolTip, QCursor, QDrag, QRect, QModelIndex,
|
QMenu, QPoint, QToolTip, QCursor, QDrag, QRect, QModelIndex,
|
||||||
QLinearGradient, QPalette, QColor, QPen, QBrush, QFont, QTimer
|
QLinearGradient, QPalette, QColor, QPen, QBrush, QFont, QTimer
|
||||||
)
|
)
|
||||||
@ -335,7 +335,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
# I don't see how current_index can ever be not valid, but ...
|
# I don't see how current_index can ever be not valid, but ...
|
||||||
if self.currentIndex().isValid():
|
if self.currentIndex().isValid():
|
||||||
if (gprefs['tag_browser_allow_keyboard_focus'] and
|
if (gprefs['tag_browser_allow_keyboard_focus'] and
|
||||||
event.key() == Qt.Key.Key_Return and self.state() != self.EditingState):
|
event.key() == Qt.Key.Key_Return and self.state() != QAbstractItemView.State.EditingState):
|
||||||
self.toggle_current_index()
|
self.toggle_current_index()
|
||||||
return
|
return
|
||||||
# If this is an edit request, mark the node to request whether to use VLs
|
# If this is an edit request, mark the node to request whether to use VLs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user