mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LibGUI: Show an error message box in the FilePicker on no permissions
The first attempt in #9037 used a special label as a view, if it wanted to communicate any kind of error, but that sure did look a bit ugly. Here, we are just showing a message box right before setting the new path as: - the contents of the previous directory will be visible in background, which I find pretty nice, and - I don't have to deal with adding a path history vector to reopen the previous directory (which might not even exist then). :^)
This commit is contained in:
parent
14c30af7d8
commit
848c4fc43d
1 changed files with 8 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <LibGfx/FontDatabase.h>
|
#include <LibGfx/FontDatabase.h>
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
@ -291,6 +292,13 @@ void FilePicker::on_file_return()
|
||||||
|
|
||||||
void FilePicker::set_path(const String& path)
|
void FilePicker::set_path(const String& path)
|
||||||
{
|
{
|
||||||
|
if (access(path.characters(), R_OK | X_OK) == -1) {
|
||||||
|
GUI::MessageBox::show(this, String::formatted("Could not open '{}':\n{}", path, strerror(errno)), "Error", GUI::MessageBox::Type::Error);
|
||||||
|
for (auto location_button : m_common_location_buttons)
|
||||||
|
location_button.button.set_checked(m_model->root_path() == location_button.path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto new_path = LexicalPath(path).string();
|
auto new_path = LexicalPath(path).string();
|
||||||
m_location_textbox->set_icon(FileIconProvider::icon_for_path(new_path).bitmap_for_size(16));
|
m_location_textbox->set_icon(FileIconProvider::icon_for_path(new_path).bitmap_for_size(16));
|
||||||
m_model->set_root_path(new_path);
|
m_model->set_root_path(new_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue