diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-04-16 16:07:54 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-18 10:05:21 +0200 |
commit | 5872fe6536909133e44a18ffe1871b5cd4e788e3 (patch) | |
tree | 45eaf0aad61e4b356ec045a2f413a04d2fb09f0c /Userland | |
parent | bc8b409a3cde064dcedd7d037e2780dedd321e52 (diff) | |
download | serenity-5872fe6536909133e44a18ffe1871b5cd4e788e3.zip |
SpreadSheet: Use new InputBox features
Rename now uses a compact box and populates the editor with the
old name, and "Add new" now has a comfy icon. Both prevent empty
names.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index c8ca139905..608d8e1683 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -100,8 +100,8 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR 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, DeprecatedString::formatted("New name for '{}'", sheet.name()), "Rename sheet"sv) == GUI::Dialog::ExecResult::OK) { + String new_name = String::from_deprecated_string(sheet.name()).release_value_but_fixme_should_propagate_errors(); + if (GUI::InputBox::show(window(), new_name, {}, "Rename sheet"sv, GUI::InputType::NonemptyText, "Name"sv) == GUI::Dialog::ExecResult::OK) { 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); @@ -110,7 +110,8 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR m_tab_context_menu->add_action(*m_rename_action); m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { String name; - if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) { + auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-spreadsheet.png"sv).release_value_but_fixme_should_propagate_errors(); + if (GUI::InputBox::show(window(), name, "Enter a name:"sv, "New sheet"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::Dialog::ExecResult::OK) { Vector<NonnullRefPtr<Sheet>> new_sheets; new_sheets.append(m_workbook->add_sheet(name)); setup_tabs(move(new_sheets)); |