From 20dbbdf90c271a948a7cf809227d9998424b8424 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 27 Feb 2022 11:40:55 +0100 Subject: [PATCH] Spreadsheet: Simplify enabling actions on selection Since the function will *always* be called with some selection, we can straight up enable actions. --- .../Applications/Spreadsheet/SpreadsheetWidget.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 746ff3b2b3..733f8b5187 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -274,10 +274,13 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) auto& sheet = *sheet_ptr; VERIFY(!selection.is_empty()); + m_cut_action->set_enabled(true); + m_copy_action->set_enabled(true); + m_current_cell_label->set_enabled(true); + m_cell_value_editor->set_enabled(true); if (selection.size() == 1) { auto& position = selection.first(); - m_current_cell_label->set_enabled(true); m_current_cell_label->set_text(position.to_cell_identifier(sheet)); auto& cell = sheet.ensure(position); @@ -292,9 +295,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) sheet.update(); update(); }; - m_cell_value_editor->set_enabled(true); - m_cut_action->set_enabled(true); - m_copy_action->set_enabled(true); static_cast(const_cast(m_cell_value_editor->syntax_highlighter()))->set_cell(&cell); return; } @@ -302,7 +302,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) // There are many cells selected, change all of them. StringBuilder builder; builder.appendff("<{}>", selection.size()); - m_current_cell_label->set_enabled(true); m_current_cell_label->set_text(builder.string_view()); Vector cells; @@ -331,7 +330,6 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) update(); } }; - m_cell_value_editor->set_enabled(true); static_cast(const_cast(m_cell_value_editor->syntax_highlighter()))->set_cell(&first_cell); }; m_selected_view->on_selection_dropped = [&]() {