diff --git a/securedrop_client/gui/__init__.py b/securedrop_client/gui/__init__.py index 1bf762bfd2..f796e3b814 100644 --- a/securedrop_client/gui/__init__.py +++ b/securedrop_client/gui/__init__.py @@ -154,16 +154,21 @@ def __init__( flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags(), wordwrap: bool = True, max_length: int = 0, + with_tooltip: bool = True, ): super().__init__(parent, flags) self.wordwrap = wordwrap self.max_length = max_length self.setWordWrap(wordwrap) # If True, wraps text at default of 70 characters + self.with_tooltip = with_tooltip self.setText(text) self.elided = True if self.text() != text else False def setText(self, text: str) -> None: self.setTextFormat(Qt.PlainText) + if self.with_tooltip: + tooltip_label = SecureQLabel(text, with_tooltip=False) + self.setToolTip(tooltip_label.text()) elided_text = self.get_elided_text(text) self.elided = True if elided_text != text else False super().setText(elided_text) @@ -179,8 +184,6 @@ def get_elided_text(self, full_text: str) -> str: fm = self.fontMetrics() filename_width = fm.horizontalAdvance(full_text) if filename_width > self.max_length: - wrapped_tool_tip = SecureQLabel(full_text) - self.setToolTip(wrapped_tool_tip.text()) elided_text = '' for c in full_text: if fm.horizontalAdvance(elided_text) > self.max_length: diff --git a/securedrop_client/gui/widgets.py b/securedrop_client/gui/widgets.py index 21209e3032..b7911503f9 100644 --- a/securedrop_client/gui/widgets.py +++ b/securedrop_client/gui/widgets.py @@ -1133,7 +1133,7 @@ def __init__(self, controller: Controller, source: Source): summary_layout.setSpacing(0) self.name = QLabel() self.name.setObjectName('source_name') - self.preview = SecureQLabel(max_length=self.PREVIEW_WIDTH) + self.preview = SecureQLabel(max_length=self.PREVIEW_WIDTH, with_tooltip=False) self.preview.setObjectName('preview') self.preview.setFixedSize(QSize(self.PREVIEW_WIDTH, self.PREVIEW_HEIGHT)) self.waiting_delete_confirmation = QLabel('Deletion in progress')