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

playlist export: add missing file extension #4531

Merged
merged 4 commits into from
Dec 17, 2021

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Nov 19, 2021

original bug https://bugs.launchpad.net/mixxx/+bug/1197302
follow-up https://bugs.launchpad.net/mixxx/+bug/1889352
the fix from #430 got lost somehow.

related pending bug:
"extension is not autocompleted in dialog"
https://bugs.launchpad.net/mixxx/+bug/1455749

@ronso0 ronso0 added this to the 2.3.2 milestone Nov 19, 2021
src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Nov 23, 2021

@uklotzde Refactored to use regexp in util/string.h

@ronso0
Copy link
Member Author

ronso0 commented Nov 23, 2021

for anyone testing this without reading the code:
the file dialog behaves unexpectedly, but predictably. this behaviour is caused by QFileDialog itself, not the changes of this PR.

  • if the current file name has no suffix the selected suffix is not appended
  • if there IS a 'suffix' it is replaced. Though ANY .-separated segement at the end is replaced

so for example
Birtday-party-15.9.2021
becomes
Birtday-party-15.9.m3u

src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
src/library/crate/cratefeature.cpp Outdated Show resolved Hide resolved
src/library/crate/cratefeature.cpp Outdated Show resolved Hide resolved
src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Nov 29, 2021

ping, this is ready.

src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
src/library/baseplaylistfeature.cpp Outdated Show resolved Hide resolved
src/library/crate/cratefeature.cpp Outdated Show resolved Hide resolved
src/library/crate/cratefeature.cpp Outdated Show resolved Hide resolved
src/util/string.h Outdated Show resolved Hide resolved
src/util/string.h Outdated Show resolved Hide resolved
src/util/string.h Outdated Show resolved Hide resolved
src/library/crate/cratefeature.cpp Show resolved Hide resolved
src/util/string.h Outdated Show resolved Hide resolved
src/util/string.h Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Dec 8, 2021

This has grown way beyond re-applying an old 10-line commit. @Swiftb0y @uklotzde I'll try to wrap my head around your sugestions when I find time. Feel free to finish it.

@Swiftb0y
Copy link
Member

Swiftb0y commented Dec 8, 2021

@ronso0, I took the liberty and pushed my changes directly to your branch so my changes don't get detached from the PR.

@ronso0
Copy link
Member Author

ronso0 commented Dec 9, 2021

Perfecto, thanks!

Comment on lines 40 to 42
const ConfigKey kConfigKeyLastImportExportCrateDirectoryKey(
"[Library]", "last_import_export_crate_directory");

Copy link
Member

@Swiftb0y Swiftb0y Dec 12, 2021

Choose a reason for hiding this comment

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

@uklotzde I'd like to hear your opinion on this. Instead of defining kConfigKeyLastImportExportCrateDirectoryKey in a bunch of cpp files all at once, put it in a header file under the mixxx namespace and then #include it where its needed. Does that make sense, what do you need to specify for it to work? something like inline const ConfigKey ...?

nevermind, its not defined in more than one translation unit. Don't know how I got that idea.

@ronso0
Copy link
Member Author

ronso0 commented Dec 12, 2021

Now that the cleanup is done I'd prefer to squash the later commits into 0171cc3 and 3d78e2f, so we have 3 instead of 7 commits.
Okay?

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

LGTM, though I'm not sure if I'm allowed to merge since this PR does contain commits I made.

@ronso0
Copy link
Member Author

ronso0 commented Dec 12, 2021

sqashed, rebased, tested if all commits build.
Ready for final review.

@ronso0 ronso0 added the changelog This PR should be included in the changelog label Dec 12, 2021
@ronso0
Copy link
Member Author

ronso0 commented Dec 12, 2021

LGTM, though I'm not sure if I'm allowed to merge since this PR does contain commits I made.

I think it doesn't make a difference if your review proposals are implemented or if you implment them yourself.
@uklotzde could take a final look though.

@ronso0
Copy link
Member Author

ronso0 commented Dec 12, 2021

pushed again because I squashing wiped your co-authorship @Swiftb0y

@ronso0
Copy link
Member Author

ronso0 commented Dec 13, 2021

Btw the overwrite issue @Holzhaus discovered in #4539 occurs here as well.

@ronso0
Copy link
Member Author

ronso0 commented Dec 14, 2021

The last two commits contain the experimental workaround for the QFileDialog suffix bug (with the Qt dialog).
We could merge filePathWithSelectedExtension() into the new function if there's no spot where we need it without the file dialog.

return fileLocation;
}

QString checkedFilePathWithSelectedExtension(const QString& caption,
Copy link
Member

Choose a reason for hiding this comment

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

The function name sounds as if it will just do the check. It also pops up a dialog.
This should be expressed by the name.
Something like:
SaveFileDialogWithVerifiedExtension() or such

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, thank you. consider this WIP and the name will be adjusted.
What I care about here is whether this approach works for everyone, or not.

if this get's sufficient 👍 I'll implement it in other places, too, and change the name.

Copy link
Member Author

Choose a reason for hiding this comment

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

considering the return value I'd name it filePathWithVerifiedExtensionFromFileDialog

Copy link
Member

Choose a reason for hiding this comment

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

Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Try to name functions starting with an imperative verb if possible. Like good commit messages ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

getFilePathWithVerifiedExtensionFromFileDialog ;)

@daschuer
Copy link
Member

I have tested this and it works quite good. Since the roundtrip happens only in an exceptional case, it is a good solution.

I have noticed if you, misspell the extension, the correctly spelled extension is appended.
I guess that is the expected behavior ...

I think we can merge it after the function name has been adjusted.

@daschuer
Copy link
Member

@uklotzde Are all your review findings solved.

@ronso0
Copy link
Member Author

ronso0 commented Dec 15, 2021

I'll address @Swiftb0y's recent comments after implementing the new dialog.

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

The naming could be improved, but I don't have concerns regarding the code. Merge when ready.

return fileLocation;
}

QString checkedFilePathWithSelectedExtension(const QString& caption,
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to name functions starting with an imperative verb if possible. Like good commit messages ;)

@ronso0
Copy link
Member Author

ronso0 commented Dec 16, 2021

Okay then, thanks for reviewing!
As usual I'll squash all this back and forth changes into a few easily digestible commits.

@ronso0
Copy link
Member Author

ronso0 commented Dec 17, 2021

Done. Every commit builds and works as intended.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you for all these bug fixes of this type. That makes really a difference.

@daschuer daschuer merged commit 4e0ae6e into mixxxdj:2.3 Dec 17, 2021
@ronso0 ronso0 deleted the playlist-export-extension branch December 17, 2021 11:57
@ronso0 ronso0 mentioned this pull request Jan 15, 2022
m_pConfig->set(ConfigKey("[Library]", "LastImportExportPlaylistDirectory"),
ConfigValue(fileName.dir().absolutePath()));
QString fileDirectory(playlistFile);
fileDirectory.truncate(playlistFile.lastIndexOf(QDir::separator()));
Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect this always truncates at position 0, see https://bugs.launchpad.net/bugs/1964508

Native separator is \ on Windows and maybe Qt has already converted the path to use /? In that case lastIndexOf("\") would return -1 which is equivalent to passing 0 to truncate
https://doc.qt.io/qt-5/qstring.html#truncate
It is not recommended to use QDir::separator() for constructing paths, but appearantly it also creates issues when computing paths
https://doc.qt.io/qt-5/qdir.html#separator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This PR should be included in the changelog library regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants