LibGUI: Add input types to GMessageBox.

Currently the two available input types are:

- GMessageBox::InputType::OK (default)
- GMessageBox::InputType::OKCancel

Based on your choice, GMessageBox::exec() will return ExecOK or ExecCancel.
This commit is contained in:
Andreas Kling 2019-07-16 21:32:10 +02:00
parent 62335c5f0c
commit a17fbd98e7
Notes: sideshowbarker 2024-07-19 13:13:55 +09:00
8 changed files with 63 additions and 26 deletions

View file

@ -40,7 +40,7 @@ Optional<String> GFilePicker::get_save_filepath()
if (GFilePicker::file_exists(file_path)) {
//TODO: Add Yes, No Messagebox to give the user a proper option
GMessageBox::show("File already exists: Overwrite?\n", "Warning", GMessageBox::Type::Warning, &picker);
GMessageBox::show("File already exists: Overwrite?\n", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OK, &picker);
return file_path;
}
@ -110,7 +110,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
.string();
int rc = mkdir(new_dir_path.characters(), 0777);
if (rc < 0) {
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, this);
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, this);
} else {
m_model->update();
}
@ -244,4 +244,4 @@ bool GFilePicker::file_exists(const StringView& path)
return true;
}
return false;
}
}