mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibGUI: Show an error message on open error in the FilePicker
This commit is contained in:
parent
f2d3fcb7cd
commit
80e3cf3ef7
2 changed files with 11 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <LibGUI/FilePickerDialogGML.h>
|
#include <LibGUI/FilePickerDialogGML.h>
|
||||||
#include <LibGUI/FileSystemModel.h>
|
#include <LibGUI/FileSystemModel.h>
|
||||||
#include <LibGUI/InputBox.h>
|
#include <LibGUI/InputBox.h>
|
||||||
|
#include <LibGUI/Label.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibGUI/MultiView.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_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] {
|
m_location_textbox->on_return_pressed = [this] {
|
||||||
set_path(m_location_textbox->text());
|
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");
|
auto& common_locations_frame = *widget.find_descendant_of_type_named<Frame>("common_locations_frame");
|
||||||
common_locations_frame.set_background_role(Gfx::ColorRole::Tray);
|
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_model->on_complete = [&] {
|
||||||
|
m_view->set_active_widget(&m_view->current_view());
|
||||||
for (auto location_button : m_common_location_buttons)
|
for (auto location_button : m_common_location_buttons)
|
||||||
location_button.button.set_checked(m_model->root_path() == location_button.path);
|
location_button.button.set_checked(m_model->root_path() == location_button.path);
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,6 +68,8 @@ private:
|
||||||
NonnullRefPtr<FileSystemModel> m_model;
|
NonnullRefPtr<FileSystemModel> m_model;
|
||||||
String m_selected_file;
|
String m_selected_file;
|
||||||
|
|
||||||
|
RefPtr<GUI::Label> m_error_label;
|
||||||
|
|
||||||
RefPtr<TextBox> m_filename_textbox;
|
RefPtr<TextBox> m_filename_textbox;
|
||||||
RefPtr<TextBox> m_location_textbox;
|
RefPtr<TextBox> m_location_textbox;
|
||||||
Vector<CommonLocationButton> m_common_location_buttons;
|
Vector<CommonLocationButton> m_common_location_buttons;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue