mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Restore various missing enum values from various PyQt classes
This commit is contained in:
parent
a6b29994e1
commit
a484a02dfd
@ -7,8 +7,9 @@
|
|||||||
# party plugin code, we NEED backward compat.
|
# party plugin code, we NEED backward compat.
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QDialog, QDrag, QEventLoop, QMenu, QMessageBox, QSinglePointEvent,
|
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
||||||
QThread, QModelIndex
|
QEventLoop, QFrame, QLineEdit, QMenu, QMessageBox, QModelIndex,
|
||||||
|
QSinglePointEvent, Qt, QThread, QToolButton
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre_extensions import progress_indicator
|
from calibre_extensions import progress_indicator
|
||||||
@ -25,12 +26,17 @@ QSinglePointEvent.windowPos = lambda self: self.scenePosition()
|
|||||||
|
|
||||||
|
|
||||||
# Restore the removed exec_ method
|
# Restore the removed exec_ method
|
||||||
QDialog.exec_ = QDialog.exec
|
|
||||||
QMenu.exec_ = QMenu.exec
|
def exec_(self):
|
||||||
QDrag.exec_ = QDrag.exec
|
return self.exec()
|
||||||
QEventLoop.exec_ = QEventLoop.exec
|
|
||||||
QThread.exec_ = QThread.exec
|
|
||||||
QMessageBox.exec_ = QMessageBox.exec
|
QDialog.exec_ = exec_
|
||||||
|
QMenu.exec_ = exec_
|
||||||
|
QDrag.exec_ = exec_
|
||||||
|
QEventLoop.exec_ = exec_
|
||||||
|
QThread.exec_ = exec_
|
||||||
|
QMessageBox.exec_ = exec_
|
||||||
|
|
||||||
|
|
||||||
# Restore ability to associate a menu with an action
|
# Restore ability to associate a menu with an action
|
||||||
@ -43,5 +49,14 @@ QAction.setMenu = set_menu
|
|||||||
QAction.menu = lambda self: progress_indicator.menu_for_action(self)
|
QAction.menu = lambda self: progress_indicator.menu_for_action(self)
|
||||||
|
|
||||||
|
|
||||||
# Restore QModelIndex child
|
# Restore QModelIndex::child
|
||||||
QModelIndex.child = lambda self, row, column: self.model().index(row, column, self)
|
QModelIndex.child = lambda self, row, column: self.model().index(row, column, self)
|
||||||
|
|
||||||
|
|
||||||
|
# Restore enum values to various classes
|
||||||
|
for cls in (Qt, QDialog, QToolButton, QAbstractItemView, QDialogButtonBox, QFrame, QComboBox, QLineEdit, QAction):
|
||||||
|
for var in tuple(vars(cls).values()):
|
||||||
|
m = getattr(var, '__members__', {})
|
||||||
|
for k, v in m.items():
|
||||||
|
if not hasattr(cls, k):
|
||||||
|
setattr(cls, k, v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user