From e4cce88002001a5dbca08dbd10796158528ef27d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 13 Jan 2021 18:35:35 +0530 Subject: [PATCH] Dont use deprecated QApplication.fontMetrics() --- src/calibre/gui2/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 19f3bb5caf..ec5ca7d6fe 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1387,7 +1387,9 @@ def elided_text(text, font=None, width=300, pos='middle'): of the string with an ellipsis. Results in a string much closer to the limit than Qt's elidedText().''' from PyQt5.Qt import QFontMetrics, QApplication - fm = QApplication.fontMetrics() if font is None else (font if isinstance(font, QFontMetrics) else QFontMetrics(font)) + if font is None: + font = QApplication.instance().font() + fm = (font if isinstance(font, QFontMetrics) else QFontMetrics(font)) delta = 4 ellipsis = '\u2026'