mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
Spreadsheet: Allow sheet renaming after double clicking on the tabwidget
This commit is contained in:
parent
0cfe446d3f
commit
e052d647b7
1 changed files with 15 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue