mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:47:45 +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
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue