diff --git a/securedrop_client/gui/__init__.py b/securedrop_client/gui/__init__.py index 54b1aac2d4..e40cdde42f 100644 --- a/securedrop_client/gui/__init__.py +++ b/securedrop_client/gui/__init__.py @@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . """ +import textwrap from typing import Union from PyQt5.QtWidgets import QLabel, QHBoxLayout, QPushButton, QWidget @@ -170,8 +171,13 @@ def setText(self, text: str) -> None: self.elided = True if elided_text != text else False if self.elided and self.with_tooltip: tooltip_label = SecureQLabel(text) - self.setToolTip(tooltip_label.text()) - super().setText(elided_text) + tooltip_text = tooltip_label.text() + if tooltip_text.find("\n") != -1: + tooltip_text = "".join(tooltip_text.split("\n")) + self.setToolTip(tooltip_text) + + wrapped = "\n".join(textwrap.wrap(elided_text)) + super().setText(wrapped) def get_elided_text(self, full_text: str) -> str: if not self.max_length: