|
@@ -11,6 +11,7 @@
|
|
#include <LibGUI/Application.h>
|
|
#include <LibGUI/Application.h>
|
|
#include <LibGUI/BoxLayout.h>
|
|
#include <LibGUI/BoxLayout.h>
|
|
#include <LibGUI/Button.h>
|
|
#include <LibGUI/Button.h>
|
|
|
|
+#include <LibGUI/EmojiInputDialog.h>
|
|
#include <LibGUI/InputBox.h>
|
|
#include <LibGUI/InputBox.h>
|
|
#include <LibGUI/Label.h>
|
|
#include <LibGUI/Label.h>
|
|
#include <LibGUI/Menu.h>
|
|
#include <LibGUI/Menu.h>
|
|
@@ -209,6 +210,31 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|
},
|
|
},
|
|
window());
|
|
window());
|
|
|
|
|
|
|
|
+ m_insert_emoji_action = GUI::CommonActions::make_insert_emoji_action([&](auto&) {
|
|
|
|
+ auto emoji_input_dialog = GUI::EmojiInputDialog::construct(window());
|
|
|
|
+ emoji_input_dialog->set_window_mode(GUI::WindowMode::Passive);
|
|
|
|
+ if (emoji_input_dialog->exec() != GUI::EmojiInputDialog::ExecResult::OK)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ auto emoji_code_point = emoji_input_dialog->selected_emoji_text();
|
|
|
|
+
|
|
|
|
+ if (m_cell_value_editor->has_focus_within()) {
|
|
|
|
+ m_cell_value_editor->insert_at_cursor_or_replace_selection(emoji_code_point);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ auto* worksheet_ptr = current_worksheet_if_available();
|
|
|
|
+ if (!worksheet_ptr) {
|
|
|
|
+ GUI::MessageBox::show_error(window(), "There are no active worksheets"sv);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ auto& sheet = *worksheet_ptr;
|
|
|
|
+ for (auto& cell : sheet.selected_cells())
|
|
|
|
+ sheet.ensure(cell).set_data(emoji_code_point);
|
|
|
|
+
|
|
|
|
+ update();
|
|
|
|
+ },
|
|
|
|
+ window());
|
|
|
|
+
|
|
m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
|
m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
|
undo();
|
|
undo();
|
|
});
|
|
});
|
|
@@ -253,6 +279,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|
m_cut_action->set_enabled(false);
|
|
m_cut_action->set_enabled(false);
|
|
m_copy_action->set_enabled(false);
|
|
m_copy_action->set_enabled(false);
|
|
m_paste_action->set_enabled(false);
|
|
m_paste_action->set_enabled(false);
|
|
|
|
+ m_insert_emoji_action->set_enabled(false);
|
|
|
|
|
|
m_tab_widget->on_change = [this](auto& selected_widget) {
|
|
m_tab_widget->on_change = [this](auto& selected_widget) {
|
|
// for keyboard shortcuts and command palette
|
|
// for keyboard shortcuts and command palette
|
|
@@ -305,6 +332,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
|
m_cut_action->set_enabled(true);
|
|
m_cut_action->set_enabled(true);
|
|
m_copy_action->set_enabled(true);
|
|
m_copy_action->set_enabled(true);
|
|
m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/"sv));
|
|
m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/"sv));
|
|
|
|
+ m_insert_emoji_action->set_enabled(true);
|
|
m_current_cell_label->set_enabled(true);
|
|
m_current_cell_label->set_enabled(true);
|
|
m_cell_value_editor->set_enabled(true);
|
|
m_cell_value_editor->set_enabled(true);
|
|
|
|
|
|
@@ -373,6 +401,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
|
|
m_cut_action->set_enabled(false);
|
|
m_cut_action->set_enabled(false);
|
|
m_copy_action->set_enabled(false);
|
|
m_copy_action->set_enabled(false);
|
|
m_paste_action->set_enabled(false);
|
|
m_paste_action->set_enabled(false);
|
|
|
|
+ m_insert_emoji_action->set_enabled(false);
|
|
|
|
|
|
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(nullptr);
|
|
static_cast<CellSyntaxHighlighter*>(const_cast<Syntax::Highlighter*>(m_cell_value_editor->syntax_highlighter()))->set_cell(nullptr);
|
|
};
|
|
};
|
|
@@ -597,6 +626,7 @@ void SpreadsheetWidget::initialize_menubar(GUI::Window& window)
|
|
edit_menu.add_action(*m_cut_action);
|
|
edit_menu.add_action(*m_cut_action);
|
|
edit_menu.add_action(*m_copy_action);
|
|
edit_menu.add_action(*m_copy_action);
|
|
edit_menu.add_action(*m_paste_action);
|
|
edit_menu.add_action(*m_paste_action);
|
|
|
|
+ edit_menu.add_action(*m_insert_emoji_action);
|
|
|
|
|
|
auto& help_menu = window.add_menu("&Help");
|
|
auto& help_menu = window.add_menu("&Help");
|
|
help_menu.add_action(*m_functions_help_action);
|
|
help_menu.add_action(*m_functions_help_action);
|