Skip to content

Commit

Permalink
Fixes #815 adds wordwrap for SecureQLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
kushaldas committed Apr 7, 2020
1 parent 56e0981 commit 9373be6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions securedrop_client/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import textwrap
from typing import Union

from PyQt5.QtWidgets import QLabel, QHBoxLayout, QPushButton, QWidget
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9373be6

Please sign in to comment.