mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGUI: Don't mark "open" FilePicker as done if the file is not found
If you type in a filename that doesn't exist, show an error message instead of closing the FilePicker "successfully."
This commit is contained in:
parent
9b9966b63b
commit
54f6ac1854
Notes:
sideshowbarker
2024-07-18 17:42:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/54f6ac1854f
1 changed files with 8 additions and 1 deletions
|
@ -252,7 +252,14 @@ void FilePicker::on_file_return()
|
||||||
path = LexicalPath::join(m_model->root_path(), path).string();
|
path = LexicalPath::join(m_model->root_path(), path).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::File::exists(path) && m_mode == Mode::Save) {
|
bool file_exists = Core::File::exists(path);
|
||||||
|
|
||||||
|
if (!file_exists && (m_mode == Mode::Open || m_mode == Mode::OpenFolder)) {
|
||||||
|
MessageBox::show(this, String::formatted("No such file or directory: {}", m_filename_textbox->text()), "File not found", MessageBox::Type::Error, MessageBox::InputType::OK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists && m_mode == Mode::Save) {
|
||||||
auto result = MessageBox::show(this, "File already exists. Overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel);
|
auto result = MessageBox::show(this, "File already exists. Overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel);
|
||||||
if (result == MessageBox::ExecCancel)
|
if (result == MessageBox::ExecCancel)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue