Skip to content

Add a Save As location preference - #145

Open
mindprint wants to merge 1 commit into
SublerApp:mainfrom
mindprint:save-as-location
Open

Add a Save As location preference#145
mindprint wants to merge 1 commit into
SublerApp:mainfrom
mindprint:save-as-location

Conversation

@mindprint

Copy link
Copy Markdown

Problem

Subler imports some files instead of editing them. It then makes an untitled document, which has no file URL. Thus the Save As panel does not know the source folder. The panel shows the last folder that you used.

This happens in two conditions. SBDocumentController opens mkv, mka, mks, mov, 264 and h264 files as new untitled documents. Also, Document.makeWindowControllers() sets fileURL to nil for a file that Subler cannot edit.

Subler already finds the source file for the name. MP42File.preferredFileName() reads the URL of the first track. SaveOptions puts this name in the panel. But the panel does not get the folder.

The queue does this correctly. Its Location: menu has a "Same as file" item, and QueueController.destination(for:) writes the new file next to the source file. Thus the two parts of the app do not agree.

Change

This change adds a Save As: menu to the General preferences. The menu has three items:

  • Last Used Folder. This is the default. The behaviour does not change.
  • Same as File. Subler uses the folder of the imported file.
  • Other… You select a folder. Subler then shows this folder in the menu.

SaveOptions.viewDidLoad sets savePanel.directoryURL, next to the code for the file name. Save As and Send To Queue both use Document.prepareSavePanel. Thus the two commands operate in the same manner.

MP42File.preferredFileDirectory() uses the same track lookup as preferredFileName(). Thus the name and the folder come from the same source file.

Design notes

  • The default keeps the current behaviour. Users who upgrade see no change.
  • Subler keeps one folder, not a list. The queue keeps six recent folders, because you change the queue target frequently. A preference does not need this list.
  • This change does not modify the menu of the queue. I can make the two menus use the same code, if you prefer.
  • Subler stores the folder as a security scoped bookmark, with the MP42SecurityAccessToken functions. Thus the folder stays available after a restart. The // TODO: Sandbox comment in OptionsViewController.saveRecentDestinations() asks for this.

Tests

I built the app with Xcode 26.6 and tested a sandboxed build manually. First I set the last used folder to a different folder than the source folder. If you do not do this, all three items give the same result.

Item The panel opens at
Last Used Folder the last folder that you used
Same as File the folder of the source file
Other… the folder that you selected

The selected folder stayed available after a restart. Send To Queue used the same preference.

Notes

This change does not correct #94. DocumentWindowController.export(_:) makes its own NSSavePanel and does not use prepareSavePanel. Thus subtitle export is a different path. I can correct it later.

I edited Base.lproj/GeneralPrefsViewController.xib manually as XML, to keep the difference small. Interface Builder writes the full file again, if you open and save it.

Add a General preferences option controlling where the Save As panel
opens: the last used folder (default), the same folder as the
imported file, or a custom folder chosen by the user. The custom
folder is stored as a security scoped bookmark so it stays reachable
after a relaunch, and MP42File gains a helper to find the source
file's directory when "Same as File" is selected.
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.

1 participant