From cdcfc358e8ae012a8d2ce33bdc7fd08857c262c1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 27 Oct 2014 14:42:49 +0530 Subject: [PATCH] Ensure details widget has fixed width for its size hint in the proceed popup --- src/calibre/gui2/proceed.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/proceed.py b/src/calibre/gui2/proceed.py index 7f0fe5f934..b969592b29 100644 --- a/src/calibre/gui2/proceed.py +++ b/src/calibre/gui2/proceed.py @@ -11,7 +11,7 @@ from collections import namedtuple from PyQt5.Qt import ( QWidget, Qt, QLabel, QVBoxLayout, QPixmap, QDialogButtonBox, QApplication, QTimer, - QSize, pyqtSignal, QIcon, QPlainTextEdit, QCheckBox, QPainter, QHBoxLayout, + QSize, pyqtSignal, QIcon, QPlainTextEdit, QCheckBox, QPainter, QHBoxLayout, QFontMetrics, QPainterPath, QRectF, pyqtProperty, QPropertyAnimation, QEasingCurve, QSizePolicy) from calibre.constants import __version__ @@ -69,6 +69,13 @@ class Icon(QWidget): p.drawPixmap(self.rect(), self.icon) p.end() +class PlainTextEdit(QPlainTextEdit): + + def sizeHint(self): + fm = QFontMetrics(self.font()) + ans = QPlainTextEdit.sizeHint(self) + ans.setWidth(fm.averageCharWidth() * 50) + return ans class ProceedQuestion(QWidget): @@ -117,7 +124,7 @@ class ProceedQuestion(QWidget): self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) - self.det_msg = QPlainTextEdit(self) + self.det_msg = PlainTextEdit(self) self.det_msg.setReadOnly(True) self.bb.setStandardButtons(self.bb.Yes|self.bb.No|self.bb.Ok) self.bb.button(self.bb.Yes).setDefault(True)