fix & improve Sampler export#4539
Conversation
377b85b to
66854d2
Compare
66854d2 to
9c64640
Compare
9c64640 to
9c66ff4
Compare
Holzhaus
left a comment
There was a problem hiding this comment.
If the file "foo.xml" already exists and I type "foo.xml" into the filename field of save file dialog (or if I just select the existing file), I'm asked if I really want to overwrite the existing file. If I just type "foo", the ".xml" suffix is appended and the file is overwritten without warning.
I'm really annoyed by havin to work around this Qt bug (missing file extension, which was fixed for Windows btw but not for Linux). |
|
Actually I'm in favor of A (IINM we'd just need to feed back the fileFilter and the file location) even though that would create small UX hickup: when clicking Save that would open the dialog again with the file and the extension being preselected. Then Save and you'd get asked if to overwrite or not. |
|
We already have the override Dialog in main? I think this is a good solution, because the is use case for overriding when the user has lets say 4 favorit sets and wants to adjust one of it. |
|
Oh, I now understand. We bypass the current solution by the added extension. |
Downside of this is that it's needed only for Linux environments which don't supply a native file dialog -- all other OS and distros would request overwrite confirmation twice :\ All in all this feels like re-inventing the wheel. We could as well use an own QFileDialog with the root issue fixed. |
|
I implemented A in #4531. It's the last two commits and for now only implemented for exporting playlists from the Playlist feature. |
9c66ff4 to
364635e
Compare
|
This is now based on #4531 so only the changes in /src/mixer are relevant. |
|
|
||
| const QString SamplerBank::samplerFiletype() { | ||
| return tr("Mixxx Sampler Banks (*.xml)"); | ||
| } |
There was a problem hiding this comment.
Doesn't feel this is the smartest way to define a tr string which is used multple times.
Are there any other ways to do that?
There was a problem hiding this comment.
QT_TR_NOOP seems to be the weapon of choice, put in the anonymous namespace.
const QString kSamplerFileType = QT_TR_NOOP("Mixxx Sampler Banks (*.xml)");
Let me know what you think.
There was a problem hiding this comment.
Shouldn't const QString kSamplerFileType = QObject::tr("Mixxx Sampler Banks (*.xml)"); work just as well? According to Qt docs, QT_TR_NOOP marks a string for "delayed translation", but I don't know what that means, maybe lazy loading of the translated string on first use?
There was a problem hiding this comment.
I'll try to test the translation for both to be sure. Never did that before though..
There was a problem hiding this comment.
Does nothing:
#define QT_TR_NOOP(x) x
https://github.com/qt/qtbase/blob/eba9196304dcc9129a7bb68db87c6fb42c953090/src/corelib/global/qglobal.h#L1356
But ... lupdate finds it so that later use of tr() with this variable can be translated.
This is demontarted here:
https://github.com/qt/qtbase/blob/fb33e2a8e82cfc28cf3c3c4bad657e0400640cb2/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp#L389
There was a problem hiding this comment.
This means the current code translates the string on every call. The proposed solution of @Swiftb0y only translates one time. However I am not sure if the translation is initialized before the string is initialized.
There was a problem hiding this comment.
Unfortunately I'm not familiar with the translation workflow, so I appreciate any advice how to proceed here.
Edit just noticed you reply below, I'll take a look.
|
#4531 is now merged. Can you rebase this again? |
|
|
||
| const ConfigKey kConfigkeyLastImportExportDirectory( | ||
| "[Samplers]", "last_import_export_directory"); | ||
| const QString kSamplerFileType = QT_TR_NOOP("Mixxx Sampler Banks (*.xml)"); |
There was a problem hiding this comment.
| const QString kSamplerFileType = QT_TR_NOOP("Mixxx Sampler Banks (*.xml)"); | |
| const char kSamplerFileType[] = QT_TR_NOOP("Mixxx Sampler Banks (*.xml)"); |
There was a problem hiding this comment.
can explain why a char[] is preferred here? QT_TR_NOOP is used nowhere else in mixxx so explaining why its used here definitively deserves explanation in the code IMO.
There was a problem hiding this comment.
ping
Shall we add a comment, then merge?
There was a problem hiding this comment.
QT_TR_NOOP should always used with char[] or char*, because the result will be used as key for fetching the translated string in tr()
https://doc.qt.io/qt-5/qobject.html#tr
Using QString will convert from char[] and back to char*
7cc97e1 to
fc9a5a2
Compare
|
Thank you! I rebased onto 2.3, added recent |
daschuer
left a comment
There was a problem hiding this comment.
LGTM.
There is still room for improving redundant translations lookups, but let's move on to more important tasks
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
fc9a5a2 to
9d7ecb5
Compare
|
Alright, done here. |
|
Okay, great. Ready! |
|
Oh sorry, I guess that is my dog food. I will prepare a fixed branch you can reset too, or we can merge this and fix it upstream. |
|
ah, okay: pre-commit, trailing whitespaces |
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
832014e to
555455e
Compare
|
Done and CI all green. |
|
Thank you! |
.xmlwas added to any specified export file even if it ended with.xml