1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:37:35 +00:00

FileManager: Use InputBox icons for file and directory creation

And set a window icon in desktop mode.
This commit is contained in:
thankyouverycool 2023-04-16 16:06:31 -04:00 committed by Andreas Kling
parent ca8918f310
commit 14072ce8f0
2 changed files with 7 additions and 2 deletions

View file

@ -569,7 +569,8 @@ void DirectoryView::setup_actions()
{ {
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value; String value;
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors();
if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New directory"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) {
auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
int rc = mkdir(new_dir_path.characters(), 0777); int rc = mkdir(new_dir_path.characters(), 0777);
if (rc < 0) { if (rc < 0) {
@ -581,7 +582,8 @@ void DirectoryView::setup_actions()
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value; String value;
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors();
if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New file"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) {
auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value));
struct stat st; struct stat st;
int rc = stat(new_file_path.characters(), &st); int rc = stat(new_file_path.characters(), &st);

View file

@ -384,6 +384,9 @@ ErrorOr<int> run_in_desktop_mode()
window->set_window_type(GUI::WindowType::Desktop); window->set_window_type(GUI::WindowType::Desktop);
window->set_has_alpha_channel(true); window->set_has_alpha_channel(true);
auto desktop_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/desktop.png"sv));
window->set_icon(desktop_icon);
auto desktop_widget = TRY(window->set_main_widget<FileManager::DesktopWidget>()); auto desktop_widget = TRY(window->set_main_widget<FileManager::DesktopWidget>());
TRY(desktop_widget->try_set_layout<GUI::VerticalBoxLayout>()); TRY(desktop_widget->try_set_layout<GUI::VerticalBoxLayout>());