mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pyqt6: port QFontMetrics::width
This commit is contained in:
parent
a24c16608a
commit
d691d0a69a
@ -858,7 +858,7 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
|
|||||||
wij = w.widgets[c]
|
wij = w.widgets[c]
|
||||||
if label_width == 0:
|
if label_width == 0:
|
||||||
font_metrics = wij.fontMetrics()
|
font_metrics = wij.fontMetrics()
|
||||||
colon_width = font_metrics.width(':')
|
colon_width = font_metrics.horizontalAdvance(':')
|
||||||
if bulk:
|
if bulk:
|
||||||
label_width = (font_metrics.averageCharWidth() *
|
label_width = (font_metrics.averageCharWidth() *
|
||||||
gprefs['edit_metadata_bulk_cc_label_length']) - colon_width
|
gprefs['edit_metadata_bulk_cc_label_length']) - colon_width
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
||||||
QEventLoop, QFrame, QImage, QIODevice, QLineEdit, QMenu, QMessageBox,
|
QEventLoop, QFontMetrics, QFrame, QImage, QIODevice, QLineEdit, QMenu,
|
||||||
QModelIndex, QSinglePointEvent, Qt, QThread, QToolButton
|
QMessageBox, QModelIndex, QSinglePointEvent, Qt, QThread, QToolButton, QPalette
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre_extensions import progress_indicator
|
from calibre_extensions import progress_indicator
|
||||||
@ -53,8 +53,11 @@ QAction.menu = lambda self: progress_indicator.menu_for_action(self)
|
|||||||
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 QFontMetrics::width
|
||||||
|
QFontMetrics.width = lambda self, text: self.horizontalAdvance(text)
|
||||||
|
|
||||||
# Restore enum values to various classes
|
# 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()):
|
for var in tuple(vars(cls).values()):
|
||||||
m = getattr(var, '__members__', {})
|
m = getattr(var, '__members__', {})
|
||||||
for k, v in m.items():
|
for k, v in m.items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user