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

Gui: allow LineEdit to grow with text - fixes #17747 #18099

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

VincidaB
Copy link

This adds a DynamicQLineEdit dynamic class for the model Tree so that the edit field can grow with what is being typed during renaming. This fixes #17747 .

2024-11-23.16-58-11.mp4

I am not sure if this merits an new class or if it should have been added to ExpLineEdit. (I didn't want to disturb the existing class).

@github-actions github-actions bot added the Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Nov 23, 2024
src/Gui/Tree.cpp Outdated
Comment on lines 552 to 553
int availableWidth = parentWidget()->width() - geometry().x() - 20; // Calculate available width
size.setWidth(std::min(fm.horizontalAdvance(text()) + 30, availableWidth)); // Add some padding and max width
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are 20 and 30 come from?

Copy link
Author

Choose a reason for hiding this comment

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

Some padding as to not overflow on the right, but might not be necessary.
I'll remove it and test.

Copy link
Author

@VincidaB VincidaB Nov 27, 2024

Choose a reason for hiding this comment

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

I changed the 30 to :

2 * (style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1)
                    + 2 * style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing)
                    + TreeParams::getItemBackgroundPadding();

I took inspiration from QRect TreeWidgetItemDelegate::calculateItemRect(), but I am not certain of what I did.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kadet1090 can you explain?

src/Gui/Tree.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI: Tree view renaming field does not automatically expand and the default can be very small
2 participants