mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Spreadsheet: Propagate errors from SpreadsheetWidget::initialize_menubar
This commit is contained in:
parent
1e275dd942
commit
b746d324cf
Notes:
sideshowbarker
2024-07-17 03:51:15 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/b746d324cf Pull-request: https://github.com/SerenityOS/serenity/pull/18165 Reviewed-by: https://github.com/alimpfard ✅
3 changed files with 35 additions and 33 deletions
|
@ -646,40 +646,42 @@ void SpreadsheetWidget::clipboard_action(bool is_cut)
|
|||
GUI::Clipboard::the().set_data(text_builder.string_view().bytes(), "text/plain", move(metadata));
|
||||
}
|
||||
|
||||
void SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
||||
ErrorOr<void> SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto& file_menu = window.add_menu("&File");
|
||||
file_menu.add_action(*m_new_action);
|
||||
file_menu.add_action(*m_open_action);
|
||||
file_menu.add_action(*m_save_action);
|
||||
file_menu.add_action(*m_save_as_action);
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(*m_import_action);
|
||||
file_menu.add_separator();
|
||||
file_menu.add_recent_files_list([&](auto& action) {
|
||||
if (!request_close())
|
||||
return;
|
||||
auto file_menu = TRY(window.try_add_menu("&File"));
|
||||
TRY(file_menu->try_add_action(*m_new_action));
|
||||
TRY(file_menu->try_add_action(*m_open_action));
|
||||
TRY(file_menu->try_add_action(*m_save_action));
|
||||
TRY(file_menu->try_add_action(*m_save_as_action));
|
||||
TRY(file_menu->try_add_separator());
|
||||
TRY(file_menu->try_add_action(*m_import_action));
|
||||
TRY(file_menu->try_add_separator());
|
||||
TRY(file_menu->add_recent_files_list([&](auto& action) {
|
||||
if (!request_close())
|
||||
return;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
||||
if (response.is_error())
|
||||
return;
|
||||
load_file(response.value().filename(), response.value().stream());
|
||||
})
|
||||
.release_value_but_fixme_should_propagate_errors();
|
||||
file_menu.add_action(*m_quit_action);
|
||||
auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text());
|
||||
if (response.is_error())
|
||||
return;
|
||||
load_file(response.value().filename(), response.value().stream());
|
||||
}));
|
||||
TRY(file_menu->try_add_action(*m_quit_action));
|
||||
|
||||
auto& edit_menu = window.add_menu("&Edit");
|
||||
edit_menu.add_action(*m_undo_action);
|
||||
edit_menu.add_action(*m_redo_action);
|
||||
edit_menu.add_separator();
|
||||
edit_menu.add_action(*m_cut_action);
|
||||
edit_menu.add_action(*m_copy_action);
|
||||
edit_menu.add_action(*m_paste_action);
|
||||
edit_menu.add_action(*m_insert_emoji_action);
|
||||
auto edit_menu = TRY(window.try_add_menu("&Edit"));
|
||||
TRY(edit_menu->try_add_action(*m_undo_action));
|
||||
TRY(edit_menu->try_add_action(*m_redo_action));
|
||||
TRY(edit_menu->try_add_separator());
|
||||
TRY(edit_menu->try_add_action(*m_cut_action));
|
||||
TRY(edit_menu->try_add_action(*m_copy_action));
|
||||
TRY(edit_menu->try_add_action(*m_paste_action));
|
||||
TRY(edit_menu->try_add_action(*m_insert_emoji_action));
|
||||
|
||||
auto& help_menu = window.add_menu("&Help");
|
||||
help_menu.add_action(*m_search_action);
|
||||
help_menu.add_action(*m_functions_help_action);
|
||||
help_menu.add_action(*m_about_action);
|
||||
auto help_menu = TRY(window.try_add_menu("&Help"));
|
||||
TRY(help_menu->try_add_action(*m_search_action));
|
||||
TRY(help_menu->try_add_action(*m_functions_help_action));
|
||||
TRY(help_menu->try_add_action(*m_about_action));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
return current_view()->cursor();
|
||||
}
|
||||
|
||||
void initialize_menubar(GUI::Window&);
|
||||
ErrorOr<void> initialize_menubar(GUI::Window&);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
|
|
@ -57,7 +57,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto spreadsheet_widget = TRY(window->set_main_widget<Spreadsheet::SpreadsheetWidget>(*window, Vector<NonnullRefPtr<Spreadsheet::Sheet>> {}, filename.is_empty()));
|
||||
|
||||
spreadsheet_widget->initialize_menubar(*window);
|
||||
TRY(spreadsheet_widget->initialize_menubar(*window));
|
||||
spreadsheet_widget->update_window_title();
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
|
|
Loading…
Reference in a new issue