summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorErik Biederstadt <biederstadterik@gmail.com>2021-11-30 09:45:11 -0700
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-12-01 00:44:26 +0330
commite052d647b71c69622ccdb24e5617c1a9412bceaf (patch)
treef6615e4583e8f66d4af73cb5ea72081617de5c41 /Userland/Applications
parent0cfe446d3f53cff782644df364beb6855c9c36b2 (diff)
downloadserenity-e052d647b71c69622ccdb24e5617c1a9412bceaf.zip
Spreadsheet: Allow sheet renaming after double clicking on the tabwidget
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
index 95272b8fb2..936ab2542e 100644
--- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
+++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
@@ -338,6 +338,21 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector<Sheet> new_sheets)
m_tab_context_menu_sheet_view = static_cast<SpreadsheetView&>(widget);
m_tab_context_menu->popup(event.screen_position());
};
+
+ m_tab_widget->on_double_click = [&](auto& widget) {
+ m_tab_context_menu_sheet_view = static_cast<SpreadsheetView&>(widget);
+ VERIFY(m_tab_context_menu_sheet_view);
+
+ auto* sheet_ptr = m_tab_context_menu_sheet_view->sheet_if_available();
+ VERIFY(sheet_ptr); // How did we get here without a sheet?
+ auto& sheet = *sheet_ptr;
+ String new_name;
+ if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecOK) {
+ sheet.set_name(new_name);
+ sheet.update();
+ m_tab_widget->set_tab_title(static_cast<GUI::Widget&>(*m_tab_context_menu_sheet_view), new_name);
+ }
+ };
}
void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source, size_t cursor_offset)