summaryrefslogtreecommitdiff
path: root/Applications/Spreadsheet/main.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-08-25 01:06:32 +0430
committerAndreas Kling <kling@serenityos.org>2020-08-25 09:46:28 +0200
commit3320bb45d1cd5df66e3f29c55f5aacb112308b95 (patch)
treedef755a3d8ca7ba00bf1b5b379ce2c0b4d559308 /Applications/Spreadsheet/main.cpp
parent5568da9a59df8d2f68849345338f9263ae0cbae0 (diff)
downloadserenity-3320bb45d1cd5df66e3f29c55f5aacb112308b95.zip
Spreadsheet: Add "Save As"
Diffstat (limited to 'Applications/Spreadsheet/main.cpp')
-rw-r--r--Applications/Spreadsheet/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Applications/Spreadsheet/main.cpp b/Applications/Spreadsheet/main.cpp
index b0c7eaa393..d45f4c0ba6 100644
--- a/Applications/Spreadsheet/main.cpp
+++ b/Applications/Spreadsheet/main.cpp
@@ -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));