SpreadsheetWidget.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. /*
  2. * Copyright (c) 2020-2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "SpreadsheetWidget.h"
  7. #include "CellSyntaxHighlighter.h"
  8. #include "HelpWindow.h"
  9. #include "LibFileSystemAccessClient/Client.h"
  10. #include <LibGUI/Application.h>
  11. #include <LibGUI/BoxLayout.h>
  12. #include <LibGUI/Button.h>
  13. #include <LibGUI/FilePicker.h>
  14. #include <LibGUI/InputBox.h>
  15. #include <LibGUI/Label.h>
  16. #include <LibGUI/Menu.h>
  17. #include <LibGUI/MessageBox.h>
  18. #include <LibGUI/Splitter.h>
  19. #include <LibGUI/TabWidget.h>
  20. #include <LibGUI/TextEditor.h>
  21. #include <LibGUI/Toolbar.h>
  22. #include <LibGUI/ToolbarContainer.h>
  23. #include <LibGfx/FontDatabase.h>
  24. #include <string.h>
  25. namespace Spreadsheet {
  26. SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVector<Sheet>&& sheets, bool should_add_sheet_if_empty)
  27. : m_workbook(make<Workbook>(move(sheets), parent_window))
  28. {
  29. set_fill_with_background_color(true);
  30. set_layout<GUI::VerticalBoxLayout>().set_margins(2);
  31. auto& toolbar_container = add<GUI::ToolbarContainer>();
  32. auto& toolbar = toolbar_container.add<GUI::Toolbar>();
  33. auto& container = add<GUI::VerticalSplitter>();
  34. auto& top_bar = container.add<GUI::Frame>();
  35. top_bar.set_layout<GUI::HorizontalBoxLayout>().set_spacing(1);
  36. top_bar.set_fixed_height(26);
  37. auto& current_cell_label = top_bar.add<GUI::Label>("");
  38. current_cell_label.set_fixed_width(50);
  39. auto& help_button = top_bar.add<GUI::Button>("");
  40. help_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors());
  41. help_button.set_tooltip("Functions Help");
  42. help_button.set_fixed_size(20, 20);
  43. help_button.on_click = [&](auto) {
  44. if (!current_view()) {
  45. GUI::MessageBox::show_error(window(), "Can only show function documentation/help when a worksheet exists and is open");
  46. } else if (auto* sheet_ptr = current_worksheet_if_available()) {
  47. auto docs = sheet_ptr->gather_documentation();
  48. auto help_window = HelpWindow::the(window());
  49. help_window->set_docs(move(docs));
  50. help_window->show();
  51. }
  52. };
  53. auto& cell_value_editor = top_bar.add<GUI::TextEditor>(GUI::TextEditor::Type::SingleLine);
  54. cell_value_editor.set_font(Gfx::FontDatabase::default_fixed_width_font());
  55. cell_value_editor.set_scrollbars_enabled(false);
  56. cell_value_editor.on_return_pressed = [this]() {
  57. current_view()->move_cursor(GUI::AbstractView::CursorMovement::Down);
  58. };
  59. cell_value_editor.set_syntax_highlighter(make<CellSyntaxHighlighter>());
  60. cell_value_editor.set_enabled(false);
  61. current_cell_label.set_enabled(false);
  62. m_tab_widget = container.add<GUI::TabWidget>();
  63. m_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
  64. m_cell_value_editor = cell_value_editor;
  65. m_current_cell_label = current_cell_label;
  66. m_inline_documentation_window = GUI::Window::construct(window());
  67. m_inline_documentation_window->set_rect(m_cell_value_editor->rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
  68. m_inline_documentation_window->set_window_type(GUI::WindowType::Tooltip);
  69. m_inline_documentation_window->set_resizable(false);
  70. auto& inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>();
  71. inline_widget.set_fill_with_background_color(true);
  72. inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
  73. inline_widget.set_frame_shape(Gfx::FrameShape::Box);
  74. m_inline_documentation_label = inline_widget.add<GUI::Label>();
  75. m_inline_documentation_label->set_fill_with_background_color(true);
  76. m_inline_documentation_label->set_autosize(false);
  77. m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
  78. if (!m_workbook->has_sheets() && should_add_sheet_if_empty)
  79. m_workbook->add_sheet("Sheet 1");
  80. m_tab_context_menu = GUI::Menu::construct();
  81. m_rename_action = GUI::CommonActions::make_rename_action([this](auto&) {
  82. VERIFY(m_tab_context_menu_sheet_view);
  83. auto* sheet_ptr = m_tab_context_menu_sheet_view->sheet_if_available();
  84. VERIFY(sheet_ptr); // How did we get here without a sheet?
  85. auto& sheet = *sheet_ptr;
  86. String new_name;
  87. if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecOK) {
  88. sheet.set_name(new_name);
  89. sheet.update();
  90. m_tab_widget->set_tab_title(static_cast<GUI::Widget&>(*m_tab_context_menu_sheet_view), new_name);
  91. }
  92. });
  93. m_tab_context_menu->add_action(*m_rename_action);
  94. m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
  95. String name;
  96. if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecOK) {
  97. NonnullRefPtrVector<Sheet> new_sheets;
  98. new_sheets.append(m_workbook->add_sheet(name));
  99. setup_tabs(move(new_sheets));
  100. }
  101. }));
  102. setup_tabs(m_workbook->sheets());
  103. m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
  104. add_sheet();
  105. });
  106. m_open_action = GUI::CommonActions::make_open_action([&](auto&) {
  107. if (!request_close())
  108. return;
  109. Optional<String> load_path = GUI::FilePicker::get_open_filepath(window());
  110. if (!load_path.has_value())
  111. return;
  112. auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window(), *load_path);
  113. if (response.is_error())
  114. return;
  115. load_file(*response.value());
  116. });
  117. m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
  118. if (current_filename().is_empty()) {
  119. m_save_as_action->activate();
  120. return;
  121. }
  122. save(current_filename());
  123. });
  124. m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
  125. String name = "workbook";
  126. Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(), name, "sheets");
  127. if (!save_path.has_value())
  128. return;
  129. save(save_path.value());
  130. update_window_title();
  131. });
  132. m_quit_action = GUI::CommonActions::make_quit_action([&](auto&) {
  133. if (!request_close())
  134. return;
  135. GUI::Application::the()->quit(0);
  136. });
  137. m_cut_action = GUI::CommonActions::make_cut_action([&](auto&) { clipboard_action(true); }, window());
  138. m_copy_action = GUI::CommonActions::make_copy_action([&](auto&) { clipboard_action(false); }, window());
  139. m_paste_action = GUI::CommonActions::make_paste_action([&](auto&) {
  140. ScopeGuard update_after_paste { [&] { update(); } };
  141. auto* worksheet_ptr = current_worksheet_if_available();
  142. if (!worksheet_ptr) {
  143. GUI::MessageBox::show_error(window(), "There are no active worksheets");
  144. return;
  145. }
  146. auto& sheet = *worksheet_ptr;
  147. auto& cells = sheet.selected_cells();
  148. VERIFY(!cells.is_empty());
  149. const auto& data = GUI::Clipboard::the().fetch_data_and_type();
  150. if (auto spreadsheet_data = data.metadata.get("text/x-spreadsheet-data"); spreadsheet_data.has_value()) {
  151. Vector<Spreadsheet::Position> source_positions, target_positions;
  152. auto lines = spreadsheet_data.value().split_view('\n');
  153. auto action = lines.take_first();
  154. for (auto& line : lines) {
  155. dbgln("Paste line '{}'", line);
  156. auto position = sheet.position_from_url(line);
  157. if (position.has_value())
  158. source_positions.append(position.release_value());
  159. }
  160. for (auto& position : sheet.selected_cells())
  161. target_positions.append(position);
  162. if (source_positions.is_empty())
  163. return;
  164. auto first_position = source_positions.take_first();
  165. sheet.copy_cells(move(source_positions), move(target_positions), first_position, action == "cut" ? Spreadsheet::Sheet::CopyOperation::Cut : Spreadsheet::Sheet::CopyOperation::Copy);
  166. } else {
  167. for (auto& cell : sheet.selected_cells())
  168. sheet.ensure(cell).set_data(StringView { data.data.data(), data.data.size() });
  169. update();
  170. }
  171. },
  172. window());
  173. m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
  174. undo();
  175. });
  176. m_redo_action = GUI::CommonActions::make_redo_action([&](auto&) {
  177. redo();
  178. });
  179. m_undo_stack.on_state_change = [this] {
  180. m_undo_action->set_enabled(m_undo_stack.can_undo());
  181. m_redo_action->set_enabled(m_undo_stack.can_redo());
  182. };
  183. m_undo_action->set_enabled(false);
  184. m_redo_action->set_enabled(false);
  185. m_functions_help_action = GUI::Action::create(
  186. "&Functions Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
  187. if (auto* worksheet_ptr = current_worksheet_if_available()) {
  188. auto docs = worksheet_ptr->gather_documentation();
  189. auto help_window = Spreadsheet::HelpWindow::the(window());
  190. help_window->set_docs(move(docs));
  191. help_window->show();
  192. } else {
  193. GUI::MessageBox::show_error(window(), "Cannot prepare documentation/help without an active worksheet");
  194. }
  195. },
  196. window());
  197. m_about_action = GUI::CommonActions::make_about_action("Spreadsheet", GUI::Icon::default_icon("app-spreadsheet"), window());
  198. toolbar.add_action(*m_new_action);
  199. toolbar.add_action(*m_open_action);
  200. toolbar.add_action(*m_save_action);
  201. toolbar.add_separator();
  202. toolbar.add_action(*m_cut_action);
  203. toolbar.add_action(*m_copy_action);
  204. toolbar.add_action(*m_paste_action);
  205. toolbar.add_action(*m_undo_action);
  206. toolbar.add_action(*m_redo_action);
  207. m_cut_action->set_enabled(false);
  208. m_copy_action->set_enabled(false);
  209. m_tab_widget->on_change = [this](auto& selected_widget) {
  210. // for keyboard shortcuts and command palette
  211. m_tab_context_menu_sheet_view = static_cast<SpreadsheetView&>(selected_widget);
  212. };
  213. m_tab_widget->on_context_menu_request = [&](auto& widget, auto& event) {
  214. m_tab_context_menu_sheet_view = static_cast<SpreadsheetView&>(widget);
  215. m_tab_context_menu->popup(event.screen_position());
  216. };
  217. m_tab_widget->on_double_click = [&](auto& widget) {
  218. m_tab_context_menu_sheet_view = static_cast<SpreadsheetView&>(widget);
  219. m_rename_action->activate();
  220. };
  221. }
  222. void SpreadsheetWidget::resize_event(GUI::ResizeEvent& event)
  223. {
  224. GUI::Widget::resize_event(event);
  225. if (m_inline_documentation_window && m_cell_value_editor && window())
  226. m_inline_documentation_window->set_rect(m_cell_value_editor->screen_relative_rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
  227. }
  228. void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
  229. {
  230. for (auto& sheet : new_sheets) {
  231. auto& new_view = m_tab_widget->add_tab<SpreadsheetView>(sheet.name(), sheet);
  232. new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) {
  233. undo_stack().push(make<CellUndoCommand>(cell, previous_data));
  234. window()->set_modified(true);
  235. };
  236. new_view.on_selection_changed = [&](Vector<Position>&& selection) {
  237. auto* sheet_ptr = current_worksheet_if_available();
  238. // How did this even happen?
  239. VERIFY(sheet_ptr);
  240. auto& sheet = *sheet_ptr;
  241. VERIFY(!selection.is_empty());
  242. m_cut_action->set_enabled(true);
  243. m_copy_action->set_enabled(true);
  244. m_current_cell_label->set_enabled(true);
  245. m_cell_value_editor->set_enabled(true);
  246. if (selection.size() == 1) {
  247. auto& position = selection.first();
  248. m_current_cell_label->set_text(position.to_cell_identifier(sheet));
  249. auto& cell = sheet.ensure(position);
  250. m_cell_value_editor->on_change = nullptr;
  251. m_cell_value_editor->set_text(cell.source());
  252. m_cell_value_editor->on_change = [&] {
  253. auto text = m_cell_value_editor->text();
  254. // FIXME: Lines?
  255. auto offset = m_cell_value_editor->cursor().column();
  256. try_generate_tip_for_input_expression(text, offset);
  257. cell.set_data(move(text));
  258. sheet.update();
  259. update();
  260. };
  261. static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&cell);
  262. return;
  263. }
  264. // There are many cells selected, change all of them.
  265. StringBuilder builder;
  266. builder.appendff("<{}>", selection.size());
  267. m_current_cell_label->set_text(builder.string_view());
  268. Vector<Cell&> cells;
  269. for (auto& position : selection)
  270. cells.append(sheet.ensure(position));
  271. auto& first_cell = cells.first();
  272. m_cell_value_editor->on_change = nullptr;
  273. m_cell_value_editor->set_text("");
  274. m_should_change_selected_cells = false;
  275. m_cell_value_editor->on_focusin = [this] { m_should_change_selected_cells = true; };
  276. m_cell_value_editor->on_focusout = [this] { m_should_change_selected_cells = false; };
  277. m_cell_value_editor->on_change = [cells = move(cells), this]() mutable {
  278. if (m_should_change_selected_cells) {
  279. auto* sheet_ptr = current_worksheet_if_available();
  280. if (!sheet_ptr)
  281. return;
  282. auto& sheet = *sheet_ptr;
  283. auto text = m_cell_value_editor->text();
  284. // FIXME: Lines?
  285. auto offset = m_cell_value_editor->cursor().column();
  286. try_generate_tip_for_input_expression(text, offset);
  287. for (auto& cell : cells)
  288. cell.set_data(text);
  289. sheet.update();
  290. update();
  291. }
  292. };
  293. static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(&first_cell);
  294. };
  295. new_view.on_selection_dropped = [&]() {
  296. m_current_cell_label->set_enabled(false);
  297. m_current_cell_label->set_text({});
  298. m_cell_value_editor->on_change = nullptr;
  299. m_cell_value_editor->on_focusin = nullptr;
  300. m_cell_value_editor->on_focusout = nullptr;
  301. m_cell_value_editor->set_text({});
  302. m_cell_value_editor->set_enabled(false);
  303. m_cut_action->set_enabled(false);
  304. m_copy_action->set_enabled(false);
  305. static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(nullptr);
  306. };
  307. }
  308. }
  309. void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source, size_t cursor_offset)
  310. {
  311. auto* sheet_ptr = current_view()->sheet_if_available();
  312. if (!sheet_ptr)
  313. return;
  314. auto& sheet = *sheet_ptr;
  315. m_inline_documentation_window->set_rect(m_cell_value_editor->screen_relative_rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6));
  316. if (!current_view() || !source.starts_with('=')) {
  317. m_inline_documentation_window->hide();
  318. return;
  319. }
  320. auto maybe_function_and_argument = get_function_and_argument_index(source.substring_view(0, cursor_offset));
  321. if (!maybe_function_and_argument.has_value()) {
  322. m_inline_documentation_window->hide();
  323. return;
  324. }
  325. auto& [name, index] = maybe_function_and_argument.value();
  326. auto text = sheet.generate_inline_documentation_for(name, index);
  327. if (text.is_empty()) {
  328. m_inline_documentation_window->hide();
  329. } else {
  330. m_inline_documentation_label->set_text(move(text));
  331. m_inline_documentation_window->show();
  332. }
  333. }
  334. void SpreadsheetWidget::undo()
  335. {
  336. if (!m_undo_stack.can_undo())
  337. return;
  338. m_undo_stack.undo();
  339. update();
  340. }
  341. void SpreadsheetWidget::redo()
  342. {
  343. if (!m_undo_stack.can_redo())
  344. return;
  345. m_undo_stack.redo();
  346. update();
  347. }
  348. void SpreadsheetWidget::save(StringView filename)
  349. {
  350. auto result = m_workbook->save(filename);
  351. if (result.is_error()) {
  352. GUI::MessageBox::show_error(window(), result.error());
  353. return;
  354. }
  355. undo_stack().set_current_unmodified();
  356. window()->set_modified(false);
  357. }
  358. void SpreadsheetWidget::load_file(Core::File& file)
  359. {
  360. auto result = m_workbook->open_file(file);
  361. if (result.is_error()) {
  362. GUI::MessageBox::show_error(window(), result.error());
  363. return;
  364. }
  365. m_tab_widget->on_change = nullptr;
  366. m_cell_value_editor->on_change = nullptr;
  367. m_current_cell_label->set_text("");
  368. m_should_change_selected_cells = false;
  369. while (auto* widget = m_tab_widget->active_widget()) {
  370. m_tab_widget->remove_tab(*widget);
  371. }
  372. setup_tabs(m_workbook->sheets());
  373. update_window_title();
  374. }
  375. bool SpreadsheetWidget::request_close()
  376. {
  377. if (!undo_stack().is_current_modified())
  378. return true;
  379. auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), current_filename());
  380. if (result == GUI::MessageBox::ExecYes) {
  381. m_save_action->activate();
  382. return !m_workbook->dirty();
  383. }
  384. if (result == GUI::MessageBox::ExecNo)
  385. return true;
  386. return false;
  387. }
  388. void SpreadsheetWidget::add_sheet()
  389. {
  390. StringBuilder name;
  391. name.append("Sheet");
  392. name.appendff(" {}", m_workbook->sheets().size() + 1);
  393. NonnullRefPtrVector<Sheet> new_sheets;
  394. new_sheets.append(m_workbook->add_sheet(name.string_view()));
  395. setup_tabs(move(new_sheets));
  396. }
  397. void SpreadsheetWidget::add_sheet(NonnullRefPtr<Sheet>&& sheet)
  398. {
  399. VERIFY(m_workbook == &sheet->workbook());
  400. NonnullRefPtrVector<Sheet> new_sheets;
  401. new_sheets.append(move(sheet));
  402. m_workbook->sheets().extend(new_sheets);
  403. setup_tabs(new_sheets);
  404. }
  405. void SpreadsheetWidget::update_window_title()
  406. {
  407. StringBuilder builder;
  408. if (current_filename().is_empty())
  409. builder.append("Untitled");
  410. else
  411. builder.append(current_filename());
  412. builder.append("[*] - Spreadsheet");
  413. window()->set_title(builder.to_string());
  414. }
  415. void SpreadsheetWidget::clipboard_action(bool is_cut)
  416. {
  417. /// text/x-spreadsheet-data:
  418. /// - action: copy/cut
  419. /// - currently selected cell
  420. /// - selected cell+
  421. auto* worksheet_ptr = current_worksheet_if_available();
  422. if (!worksheet_ptr) {
  423. GUI::MessageBox::show_error(window(), "There are no active worksheets");
  424. return;
  425. }
  426. auto& worksheet = *worksheet_ptr;
  427. auto& cells = worksheet.selected_cells();
  428. VERIFY(!cells.is_empty());
  429. StringBuilder text_builder, url_builder;
  430. url_builder.append(is_cut ? "cut\n" : "copy\n");
  431. bool first = true;
  432. auto cursor = current_selection_cursor();
  433. if (cursor) {
  434. Spreadsheet::Position position { (size_t)cursor->column(), (size_t)cursor->row() };
  435. url_builder.append(position.to_url(worksheet).to_string());
  436. url_builder.append('\n');
  437. }
  438. for (auto& cell : cells) {
  439. if (first && !cursor) {
  440. url_builder.append(cell.to_url(worksheet).to_string());
  441. url_builder.append('\n');
  442. }
  443. url_builder.append(cell.to_url(worksheet).to_string());
  444. url_builder.append('\n');
  445. auto cell_data = worksheet.at(cell);
  446. if (!first)
  447. text_builder.append('\t');
  448. if (cell_data)
  449. text_builder.append(cell_data->data());
  450. first = false;
  451. }
  452. HashMap<String, String> metadata;
  453. metadata.set("text/x-spreadsheet-data", url_builder.to_string());
  454. dbgln(url_builder.to_string());
  455. GUI::Clipboard::the().set_data(text_builder.string_view().bytes(), "text/plain", move(metadata));
  456. }
  457. void SpreadsheetWidget::initialize_menubar(GUI::Window& window)
  458. {
  459. auto& file_menu = window.add_menu("&File");
  460. file_menu.add_action(*m_new_action);
  461. file_menu.add_action(*m_open_action);
  462. file_menu.add_action(*m_save_action);
  463. file_menu.add_action(*m_save_as_action);
  464. file_menu.add_separator();
  465. file_menu.add_action(*m_quit_action);
  466. auto& edit_menu = window.add_menu("&Edit");
  467. edit_menu.add_action(*m_undo_action);
  468. edit_menu.add_action(*m_redo_action);
  469. edit_menu.add_separator();
  470. edit_menu.add_action(*m_cut_action);
  471. edit_menu.add_action(*m_copy_action);
  472. edit_menu.add_action(*m_paste_action);
  473. auto& help_menu = window.add_menu("&Help");
  474. help_menu.add_action(*m_functions_help_action);
  475. help_menu.add_action(*m_about_action);
  476. }
  477. }