Skip to content

Conversation

irrenhaus3
Copy link
Contributor

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.

@tresf
Copy link
Member

tresf commented Jul 21, 2017

Do not have a hard-coded order at all

This seems like the best solution.

return ProjectRenderer::MP3File;
#endif // If neither ogg nor mp3 are available, index 1 is OOB; fall through to default case
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.
@tresf
Copy link
Member

tresf commented Jul 21, 2017

@irrenhaus3 this is very clean, thank you. Can you please reformat the code to use tabs instead of spaces? Sorry for the inconvenience.

@PhysSong
Copy link
Member

PhysSong commented Jul 25, 2017

@irrenhaus3 @tresf Did you test it for every configuration?

@tresf
Copy link
Member

tresf commented Jul 25, 2017

I did not test this PR at all.

@irrenhaus3
Copy link
Contributor Author

@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
It should therefore work for any arbitrary flag configuration and continue to work when new flags are added in the future.

@PhysSong
Copy link
Member

I'll do a final test and merge it soon. Thanks for your work, @irrenhaus3!

@PhysSong
Copy link
Member

Tested and works good. I'll merge it soon if there's no objection.

@PhysSong PhysSong merged commit c8af34a into LMMS:master Jul 26, 2017
PhysSong pushed a commit that referenced this pull request Jul 27, 2017
* 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.
@PhysSong
Copy link
Member

Backported via b83c1bd.

sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
* 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.
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
* 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.
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.

3 participants