Device GUI window size constraints #1508
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed a problem whereby somewhat randomly, a Device GUI would not be displayed properly. One way to repeatedly reproduce this issue is to maximize the window (although there currently isn't any code to do that - I found it while trying to track down the original problem).
This problem appears to be due to the way the size of windows are currently constrained, by having a resizeEvent handler, that ignores the requested size, and calls adjustSize(), which resizes to the minimum size hint instead. I think this code was added to prevent the Tile windows button from making the Device windows too big, as the Tile code seems to ignore the Fixed size policy.
However, it seems the problem can be fixed by calling setMinimumSize() and setMaximumSize() for the window, and Tile respects these constraints.
To avoid hardcoding sizes, I added the sizeToContents() function, which calculates the min/max window size from the .ui file. It also picks up the sizePolicy from the .ui file as well, so the hardcoding for that has been able to be removed.
With the problem resolved, it's now possible to call showMaximized(), without windows being corrupted. I therefore thought it might be useful to add a Maximize window button, as we already have a Shrink button:
However, most of the Device GUIs are fixed size, so these buttons and the resize grip are redundant, so I thought I'd hide them in sizeToContents() if the size policy was Fixed in both directions. This helps to declutter the title bar a little bit:
If you're happy with the changes, I can then do the same for Channels and Features. (I'm not particularly bothered about the Maximize button, if you don't want it. More useful for some of the Features/Channels though)