1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:48:14 +00:00

Spreadsheet: Add "Save As"

This commit is contained in:
AnotherTest 2020-08-25 01:06:32 +04:30 committed by Andreas Kling
parent 5568da9a59
commit 3320bb45d1
3 changed files with 41 additions and 0 deletions

View file

@ -107,13 +107,31 @@ int main(int argc, char* argv[])
spreadsheet_widget.load(load_path.value());
}));
file_menu.add_action(GUI::CommonActions::make_save_action([&](auto&) {
if (spreadsheet_widget.current_filename().is_empty()) {
String name = "sheet";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "json");
if (!save_path.has_value())
return;
spreadsheet_widget.save(save_path.value());
} else {
spreadsheet_widget.save(spreadsheet_widget.current_filename());
}
}));
file_menu.add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
auto current_filename = spreadsheet_widget.current_filename();
String name = "sheet";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "json");
if (!save_path.has_value())
return;
spreadsheet_widget.save(save_path.value());
if (!current_filename.is_empty())
spreadsheet_widget.set_filename(current_filename);
}));
app->set_menubar(move(menubar));