MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

Fix truncated default file name in save dialog for new scores

Open kettogg opened this issue 10 months ago • 4 comments

Resolves: #22027

https://github.com/musescore/MuseScore/assets/105774228/48655f6c-3500-4d5c-a455-94b922c8af44

  • [x] I signed the CLA
  • [x] The title of the PR describes the problem it addresses
  • [x] Each commit's message describes its purpose and effects, and references the issue it resolves
  • [x] If changes are extensive, there is a sequence of easily reviewable commits
  • [x] The code in the PR follows the coding rules
  • [x] There are no unnecessary changes
  • [x] The code compiles and runs on my machine, preferably after each commit individually

kettogg avatar Apr 23 '24 21:04 kettogg

In case of new scores, the default filename was being generated by io::filename(projectPath, false) which calls FileInfo::completeBaseName() (It uses m_filePath to get the filename by truncating it between / and .). However, for new scores that are not saved yet, Piano Sonata No. 21 in B-flat major was being set as m_filePath and hence it was getting truncated by FileInfo::completeBaseName() to just Piano Sonata No

Instead, project->metaInfo().title can be used. @cbjeukendrup lmk if this would be a correct approach.

kettogg avatar Apr 23 '24 22:04 kettogg

Thank you for this fix, as a classical music transcriber, it’s been frustrating for me to complete the title as well as add the catalog number(Opus, Köchel, whatever) and nickname. Like when I started on the Eroica symphony, it started out as Symphony no. 3 in Eb, then when I went to save it it was truncated to Symphony no. and so I had to fill out everything until I ended up with Symphony no. 3 in Eb Op. 55 (Eroica).mscz

And I’ve had to do that with a lot of other pieces too, so thank you for fixing the truncation so that I only have to do that last part of adding the catalog number and nickname.

DaddyLudwig avatar Apr 24 '24 19:04 DaddyLudwig

@re1san When importing a file, the resulting score will also be treated as newly created, but in that case the filename should be based on the name of the imported file, so calling project->metaInfo().title is no option.

I did have an idea that might help here: if projectPath is an absolute path, then it was likely an imported file (or an existing score being saved with "Save as…"). Otherwise, it's likely just a filename. So, if it's an absolute path, call io::filename(projectPath, false), otherwise io::filename(projectPath, true).

Does that make sense?

cbjeukendrup avatar Apr 25 '24 11:04 cbjeukendrup

Yeah right, it makes sense 👍🏻

kettogg avatar Apr 26 '24 02:04 kettogg

Tested on MacOS 14, Windows 11, Ubuntu 22.04.3. Approved https://github.com/musescore/MuseScore/issues/22027 FIXED

zacjansheski avatar May 01 '24 13:05 zacjansheski