LibGUI: Disable changing the view on error in the FilePicker

Prior to this change, changing the view would hide the error label
and show an empty directory.
This commit is contained in:
Karol Kosek 2021-07-27 15:48:02 +02:00 committed by Gunnar Beutner
commit 99d46caa28
Notes: sideshowbarker 2024-07-19 17:22:28 +09:00

View file

@ -219,11 +219,19 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
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_view->view_as_icons_action().set_enabled(false);
m_view->view_as_table_action().set_enabled(false);
m_view->view_as_columns_action().set_enabled(false);
};
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);
m_view->view_as_icons_action().set_enabled(true);
m_view->view_as_table_action().set_enabled(true);
m_view->view_as_columns_action().set_enabled(true);
};
for (auto& location : CommonLocationsProvider::common_locations()) {