summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhin123 <ryanrhin@gmail.com>2019-07-17 11:28:47 -0500
committerAndreas Kling <awesomekling@gmail.com>2019-07-18 21:04:02 +0200
commit598715d4ccd328d09e67d496eb34a91e62fcfd39 (patch)
tree149a377f545fb60152d359c7f070d9c0b96a8a7e
parent4da2521606e0820ac8c3ae5b6367f8f09e5884cf (diff)
downloadserenity-598715d4ccd328d09e67d496eb34a91e62fcfd39.zip
GFilePicker: OKCancel MsgBox for overwriting files
Allow the user to Overwrite/Cancel when writing to an existing file.
-rw-r--r--Libraries/LibGUI/GFilePicker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Libraries/LibGUI/GFilePicker.cpp b/Libraries/LibGUI/GFilePicker.cpp
index fb4b3c819c..794fc34cc6 100644
--- a/Libraries/LibGUI/GFilePicker.cpp
+++ b/Libraries/LibGUI/GFilePicker.cpp
@@ -38,12 +38,6 @@ Optional<String> GFilePicker::get_save_filepath()
if (file_path.is_null())
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 {};
@@ -177,6 +171,13 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
ok_button->set_text(ok_button_name(m_mode));
ok_button->on_click = [this, filename_textbox](auto&) {
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;
done(ExecOK);
};