mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
GFilePicker: OKCancel MsgBox for overwriting files
Allow the user to Overwrite/Cancel when writing to an existing file.
This commit is contained in:
parent
4da2521606
commit
598715d4cc
1 changed files with 7 additions and 6 deletions
|
@ -38,12 +38,6 @@ Optional<String> GFilePicker::get_save_filepath()
|
||||||
if (file_path.is_null())
|
if (file_path.is_null())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
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, GMessageBox::InputType::OK, &picker);
|
|
||||||
return file_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return file_path;
|
return file_path;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -177,6 +171,13 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
||||||
ok_button->set_text(ok_button_name(m_mode));
|
ok_button->set_text(ok_button_name(m_mode));
|
||||||
ok_button->on_click = [this, filename_textbox](auto&) {
|
ok_button->on_click = [this, filename_textbox](auto&) {
|
||||||
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters()));
|
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters()));
|
||||||
|
|
||||||
|
if (GFilePicker::file_exists(path.string()) && m_mode == Mode::Save) {
|
||||||
|
GMessageBox box("File already exists, overwrite?", "Existing File", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel);
|
||||||
|
if (box.exec() == GMessageBox::ExecCancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_selected_file = path;
|
m_selected_file = path;
|
||||||
done(ExecOK);
|
done(ExecOK);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue