mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
More stupid PyQt enums
More stupid PyQt enums
This commit is contained in:
parent
63fbb991e1
commit
48000d4514
@ -7,7 +7,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.Qt import QTimer, QApplication, Qt
|
||||
from PyQt5.Qt import QTimer, QApplication, Qt, QEvent
|
||||
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
@ -79,7 +79,7 @@ class MarkBooksAction(InterfaceAction):
|
||||
continue
|
||||
|
||||
def eventFilter(self, obj, ev):
|
||||
if ev.type() == ev.MouseButtonPress and ev.button() == Qt.MouseButton.LeftButton:
|
||||
if ev.type() == QEvent.Type.MouseButtonPress and ev.button() == Qt.MouseButton.LeftButton:
|
||||
mods = QApplication.keyboardModifiers()
|
||||
if mods & Qt.KeyboardModifier.ControlModifier or mods & Qt.KeyboardModifier.ShiftModifier:
|
||||
self.show_marked()
|
||||
|
@ -512,7 +512,7 @@ class EditWithComplete(EnComboBox):
|
||||
except AttributeError:
|
||||
return False
|
||||
etype = e.type()
|
||||
if self.eat_focus_out and self is obj and etype == e.FocusOut:
|
||||
if self.eat_focus_out and self is obj and etype == QEvent.Type.FocusOut:
|
||||
if c.isVisible():
|
||||
return True
|
||||
return EnComboBox.eventFilter(self, obj, e)
|
||||
|
@ -8,7 +8,7 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import time
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QApplication, QMainWindow, QVBoxLayout, Qt, QKeySequence, QAction,
|
||||
QApplication, QMainWindow, QVBoxLayout, Qt, QKeySequence, QAction, QEvent,
|
||||
QActionGroup, QMenu, QPushButton, QWidget, QTimer, QMessageBox, pyqtSignal)
|
||||
|
||||
from calibre.gui2.dbus_export.utils import setup_for_cli_run
|
||||
@ -153,8 +153,8 @@ class MainWindow(QMainWindow):
|
||||
QMessageBox.information(self, 'A test dialog', 'While this dialog is shown, the global menu should be hidden')
|
||||
|
||||
def event(self, ev):
|
||||
if ev.type() in (ev.WindowBlocked, ev.WindowUnblocked):
|
||||
if ev.type() == ev.WindowBlocked:
|
||||
if ev.type() in (QEvent.Type.WindowBlocked, QEvent.Type.WindowUnblocked):
|
||||
if ev.type() == QEvent.Type.WindowBlocked:
|
||||
self.window_blocked.emit()
|
||||
else:
|
||||
self.window_unblocked.emit()
|
||||
|
@ -10,7 +10,7 @@ import functools
|
||||
from PyQt5.Qt import (
|
||||
QAction, QApplication, QIcon, QLabel, QMenu, QPainter, QSizePolicy, QSplitter,
|
||||
QStackedWidget, QStatusBar, QStyle, QStyleOption, Qt, QTabBar, QTimer,
|
||||
QToolButton, QVBoxLayout, QWidget, QDialog
|
||||
QToolButton, QVBoxLayout, QWidget, QDialog, QEvent
|
||||
)
|
||||
|
||||
from calibre.constants import __appname__, get_version, ismacos
|
||||
@ -239,9 +239,9 @@ class VersionLabel(QLabel): # {{{
|
||||
def event(self, ev):
|
||||
m = None
|
||||
et = ev.type()
|
||||
if et == ev.Enter:
|
||||
if et == QEvent.Type.Enter:
|
||||
m = True
|
||||
elif et == ev.Leave:
|
||||
elif et == QEvent.Type.Leave:
|
||||
m = False
|
||||
if m is not None and m != self.mouse_over:
|
||||
self.mouse_over = m
|
||||
|
@ -7,8 +7,8 @@ __copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QBrush, QColor, QEasingCurve, QPainter, QPainterPath, QPalette, QPoint, QPointF,
|
||||
QPropertyAnimation, QRect, Qt, QWidget
|
||||
QAbstractAnimation, QBrush, QColor, QEasingCurve, QPainter, QPainterPath,
|
||||
QPalette, QPoint, QPointF, QPropertyAnimation, QRect, Qt, QWidget
|
||||
)
|
||||
|
||||
from calibre.gui2 import config
|
||||
@ -78,7 +78,7 @@ class Pointer(QWidget):
|
||||
self.path.closeSubpath()
|
||||
self.animation.setStartValue(self.rect_at(0.0))
|
||||
self.animation.setEndValue(self.rect_at(1.0))
|
||||
self.animation.setDirection(self.animation.Backward)
|
||||
self.animation.setDirection(QAbstractAnimation.Direction.Backward)
|
||||
num_keys = 100
|
||||
for i in range(1, num_keys):
|
||||
i /= num_keys
|
||||
|
@ -12,7 +12,7 @@ Job management.
|
||||
import time
|
||||
|
||||
from PyQt5.Qt import (QAbstractTableModel, QModelIndex, Qt, QPainter,
|
||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication,
|
||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication, QEvent,
|
||||
QSize, QStyleOptionProgressBar, QStyle, QToolTip, QWidget, QStyleOption,
|
||||
QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction,
|
||||
QByteArray, QSortFilterProxyModel, QTextBrowser, QPlainTextEdit, QDialogButtonBox)
|
||||
@ -533,9 +533,9 @@ class JobsButton(QWidget): # {{{
|
||||
def event(self, ev):
|
||||
m = None
|
||||
et = ev.type()
|
||||
if et == ev.Enter:
|
||||
if et == QEvent.Type.Enter:
|
||||
m = True
|
||||
elif et == ev.Leave:
|
||||
elif et == QEvent.Type.Leave:
|
||||
m = False
|
||||
if m is not None and m != self.mouse_over:
|
||||
self.mouse_over = m
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QFontMetrics, QHBoxLayout, QIcon, QMenu, QPainter, QPushButton, QSize,
|
||||
QSizePolicy, Qt, QWidget, QStyleOption, QStyle)
|
||||
QSizePolicy, Qt, QWidget, QStyleOption, QStyle, QEvent)
|
||||
|
||||
|
||||
ICON_SZ = 64
|
||||
@ -38,9 +38,9 @@ class LayoutItem(QWidget):
|
||||
def event(self, ev):
|
||||
m = None
|
||||
et = ev.type()
|
||||
if et == ev.Enter:
|
||||
if et == QEvent.Type.Enter:
|
||||
m = True
|
||||
elif et == ev.Leave:
|
||||
elif et == QEvent.Type.Leave:
|
||||
m = False
|
||||
if m is not None and m != self.mouse_over:
|
||||
self.mouse_over = m
|
||||
|
@ -60,9 +60,9 @@ class HeaderView(QHeaderView): # {{{
|
||||
self.fm = QFontMetrics(self.current_font)
|
||||
|
||||
def event(self, e):
|
||||
if e.type() in (e.HoverMove, e.HoverEnter):
|
||||
if e.type() in (QEvent.Type.HoverMove, QEvent.Type.HoverEnter):
|
||||
self.hover = self.logicalIndexAt(e.pos())
|
||||
elif e.type() in (e.Leave, e.HoverLeave):
|
||||
elif e.type() in (QEvent.Type.Leave, QEvent.Type.HoverLeave):
|
||||
self.hover = -1
|
||||
return QHeaderView.event(self, e)
|
||||
|
||||
|
@ -717,8 +717,8 @@ class MetadataSingleDialogBase(QDialog):
|
||||
' [Alt+Left]')%prev
|
||||
self.prev_button.setToolTip(tip)
|
||||
self.prev_button.setEnabled(prev is not None)
|
||||
self.button_box.button(self.button_box.Ok).setDefault(True)
|
||||
self.button_box.button(self.button_box.Ok).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.button_box.button(QDialogButtonBox.StandardButton.Ok).setDefault(True)
|
||||
self.button_box.button(QDialogButtonBox.StandardButton.Ok).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self(self.db.id(self.row_list[self.current_row]))
|
||||
for w, state in iteritems(self.comments_edit_state_at_apply):
|
||||
if state == 'code':
|
||||
|
@ -258,8 +258,8 @@ class Preferences(QDialog):
|
||||
|
||||
self.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu)
|
||||
self.title_bar = TitleBar(self)
|
||||
for ac, tt in [(self.bb.Apply, _('Save changes')),
|
||||
(self.bb.Discard, _('Cancel and return to overview'))]:
|
||||
for ac, tt in [(QDialogButtonBox.StandardButton.Apply, _('Save changes')),
|
||||
(QDialogButtonBox.StandardButton.Discard, _('Cancel and return to overview'))]:
|
||||
self.bb.button(ac).setToolTip(tt)
|
||||
|
||||
l.addWidget(self.title_bar), l.addWidget(self.stack), l.addWidget(self.bb)
|
||||
@ -323,7 +323,7 @@ class Preferences(QDialog):
|
||||
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False)
|
||||
self.wizard_button.setVisible(False)
|
||||
for button in (self.bb.Apply, self.bb.RestoreDefaults, self.bb.Discard):
|
||||
for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard):
|
||||
button = self.bb.button(button)
|
||||
button.setVisible(True)
|
||||
|
||||
@ -353,7 +353,7 @@ class Preferences(QDialog):
|
||||
self.title_bar.show_plugin()
|
||||
self.setWindowIcon(QIcon(I('config.png')))
|
||||
|
||||
for button in (self.bb.Apply, self.bb.RestoreDefaults, self.bb.Discard):
|
||||
for button in (QDialogButtonBox.StandardButton.Apply, QDialogButtonBox.StandardButton.RestoreDefaults, QDialogButtonBox.StandardButton.Discard):
|
||||
button = self.bb.button(button)
|
||||
button.setVisible(False)
|
||||
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
from collections import namedtuple
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QWidget, Qt, QLabel, QVBoxLayout, QDialogButtonBox, QApplication, QTimer, QPixmap,
|
||||
QWidget, Qt, QLabel, QVBoxLayout, QDialogButtonBox, QApplication, QTimer, QPixmap, QEvent,
|
||||
QSize, pyqtSignal, QIcon, QPlainTextEdit, QCheckBox, QPainter, QHBoxLayout, QFontMetrics,
|
||||
QPainterPath, QRectF, pyqtProperty, QPropertyAnimation, QEasingCurve, QSizePolicy, QImage, QPalette)
|
||||
|
||||
@ -160,7 +160,7 @@ class ProceedQuestion(QWidget):
|
||||
t.setSingleShot(True), t.setInterval(100), t.timeout.connect(self.parent_resized)
|
||||
|
||||
def eventFilter(self, obj, ev):
|
||||
if ev.type() == ev.Resize and self.isVisible():
|
||||
if ev.type() == QEvent.Type.Resize and self.isVisible():
|
||||
self.resize_timer.start()
|
||||
return False
|
||||
|
||||
|
@ -11,7 +11,7 @@ from PyQt5.Qt import (
|
||||
QApplication, QCheckBox, QCursor, QDialog, QDialogButtonBox, QFrame, QGridLayout,
|
||||
QIcon, QInputDialog, QItemSelectionModel, QKeySequence, QLabel, QMenu,
|
||||
QPushButton, QScrollArea, QSize, QSizePolicy, QStackedWidget, Qt, QAbstractItemView,
|
||||
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
||||
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal, QEvent
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
@ -770,7 +770,7 @@ class TOCView(QWidget): # {{{
|
||||
self.item_view.edit_item()
|
||||
|
||||
def event(self, e):
|
||||
if e.type() == e.StatusTip:
|
||||
if e.type() == QEvent.Type.StatusTip:
|
||||
txt = unicode_type(e.tip()) or self.default_msg
|
||||
self.hl.setText(txt)
|
||||
return super(TOCView, self).event(e)
|
||||
|
@ -200,7 +200,7 @@ class ChoosePopupWidget(QWidget):
|
||||
if ret:
|
||||
ev.accept()
|
||||
return ret
|
||||
elif etype == ev.Resize:
|
||||
elif etype == QEvent.Type.Resize:
|
||||
self.relayout_timer.start()
|
||||
return False
|
||||
|
||||
|
@ -15,7 +15,7 @@ from polyglot.builtins import iteritems, unicode_type, zip, range, as_bytes, map
|
||||
|
||||
import regex
|
||||
from PyQt5.Qt import (
|
||||
QSplitter, QApplication, QTimer,
|
||||
QSplitter, QApplication, QTimer, QEvent,
|
||||
QTextCursor, QTextCharFormat, Qt, QRect, QPainter, QPalette, QPen, QBrush,
|
||||
QColor, QTextLayout, QCursor, QFont, QSplitterHandle, QPainterPath,
|
||||
QHBoxLayout, QWidget, QScrollBar, QEventLoop, pyqtSignal, QImage, QPixmap,
|
||||
@ -401,8 +401,8 @@ class DiffSplitHandle(QSplitterHandle): # {{{
|
||||
wheel_event = pyqtSignal(object)
|
||||
|
||||
def event(self, ev):
|
||||
if ev.type() in (ev.HoverEnter, ev.HoverLeave):
|
||||
self.hover = ev.type() == ev.HoverEnter
|
||||
if ev.type() in (QEvent.Type.HoverEnter, QEvent.Type.HoverLeave):
|
||||
self.hover = ev.type() == QEvent.Type.HoverEnter
|
||||
return QSplitterHandle.event(self, ev)
|
||||
|
||||
def paintEvent(self, event):
|
||||
|
@ -699,7 +699,7 @@ class EbookViewer(MainWindow):
|
||||
t.start()
|
||||
|
||||
def eventFilter(self, obj, ev):
|
||||
if ev.type() == ev.MouseMove:
|
||||
if ev.type() == QEvent.Type.MouseMove:
|
||||
if self.cursor_hidden:
|
||||
self.cursor_hidden = False
|
||||
QApplication.instance().restoreOverrideCursor()
|
||||
|
@ -8,7 +8,7 @@ import shutil
|
||||
import sys
|
||||
from itertools import count
|
||||
from PyQt5.Qt import (
|
||||
QT_VERSION, QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QPalette,
|
||||
QT_VERSION, QApplication, QBuffer, QByteArray, QFontDatabase, QFontInfo, QPalette, QEvent,
|
||||
QHBoxLayout, QMimeData, QSize, Qt, QTimer, QUrl, QWidget, pyqtSignal, QIODevice, QLocale
|
||||
)
|
||||
from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler
|
||||
@ -572,7 +572,7 @@ class WebView(RestartingWebEngineView):
|
||||
' You should try restarting the viewer.') , show=True)
|
||||
|
||||
def event(self, event):
|
||||
if event.type() == event.ChildPolished:
|
||||
if event.type() == QEvent.Type.ChildPolished:
|
||||
child = event.child()
|
||||
if 'HostView' in child.metaObject().className():
|
||||
self._host_widget = child
|
||||
|
Loading…
x
Reference in New Issue
Block a user