1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 03:08:13 +00:00

Spreadsheet: Merge File menu into 'Spreadsheet' app menu

This is the common convention among the other apps. Also remove
a superfluous separator
This commit is contained in:
thankyouverycool 2021-02-26 07:12:08 -05:00 committed by Andreas Kling
parent a2e935e7a2
commit 132ca7e37b

View file

@ -109,7 +109,39 @@ int main(int argc, char* argv[])
app_menu.add_action(GUI::Action::create("Add New Sheet", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"), [&](auto&) {
spreadsheet_widget.add_sheet();
}));
app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
Optional<String> load_path = GUI::FilePicker::get_open_filepath(window);
if (!load_path.has_value())
return;
spreadsheet_widget.load(load_path.value());
}));
app_menu.add_action(GUI::CommonActions::make_save_action([&](auto&) {
if (spreadsheet_widget.current_filename().is_empty()) {
String name = "workbook";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "sheets");
if (!save_path.has_value())
return;
spreadsheet_widget.save(save_path.value());
} else {
spreadsheet_widget.save(spreadsheet_widget.current_filename());
}
}));
app_menu.add_action(GUI::CommonActions::make_save_as_action([&](auto&) {
auto current_filename = spreadsheet_widget.current_filename();
String name = "workbook";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "sheets");
if (!save_path.has_value())
return;
spreadsheet_widget.save(save_path.value());
if (!current_filename.is_empty())
spreadsheet_widget.set_filename(current_filename);
}));
app_menu.add_separator();
app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
@ -124,41 +156,6 @@ int main(int argc, char* argv[])
return GUI::Window::CloseRequestDecision::StayOpen;
};
auto& file_menu = menubar->add_menu("File");
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
Optional<String> load_path = GUI::FilePicker::get_open_filepath(window);
if (!load_path.has_value())
return;
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 = "workbook";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "sheets");
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 = "workbook";
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, name, "sheets");
if (!save_path.has_value())
return;
spreadsheet_widget.save(save_path.value());
if (!current_filename.is_empty())
spreadsheet_widget.set_filename(current_filename);
}));
auto& edit_menu = menubar->add_menu("Edit");
edit_menu.add_action(GUI::CommonActions::make_copy_action([&](auto&) {
/// text/x-spreadsheet-data:
@ -241,8 +238,6 @@ int main(int argc, char* argv[])
},
window));
app_menu.add_separator();
help_menu.add_action(GUI::CommonActions::make_about_action("Spreadsheet", app_icon, window));
app->set_menubar(move(menubar));