HEXRD / hexrdgui

Qt6 PySide6 based GUI for the HEXRD library.
Other
29 stars 13 forks source link

MacOS QPushButton alignment in QTreeView #1114

Closed bnmajor closed 2 years ago

bnmajor commented 2 years ago

For some reason on the mac the styling is different than on other platforms and the QPushButton added in the tree view for the panel buffer is cut off: Screen Shot 2022-01-06 at 12 41 56 PM

When comparing the mac to linux there seems to be some sort of margin set on the button or padding set on the tree row/around the item delegate (although we don't see this issue with the checkbox): linux_margin mac_margin

After looking around for users with similar issues and attempting to adjust the style every way I could think of there were three solutions that I came up with, all of which have trade-offs:

  1. Setting the padding to zero pixels in the button style sheet. This does adjust the text but not the button border for some reason:

    mac_adjusted_padding

  2. Setting the padding to zero and setting the border in the style sheet as well. This redraws the border in the correct position but loses the mac styling (setting the style sheet on an item overrides whatever base os styling is initially applied):

    adjusted_border_mac'

  3. There is an option to set a universal style that is platform independent. This fixes the button styling issue, but applies the Linux styling across all platforms, which means Windows and Mac lose their nicer, os-consistent styling (This screenshot is on the mac):

    fusion_styling

bnmajor commented 2 years ago

@joelvbernier Do have a preference on any of these solutions?

@psavery @cjh1 If either of you have found issues like this before and have any suggestions or see something I'm missing please let me know. I keep feeling like I'm overlooking something obvious but it may be that there is just no ideal solution here...

psavery commented 2 years ago

I'm hoping to take a closer look at this later today

joelvbernier commented 2 years ago

Ranked choice: 3, 2, 1

psavery commented 2 years ago

@bnmajor For number 2, I wonder what it would look like if we added to the style sheet background-color: white?

bnmajor commented 2 years ago

@psavery Yes, I did try that but never updated my screenshots here, sorry: styled_mac_button

So the mac styling is technically still not there but it certainly doesn't look as bad. Personally this is my favorite approach. @joelvbernier Does this change your opinion at all? Or should we still stick with option 3?

joelvbernier commented 2 years ago

I think that option 2 looks pretty good! Make it so!

joelvbernier commented 2 years ago

There might be a few other places to apply this fix...

bnmajor commented 2 years ago

@joelvbernier If you come across some more let me know and I can add them onto the PR that I created. Otherwise we can always just add new fixes as the need arises.

psavery commented 2 years ago

By the way, it looks to me like the original Mac ones don't have much of a border, whereas ours has more of a border? But it doesn't matter too much.