From 74938e6f426bde667dfcae748d7d5139afeb5377 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Mon, 29 Nov 2021 09:44:26 -0500 Subject: [PATCH] FontEditor: Factor out redundant code for a request to close --- Userland/Applications/FontEditor/FontEditor.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 8eb74ae199..c2cf9c8bb4 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -135,16 +135,8 @@ FontEditorWidget::FontEditorWidget() m_glyph_map_widget = glyph_map_container.add(); m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { - if (window()->is_modified()) { - auto result = GUI::MessageBox::show(window(), "Save changes to the current font?", "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); - if (result == GUI::Dialog::ExecResult::ExecYes) { - m_save_action->activate(); - if (window()->is_modified()) - return; - } - if (result == GUI::Dialog::ExecResult::ExecCancel) - return; - } + if (!request_close()) + return; auto new_font_wizard = NewFontDialog::construct(window()); if (new_font_wizard->exec() == GUI::Dialog::ExecOK) { auto metadata = new_font_wizard->new_font_metadata();