Use native file dialog save on Desktop

We now instantiate a file save dialog to allow saving wav files on
Desktop.
This commit is contained in:
Sebastian Lohff 2025-02-24 02:07:08 +01:00
parent b6bbc80062
commit d709625ca0
1 changed files with 17 additions and 2 deletions

View File

@ -107,8 +107,23 @@ func _on_wav_button_pressed() -> void:
var proposed_fname := "morse-" + Time.get_datetime_string_from_system(true) + ".wav"
match OS.get_name():
"Linux", "macOS", "Windows":
wav.save_to_wav("/tmp/foo.wav")
print("GLobalized path: " + ProjectSettings.globalize_path("user://morse.wav"))
print("Save on ", OS.get_name())
# create file dialog
var fd := FileDialog.new()
fd.title = "Save Wav file"
fd.use_native_dialog = true
fd.add_filter("*.wav", "WAV files")
fd.current_file = proposed_fname
var save_method := func _save(path: String):
print("Save as ", path)
wav.save_to_wav(path)
fd.file_selected.connect(save_method)
add_child(fd)
fd.popup_centered()
"Android":
print("Sharing file on android")
var tmp_file_path := OS.get_user_data_dir().path_join(proposed_fname)