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

Conversation

ntoll
Copy link
Contributor

@ntoll ntoll commented Mar 23, 2020

Description

Fixes #932.

I use the FontMetric instance on the status_bar object to set the new minimum width, then reformat to dynamically adjust the width.

Screenie:

error_width

Test Plan

Eyeball Mk1 to ensure the UI changes take effect as expected. 👀

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, packaging logic (e.g., the AppArmor profile) may need to be updated. Please check as applicable:

  • I have submitted a separate PR to the packaging repo
  • No update to the packaging logic (e.g., AppArmor profile) is required for these changes
  • I don't know and would appreciate guidance

@@ -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. 👍

@sssoleileraaa
Copy link
Contributor

Today we agreed to merge this even though it doesn't auto-resize the status bar for smaller messages. This can be iterated on in the future.

@sssoleileraaa sssoleileraaa force-pushed the error-width-in-minimized-window branch from e7ef860 to 7e10d2a Compare March 24, 2020 19:08
@sssoleileraaa sssoleileraaa merged commit 43eeba5 into freedomofpress:master Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reconnecting text gets cut off on minimized window
3 participants