Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
315 stars 135 forks source link

[UI] DB edits in Options dialog #570

Closed xzfantom closed 3 years ago

xzfantom commented 3 years ago

Edits for folders on Database tab in Options don't stretch out (at least in Windows).

изображение

This elements are created in code and due lack of experience I couldn't manage how to make them stretch like other elements, that were created in QTCreator. setSizePolicy and setMaximumLength don't work for me.

matty0ung commented 3 years ago

This is usually pretty simple to fix: change BtLineEdit to QLineEdit for the relevant entry field. BtLineEdit is only needed for numeric fields, where it adds the logic to convert units (eg °F to °C, or grams to kilograms, etc). Its mechanism for deciding its width (which has to work on regular and high DPI displays) is pretty primitive (which I know because I wrote it!). QLineEdit is sufficient for text fields and has better built-in logic for deciding what width it should be.

matty0ung commented 3 years ago

(From a quick look, I already did these two fields in Brewken, but didn't yet port it back to Brewtarget.)

Alternatively, we could try to make BtLineEdit smarter about giving width hints to Qt or see if we can remove all its hints and get it to behave the same as QLineEdit with regards to layout.

xzfantom commented 3 years ago

Alternatively, we could try to make BtLineEdit smarter about giving width hints to Qt or see if we can remove all its hints and get it to behave the same as QLineEdit with regards to layout.

If BtLineEdit is used mostly for units, not a big deal if it can't stretch. I think using more appropriate widget is best approach.

mikfire commented 3 years ago

I would prefer to make BtLineEdits smarter. Frankly, they should just be inheriting from QLineEdit on most things.

I really like consistency. Please do not ask me to think "Do I need a QLineEdit here, or a BtLineEdit", because I promise I will get it wrong.

mikfire commented 3 years ago

Having looked at it, the reason it doesn't expand is I am building those grids in code and it's not always obvious how the parameters interplay.

There are any number of places in the code where the BtLineEdit does expand correctly. BtLineEdit inherits from QLineEdit and really just overrides the display methods. Everything else should work for a BtLineEdit as it does for a QLineEdit.

Let me see if I can make some sense of this.

mikfire commented 3 years ago

I have a fix for this, but it is cascading into something larger. Give me a day or three and then I will discuss the PR.

xzfantom commented 3 years ago

Closed in #575