-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Respect build options in ExportProjectDialog #3714
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
Conversation
This seems like the best solution. |
src/gui/ExportProjectDialog.cpp
Outdated
return ProjectRenderer::MP3File; | ||
#endif // If neither ogg nor mp3 are available, index 1 is OOB; fall through to default case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard to read and will be even harder to add new items to. Let's instead parse "OGG, WAV, MP3" from the dropdown and make our assumptions there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But I don't think parsing strings is the best solution either. I think it's best to use the User Data field in QItem to tag each combo box item directly with the ProjectRenderer::ExportFileFormat, converted to int. That way, we can extract this value in onFileFormatChanged, convert it back to the enum type, and work directly with it. This would also make this dialog a lot more extensible for the purpose of adding more renderers.
I'll work on it and update this pull request once I have something that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think parsing strings is the best solution either.
The dialog mandates a file extension filter. Parsing string is perfectly sane here. I prefer enum approaches too and we need them elsewhere, but I see no logic flaw in .ogg
= OGG
at this point. It's not going to change.
…t in ExportProjectDialog For compatibility with QVariant, ExportFileFormats is now explicitly an int.
@irrenhaus3 this is very clean, thank you. Can you please reformat the code to use tabs instead of spaces? Sorry for the inconvenience. |
@irrenhaus3 @tresf Did you test it for every configuration? |
I did not test this PR at all. |
@PhysSong @tresf I didn't test it for every configuration, just for (OGG enabled, MP3 disabled) and (both enabled). However, this PR specifically removes the need to check these configurations in the UI code and replaces them with runtime checks on whatever is available after this initialization: https://github.com/irrenhaus3/lmms/blob/6368bf1c886b961cbafe168c5d650eede62eb980/src/core/ProjectRenderer.cpp#L39 |
I'll do a final test and merge it soon. Thanks for your work, @irrenhaus3! |
Tested and works good. I'll merge it soon if there's no objection. |
* Respect build options in ExportProjectDialog * Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog * For compatibility with QVariant, ExportFileFormats is now explicitly an int. * Don't break out of format identifier loop prematurely in Song export.
Backported via b83c1bd. |
* Respect build options in ExportProjectDialog * Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog * For compatibility with QVariant, ExportFileFormats is now explicitly an int. * Don't break out of format identifier loop prematurely in Song export.
* Respect build options in ExportProjectDialog * Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog * For compatibility with QVariant, ExportFileFormats is now explicitly an int. * Don't break out of format identifier loop prematurely in Song export.
Addresses issue #3713 by implementing a workaround on the existing hard-coded ordering. This is obviously not the optimal solution because the core problem is the hard-coded ordering itself.