mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
LibGUI: Make GUI::FilePicker handle absolute paths better
Some people apparently like to type in full absolute paths into the filename box of GUI::FilePicker. So let's handle that as you'd expect by using the full path as the selected path.
This commit is contained in:
parent
3773e72752
commit
9b9966b63b
1 changed files with 6 additions and 3 deletions
|
@ -247,15 +247,18 @@ void FilePicker::model_did_update(unsigned)
|
||||||
|
|
||||||
void FilePicker::on_file_return()
|
void FilePicker::on_file_return()
|
||||||
{
|
{
|
||||||
LexicalPath path(String::formatted("{}/{}", m_model->root_path(), m_filename_textbox->text()));
|
auto path = m_filename_textbox->text();
|
||||||
|
if (!path.starts_with('/')) {
|
||||||
|
path = LexicalPath::join(m_model->root_path(), path).string();
|
||||||
|
}
|
||||||
|
|
||||||
if (Core::File::exists(path.string()) && m_mode == Mode::Save) {
|
if (Core::File::exists(path) && 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selected_file = path.string();
|
m_selected_file = path;
|
||||||
done(ExecOK);
|
done(ExecOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue