Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically resizes status bar to width of error message string. #977

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ def update_message(self, message: str, duration: int) -> None:
continuously show message.
"""
self.status_bar.showMessage(message, duration)
new_width = self.fontMetrics().horizontalAdvance(message)
self.status_bar.setMinimumWidth(new_width)
self.status_bar.reformat()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does fix the issue where we hide part of the "reconnect..." word when the client is minimized to its smallest window size, but after reading this code I was expecting this change to fit the white error status bar to the message text (maybe it does on your system?) For example you can see what I'm seeing with "Failed to update star.":
Screenshot from 2020-03-23 11-32-22

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked into this and, while not 100% certain, I believe the following is going on:

When the status_bar is added to the parent, it (and the icon and red bar to its left) are also surrounded by padding to presumably ensure it remains properly centred.

I can only assume that the behaviour you see is simple the outcome of such an interaction between the width defined by the padding I just mentioned and the width as specified by my code. The outcome is, I guess, that there's a minimal width.

Here's where we get pragmatic. I could spend much more time on this, but would it be worth it? The text is guaranteed to be displayed by my change, and shorter text may have a larger width (because of the padding behaviour) but that will be of a uniform width, as far as I can tell.

Happy to change things around, but I don't want to dive into a rabbit hole if it's not necessary. 👍


if duration != 0:
self.status_timer.start(duration)
Expand Down