summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-07-27 13:52:28 +0200
committerGunnar Beutner <gunnar@beutner.name>2021-07-27 19:06:21 +0200
commit80e3cf3ef7e7934205fba2c7ad8e3310178d322b (patch)
treecdb9daa74f40fb69eef30719c66f34e1651da069
parentf2d3fcb7cd6e97c15f2911bf16ee777173f1ea54 (diff)
downloadserenity-80e3cf3ef7e7934205fba2c7ad8e3310178d322b.zip
LibGUI: Show an error message on open error in the FilePicker
-rw-r--r--Userland/Libraries/LibGUI/FilePicker.cpp9
-rw-r--r--Userland/Libraries/LibGUI/FilePicker.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp
index daaf2df9b1..f3e97cdbe3 100644
--- a/Userland/Libraries/LibGUI/FilePicker.cpp
+++ b/Userland/Libraries/LibGUI/FilePicker.cpp
@@ -17,6 +17,7 @@
#include <LibGUI/FilePickerDialogGML.h>
#include <LibGUI/FileSystemModel.h>
#include <LibGUI/InputBox.h>
+#include <LibGUI/Label.h>
#include <LibGUI/Menu.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/MultiView.h>
@@ -104,6 +105,9 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
m_model->register_client(*this);
+ m_error_label = m_view->add<GUI::Label>();
+ m_error_label->set_font(m_error_label->font().bold_variant());
+
m_location_textbox->on_return_pressed = [this] {
set_path(m_location_textbox->text());
};
@@ -212,7 +216,12 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
auto& common_locations_frame = *widget.find_descendant_of_type_named<Frame>("common_locations_frame");
common_locations_frame.set_background_role(Gfx::ColorRole::Tray);
+ m_model->on_directory_change_error = [&](int, char const* error_string) {
+ m_error_label->set_text(String::formatted("Could not open {}:\n{}", m_model->root_path(), error_string));
+ m_view->set_active_widget(m_error_label);
+ };
m_model->on_complete = [&] {
+ m_view->set_active_widget(&m_view->current_view());
for (auto location_button : m_common_location_buttons)
location_button.button.set_checked(m_model->root_path() == location_button.path);
};
diff --git a/Userland/Libraries/LibGUI/FilePicker.h b/Userland/Libraries/LibGUI/FilePicker.h
index 216a97dfb1..44858dfcda 100644
--- a/Userland/Libraries/LibGUI/FilePicker.h
+++ b/Userland/Libraries/LibGUI/FilePicker.h
@@ -68,6 +68,8 @@ private:
NonnullRefPtr<FileSystemModel> m_model;
String m_selected_file;
+ RefPtr<GUI::Label> m_error_label;
+
RefPtr<TextBox> m_filename_textbox;
RefPtr<TextBox> m_location_textbox;
Vector<CommonLocationButton> m_common_location_buttons;