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

Align the rename box for tracks #7414

Merged
merged 6 commits into from
Oct 7, 2024
Merged

Conversation

BaraMGB
Copy link
Contributor

@BaraMGB BaraMGB commented Aug 1, 2024

Fixing #7413 , on rename we set the text of the TrackLabelButton to an empty String. After renaming we set the text to the tracks name.

It's my first PR after a cuple of years. I hope I did it right.;)

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 1, 2024

Wow, another dev returns.

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 1, 2024

Looks like this is related to #7114 and #7209, @michaelgregorius you have any idea?

@sakertooth
Copy link
Contributor

I think it would be better for the renaming box to be "inlined" with the text box. When the user wants to rename the track, it would replace the text box with the renaming box itself, but that might be more work.

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 1, 2024

@sakertooth i agree. That should be the default approach, @BaraMGB hope you can implement that method without much issues.

@BaraMGB
Copy link
Contributor Author

BaraMGB commented Aug 1, 2024

Yes, I will have a look at this. Shouldn't be that difficult.

@michaelgregorius
Copy link
Contributor

Looks like this is related to #7114 and #7209, @michaelgregorius you have any idea?

In how far do you think it is related? As in "is caused by it"? IIRC, #7209 only undoes some of the changes that have been made with #7114.

@BaraMGB
Copy link
Contributor Author

BaraMGB commented Aug 2, 2024

I reverted the hiding approach and lined up the ReadLine to the TrackLabelButtons text.

@Rossmaxx
Copy link
Contributor

Rossmaxx commented Aug 2, 2024

In how far do you think it is related? As in "is caused by it"?

I suspected that #7114 caused it. About the undoing, i thought the rename line edit was left out, causing the bug.

Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

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

Style review. Also might help if you posted a screenshot demonstrating the fix.

src/gui/tracks/TrackLabelButton.cpp Outdated Show resolved Hide resolved
src/gui/tracks/TrackLabelButton.cpp Outdated Show resolved Hide resolved
src/gui/tracks/TrackLabelButton.cpp Outdated Show resolved Hide resolved
@BaraMGB
Copy link
Contributor Author

BaraMGB commented Aug 2, 2024

readLine_lmms

@@ -60,8 +63,8 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) :
else
{
setFixedSize( 160, 29 );
m_renameLineEdit->move( 30, ( height() / 2 ) - ( m_renameLineEdit->sizeHint().height() / 2 ) );
m_renameLineEdit->setFixedWidth( width() - 33 );
m_renameLineEdit->move(25, ( height() / 2 - m_renameLineEdit->sizeHint().height() / 2 ) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just thought of this now, is it possible to use layouts to dynamically place the line edit widget instead of calling move() explicitly? Sorry for the nitpicks, have to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there an example of using layouts in the code base? So I can see, how it works?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the MixerChannelView now uses layout to handle something similar.

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 will have a look. I need to build for Windows and Mac, too. So I can see if it looks all the same on all systems.

Copy link
Contributor

Choose a reason for hiding this comment

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

@BaraMGB, if you search for QVBoxLayout, QHBoxLayout or QBoxLayout you should find several places in the code. Another type of layout is QGridLayout.

I think it might even make sense to add a new widget for the label/line edit combination which implements the switching.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I don't see the benefits of your idea. The current implementation is clean and works perfect. Actually this is only a simple bug fix PR. I don't see, why we should it make more complicated as it is. If someone wants to make the width of the track header dynamic one day, he could do it. But in my opinion, this goes beyond the purpose of this pull request.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe TrackContentWidget already uses a QHBoxLayout and calling move() explicitly might have different results depending on the host system.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I don't see the benefits of your idea. The current implementation is clean and works perfect. Actually this is only a simple bug fix PR. I don't see, why we should it make more complicated as it is. If someone wants to make the width of the track header dynamic one day, he could do it. But in my opinion, this goes beyond the purpose of this pull request.

I think it might be a bit more stable solution than the current one as can be seen by this issue. I agree that it is not in the scope of this PR though. It was just meant as some food for thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaelgregorius I guess, the best option for this, is to use the QLineEdit itself. There should not need a stacked widget, because the QLineEdit has got 2 modes, a label mode and an edit mode. I try to push a new commit in the next days. Thank you for your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

[...] the QLineEdit has got 2 modes, a label mode and an edit mode.

That sounds even better! 😃

@sakertooth sakertooth linked an issue Aug 5, 2024 that may be closed by this pull request
1 task
@sakertooth sakertooth changed the title fix: #7413: Renaming track visual glitch Align the rename box for tracks Aug 5, 2024
Make sure that the rename line edit of the `TrackLabelButton` has the
same font size as the widget itself. Because the font size is defined
via style sheets the font size of the line edit has to be set when the
actual renaming starts and not in the constructor. The reason is that
style sheets are set after the constructor has run.

Rename the local variable `txt` to the more speaking name `trackName`.

Ensure that the line edit is moved to the correct place for different
icon sizes by taking the icon size into account. To make this work this
also has to be done in the `rename` method.
Streamline the default style sheet of `TrackLabelButton` by removing
repeated properties that are inherited from the "main" style sheet, i.e.
that are already part of `lmms--gui--TrackLabelButton`.

Interestingly, the `background-color` property had to be repeated for
`lmms--gui--TrackLabelButton:hover`.
Copy link
Contributor

@michaelgregorius michaelgregorius left a comment

Choose a reason for hiding this comment

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

I have added some additional improvements with commit c60b5fe and 2278f7a. For me this is good to go now as it fixes the problem and "perfect is the enemy of the good".

@michaelgregorius michaelgregorius merged commit 066f6b5 into LMMS:master Oct 7, 2024
11 checks passed
@michaelgregorius
Copy link
Contributor

I have merged this pull request now as it solves the problem. Any potential further improvements can be done in separate pull requests.

mmeeaallyynn pushed a commit to mmeeaallyynn/lmms that referenced this pull request Oct 27, 2024
Align the rename line edit for tracks.

Make sure that the rename line edit of the `TrackLabelButton` has the
same font size as the widget itself. Because the font size is defined
via style sheets the font size of the line edit has to be set when the
actual renaming starts and not in the constructor. The reason is that
style sheets are set after the constructor has run.

Rename the local variable `txt` to the more speaking name `trackName`.

Ensure that the line edit is moved to the correct place for different
icon sizes by taking the icon size into account. To make this work this
also has to be done in the `rename` method.

## Other changes

Streamline the default style sheet of `TrackLabelButton` by removing
repeated properties that are inherited from the "main" style sheet, i.e.
that are already part of `lmms--gui--TrackLabelButton`.

Interestingly, the `background-color` property had to be repeated for
`lmms--gui--TrackLabelButton:hover`.

---------

Co-authored-by: Michael Gregorius <[email protected]>
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.

Renaming track visual glitch
4 participants