-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Use file dialog filter extension on file save #27701
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
base: master
Are you sure you want to change the base?
Use file dialog filter extension on file save #27701
Conversation
|
@cbjeukendrup can you kindly take a look on this new attempt? |
aac3eb1 to
fd6bdd2
Compare
| QVariantMap resultMap = rv.val.toQVariant().toMap(); | ||
|
|
||
| io::path_t selectedPath = QUrl::fromUserInput(resultMap["path"].toString()).toLocalFile(); | ||
| std::string extension{}; |
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.
Shouldn't extension be initialised to muse::io::suffix(path)?
Or is the muse::io::suffix(path).empty() condition maybe not necessary?
Or what is the intended logic?
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.
Yeah! Probably it was not a nice code and it is hard to get the intention.
The user can fill the filename with the extension. On that specific case I won´t add the extension once the selectedPath already contains one. Maybe I can check if there is already an extension on selectedPath and extract from it. What do you think?
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.
Perhaps InteractiveProvider::openFileDialog should just be "dumb", and just return the path that the user entered, and the extension that was selected. Like this:
io::path_t selectedPath = QUrl::fromUserInput(resultMap["path"].toString()).toLocalFile();
std::string extension = resultMap["extension"].toString().toStdString();
result.val = { selectedPath, extension };Then the post processing can happen in InteractiveProvider::selectSavingFile.
I would think the logic should be something like this:
- Look at the extension of
fileInfo.val.path - If it matches one of the allowed extensions of the selected filter, then just return that path
- If it does not match one of the allowed extensions, first allowed extension of the selected filter, and append it to the path, and return that.
(One filter can namely have multiple extensions, for example for MIDI files, the allowed extensions are *.mid and *.midi.)
And of course, we need to have special handling for the * filter, and I seem to recall that on Windows, there is a special filter for "no extension", namely *.. We use that for MSCX files.
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.
Done!
Is there anything else I should do to support the MSCX files?
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.
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.
@embarc-gabriel Sorry for the delay, it was not entirely like what I was thinking of, so I pushed a commit with what I had in mind. Could you please check if this works for you?
I'll also ask our QA team to double-check that it works well on all OS.
09ee4aa to
b737a55
Compare
b737a55 to
bd28b85
Compare
|
@DmitryArefiev Could you please help testing the following:
|
|
@embarc-gabriel @cbjeukendrup Tested on Win10, Mac13.7.2, LinuxUbuntu24.04.2 LTS On Linux it crashes on save for new scores (when file browser appears to indicate the location) Screencast.from.2025-05-06.18-33-36.webm |
|
@cbjeukendrup the problem is converting the extensions on FileDialog to RetVal. Val::fromQVariant | Not supported type: QStringList |
|
@cbjeukendrup we can do something like this, for example:
We can also update the val.cpp file. |
|
First of all, apologies, I thought I had tested this, but forgot that the code in question runs only on Linux (even though it is also compiled on other OSs). Yet another option would be to change the type of But if that's too complicated, modifying |
|
@cbjeukendrup I have added a new commit with your first suggestion. |
|
@DmitryArefiev Ready for second round :) |
|
@cbjeukendrup There is a kind of regression (comparing with #11615) on Linux Screencast.from.2025-05-08.15-15-52.webm |
|
@DmitryArefiev @cbjeukendrup I didn´t understand the issue just watching the video. |
|
The problem is that the word "experimental" gets picked up as if it is the extension specification, because it is between parentheses... easiest workaround would be to change the parentheses around that word to square brackets. |
|
@cbjeukendrup should I change it on the selectScoreOpeningFile function, right? I am a little bit lost where this change should take place. |
|
Yes, and also Actually, in |
|
Fixed! Can we test it again @cbjeukendrup @DmitryArefiev ? |
|
On Linux, when saving Untitled score.mscz , it adds one period (at the end) in folder name, and two periods in file name. Screencast.from.2025-05-14.17-04-35.webm@cbjeukendrup With folder name it's probably fine.. but can we remove one period in file name (Untitled score.mscz..mscx) ? |
| || muse::contains(fileInfo.val.allowedExtensions, ALL_FILES_FILTER) | ||
| || muse::contains(fileInfo.val.allowedExtensions, WINDOWS_NO_EXTENSION_FILTER)) { |
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.
Perhaps we made a mistake here: instead of a filter, we will see an extension. So maybe the logic should be muse::contains(fileInfo.val.allowedExtensions, std::string()), to check if an empty extension is one of the allowed extensions. Because in that case, we should not add an extra ..
Resolves: audacity/audacity#8166
The file dialog is ignoring the selected filter extension on file save.