mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
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:
parent
62335c5f0c
commit
a17fbd98e7
8 changed files with 63 additions and 26 deletions
|
@ -97,7 +97,7 @@ int main(int argc, char** argv)
|
|||
input_box.text_value().characters()));
|
||||
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, window);
|
||||
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
||||
} else {
|
||||
directory_view->refresh();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ int main(int argc, char** argv)
|
|||
auto filename = picker.selected_file().string();
|
||||
auto bitmap = load_png(filename);
|
||||
if (!bitmap) {
|
||||
GMessageBox msgbox(String::format("Failed to load '%s'", filename.characters()), "Open failed", GMessageBox::Type::Error, window);
|
||||
GMessageBox msgbox(String::format("Failed to load '%s'", filename.characters()), "Open failed", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
|
||||
msgbox.exec();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ int run_shutdown_dialog(int argc, char** argv)
|
|||
GApplication app(argc, argv);
|
||||
|
||||
{
|
||||
GMessageBox box("Shut down Serenity?", "Confirm Shutdown", GMessageBox::Type::Warning, GMessageBox::InputType::OkCancel);
|
||||
GMessageBox box("Shut down Serenity?", "Confirm Shutdown", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel);
|
||||
auto result = box.exec();
|
||||
|
||||
if (result == GMessageBox::ExecOK) {
|
||||
|
|
|
@ -46,7 +46,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
auto save_action = GAction::create("Save document", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GAction&) {
|
||||
if (!m_path.is_empty()) {
|
||||
if (!m_editor->write_to_file(m_path))
|
||||
GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, window());
|
||||
GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
return;
|
||||
|
||||
if (!m_editor->write_to_file(save_name.value())) {
|
||||
GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, window());
|
||||
GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,10 +135,10 @@ void TextEditorWidget::open_sesame(const String& path)
|
|||
CFile file(path);
|
||||
|
||||
if (!file.open(CIODevice::ReadOnly)) {
|
||||
GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, window());
|
||||
GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
}
|
||||
|
||||
window()->set_title(String::format("Text Editor: %s", path.characters()));
|
||||
m_editor->set_text(String::copy(file.read_all()));
|
||||
m_path = path;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue