mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-03 17:22:59 +02:00
pyqt6: port QFontMetrics::width
This commit is contained in:
parent
841aa7b275
commit
a559b10899
2 changed files with 7 additions and 4 deletions
|
|
@ -857,7 +857,7 @@ def widget_factory(typ, key):
|
|||
wij = w.widgets[c]
|
||||
if label_width == 0:
|
||||
font_metrics = wij.fontMetrics()
|
||||
colon_width = font_metrics.width(':')
|
||||
colon_width = font_metrics.horizontalAdvance(':')
|
||||
if bulk:
|
||||
label_width = (font_metrics.averageCharWidth() *
|
||||
gprefs['edit_metadata_bulk_cc_label_length']) - colon_width
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
from qt.core import (
|
||||
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
||||
QEventLoop, QFrame, QImage, QIODevice, QLineEdit, QMenu, QMessageBox,
|
||||
QModelIndex, QSinglePointEvent, Qt, QThread, QToolButton
|
||||
QEventLoop, QFontMetrics, QFrame, QImage, QIODevice, QLineEdit, QMenu,
|
||||
QMessageBox, QModelIndex, QSinglePointEvent, Qt, QThread, QToolButton, QPalette
|
||||
)
|
||||
|
||||
from calibre_extensions import progress_indicator
|
||||
|
|
@ -53,8 +53,11 @@ def set_menu(self, menu):
|
|||
QModelIndex.child = lambda self, row, column: self.model().index(row, column, self)
|
||||
|
||||
|
||||
# Restore QFontMetrics::width
|
||||
QFontMetrics.width = lambda self, text: self.horizontalAdvance(text)
|
||||
|
||||
# Restore enum values to various classes
|
||||
for cls in (Qt, QDialog, QToolButton, QAbstractItemView, QDialogButtonBox, QFrame, QComboBox, QLineEdit, QAction, QImage, QIODevice):
|
||||
for cls in (Qt, QDialog, QToolButton, QAbstractItemView, QDialogButtonBox, QFrame, QComboBox, QLineEdit, QAction, QImage, QIODevice, QPalette):
|
||||
for var in tuple(vars(cls).values()):
|
||||
m = getattr(var, '__members__', {})
|
||||
for k, v in m.items():
|
||||
|
|
|
|||
Loading…
Reference in a new issue