mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 07:35:07 +00:00
FileManager: Show an inline error message for inaccessible directories
Instead of popping up a message box whenever we can't read an opened directory, show the error message inside the DirectoryView (as a label) instead. This fixes a visual inconsistency where an inaccessible directory would be selected in the left-side treeview while the previous directory's contents were still showing on the right. This also makes keyboard navigation a bit more pleasant since you're not suddenly interrupted by a message box.
This commit is contained in:
parent
9b89303767
commit
8075db683b
3 changed files with 16 additions and 12 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <LibCore/MimeData.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/SortingProxyModel.h>
|
||||
#include <serenity.h>
|
||||
|
@ -135,6 +136,9 @@ DirectoryView::DirectoryView(Mode mode)
|
|||
|
||||
setup_actions();
|
||||
|
||||
m_error_label = add<GUI::Label>();
|
||||
m_error_label->set_font(m_error_label->font().bold_family_font());
|
||||
|
||||
setup_model();
|
||||
|
||||
setup_icon_view();
|
||||
|
@ -155,15 +159,20 @@ void DirectoryView::setup_model()
|
|||
{
|
||||
m_model->set_root_path(Core::StandardPaths::desktop_directory());
|
||||
|
||||
m_model->on_error = [this](int error, const char* error_string) {
|
||||
m_model->on_error = [this](int, const char* error_string) {
|
||||
auto failed_path = m_model->root_path();
|
||||
bool quit = false;
|
||||
if (m_path_history.size())
|
||||
open(m_path_history.at(m_path_history_position));
|
||||
else
|
||||
quit = true;
|
||||
|
||||
if (on_error)
|
||||
on_error(error, error_string, quit);
|
||||
if (quit)
|
||||
exit(1);
|
||||
|
||||
auto error_message = String::format("Could not read %s:\n%s", failed_path.characters(), error_string);
|
||||
m_error_label->set_text(error_message);
|
||||
set_active_widget(m_error_label);
|
||||
};
|
||||
|
||||
m_model->on_complete = [this] {
|
||||
|
@ -321,6 +330,8 @@ void DirectoryView::open(const StringView& path)
|
|||
model().update();
|
||||
return;
|
||||
}
|
||||
|
||||
set_active_widget(¤t_view());
|
||||
model().set_root_path(path);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue