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
2b69620c51
commit
dc10461cba
@ -17,7 +17,7 @@ from PyQt5.Qt import (
|
|||||||
QHBoxLayout, QIcon, QKeySequence, QLabel, QLineEdit, QMenu, QPalette,
|
QHBoxLayout, QIcon, QKeySequence, QLabel, QLineEdit, QMenu, QPalette,
|
||||||
QPlainTextEdit, QPushButton, QSize, QSyntaxHighlighter, Qt, QTabWidget,
|
QPlainTextEdit, QPushButton, QSize, QSyntaxHighlighter, Qt, QTabWidget,
|
||||||
QTextBlockFormat, QTextCharFormat, QTextCursor, QTextEdit, QTextListFormat,
|
QTextBlockFormat, QTextCharFormat, QTextCursor, QTextEdit, QTextListFormat,
|
||||||
QToolBar, QUrl, QVBoxLayout, QWidget, pyqtSignal, pyqtSlot
|
QToolBar, QUrl, QVBoxLayout, QWidget, pyqtSignal, pyqtSlot, QToolButton
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import xml_replace_entities
|
from calibre import xml_replace_entities
|
||||||
@ -1126,7 +1126,7 @@ class Editor(QWidget): # {{{
|
|||||||
self.toolbar2.addAction(self.editor.action_block_style)
|
self.toolbar2.addAction(self.editor.action_block_style)
|
||||||
w = self.toolbar2.widgetForAction(self.editor.action_block_style)
|
w = self.toolbar2.widgetForAction(self.editor.action_block_style)
|
||||||
if hasattr(w, 'setPopupMode'):
|
if hasattr(w, 'setPopupMode'):
|
||||||
w.setPopupMode(w.InstantPopup)
|
w.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
self.toolbar2.addAction(self.editor.action_insert_link)
|
self.toolbar2.addAction(self.editor.action_insert_link)
|
||||||
self.toolbar2.addAction(self.editor.action_insert_hr)
|
self.toolbar2.addAction(self.editor.action_insert_hr)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -634,7 +634,7 @@ class LayoutMixin(object): # {{{
|
|||||||
else:
|
else:
|
||||||
self.layout_button = b = QToolButton(self)
|
self.layout_button = b = QToolButton(self)
|
||||||
b.setAutoRaise(True), b.setCursor(Qt.CursorShape.PointingHandCursor)
|
b.setAutoRaise(True), b.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
b.setPopupMode(b.InstantPopup)
|
b.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||||
b.setText(_('Layout')), b.setIcon(QIcon(I('config.png')))
|
b.setText(_('Layout')), b.setIcon(QIcon(I('config.png')))
|
||||||
b.setMenu(LayoutMenu(self))
|
b.setMenu(LayoutMenu(self))
|
||||||
|
@ -198,7 +198,7 @@ class SearchBar(QFrame): # {{{
|
|||||||
|
|
||||||
x = parent.virtual_library = QToolButton(self)
|
x = parent.virtual_library = QToolButton(self)
|
||||||
x.setCursor(Qt.CursorShape.PointingHandCursor)
|
x.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
x.setPopupMode(x.InstantPopup)
|
x.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
x.setText(_('Virtual library'))
|
x.setText(_('Virtual library'))
|
||||||
x.setAutoRaise(True)
|
x.setAutoRaise(True)
|
||||||
x.setIcon(QIcon(I('vl.png')))
|
x.setIcon(QIcon(I('vl.png')))
|
||||||
@ -304,7 +304,7 @@ class SearchBar(QFrame): # {{{
|
|||||||
x.setText(_('Saved search'))
|
x.setText(_('Saved search'))
|
||||||
x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
x.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||||
x.setCursor(Qt.CursorShape.PointingHandCursor)
|
x.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
x.setPopupMode(x.InstantPopup)
|
x.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
x.setAutoRaise(True)
|
x.setAutoRaise(True)
|
||||||
x.setIcon(QIcon(I("bookmarks.png")))
|
x.setIcon(QIcon(I("bookmarks.png")))
|
||||||
l.addWidget(x)
|
l.addWidget(x)
|
||||||
|
@ -699,7 +699,7 @@ class GridView(QListView):
|
|||||||
setup_dnd_interface(self)
|
setup_dnd_interface(self)
|
||||||
self.setUniformItemSizes(True)
|
self.setUniformItemSizes(True)
|
||||||
self.setWrapping(True)
|
self.setWrapping(True)
|
||||||
self.setFlow(self.LeftToRight)
|
self.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
# We cannot set layout mode to batched, because that breaks
|
# We cannot set layout mode to batched, because that breaks
|
||||||
# restore_vpos()
|
# restore_vpos()
|
||||||
# self.setLayoutMode(self.Batched)
|
# self.setLayoutMode(self.Batched)
|
||||||
|
@ -80,7 +80,7 @@ class ConfigWidget(QWidget):
|
|||||||
g.setContentsMargins(0, 0, 0, 0)
|
g.setContentsMargins(0, 0, 0, 0)
|
||||||
self.fields_view = v = FieldsList(self)
|
self.fields_view = v = FieldsList(self)
|
||||||
g.addWidget(v)
|
g.addWidget(v)
|
||||||
v.setFlow(v.LeftToRight)
|
v.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
v.setWrapping(True)
|
v.setWrapping(True)
|
||||||
v.setResizeMode(v.Adjust)
|
v.setResizeMode(v.Adjust)
|
||||||
self.fields_model = FieldsModel(self.plugin)
|
self.fields_model = FieldsModel(self.plugin)
|
||||||
|
@ -769,7 +769,7 @@ class CoversView(QListView): # {{{
|
|||||||
self.m = CoversModel(current_cover, self)
|
self.m = CoversModel(current_cover, self)
|
||||||
self.setModel(self.m)
|
self.setModel(self.m)
|
||||||
|
|
||||||
self.setFlow(self.LeftToRight)
|
self.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
self.setWrapping(True)
|
self.setWrapping(True)
|
||||||
self.setResizeMode(self.Adjust)
|
self.setResizeMode(self.Adjust)
|
||||||
self.setGridSize(QSize(190, 260))
|
self.setGridSize(QSize(190, 260))
|
||||||
|
@ -47,7 +47,7 @@ class TextureChooser(QDialog):
|
|||||||
il.itemDoubleClicked.connect(self.accept, type=Qt.ConnectionType.QueuedConnection)
|
il.itemDoubleClicked.connect(self.accept, type=Qt.ConnectionType.QueuedConnection)
|
||||||
il.setIconSize(QSize(256, 256))
|
il.setIconSize(QSize(256, 256))
|
||||||
il.setViewMode(il.IconMode)
|
il.setViewMode(il.IconMode)
|
||||||
il.setFlow(il.LeftToRight)
|
il.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
il.setSpacing(20)
|
il.setSpacing(20)
|
||||||
il.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
il.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
|
||||||
il.itemSelectionChanged.connect(self.update_remove_state)
|
il.itemSelectionChanged.connect(self.update_remove_state)
|
||||||
|
@ -468,7 +468,7 @@ class TagBrowserBar(QWidget): # {{{
|
|||||||
b.setAutoRaise(True)
|
b.setAutoRaise(True)
|
||||||
b.setText(_('Configure')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
b.setText(_('Configure')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||||
b.setCursor(Qt.CursorShape.PointingHandCursor)
|
b.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
b.setPopupMode(b.InstantPopup)
|
b.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
b.setToolTip(textwrap.fill(_(
|
b.setToolTip(textwrap.fill(_(
|
||||||
'Change how the Tag browser works, such as,'
|
'Change how the Tag browser works, such as,'
|
||||||
' how it is sorted, what happens when you click'
|
' how it is sorted, what happens when you click'
|
||||||
|
@ -591,7 +591,7 @@ class CharView(QListView):
|
|||||||
self.delegate = CharDelegate(self)
|
self.delegate = CharDelegate(self)
|
||||||
self.setResizeMode(self.Adjust)
|
self.setResizeMode(self.Adjust)
|
||||||
self.setItemDelegate(self.delegate)
|
self.setItemDelegate(self.delegate)
|
||||||
self.setFlow(self.LeftToRight)
|
self.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
self.setWrapping(True)
|
self.setWrapping(True)
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
self.setSpacing(2)
|
self.setSpacing(2)
|
||||||
|
@ -280,7 +280,7 @@ class Diff(Dialog):
|
|||||||
b.setIcon(QIcon(I('config.png')))
|
b.setIcon(QIcon(I('config.png')))
|
||||||
b.setText(_('&Options')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
b.setText(_('&Options')), b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||||
b.setToolTip(_('Change how the differences are displayed'))
|
b.setToolTip(_('Change how the differences are displayed'))
|
||||||
b.setPopupMode(b.InstantPopup)
|
b.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
m = QMenu(b)
|
m = QMenu(b)
|
||||||
b.setMenu(m)
|
b.setMenu(m)
|
||||||
cm = self.cm = QMenu(_('Lines of context around each change'))
|
cm = self.cm = QMenu(_('Lines of context around each change'))
|
||||||
|
@ -215,7 +215,7 @@ class InsertImage(Dialog):
|
|||||||
|
|
||||||
self.view = v = QListView(self)
|
self.view = v = QListView(self)
|
||||||
v.setViewMode(v.IconMode)
|
v.setViewMode(v.IconMode)
|
||||||
v.setFlow(v.LeftToRight)
|
v.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
v.setSpacing(4)
|
v.setSpacing(4)
|
||||||
v.setResizeMode(v.Adjust)
|
v.setResizeMode(v.Adjust)
|
||||||
v.setUniformItemSizes(True)
|
v.setUniformItemSizes(True)
|
||||||
|
@ -486,7 +486,7 @@ class EditSnippet(QWidget):
|
|||||||
add_row(_('&Template:'), t)
|
add_row(_('&Template:'), t)
|
||||||
|
|
||||||
self.types = t = QListWidget(self)
|
self.types = t = QListWidget(self)
|
||||||
t.setFlow(t.LeftToRight)
|
t.setFlow(Qt.LayoutDirection.LeftToRight)
|
||||||
t.setWrapping(True), t.setResizeMode(t.Adjust), t.setSpacing(5)
|
t.setWrapping(True), t.setResizeMode(t.Adjust), t.setSpacing(5)
|
||||||
fm = t.fontMetrics()
|
fm = t.fontMetrics()
|
||||||
t.setMaximumHeight(2*(fm.ascent() + fm.descent()) + 25)
|
t.setMaximumHeight(2*(fm.ascent() + fm.descent()) + 25)
|
||||||
|
@ -206,7 +206,7 @@ class ActionsToolBar(ToolBar):
|
|||||||
pass
|
pass
|
||||||
w = self.widgetForAction(self.color_scheme_action)
|
w = self.widgetForAction(self.color_scheme_action)
|
||||||
if w:
|
if w:
|
||||||
w.setPopupMode(w.InstantPopup)
|
w.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||||
|
|
||||||
def update_mode_action(self):
|
def update_mode_action(self):
|
||||||
mode = get_session_pref('read_mode', default='paged', group=None)
|
mode = get_session_pref('read_mode', default='paged', group=None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user