From cdffe556c8fcca034b10cf91f0b05c17d835bc7b Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 13 May 2022 13:10:27 +0100 Subject: LibGUI+Userland: Make Dialog::ExecResult an enum class --- Userland/Applications/HexEditor/FindDialog.cpp | 10 +++++----- Userland/Applications/HexEditor/FindDialog.h | 2 +- Userland/Applications/HexEditor/GoToOffsetDialog.cpp | 8 ++++---- Userland/Applications/HexEditor/GoToOffsetDialog.h | 2 +- Userland/Applications/HexEditor/HexEditorWidget.cpp | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'Userland/Applications/HexEditor') 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 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 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 #include -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) -- cgit v1.2.3