mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibGUI+Userland: Make Dialog::ExecResult an enum class
This commit is contained in:
parent
1f82beded3
commit
cdffe556c8
90 changed files with 232 additions and 232 deletions
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue