diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-05-13 13:10:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-13 16:27:43 +0200 |
commit | cdffe556c8fcca034b10cf91f0b05c17d835bc7b (patch) | |
tree | 189cbd59652eee1b2783a8323a7194100c78fd07 /Userland | |
parent | 1f82beded3ae3664265f1ddf6075f64ca5a08cde (diff) | |
download | serenity-cdffe556c8fcca034b10cf91f0b05c17d835bc7b.zip |
LibGUI+Userland: Make Dialog::ExecResult an enum class
Diffstat (limited to 'Userland')
90 files changed, 232 insertions, 232 deletions
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index 15bd03cd28..c756725520 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -35,7 +35,7 @@ public: editor->set_title("Edit Bookmark"); editor->set_icon(g_icon_bag.bookmark_filled); - if (editor->exec() == Dialog::ExecOK) { + if (editor->exec() == ExecResult::OK) { return Vector<JsonValue> { editor->title(), editor->url() }; } @@ -58,23 +58,23 @@ private: m_title_textbox->set_focus(true); m_title_textbox->select_all(); m_title_textbox->on_return_pressed = [this] { - done(Dialog::ExecOK); + done(ExecResult::OK); }; m_url_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("url_textbox"); m_url_textbox->set_text(url); m_url_textbox->on_return_pressed = [this] { - done(Dialog::ExecOK); + done(ExecResult::OK); }; auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button"); ok_button.on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 5ec448c3a5..47806aea86 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -247,7 +247,7 @@ void BrowserWindow::build_menus() m_change_homepage_action = GUI::Action::create( "Set Homepage URL...", g_icon_bag.go_home, [this](auto&) { auto homepage_url = Config::read_string("Browser", "Preferences", "Home", "about:blank"); - if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) { + if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecResult::OK) { if (URL(homepage_url).is_valid()) { Config::write_string("Browser", "Preferences", "Home", homepage_url); Browser::g_home_url = homepage_url; @@ -373,7 +373,7 @@ void BrowserWindow::build_menus() auto custom_user_agent = GUI::Action::create_checkable("Custom...", [this](auto& action) { String user_agent; - if (GUI::InputBox::show(this, user_agent, "Enter User Agent:", "Custom User Agent") != GUI::InputBox::ExecOK || user_agent.is_empty() || user_agent.is_null()) { + if (GUI::InputBox::show(this, user_agent, "Enter User Agent:", "Custom User Agent") != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) { m_disable_user_agent_spoofing->activate(); return; } @@ -455,7 +455,7 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu) auto custom_search_engine_action = GUI::Action::create_checkable("Custom...", [&](auto& action) { String search_engine; - if (GUI::InputBox::show(this, search_engine, "Enter URL template:", "Custom Search Engine", "https://host/search?q={}") != GUI::InputBox::ExecOK || search_engine.is_empty()) { + if (GUI::InputBox::show(this, search_engine, "Enter URL template:", "Custom Search Engine", "https://host/search?q={}") != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) { m_disable_search_engine_action->activate(); return; } diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index c277da6e11..89059ad28c 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -119,7 +119,7 @@ ContentFilterSettingsWidget::ContentFilterSettingsWidget() m_add_new_domain_button->on_click = [&](unsigned) { String text; - if (GUI::InputBox::show(window(), text, "Enter domain name", "Add domain to Content Filter") == GUI::Dialog::ExecOK) { + if (GUI::InputBox::show(window(), text, "Enter domain name", "Add domain to Content Filter") == GUI::Dialog::ExecResult::OK) { m_domain_list_model->add_domain(std::move(text)); set_modified(true); } diff --git a/Userland/Applications/Calendar/AddEventDialog.cpp b/Userland/Applications/Calendar/AddEventDialog.cpp index 904f4f2254..6c092cc3e0 100644 --- a/Userland/Applications/Calendar/AddEventDialog.cpp +++ b/Userland/Applications/Calendar/AddEventDialog.cpp @@ -76,7 +76,7 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window) ok_button.set_fixed_size(80, 20); ok_button.on_click = [this](auto) { dbgln("TODO: Add event icon on specific tile"); - done(Dialog::ExecOK); + done(ExecResult::OK); }; event_title_textbox.set_focus(true); diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index 6563b2e2d8..da03b59645 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -39,7 +39,7 @@ CharacterMapWidget::CharacterMapWidget() m_choose_font_action = GUI::Action::create("Choose Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto font_picker = GUI::FontPicker::construct(window(), &font(), false); - if (font_picker->exec() == GUI::Dialog::ExecOK) { + if (font_picker->exec() == GUI::Dialog::ExecResult::OK) { auto& font = *font_picker->font(); Config::write_string("CharacterMap", "History", "Font", font.qualified_name()); set_font(font); @@ -70,7 +70,7 @@ CharacterMapWidget::CharacterMapWidget() m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { String input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecOK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; diff --git a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp index 00016ecb5c..7a683a4dce 100644 --- a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp @@ -28,7 +28,7 @@ FontSettingsWidget::FontSettingsWidget() auto& default_font_button = *find_descendant_of_type_named<GUI::Button>("default_font_button"); default_font_button.on_click = [this](auto) { auto font_picker = GUI::FontPicker::construct(window(), &m_default_font_label->font(), false); - if (font_picker->exec() == GUI::Dialog::ExecOK) { + if (font_picker->exec() == GUI::Dialog::ExecResult::OK) { update_label_with_font(*m_default_font_label, *font_picker->font()); set_modified(true); } @@ -41,7 +41,7 @@ FontSettingsWidget::FontSettingsWidget() auto& fixed_width_font_button = *find_descendant_of_type_named<GUI::Button>("fixed_width_font_button"); fixed_width_font_button.on_click = [this](auto) { auto font_picker = GUI::FontPicker::construct(window(), &m_fixed_width_font_label->font(), true); - if (font_picker->exec() == GUI::Dialog::ExecOK) { + if (font_picker->exec() == GUI::Dialog::ExecResult::OK) { update_label_with_font(*m_fixed_width_font_label, *font_picker->font()); set_modified(true); } diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index ac0d5950f6..d5049e4084 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -254,7 +254,7 @@ void MonitorSettingsWidget::apply_settings() revert_timer->start(); // If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes. - if (box->exec() == GUI::MessageBox::ExecYes) { + if (box->exec() == GUI::MessageBox::ExecResult::Yes) { auto save_result = GUI::ConnectionToWindowServer::the().save_screen_layout(); if (!save_result.success()) { GUI::MessageBox::show(window(), String::formatted("Error saving settings: {}", save_result.error_msg()), diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index e4f3d4c7dc..1c4427a33a 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -542,7 +542,7 @@ void DirectoryView::setup_actions() { m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { @@ -554,7 +554,7 @@ void DirectoryView::setup_actions() m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); struct stat st; int rc = stat(new_file_path.characters(), &st); diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index ef6aa1043f..fdcc66b7dc 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -32,7 +32,7 @@ void delete_paths(Vector<String> const& paths, bool should_confirm, GUI::Window* "Confirm deletion", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - if (result == GUI::MessageBox::ExecCancel) + if (result == GUI::MessageBox::ExecResult::Cancel) return; } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 00e649e196..a9c0b52378 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -194,7 +194,7 @@ void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* wind void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* window) { String archive_name; - if (GUI::InputBox::show(window, archive_name, "Enter name:", "Create Archive") != GUI::InputBox::ExecOK) + if (GUI::InputBox::show(window, archive_name, "Enter name:", "Create Archive") != GUI::InputBox::ExecResult::OK) return; auto output_directory_path = LexicalPath(selected_file_paths.first()); diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 4aa7ecd4e7..5ae381154e 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -146,7 +146,7 @@ FontEditorWidget::FontEditorWidget() if (!request_close()) return; auto new_font_wizard = NewFontDialog::construct(window()); - if (new_font_wizard->exec() == GUI::Dialog::ExecOK) { + if (new_font_wizard->exec() == GUI::Dialog::ExecResult::OK) { auto metadata = new_font_wizard->new_font_metadata(); auto new_font = Gfx::BitmapFont::create(metadata.glyph_height, metadata.glyph_width, metadata.is_fixed_width, 0x110000); new_font->set_name(metadata.name); @@ -241,7 +241,7 @@ FontEditorWidget::FontEditorWidget() m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { String input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecOK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; @@ -782,12 +782,12 @@ bool FontEditorWidget::request_close() if (!window()->is_modified()) return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path, m_undo_stack->last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { m_save_action->activate(); if (!window()->is_modified()) return true; } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return true; return false; } diff --git a/Userland/Applications/HexEditor/FindDialog.cpp b/Userland/Applications/HexEditor/FindDialog.cpp index fd4728dbd7..0925e99327 100644 --- a/Userland/Applications/HexEditor/FindDialog.cpp +++ b/Userland/Applications/HexEditor/FindDialog.cpp @@ -31,7 +31,7 @@ static constexpr Array<Option, 2> options = { } }; -int FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& out_buffer, bool& find_all) +GUI::Dialog::ExecResult FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& out_buffer, bool& find_all) { auto dialog = FindDialog::construct(); @@ -46,7 +46,7 @@ int FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& o auto result = dialog->exec(); - if (result != GUI::Dialog::ExecOK) + if (result != ExecResult::OK) return result; auto selected_option = dialog->selected_option(); @@ -56,7 +56,7 @@ int FindDialog::show(GUI::Window* parent_window, String& out_text, ByteBuffer& o if (processed.is_error()) { GUI::MessageBox::show_error(parent_window, processed.error()); - result = GUI::Dialog::ExecAborted; + result = ExecResult::Aborted; } else { out_buffer = move(processed.value()); } @@ -138,7 +138,7 @@ FindDialog::FindDialog() auto text = m_text_editor->text(); if (!text.is_empty()) { m_text_value = text; - done(ExecResult::ExecOK); + done(ExecResult::OK); } }; @@ -148,6 +148,6 @@ FindDialog::FindDialog() }; m_cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/Applications/HexEditor/FindDialog.h b/Userland/Applications/HexEditor/FindDialog.h index 89063c5360..73d41a3b8f 100644 --- a/Userland/Applications/HexEditor/FindDialog.h +++ b/Userland/Applications/HexEditor/FindDialog.h @@ -19,7 +19,7 @@ class FindDialog : public GUI::Dialog { C_OBJECT(FindDialog); public: - static int show(GUI::Window* parent_window, String& out_tex, ByteBuffer& out_buffer, bool& find_all); + static ExecResult show(GUI::Window* parent_window, String& out_tex, ByteBuffer& out_buffer, bool& find_all); private: Result<ByteBuffer, String> process_input(String text_value, OptionId opt); diff --git a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp index 99b2aedff2..5af68549c0 100644 --- a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp +++ b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp @@ -17,7 +17,7 @@ #include <LibGUI/TextBox.h> #include <LibGUI/Widget.h> -int GoToOffsetDialog::show(GUI::Window* parent_window, int& history_offset, int& out_offset, int selection_offset, int buffer_size) +GUI::Dialog::ExecResult GoToOffsetDialog::show(GUI::Window* parent_window, int& history_offset, int& out_offset, int selection_offset, int buffer_size) { auto dialog = GoToOffsetDialog::construct(); dialog->m_selection_offset = selection_offset; @@ -31,7 +31,7 @@ int GoToOffsetDialog::show(GUI::Window* parent_window, int& history_offset, int& auto result = dialog->exec(); - if (result != GUI::Dialog::ExecOK) + if (result != ExecResult::OK) return result; auto input_offset = dialog->process_input(); @@ -41,7 +41,7 @@ int GoToOffsetDialog::show(GUI::Window* parent_window, int& history_offset, int& dbgln("Go to offset: value={}", new_offset); out_offset = move(new_offset); - return GUI::Dialog::ExecOK; + return ExecResult::OK; } int GoToOffsetDialog::process_input() @@ -124,7 +124,7 @@ GoToOffsetDialog::GoToOffsetDialog() }; m_go_button->on_click = [this](auto) { - done(ExecResult::ExecOK); + done(ExecResult::OK); }; m_text_editor->on_change = [this]() { diff --git a/Userland/Applications/HexEditor/GoToOffsetDialog.h b/Userland/Applications/HexEditor/GoToOffsetDialog.h index fc118b28f4..0312bc58a7 100644 --- a/Userland/Applications/HexEditor/GoToOffsetDialog.h +++ b/Userland/Applications/HexEditor/GoToOffsetDialog.h @@ -14,7 +14,7 @@ class GoToOffsetDialog : public GUI::Dialog { C_OBJECT(GoToOffsetDialog); public: - static int show(GUI::Window* parent_window, int& history_offset, int& out_offset, int selection_offset, int end); + static ExecResult show(GUI::Window* parent_window, int& history_offset, int& out_offset, int selection_offset, int end); private: GoToOffsetDialog(); diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 1c9fbb9adc..72077951f6 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -94,7 +94,7 @@ HexEditorWidget::HexEditorWidget() m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { String value; - if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecOK && !value.is_empty()) { + if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto file_size = value.to_int(); if (file_size.has_value() && file_size.value() > 0) { window()->set_modified(false); @@ -151,7 +151,7 @@ HexEditorWidget::HexEditorWidget() m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { auto old_buffer = m_search_buffer; bool find_all = false; - if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecOK) { + if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecResult::OK) { if (find_all) { auto matches = m_editor->find_all(m_search_buffer, 0); m_search_results->set_model(*new SearchResultsModel(move(matches))); @@ -193,7 +193,7 @@ HexEditorWidget::HexEditorWidget() new_offset, m_editor->selection_start_offset(), m_editor->buffer_size()); - if (result == GUI::InputBox::ExecOK) { + if (result == GUI::InputBox::ExecResult::OK) { m_editor->highlight(new_offset, new_offset); m_editor->update(); } @@ -225,7 +225,7 @@ HexEditorWidget::HexEditorWidget() m_fill_selection_action = GUI::Action::create("Fill &Selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { String value; - if (GUI::InputBox::show(window(), value, "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecOK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto fill_byte = strtol(value.characters(), nullptr, 16); m_editor->fill_selection(fill_byte); } @@ -508,11 +508,11 @@ bool HexEditorWidget::request_close() return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { m_save_action->activate(); return !window()->is_modified(); } - return result == GUI::MessageBox::ExecNo; + return result == GUI::MessageBox::ExecResult::No; } void HexEditorWidget::set_search_results_visible(bool visible) diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index 6a5bcf99aa..43b303b297 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -128,7 +128,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - if (msgbox_result == GUI::MessageBox::ExecCancel) + if (msgbox_result == GUI::MessageBox::ExecResult::Cancel) return; auto unlinked_or_error = Core::System::unlink(widget->path()); diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 62598ff9c7..7b17e604e8 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -26,7 +26,7 @@ bool KeyboardMapperWidget::request_close() if (!window()->is_modified()) return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_filename); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { ErrorOr<void> error_or = save(); if (error_or.is_error()) show_error_to_user(error_or.error()); @@ -34,7 +34,7 @@ bool KeyboardMapperWidget::request_close() if (!window()->is_modified()) return true; } - return result == GUI::MessageBox::ExecNo; + return result == GUI::MessageBox::ExecResult::No; } void KeyboardMapperWidget::create_frame() @@ -58,7 +58,7 @@ void KeyboardMapperWidget::create_frame() tmp_button.on_click = [this, &tmp_button]() { String value; - if (GUI::InputBox::show(window(), value, "New Character:", "Select Character") == GUI::InputBox::ExecOK) { + if (GUI::InputBox::show(window(), value, "New Character:", "Select Character") == GUI::InputBox::ExecResult::OK) { int i = m_keys.find_first_index(&tmp_button).value_or(0); VERIFY(i > 0); diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index 6a66500d86..27bccb2b6f 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -37,7 +37,7 @@ public: auto dialog = KeymapSelectionDialog::construct(parent_window, selected_keymaps); dialog->set_title("Add a keymap"); - if (dialog->exec() == GUI::Dialog::ExecOK) { + if (dialog->exec() == ExecResult::OK) { return dialog->selected_keymap(); } @@ -87,12 +87,12 @@ private: auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button"); ok_button.on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index 50fe6aad45..865a1f6497 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -101,8 +101,8 @@ bool MailWidget::connect_and_login() auto server = Config::read_string("Mail", "Connection", "Server", {}); if (server.is_empty()) { - int result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); - if (result == GUI::MessageBox::ExecResult::ExecYes) + auto result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); + if (result == GUI::MessageBox::ExecResult::Yes) Desktop::Launcher::open(URL::create_with_file_protocol("/bin/MailSettings"), "/bin/MailSettings"); return false; } @@ -119,7 +119,7 @@ bool MailWidget::connect_and_login() auto password = Config::read_string("Mail", "User", "Password", {}); while (password.is_empty()) { - if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecOK) + if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecResult::OK) return false; } diff --git a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp index 85b77d4c84..42bb5a3bd2 100644 --- a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp @@ -49,12 +49,12 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window) auto& ok_button = button_container.add<GUI::Button>("OK"); ok_button.on_click = [this](auto) { - done(ExecOK); + done(ExecResult::OK); }; auto& cancel_button = button_container.add<GUI::Button>("Cancel"); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; width_spinbox.on_change = [this](int value) { @@ -66,7 +66,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window) }; m_name_textbox->on_return_pressed = [this] { - done(ExecOK); + done(ExecResult::OK); }; width_spinbox.set_range(1, 16384); diff --git a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp index 14e76964e0..4b46a98271 100644 --- a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp @@ -51,12 +51,12 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G auto& ok_button = button_container.add<GUI::Button>("OK"); ok_button.on_click = [this](auto) { - done(ExecOK); + done(ExecResult::OK); }; auto& cancel_button = button_container.add<GUI::Button>("Cancel"); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; width_spinbox.on_change = [this](int value) { @@ -68,7 +68,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G }; m_name_textbox->on_return_pressed = [this] { - done(ExecOK); + done(ExecResult::OK); }; width_spinbox.set_range(1, 16384); diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.cpp b/Userland/Applications/PixelPaint/EditGuideDialog.cpp index b9c8f79950..a0ea15ded9 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.cpp +++ b/Userland/Applications/PixelPaint/EditGuideDialog.cpp @@ -59,20 +59,20 @@ EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, String const& offse } else if (m_is_horizontal_checked) { m_orientation = Guide::Orientation::Horizontal; } else { - done(ExecResult::ExecAborted); + done(ExecResult::Aborted); return; } if (m_offset_text_box->text().is_empty()) - done(ExecResult::ExecAborted); + done(ExecResult::Aborted); m_offset = m_offset_text_box->text(); - done(ExecResult::ExecOK); + done(ExecResult::OK); }; cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/Applications/PixelPaint/FilterGallery.cpp b/Userland/Applications/PixelPaint/FilterGallery.cpp index 13757c347e..2ad6c8b3d9 100644 --- a/Userland/Applications/PixelPaint/FilterGallery.cpp +++ b/Userland/Applications/PixelPaint/FilterGallery.cpp @@ -69,16 +69,16 @@ FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor) apply_button->on_click = [this](auto) { if (!m_selected_filter) { - done(ExecResult::ExecAborted); + done(ExecResult::Aborted); return; } m_selected_filter->apply(); - done(ExecResult::ExecOK); + done(ExecResult::OK); }; cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h index 189e11a19b..4d7a9c63d5 100644 --- a/Userland/Applications/PixelPaint/FilterParams.h +++ b/Userland/Applications/PixelPaint/FilterParams.h @@ -91,7 +91,7 @@ private: m_should_wrap = wrap_checkbox.is_checked(); if (norm_checkbox.is_checked()) normalize(m_matrix); - done(ExecOK); + done(ExecResult::OK); }; } @@ -146,7 +146,7 @@ struct FilterParameters<Gfx::GenericConvolutionFilter<N>> { { auto input = GenericConvolutionFilterInputDialog<N>::construct(parent_window); input->exec(); - if (input->result() == GUI::Dialog::ExecOK) + if (input->result() == GUI::Dialog::ExecResult::OK) return make<typename Gfx::GenericConvolutionFilter<N>::Parameters>(input->matrix(), input->should_wrap()); return {}; diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 490271105c..a6daa02075 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -565,12 +565,12 @@ bool ImageEditor::request_close() auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), path(), undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { save_project(); return true; } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return true; return false; diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 004a881358..18b2c5f504 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -115,7 +115,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) m_new_image_action = GUI::Action::create( "&New Image...", { Mod_Ctrl, Key_N }, g_icon_bag.filetype_pixelpaint, [&](auto&) { auto dialog = PixelPaint::CreateNewImageDialog::construct(&window); - if (dialog->exec() == GUI::Dialog::ExecOK) { + if (dialog->exec() == GUI::Dialog::ExecResult::OK) { auto image = PixelPaint::Image::try_create_with_size(dialog->image_size()).release_value_but_fixme_should_propagate_errors(); auto bg_layer = PixelPaint::Layer::try_create_with_size(*image, image->size(), "Background").release_value_but_fixme_should_propagate_errors(); image->add_layer(*bg_layer); @@ -173,7 +173,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - auto result = editor->image().export_bmp_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecYes); + auto result = editor->image().export_bmp_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes); if (result.is_error()) GUI::MessageBox::show_error(&window, String::formatted("Export to BMP failed: {}", result.error())); })); @@ -188,7 +188,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - auto result = editor->image().export_png_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecYes); + auto result = editor->image().export_png_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes); if (result.is_error()) GUI::MessageBox::show_error(&window, String::formatted("Export to PNG failed: {}", result.error())); })); @@ -392,7 +392,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) m_add_guide_action = GUI::Action::create( "&Add Guide", g_icon_bag.add_guide, [&](auto&) { auto dialog = PixelPaint::EditGuideDialog::construct(&window); - if (dialog->exec() != GUI::Dialog::ExecOK) + if (dialog->exec() != GUI::Dialog::ExecResult::OK) return; auto* editor = current_image_editor(); VERIFY(editor); @@ -517,7 +517,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); auto dialog = PixelPaint::CreateNewLayerDialog::construct(editor->image().size(), &window); - if (dialog->exec() == GUI::Dialog::ExecOK) { + if (dialog->exec() == GUI::Dialog::ExecResult::OK) { auto layer_or_error = PixelPaint::Layer::try_create_with_size(editor->image(), dialog->layer_size(), dialog->layer_name()); if (layer_or_error.is_error()) { GUI::MessageBox::show_error(&window, String::formatted("Unable to create layer with size {}", dialog->size())); @@ -671,7 +671,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); auto dialog = PixelPaint::FilterGallery::construct(&window, editor); - if (dialog->exec() != GUI::Dialog::ExecOK) + if (dialog->exec() != GUI::Dialog::ExecResult::OK) return; })); diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index 7595c30caf..bb5a7702df 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -34,7 +34,7 @@ public: { if (event.modifiers() & KeyModifier::Mod_Ctrl) { auto dialog = GUI::ColorPicker::construct(m_color, window()); - if (dialog->exec() == GUI::Dialog::ExecOK) { + if (dialog->exec() == GUI::Dialog::ExecResult::OK) { m_color = dialog->color(); auto pal = palette(); pal.set_color(ColorRole::Background, m_color); @@ -73,7 +73,7 @@ public: return; auto dialog = GUI::ColorPicker::construct(m_color, window()); - if (dialog->exec() == GUI::Dialog::ExecOK) + if (dialog->exec() == GUI::Dialog::ExecResult::OK) on_color_change(dialog->color()); } diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp index bbe4efeb70..daa86434c4 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -142,7 +142,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event) editor()->window(), String::formatted("{}", m_context_menu_guide->offset()), m_context_menu_guide->orientation()); - if (dialog->exec() != GUI::Dialog::ExecOK) + if (dialog->exec() != GUI::Dialog::ExecResult::OK) return; auto offset = dialog->offset_as_pixel(*editor()); if (!offset.has_value()) diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 04864c2265..67615db99e 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -360,7 +360,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) "Deletion failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); - if (retry_message_result == GUI::MessageBox::ExecYes) { + if (retry_message_result == GUI::MessageBox::ExecResult::Yes) { try_again = true; } } else { diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index 346dc72c06..a450db4758 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -59,7 +59,7 @@ CellTypeDialog::CellTypeDialog(Vector<Position> const& positions, Sheet& sheet, button_layout.add_spacer(); auto& ok_button = buttonbox.add<GUI::Button>("OK"); ok_button.set_fixed_width(80); - ok_button.on_click = [&](auto) { done(ExecOK); }; + ok_button.on_click = [&](auto) { done(ExecResult::OK); }; } Vector<String> const g_horizontal_alignments { "Left", "Center", "Right" }; diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index 31dc703b98..6139060904 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -257,7 +257,7 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File& wizard->replace_page(page.page()); auto result = wizard->exec(); - if (result == GUI::Dialog::ExecResult::ExecOK) { + if (result == GUI::Dialog::ExecResult::OK) { auto& writer = page.writer(); if (!writer.has_value()) return String { "CSV Export failed" }; @@ -312,7 +312,7 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File& wizard->push_page(page); - if (wizard->exec() != GUI::Dialog::ExecResult::ExecOK) + if (wizard->exec() != GUI::Dialog::ExecResult::OK) return String { "Export was cancelled" }; if (format_combo_box->selected_index() == 0) diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index aa6558c9f7..50d74c7089 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -187,7 +187,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W wizard->replace_page(page.page()); auto result = wizard->exec(); - if (result == GUI::Dialog::ExecResult::ExecOK) { + if (result == GUI::Dialog::ExecResult::OK) { auto& reader = page.reader(); NonnullRefPtrVector<Sheet> sheets; @@ -265,7 +265,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(GUI::W wizard->push_page(page); - if (wizard->exec() != GUI::Dialog::ExecResult::ExecOK) + if (wizard->exec() != GUI::Dialog::ExecResult::OK) return String { "Import was cancelled" }; if (format_combo_box->selected_index() == 0) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 105fdf0036..24620bf469 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -392,7 +392,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) } auto dialog = CellTypeDialog::construct(positions, *m_sheet, window()); - if (dialog->exec() == GUI::Dialog::ExecOK) { + if (dialog->exec() == GUI::Dialog::ExecResult::OK) { for (auto& position : positions) { auto& cell = m_sheet->ensure(position); cell.set_type(dialog->type()); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index d67897ef0d..c3fa95fbff 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -99,7 +99,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe 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) { + if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == 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); @@ -108,7 +108,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe m_tab_context_menu->add_action(*m_rename_action); m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { String name; - if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecOK) { + if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecResult::OK) { NonnullRefPtrVector<Sheet> new_sheets; new_sheets.append(m_workbook->add_sheet(name)); setup_tabs(move(new_sheets)); @@ -456,12 +456,12 @@ bool SpreadsheetWidget::request_close() return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), current_filename()); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { m_save_action->activate(); return !m_workbook->dirty(); } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return true; return false; diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index c7d64d6f07..43fd12ebd5 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -442,7 +442,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (pid == -1) return; auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (rc == GUI::Dialog::ExecYes) + if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGKILL); }, &process_table_view); @@ -453,7 +453,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (pid == -1) return; auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (rc == GUI::Dialog::ExecYes) + if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGSTOP); }, &process_table_view); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index e9d5635129..e133f3c00c 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -357,9 +357,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return background_process_count; }; - auto check_terminal_quit = [&]() -> int { + auto check_terminal_quit = [&]() -> GUI::Dialog::ExecResult { if (!should_confirm_close) - return GUI::MessageBox::ExecOK; + return GUI::MessageBox::ExecResult::OK; Optional<String> close_message; if (tty_has_foreground_process()) { close_message = "There is still a process running in this terminal. Closing the terminal will kill it."; @@ -372,12 +372,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } if (close_message.has_value()) return GUI::MessageBox::show(window, *close_message, "Close this terminal?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - return GUI::MessageBox::ExecOK; + return GUI::MessageBox::ExecResult::OK; }; TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { dbgln("Terminal: Quit menu activated!"); - if (check_terminal_quit() == GUI::MessageBox::ExecOK) + if (check_terminal_quit() == GUI::MessageBox::ExecResult::OK) GUI::Application::the()->quit(); }))); @@ -408,7 +408,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) }; window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision { - if (check_terminal_quit() == GUI::MessageBox::ExecOK) + if (check_terminal_quit() == GUI::MessageBox::ExecResult::OK) return GUI::Window::CloseRequestDecision::Close; return GUI::Window::CloseRequestDecision::StayOpen; }; diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index f95cd3ca00..f72c445b1f 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -150,7 +150,7 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() font_text.set_font(m_font); font_button.on_click = [&](auto) { auto picker = GUI::FontPicker::construct(window(), m_font.ptr(), true); - if (picker->exec() == GUI::Dialog::ExecOK) { + if (picker->exec() == GUI::Dialog::ExecResult::OK) { m_font = picker->font(); font_text.set_text(m_font->human_readable_name()); font_text.set_font(m_font); diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 12bff03f61..fd924d8e88 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -239,9 +239,9 @@ MainWidget::MainWidget() m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) { if (editor().document().is_modified()) { auto save_document_first_result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path, editor().document().undo_stack().last_unmodified_timestamp()); - if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) + if (save_document_first_result == GUI::Dialog::ExecResult::Yes) m_save_action->activate(); - if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && editor().document().is_modified()) + if (save_document_first_result != GUI::Dialog::ExecResult::No && editor().document().is_modified()) return; } @@ -253,9 +253,9 @@ MainWidget::MainWidget() m_open_action = GUI::CommonActions::make_open_action([this](auto&) { if (editor().document().is_modified()) { auto save_document_first_result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path, editor().document().undo_stack().last_unmodified_timestamp()); - if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) + if (save_document_first_result == GUI::Dialog::ExecResult::Yes) m_save_action->activate(); - if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && editor().document().is_modified()) + if (save_document_first_result != GUI::Dialog::ExecResult::No && editor().document().is_modified()) return; } @@ -423,7 +423,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto picker = GUI::FontPicker::construct(&window, &m_editor->font(), false); - if (picker->exec() == GUI::Dialog::ExecOK) { + if (picker->exec() == GUI::Dialog::ExecResult::OK) { dbgln("setting font {}", picker->font()->qualified_name()); m_editor->set_font(picker->font()); } @@ -719,14 +719,14 @@ bool MainWidget::request_close() return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path, editor().document().undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { m_save_action->activate(); if (editor().document().is_modified()) return false; return true; } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return true; return false; diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index 537f5f56e1..d020a43c73 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -432,14 +432,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return GUI::Window::CloseRequestDecision::Close; auto result = GUI::MessageBox::ask_about_unsaved_changes(window, path.value_or(""), last_modified_time); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { save_action->activate(); if (window->is_modified()) return GUI::Window::CloseRequestDecision::StayOpen; return GUI::Window::CloseRequestDecision::Close; } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return GUI::Window::CloseRequestDecision::Close; return GUI::Window::CloseRequestDecision::StayOpen; diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 69350adbee..0fc9aa0ded 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -98,7 +98,7 @@ GalleryWidget::GalleryWidget() m_font_button->on_click = [&](auto) { auto picker = GUI::FontPicker::try_create(window(), &m_text_editor->font(), false).release_value_but_fixme_should_propagate_errors(); - if (picker->exec() == GUI::Dialog::ExecOK) { + if (picker->exec() == GUI::Dialog::ExecResult::OK) { m_text_editor->set_font(picker->font()); } }; @@ -118,7 +118,7 @@ GalleryWidget::GalleryWidget() m_input_button->on_click = [&](auto) { String value; - if (GUI::InputBox::show(window(), value, "Enter input:", "Input") == GUI::InputBox::ExecOK && !value.is_empty()) + if (GUI::InputBox::show(window(), value, "Enter input:", "Input") == GUI::InputBox::ExecResult::OK && !value.is_empty()) m_text_editor->set_text(value); }; @@ -277,11 +277,11 @@ GalleryWidget::GalleryWidget() m_wizard_output->set_text(sb.to_string()); auto wizard = DemoWizardDialog::try_create(window()).release_value_but_fixme_should_propagate_errors(); - int result = wizard->exec(); + auto result = wizard->exec(); - sb.append(String::formatted("\nWizard execution complete.\nDialog ExecResult code: {}", result)); - if (result == GUI::Dialog::ExecResult::ExecOK) - sb.append(String::formatted(" (ExecOK)\n'Installation' location: \"{}\"", wizard->page_1_location())); + sb.append(String::formatted("\nWizard execution complete.\nDialog ExecResult code: {}", to_underlying(result))); + if (result == GUI::Dialog::ExecResult::OK) + sb.append(String::formatted(" (ExecResult::OK)\n'Installation' location: \"{}\"", wizard->page_1_location())); m_wizard_output->set_text(sb.string_view()); }; diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index a6e1c7aab0..e1c59113ff 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -106,7 +106,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode if (does_variable_support_writing(variable)) { context_menu->add_action(GUI::Action::create("Change value", [&](auto&) { String value; - if (GUI::InputBox::show(window(), value, "Enter new value:", "Set variable value") == GUI::InputBox::ExecOK) { + if (GUI::InputBox::show(window(), value, "Enter new value:", "Set variable value") == GUI::InputBox::ExecResult::OK) { auto& model = static_cast<VariablesModel&>(*m_variables_view->model()); model.set_variable_value(index, value, window()); } diff --git a/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.cpp index 4423440952..04905caea8 100644 --- a/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.cpp @@ -39,11 +39,11 @@ GitCommitDialog::GitCommitDialog(GUI::Window* parent) m_commit_button->set_enabled(!m_message_editor->text().is_empty() && on_commit); m_commit_button->on_click = [this](auto) { on_commit(m_message_editor->text()); - done(ExecResult::ExecOK); + done(ExecResult::OK); }; m_cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; } diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index d2664248a0..e349204e01 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -28,7 +28,7 @@ namespace HackStudio { static Regex<PosixExtended> const s_project_name_validity_regex("^([A-Za-z0-9_-])*$"); -int NewProjectDialog::show(GUI::Window* parent_window) +GUI::Dialog::ExecResult NewProjectDialog::show(GUI::Window* parent_window) { auto dialog = NewProjectDialog::construct(parent_window); @@ -92,7 +92,7 @@ NewProjectDialog::NewProjectDialog(GUI::Window* parent) m_cancel_button = *main_widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); m_cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; m_browse_button = *find_descendant_of_type_named<GUI::Button>("browse_button"); @@ -198,7 +198,7 @@ void NewProjectDialog::do_create_project() auto create_in = m_create_in_input->text(); if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) { auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (result != GUI::MessageBox::ExecResult::ExecYes) + if (result != GUI::MessageBox::ExecResult::Yes) return; auto created = Core::Directory::create(maybe_project_full_path.value(), Core::Directory::CreateDirectories::Yes); @@ -212,7 +212,7 @@ void NewProjectDialog::do_create_project() if (!creation_result.is_error()) { // Successfully created, attempt to open the new project m_created_project_path = maybe_project_full_path.value(); - done(ExecResult::ExecOK); + done(ExecResult::OK); } else { GUI::MessageBox::show_error(this, String::formatted("Could not create project: {}", creation_result.error())); } diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h index 1503e36186..1158ce0737 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h @@ -22,7 +22,7 @@ class NewProjectDialog : public GUI::Dialog { C_OBJECT(NewProjectDialog); public: - static int show(GUI::Window* parent_window); + static ExecResult show(GUI::Window* parent_window); Optional<String> created_project_path() const { return m_created_project_path; } diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index a6e6e0465a..3723bcbf20 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -86,7 +86,7 @@ bool GitWidget::initialize() return false; case GitRepo::CreateResult::Type::NoGitRepo: { auto decision = GUI::MessageBox::show(window(), "Create git repository?", "Git", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (decision != GUI::Dialog::ExecResult::ExecYes) + if (decision != GUI::Dialog::ExecResult::Yes) return false; m_git_repo = GitRepo::initialize_repository(m_repo_root); return true; diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 7a3741aebb..c1dfe48626 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -502,7 +502,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const { return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon).release_value_but_fixme_should_propagate_errors(), [this, extension](const GUI::Action&) { String filename; - if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecOK) + if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecResult::OK) return; if (!extension.is_empty() && !filename.ends_with(String::formatted(".{}", extension))) { @@ -543,7 +543,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action() { return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { String directory_name; - if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecOK) + if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecResult::OK) return; auto path_to_selected = selected_file_paths(); @@ -615,7 +615,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action() "Confirm deletion", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - if (result == GUI::MessageBox::ExecCancel) + if (result == GUI::MessageBox::ExecResult::Cancel) return; for (auto& file : files) { @@ -657,7 +657,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_project_action() dialog->set_icon(window()->icon()); auto result = dialog->exec(); - if (result == GUI::Dialog::ExecResult::ExecOK && dialog->created_project_path().has_value()) + if (result == GUI::Dialog::ExecResult::OK && dialog->created_project_path().has_value()) open_project(dialog->created_project_path().value()); }); } @@ -1436,7 +1436,7 @@ void HackStudioWidget::create_view_menu(GUI::Window& window) m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto picker = GUI::FontPicker::construct(&window, m_editor_font, false); - if (picker->exec() == GUI::Dialog::ExecOK) { + if (picker->exec() == GUI::Dialog::ExecResult::OK) { change_editor_font(picker->font()); } }); @@ -1550,10 +1550,10 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String auto result = GUI::MessageBox::show(window(), prompt, "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); - if (result == GUI::MessageBox::ExecCancel) + if (result == GUI::MessageBox::ExecResult::Cancel) return ContinueDecision::No; - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { for (auto& editor_wrapper : m_all_editor_wrappers) { if (editor_wrapper.editor().document().is_modified()) { editor_wrapper.save(); diff --git a/Userland/DevTools/Inspector/main.cpp b/Userland/DevTools/Inspector/main.cpp index ac32571ac7..512cb7bfdf 100644 --- a/Userland/DevTools/Inspector/main.cpp +++ b/Userland/DevTools/Inspector/main.cpp @@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (gui_mode) { choose_pid: auto process_chooser = TRY(GUI::ProcessChooser::try_create("Inspector", "Inspect", app_icon.bitmap_for_size(16))); - if (process_chooser->exec() == GUI::Dialog::ExecCancel) + if (process_chooser->exec() == GUI::Dialog::ExecResult::Cancel) return 0; pid = process_chooser->pid(); } else { diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index 57e374fe35..bd09bd5f39 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -177,9 +177,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) { if (window->is_modified()) { auto result = GUI::MessageBox::ask_about_unsaved_changes(window, file_path, editor->document().undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecYes) + if (result == GUI::MessageBox::ExecResult::Yes) save_action->activate(); - if (result != GUI::MessageBox::ExecNo && window->is_modified()) + if (result != GUI::MessageBox::ExecResult::No && window->is_modified()) return; } @@ -257,14 +257,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return GUI::Window::CloseRequestDecision::Close; auto result = GUI::MessageBox::ask_about_unsaved_changes(window, file_path, editor->document().undo_stack().last_unmodified_timestamp()); - if (result == GUI::MessageBox::ExecYes) { + if (result == GUI::MessageBox::ExecResult::Yes) { save_action->activate(); if (window->is_modified()) return GUI::Window::CloseRequestDecision::StayOpen; return GUI::Window::CloseRequestDecision::Close; } - if (result == GUI::MessageBox::ExecNo) + if (result == GUI::MessageBox::ExecResult::No) return GUI::Window::CloseRequestDecision::Close; return GUI::Window::CloseRequestDecision::StayOpen; diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 684f9361cb..8ea601987e 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -343,7 +343,7 @@ bool generate_profile(pid_t& pid) { if (!pid) { auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors()); - if (process_chooser->exec() == GUI::Dialog::ExecCancel) + if (process_chooser->exec() == GUI::Dialog::ExecResult::Cancel) return false; pid = process_chooser->pid(); } diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index e353de32cb..938a8f3f1f 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -266,9 +266,9 @@ bool MainWidget::request_close() auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), {}); switch (result) { - case GUI::Dialog::ExecResult::ExecYes: + case GUI::Dialog::ExecResult::Yes: break; - case GUI::Dialog::ExecResult::ExecNo: + case GUI::Dialog::ExecResult::No: return true; default: return false; diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.cpp b/Userland/DevTools/SQLStudio/ScriptEditor.cpp index 49ed707a8d..ac25ee786b 100644 --- a/Userland/DevTools/SQLStudio/ScriptEditor.cpp +++ b/Userland/DevTools/SQLStudio/ScriptEditor.cpp @@ -85,9 +85,9 @@ ErrorOr<bool> ScriptEditor::attempt_to_close() auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path.is_empty() ? name() : m_path, document().undo_stack().last_unmodified_timestamp()); switch (result) { - case GUI::Dialog::ExecResult::ExecYes: + case GUI::Dialog::ExecResult::Yes: return save(); - case GUI::Dialog::ExecResult::ExecNo: + case GUI::Dialog::ExecResult::No: return true; default: return false; diff --git a/Userland/Games/2048/GameSizeDialog.cpp b/Userland/Games/2048/GameSizeDialog.cpp index 3f4ccd3a4e..0f925ccbab 100644 --- a/Userland/Games/2048/GameSizeDialog.cpp +++ b/Userland/Games/2048/GameSizeDialog.cpp @@ -74,10 +74,10 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent, size_t board_size, size_t ta button_layout.set_spacing(10); buttonbox.add<GUI::Button>("Cancel").on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; buttonbox.add<GUI::Button>("OK").on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; } diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 3a2d65a55a..e42066ceb3 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -99,7 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto change_settings = [&] { auto size_dialog = GameSizeDialog::construct(window, board_size, target_tile, evil_ai); - if (size_dialog->exec() || size_dialog->result() != GUI::Dialog::ExecOK) + if (size_dialog->exec() != GUI::Dialog::ExecResult::OK) return; board_size = size_dialog->board_size(); @@ -152,7 +152,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) "Congratulations!", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (want_to_continue == GUI::MessageBox::ExecYes) + if (want_to_continue == GUI::MessageBox::ExecResult::Yes) game.set_want_to_continue(); else start_a_new_game(); diff --git a/Userland/Games/Breakout/Game.cpp b/Userland/Games/Breakout/Game.cpp index bf38388717..134c7c979e 100644 --- a/Userland/Games/Breakout/Game.cpp +++ b/Userland/Games/Breakout/Game.cpp @@ -20,7 +20,7 @@ Game::Game() { set_override_cursor(Gfx::StandardCursor::Hidden); auto level_dialog = LevelSelectDialog::show(m_board, window()); - if (level_dialog != GUI::Dialog::ExecOK) + if (level_dialog != GUI::Dialog::ExecResult::OK) m_board = -1; set_paused(false); start_timer(16); diff --git a/Userland/Games/Breakout/LevelSelectDialog.cpp b/Userland/Games/Breakout/LevelSelectDialog.cpp index dfbc5c49d4..fb45e21adc 100644 --- a/Userland/Games/Breakout/LevelSelectDialog.cpp +++ b/Userland/Games/Breakout/LevelSelectDialog.cpp @@ -20,7 +20,7 @@ LevelSelectDialog::LevelSelectDialog(Window* parent_window) build(); } -int LevelSelectDialog::show(int& board_number, Window* parent_window) +GUI::Dialog::ExecResult LevelSelectDialog::show(int& board_number, Window* parent_window) { auto box = LevelSelectDialog::construct(parent_window); box->set_resizable(false); @@ -47,12 +47,12 @@ void LevelSelectDialog::build() level_list.add<GUI::Button>("Rainbow").on_click = [this](auto) { m_level = -1; - done(Dialog::ExecOK); + done(ExecResult::OK); }; level_list.add<GUI::Button>(":^)").on_click = [this](auto) { m_level = 0; - done(Dialog::ExecOK); + done(ExecResult::OK); }; } } diff --git a/Userland/Games/Breakout/LevelSelectDialog.h b/Userland/Games/Breakout/LevelSelectDialog.h index e3321936a8..89ccb40048 100644 --- a/Userland/Games/Breakout/LevelSelectDialog.h +++ b/Userland/Games/Breakout/LevelSelectDialog.h @@ -13,7 +13,7 @@ class LevelSelectDialog : public GUI::Dialog { C_OBJECT(LevelSelectDialog) public: virtual ~LevelSelectDialog() override = default; - static int show(int& board_number, Window* parent_window); + static ExecResult show(int& board_number, Window* parent_window); int level() const { return m_level; } private: diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 5e013e464e..8c4097b8a4 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -235,7 +235,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) Chess::Move move = { m_moving_square, target_square }; if (board().is_promotion_move(move)) { auto promotion_dialog = PromotionDialog::construct(*this); - if (promotion_dialog->exec() == PromotionDialog::ExecOK) + if (promotion_dialog->exec() == PromotionDialog::ExecResult::OK) move.promote_to = promotion_dialog->selected_piece(); } @@ -262,7 +262,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) update(); if (GUI::MessageBox::show(window(), "50 moves have elapsed without a capture. Claim Draw?", "Claim Draw?", GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) - == GUI::Dialog::ExecYes) { + == GUI::Dialog::ExecResult::Yes) { msg = "Draw by 50 move rule."; } else { over = false; @@ -275,7 +275,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) update(); if (GUI::MessageBox::show(window(), "The same board state has repeated three times. Claim Draw?", "Claim Draw?", GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) - == GUI::Dialog::ExecYes) { + == GUI::Dialog::ExecResult::Yes) { msg = "Draw by threefold repetition."; } else { over = false; @@ -691,7 +691,7 @@ int ChessWidget::resign() } auto result = GUI::MessageBox::show(window(), "Are you sure you wish to resign?", "Resign", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result != GUI::MessageBox::ExecYes) + if (result != GUI::MessageBox::ExecResult::Yes) return -1; board().set_resigned(m_board.turn()); diff --git a/Userland/Games/Chess/PromotionDialog.cpp b/Userland/Games/Chess/PromotionDialog.cpp index e89bd54d9e..f20ab09148 100644 --- a/Userland/Games/Chess/PromotionDialog.cpp +++ b/Userland/Games/Chess/PromotionDialog.cpp @@ -28,7 +28,7 @@ PromotionDialog::PromotionDialog(ChessWidget& chess_widget) button.set_icon(chess_widget.get_piece_graphic({ chess_widget.board().turn(), type })); button.on_click = [this, type](auto) { m_selected_piece = type; - done(ExecOK); + done(ExecResult::OK); }; } } diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index f59a612589..83986fe52a 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -137,7 +137,7 @@ void Game::show_score_card(bool game_over) auto& close_button = button_container.add<GUI::Button>("OK"); close_button.on_click = [&score_dialog](auto) { - score_dialog->done(GUI::Dialog::ExecOK); + score_dialog->done(GUI::Dialog::ExecResult::OK); }; close_button.set_min_width(70); close_button.resize(70, 30); diff --git a/Userland/Games/Hearts/SettingsDialog.cpp b/Userland/Games/Hearts/SettingsDialog.cpp index 2e027ad4f4..c9e185cded 100644 --- a/Userland/Games/Hearts/SettingsDialog.cpp +++ b/Userland/Games/Hearts/SettingsDialog.cpp @@ -43,10 +43,10 @@ SettingsDialog::SettingsDialog(GUI::Window* parent, String player_name) button_layout.set_spacing(10); button_box.add<GUI::Button>("Cancel").on_click = [this](auto) { - done(Dialog::ExecCancel); + done(ExecResult::Cancel); }; button_box.add<GUI::Button>("OK").on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; } diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index 429779af2c..3ce2a8c0a4 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -75,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto change_settings = [&] { auto settings_dialog = SettingsDialog::construct(window, player_name); - if (settings_dialog->exec() || settings_dialog->result() != GUI::Dialog::ExecOK) + if (settings_dialog->exec() != GUI::Dialog::ExecResult::OK) return; player_name = settings_dialog->player_name(); diff --git a/Userland/Games/MasterWord/main.cpp b/Userland/Games/MasterWord/main.cpp index 2d17318e26..abdeee8ff7 100644 --- a/Userland/Games/MasterWord/main.cpp +++ b/Userland/Games/MasterWord/main.cpp @@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(game_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) { auto word_length = Config::read_i32("MasterWord", "", "word_length", 5); auto word_length_string = String::number(word_length); - if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecOK && !word_length_string.is_empty()) { + if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) { auto maybe_word_length = word_length_string.template to_uint(); if (!maybe_word_length.has_value() || maybe_word_length.value() < shortest_word || maybe_word_length.value() > longest_word) { GUI::MessageBox::show(window, String::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"); @@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(game_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) { auto max_guesses = Config::read_i32("MasterWord", "", "max_guesses", 5); auto max_guesses_string = String::number(max_guesses); - if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecOK && !max_guesses_string.is_empty()) { + if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) { auto maybe_max_guesses = max_guesses_string.template to_uint(); if (!maybe_max_guesses.has_value() || maybe_max_guesses.value() < 1 || maybe_max_guesses.value() > 20) { GUI::MessageBox::show(window, "Please enter a number between 1 and 20.", "MasterWord"); diff --git a/Userland/Games/Minesweeper/CustomGameDialog.cpp b/Userland/Games/Minesweeper/CustomGameDialog.cpp index 7cdafb2ed3..ce5194d767 100644 --- a/Userland/Games/Minesweeper/CustomGameDialog.cpp +++ b/Userland/Games/Minesweeper/CustomGameDialog.cpp @@ -9,7 +9,7 @@ #include "Field.h" #include <Games/Minesweeper/MinesweeperCustomGameWindowGML.h> -int CustomGameDialog::show(GUI::Window* parent_window, Field& field) +GUI::Dialog::ExecResult CustomGameDialog::show(GUI::Window* parent_window, Field& field) { auto dialog = CustomGameDialog::construct(parent_window); @@ -24,12 +24,12 @@ int CustomGameDialog::show(GUI::Window* parent_window, Field& field) auto result = dialog->exec(); - if (result != GUI::Dialog::ExecOK) + if (result != ExecResult::OK) return result; field.set_field_size(Field::Difficulty::Custom, dialog->m_rows_spinbox->value(), dialog->m_columns_spinbox->value(), dialog->m_mines_spinbox->value()); - return GUI::Dialog::ExecOK; + return ExecResult::OK; } void CustomGameDialog::set_max_mines() @@ -66,11 +66,11 @@ CustomGameDialog::CustomGameDialog(Window* parent_window) }; m_ok_button->on_click = [this](auto) { - done(ExecResult::ExecOK); + done(ExecResult::OK); }; m_cancel_button->on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; set_max_mines(); diff --git a/Userland/Games/Minesweeper/CustomGameDialog.h b/Userland/Games/Minesweeper/CustomGameDialog.h index 786a3252d3..42dd35625a 100644 --- a/Userland/Games/Minesweeper/CustomGameDialog.h +++ b/Userland/Games/Minesweeper/CustomGameDialog.h @@ -17,7 +17,7 @@ class CustomGameDialog : public GUI::Dialog { C_OBJECT(CustomGameDialog); public: - static int show(GUI::Window* parent_window, Field& field); + static ExecResult show(GUI::Window* parent_window, Field& field); private: CustomGameDialog(GUI::Window* parent_window); diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 2b70ce9e76..a900574f74 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -144,7 +144,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result == GUI::MessageBox::ExecYes) + if (result == GUI::MessageBox::ExecResult::Yes) return GUI::Window::CloseRequestDecision::Close; else return GUI::Window::CloseRequestDecision::StayOpen; diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index a4e2537979..db67616b80 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -201,7 +201,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - if (result == GUI::MessageBox::ExecYes) + if (result == GUI::MessageBox::ExecResult::Yes) return GUI::Window::CloseRequestDecision::Close; else return GUI::Window::CloseRequestDecision::StayOpen; diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index 63858aeac6..d40c9523d3 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -82,7 +82,7 @@ AboutDialog::AboutDialog(StringView name, Gfx::Bitmap const* icon, Window* paren auto& ok_button = button_container.add<Button>("OK"); ok_button.set_fixed_width(80); ok_button.on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; } diff --git a/Userland/Libraries/LibGUI/ColorInput.cpp b/Userland/Libraries/LibGUI/ColorInput.cpp index 0cf960adea..2a0d8ee23c 100644 --- a/Userland/Libraries/LibGUI/ColorInput.cpp +++ b/Userland/Libraries/LibGUI/ColorInput.cpp @@ -72,7 +72,7 @@ void ColorInput::mouseup_event(MouseEvent& event) if (is_color_rect_click) { auto dialog = GUI::ColorPicker::construct(m_color, window(), m_color_picker_title); dialog->set_color_has_alpha_channel(m_color_has_alpha_channel); - if (dialog->exec() == GUI::Dialog::ExecOK) + if (dialog->exec() == GUI::Dialog::ExecResult::OK) set_color(dialog->color()); event.accept(); return; diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 3711d7858e..07d2975902 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -236,14 +236,14 @@ void ColorPicker::build_ui() ok_button.set_fixed_width(80); ok_button.set_text("OK"); ok_button.on_click = [this](auto) { - done(ExecOK); + done(ExecResult::OK); }; auto& cancel_button = button_container.add<Button>(); cancel_button.set_fixed_width(80); cancel_button.set_text("Cancel"); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; } @@ -464,7 +464,7 @@ void ColorButton::doubleclick_event(GUI::MouseEvent&) { click(); m_selected = true; - m_picker.done(Dialog::ExecOK); + m_picker.done(Dialog::ExecResult::OK); } void ColorButton::paint_event(PaintEvent& event) diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp index 2f5a096c19..d28ba7e74c 100644 --- a/Userland/Libraries/LibGUI/CommandPalette.cpp +++ b/Userland/Libraries/LibGUI/CommandPalette.cpp @@ -288,7 +288,7 @@ void CommandPalette::finish_with_index(GUI::ModelIndex const& filter_index) auto* action = static_cast<GUI::Action*>(action_index.internal_data()); VERIFY(action); m_selected_action = action; - done(ExecOK); + done(ExecResult::OK); } } diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp index 556f216023..0e009dd077 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp @@ -184,7 +184,7 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key, bool focused_widget_accepts_emoji_input = window->focused_widget() && window->focused_widget()->accepts_emoji_input(); if (focused_widget_accepts_emoji_input && (modifiers == (Mod_Ctrl | Mod_Alt)) && key == Key_Space) { auto emoji_input_dialog = EmojiInputDialog::construct(window); - if (emoji_input_dialog->exec() != EmojiInputDialog::ExecOK) + if (emoji_input_dialog->exec() != EmojiInputDialog::ExecResult::OK) return; key_event->m_key = Key_Invalid; key_event->m_modifiers = 0; @@ -203,7 +203,7 @@ void ConnectionToWindowServer::key_down(i32 window_id, u32 code_point, u32 key, if (accepts_command_palette && !m_in_command_palette && modifiers == (Mod_Ctrl | Mod_Shift) && key == Key_A) { auto command_palette = CommandPalette::construct(*window); TemporaryChange change { m_in_command_palette, true }; - if (command_palette->exec() != GUI::Dialog::ExecOK) + if (command_palette->exec() != GUI::Dialog::ExecResult::OK) return; auto* action = command_palette->selected_action(); VERIFY(action); diff --git a/Userland/Libraries/LibGUI/Dialog.cpp b/Userland/Libraries/LibGUI/Dialog.cpp index d4e7e65631..7dcba9cd7f 100644 --- a/Userland/Libraries/LibGUI/Dialog.cpp +++ b/Userland/Libraries/LibGUI/Dialog.cpp @@ -20,7 +20,7 @@ Dialog::Dialog(Window* parent_window, ScreenPosition screen_position) set_minimizable(false); } -int Dialog::exec() +Dialog::ExecResult Dialog::exec() { VERIFY(!m_event_loop); m_event_loop = make<Core::EventLoop>(); @@ -87,16 +87,16 @@ int Dialog::exec() m_event_loop = nullptr; dbgln("{}: Event loop returned with result {}", *this, result); remove_from_parent(); - return result; + return static_cast<ExecResult>(result); } -void Dialog::done(int result) +void Dialog::done(ExecResult result) { if (!m_event_loop) return; m_result = result; - dbgln("{}: Quit event loop with result {}", *this, result); - m_event_loop->quit(result); + dbgln("{}: Quit event loop with result {}", *this, to_underlying(result)); + m_event_loop->quit(to_underlying(result)); } void Dialog::event(Core::Event& event) @@ -104,7 +104,7 @@ void Dialog::event(Core::Event& event) if (event.type() == Event::KeyUp || event.type() == Event::KeyDown) { auto& key_event = static_cast<KeyEvent&>(event); if (key_event.key() == KeyCode::Key_Escape) { - done(ExecCancel); + done(ExecResult::Cancel); event.accept(); return; } @@ -116,7 +116,7 @@ void Dialog::event(Core::Event& event) void Dialog::close() { Window::close(); - done(ExecCancel); + done(ExecResult::Cancel); } } diff --git a/Userland/Libraries/LibGUI/Dialog.h b/Userland/Libraries/LibGUI/Dialog.h index 259e346261..52146c8dc3 100644 --- a/Userland/Libraries/LibGUI/Dialog.h +++ b/Userland/Libraries/LibGUI/Dialog.h @@ -15,12 +15,12 @@ namespace GUI { class Dialog : public Window { C_OBJECT(Dialog) public: - enum ExecResult { - ExecOK = 0, - ExecCancel = 1, - ExecAborted = 2, - ExecYes = 3, - ExecNo = 4, + enum class ExecResult { + OK = 0, + Cancel = 1, + Aborted = 2, + Yes = 3, + No = 4, }; enum ScreenPosition { CenterWithinParent = 0, @@ -40,10 +40,10 @@ public: virtual ~Dialog() override = default; - int exec(); + ExecResult exec(); - int result() const { return m_result; } - void done(int result); + ExecResult result() const { return m_result; } + void done(ExecResult); virtual void event(Core::Event&) override; @@ -54,7 +54,7 @@ protected: private: OwnPtr<Core::EventLoop> m_event_loop; - int m_result { ExecAborted }; + ExecResult m_result { ExecResult::Aborted }; int m_screen_position { CenterWithinParent }; }; diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp index bc59774c66..e43168517c 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp @@ -85,7 +85,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window) button.set_button_style(Gfx::ButtonStyle::Coolbar); button.on_click = [this, button = &button](auto) { m_selected_emoji_text = button->text(); - done(ExecOK); + done(ExecResult::OK); }; } else { horizontal_container.add<Widget>(); @@ -99,7 +99,7 @@ void EmojiInputDialog::event(Core::Event& event) if (event.type() == Event::KeyDown) { auto& key_event = static_cast<KeyEvent&>(event); if (key_event.key() == Key_Escape) { - done(ExecCancel); + done(ExecResult::Cancel); return; } } diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index a22fe83c0e..f91c1c04cd 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -39,7 +39,7 @@ Optional<String> FilePicker::get_open_filepath(Window* parent_window, String con if (!window_title.is_null()) picker->set_title(window_title); - if (picker->exec() == Dialog::ExecOK) { + if (picker->exec() == ExecResult::OK) { String file_path = picker->selected_file(); if (file_path.is_null()) @@ -54,7 +54,7 @@ Optional<String> FilePicker::get_save_filepath(Window* parent_window, String con { auto picker = FilePicker::construct(parent_window, Mode::Save, String::formatted("{}.{}", title, extension), path, screen_position); - if (picker->exec() == Dialog::ExecOK) { + if (picker->exec() == ExecResult::OK) { String file_path = picker->selected_file(); if (file_path.is_null()) @@ -131,7 +131,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St auto mkdir_action = Action::create( "New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](Action const&) { String value; - if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) { + if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecResult::OK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { @@ -185,7 +185,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.set_text("Cancel"); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; m_filename_textbox->on_change = [&] { @@ -278,12 +278,12 @@ void FilePicker::on_file_return() if (file_exists && m_mode == Mode::Save) { auto result = MessageBox::show(this, "File already exists. Overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel); - if (result == MessageBox::ExecCancel) + if (result == MessageBox::ExecResult::Cancel) return; } m_selected_file = path; - done(ExecOK); + done(ExecResult::OK); } void FilePicker::set_path(String const& path) diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp index 570d42fa1c..244c430f1f 100644 --- a/Userland/Libraries/LibGUI/FontPicker.cpp +++ b/Userland/Libraries/LibGUI/FontPicker.cpp @@ -159,12 +159,12 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button"); ok_button.on_click = [this](auto) { - done(ExecOK); + done(ExecResult::OK); }; auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; set_font(current_font); diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp index 3cb0577bab..f6d838c09a 100644 --- a/Userland/Libraries/LibGUI/InputBox.cpp +++ b/Userland/Libraries/LibGUI/InputBox.cpp @@ -25,7 +25,7 @@ InputBox::InputBox(Window* parent_window, String& text_value, StringView prompt, build(input_type); } -int InputBox::show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type) +Dialog::ExecResult InputBox::show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type) { auto box = InputBox::construct(parent_window, text_value, prompt, title, placeholder, input_type); box->set_resizable(false); @@ -87,7 +87,7 @@ void InputBox::build(InputType input_type) m_ok_button->on_click = [this](auto) { dbgln("GUI::InputBox: OK button clicked"); m_text_value = m_text_editor->text(); - done(ExecOK); + done(ExecResult::OK); }; m_ok_button->set_default(true); @@ -95,7 +95,7 @@ void InputBox::build(InputType input_type) m_cancel_button->set_text("Cancel"); m_cancel_button->on_click = [this](auto) { dbgln("GUI::InputBox: Cancel button clicked"); - done(ExecCancel); + done(ExecResult::Cancel); }; m_text_editor->on_escape_pressed = [this] { diff --git a/Userland/Libraries/LibGUI/InputBox.h b/Userland/Libraries/LibGUI/InputBox.h index 16593ed91c..7bcd1abcf3 100644 --- a/Userland/Libraries/LibGUI/InputBox.h +++ b/Userland/Libraries/LibGUI/InputBox.h @@ -22,7 +22,7 @@ class InputBox : public Dialog { public: virtual ~InputBox() override = default; - static int show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text); + static ExecResult show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text); private: explicit InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type); diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index 5a29379ff8..a438e90928 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -16,7 +16,7 @@ namespace GUI { -int MessageBox::show(Window* parent_window, StringView text, StringView title, Type type, InputType input_type) +Dialog::ExecResult MessageBox::show(Window* parent_window, StringView text, StringView title, Type type, InputType input_type) { auto box = MessageBox::construct(parent_window, text, title, type, input_type); if (parent_window) @@ -24,12 +24,12 @@ int MessageBox::show(Window* parent_window, StringView text, StringView title, T return box->exec(); } -int MessageBox::show_error(Window* parent_window, StringView text) +Dialog::ExecResult MessageBox::show_error(Window* parent_window, StringView text) { return show(parent_window, text, "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); } -int MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Time> last_unmodified_timestamp) +Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Time> last_unmodified_timestamp) { StringBuilder builder; builder.append("Save changes to "); @@ -151,7 +151,7 @@ void MessageBox::build() constexpr int button_width = 80; int button_count = 0; - auto add_button = [&](String label, Dialog::ExecResult result) -> GUI::Button& { + auto add_button = [&](String label, ExecResult result) -> GUI::Button& { auto& button = button_container.add<Button>(); button.set_fixed_width(button_width); button.set_text(label); @@ -164,13 +164,13 @@ void MessageBox::build() button_container.layout()->add_spacer(); if (should_include_ok_button()) - m_ok_button = add_button("OK", Dialog::ExecOK); + m_ok_button = add_button("OK", ExecResult::OK); if (should_include_yes_button()) - m_yes_button = add_button("Yes", Dialog::ExecYes); + m_yes_button = add_button("Yes", ExecResult::Yes); if (should_include_no_button()) - m_no_button = add_button("No", Dialog::ExecNo); + m_no_button = add_button("No", ExecResult::No); if (should_include_cancel_button()) - m_cancel_button = add_button("Cancel", Dialog::ExecCancel); + m_cancel_button = add_button("Cancel", ExecResult::Cancel); button_container.layout()->add_spacer(); int width = (button_count * button_width) + ((button_count - 1) * button_container.layout()->spacing()) + 32; diff --git a/Userland/Libraries/LibGUI/MessageBox.h b/Userland/Libraries/LibGUI/MessageBox.h index 12d8ae72e0..2fe39754a7 100644 --- a/Userland/Libraries/LibGUI/MessageBox.h +++ b/Userland/Libraries/LibGUI/MessageBox.h @@ -32,9 +32,9 @@ public: virtual ~MessageBox() override = default; - static int show(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK); - static int show_error(Window* parent_window, StringView text); - static int ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Time> last_unmodified_timestamp = {}); + static ExecResult show(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK); + static ExecResult show_error(Window* parent_window, StringView text); + static ExecResult ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Time> last_unmodified_timestamp = {}); void set_text(String text); diff --git a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp index 37731d27bc..a961fe4108 100644 --- a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp +++ b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp @@ -42,13 +42,13 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, String title, St ok_button.on_click = [&](auto) { dbgln("GUI::PasswordInputDialog: OK button clicked"); m_password = password_box.text(); - done(ExecOK); + done(ExecResult::OK); }; auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.on_click = [this](auto) { dbgln("GUI::PasswordInputDialog: Cancel button clicked"); - done(ExecCancel); + done(ExecResult::Cancel); }; password_box.on_return_pressed = [&] { @@ -60,7 +60,7 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, String title, St password_box.set_focus(true); } -int PasswordInputDialog::show(Window* parent_window, String& text_value, String title, String server, String username) +Dialog::ExecResult PasswordInputDialog::show(Window* parent_window, String& text_value, String title, String server, String username) { auto box = PasswordInputDialog::construct(parent_window, move(title), move(server), move(username)); auto result = box->exec(); diff --git a/Userland/Libraries/LibGUI/PasswordInputDialog.h b/Userland/Libraries/LibGUI/PasswordInputDialog.h index ee3200d792..78923bd0de 100644 --- a/Userland/Libraries/LibGUI/PasswordInputDialog.h +++ b/Userland/Libraries/LibGUI/PasswordInputDialog.h @@ -17,7 +17,7 @@ class PasswordInputDialog : public Dialog { public: virtual ~PasswordInputDialog() override = default; - static int show(Window* parent_window, String& text_value, String title, String server, String username); + static ExecResult show(Window* parent_window, String& text_value, String title, String server, String username); private: explicit PasswordInputDialog(Window* parent_window, String title, String server, String username); diff --git a/Userland/Libraries/LibGUI/ProcessChooser.cpp b/Userland/Libraries/LibGUI/ProcessChooser.cpp index 2a55fbee53..6c5be287f0 100644 --- a/Userland/Libraries/LibGUI/ProcessChooser.cpp +++ b/Userland/Libraries/LibGUI/ProcessChooser.cpp @@ -65,7 +65,7 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, auto& cancel_button = button_container.add<GUI::Button>("Cancel"); cancel_button.set_fixed_width(80); cancel_button.on_click = [this](auto) { - done(ExecCancel); + done(ExecResult::Cancel); }; m_process_model->update(); @@ -102,7 +102,7 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label, void ProcessChooser::set_pid_from_index_and_close(ModelIndex const& index) { m_pid = index.data(GUI::ModelRole::Custom).as_i32(); - done(ExecOK); + done(ExecResult::OK); } } diff --git a/Userland/Libraries/LibGUI/SettingsWindow.cpp b/Userland/Libraries/LibGUI/SettingsWindow.cpp index 2034f82b0b..23815f0b8a 100644 --- a/Userland/Libraries/LibGUI/SettingsWindow.cpp +++ b/Userland/Libraries/LibGUI/SettingsWindow.cpp @@ -81,10 +81,10 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(String title, Show auto result = MessageBox::show(window, "Apply these settings before closing?", "Unsaved changes", MessageBox::Type::Warning, MessageBox::InputType::YesNoCancel); switch (result) { - case MessageBox::ExecYes: + case MessageBox::ExecResult::Yes: window->apply_settings(); return Window::CloseRequestDecision::Close; - case MessageBox::ExecNo: + case MessageBox::ExecResult::No: window->cancel_settings(); return Window::CloseRequestDecision::Close; default: diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 9565991a8a..8ea4a8ee47 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -94,7 +94,7 @@ void TextEditor::create_actions() m_go_to_line_action = Action::create( "Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { String value; - if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecOK) { + if (InputBox::show(window(), value, "Line:", "Go to line") == InputBox::ExecResult::OK) { auto line_target = value.to_uint(); if (line_target.has_value()) { set_cursor_and_focus_line(line_target.value() - 1, 0); diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp index c1d3cad741..d0c335c1c9 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp @@ -58,11 +58,11 @@ WizardDialog::WizardDialog(Window* parent_window) VERIFY(has_pages()); if (!current_page().can_go_next()) - return done(ExecOK); + return done(ExecResult::OK); auto next_page = current_page().next_page(); if (!next_page) - return done(ExecOK); + return done(ExecResult::OK); push_page(*next_page); }; @@ -143,7 +143,7 @@ void WizardDialog::handle_cancel() if (on_cancel) return on_cancel(); - done(ExecCancel); + done(ExecResult::Cancel); } } diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 28e0d18143..08f89d3151 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -329,13 +329,13 @@ void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message) { auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - return confirm_result == GUI::Dialog::ExecResult::ExecOK; + return confirm_result == GUI::Dialog::ExecResult::OK; } String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_) { String response { default_ }; - if (GUI::InputBox::show(window(), response, message, "Prompt") == GUI::InputBox::ExecOK) + if (GUI::InputBox::show(window(), response, message, "Prompt") == GUI::InputBox::ExecResult::OK) return response; return {}; } diff --git a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp index 67a4257b03..bff739df08 100644 --- a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp +++ b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp @@ -77,7 +77,7 @@ void ConnectionFromClient::request_file_handler(i32 window_server_client_id, i32 if (prompt == ShouldPrompt::Yes) { auto exe_name = LexicalPath::basename(exe_path); auto result = GUI::MessageBox::show(main_window, String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path), "File Permissions Requested", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); - approved = result == GUI::MessageBox::ExecYes; + approved = result == GUI::MessageBox::ExecResult::Yes; } else { approved = true; } diff --git a/Userland/Services/Taskbar/ShutdownDialog.cpp b/Userland/Services/Taskbar/ShutdownDialog.cpp index e2df096174..7d5840a2cc 100644 --- a/Userland/Services/Taskbar/ShutdownDialog.cpp +++ b/Userland/Services/Taskbar/ShutdownDialog.cpp @@ -33,7 +33,7 @@ Vector<char const*> ShutdownDialog::show() { auto dialog = ShutdownDialog::construct(); auto rc = dialog->exec(); - if (rc == ExecResult::ExecOK && dialog->m_selected_option != -1) + if (rc == ExecResult::OK && dialog->m_selected_option != -1) return options[dialog->m_selected_option].cmd; return {}; @@ -100,12 +100,12 @@ ShutdownDialog::ShutdownDialog() auto& ok_button = button_container.add<GUI::Button>("OK"); ok_button.set_fixed_size(80, 23); ok_button.on_click = [this](auto) { - done(Dialog::ExecOK); + done(ExecResult::OK); }; auto& cancel_button = button_container.add<GUI::Button>("Cancel"); cancel_button.set_fixed_size(80, 23); cancel_button.on_click = [this](auto) { - done(ExecResult::ExecCancel); + done(ExecResult::Cancel); }; resize(413, 235); |