Skip to content

Conversation

@consolegrl
Copy link
Contributor

Summary
This is a bug fix for an unnoticed issue "File Browser filters do nothing" The built-in file extension filers are ignored on the top level leading to a messy projects directory.

Before, the File Browser would show any and all files in the projects directory, despite an existing filter in MainWindow.cpp "*.mmp *.mmpz *.xml *.mid" which FileBrowser was ignoring at the top level, but passed down to Directory, which used it correctly and in a modern way.

Background
I was trying to add a way to show/hide the .bak and other files with some filter buttons when I noticed the code in Directory::addItems was a modernized copy pasta of the older style (not using good Qt 5 conventions) FileBrowser::addItems.

In addition, only, FileBrowser::addItems was not respecting the filter's at all. I brought both of them into line with Qt 5 practices which now respects the m_filter list of extensions for both FileBrowser and Directory. In Directory::addItems I only needed to change where the match was being done, FileBrowser::addItems didn't try to filter/match at all.

Conflict
After doing all this I noticed that #6339 has been working on something similar (dare I say better!) to what I was going to do before I discovered this bug.

I would like to help out or take over that work so we can all have nice file browser filter buttons like Blender :)
@allejok96 hit me up!

I have checked out the current state of #6339 and it segfaults unfortunately; things have moved on a bunch (209 commits behind, woof!)

I am also willing to integrate #5772 and #6189 into this work if need be as these are all sore spots for me when using LMMS daily.

I was trying to add a way to show/hide the .bak and other files with some
filter buttons when I noticed the code in FileBrowser::addItems was copy
pasta that had lava flowed from the much more modern Directory::addItems.
In addition, only, FileBrowser::addItems was not respecting the filter's
at all. I brought both of them into line with Qt 5 practices which
now respects the m_filter list of extensions for both FileBrowser
and Directory. In Directory::addItems I only needed to change where
the match was being done, FileBrowser::addItems didn't try to
filter/match at all.
@zonkmachine
Copy link
Contributor

zonkmachine commented Sep 21, 2023

I would like to help out or take over that work so we can all have nice file browser filter buttons like Blender :)
@allejok96 hit me up!

He took a break from coding and left a note here: #6700 (comment).
I read that as 'Go ahead and pick it up from where he left...'

@consolegrl
Copy link
Contributor Author

I would like to help out or take over that work so we can all have nice file browser filter buttons like Blender :)
@allejok96 hit me up!

He took a break from coding and left a note here: #6700 (comment). I read that as 'Go ahead and pick it up from where he left...'

Ah, how does one contribute to a PR, let alone take it over?

@Veratil
Copy link
Contributor

Veratil commented Sep 21, 2023

Ah, how does one contribute to a PR, let alone take it over?

A few ways, but for this you can pull the PR and start from there on your own branch.

@consolegrl
Copy link
Contributor Author

He took a break from coding and left a note here: #6700 (comment).

If that's the case, I would like to start from here, I don't relish the idea of trying to bring all their work forward through 200+ commits, I will ofc pilfer some of the better ideas and patterns from it for the glory of Lommus.

@zonkmachine
Copy link
Contributor

for the glory of Lommus.

This is the way.

Copy link
Member

@DomClark DomClark left a comment

Choose a reason for hiding this comment

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

Looking much cleaner now, good job! Only a couple of comments.

Some fixes for const iterating the file list.
Setting file name filters along with the call instead of seperately.
@consolegrl consolegrl requested a review from DomClark September 27, 2023 15:28
Copy link
Contributor

@sakertooth sakertooth left a comment

Choose a reason for hiding this comment

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

LGTM, tested and working. Just some formatting suggestions.

@sakertooth sakertooth merged commit 6bde53e into LMMS:master Oct 21, 2023
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.

5 participants