diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-11 17:32:29 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | 3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch) | |
tree | 152c7a187c98184d58bf91a326357e0af435edcf /Userland/Applications/FileManager | |
parent | e5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff) | |
download | serenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip |
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).
No functional changes.
Diffstat (limited to 'Userland/Applications/FileManager')
5 files changed, 80 insertions, 80 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index c0bbbd61bd..21ca93702e 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -125,7 +125,7 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index) unsetenv("__libgui_launch_origin_rect"); } else { auto error_message = String::formatted("Could not open {}", path); - GUI::MessageBox::show(window(), error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error); } } @@ -332,10 +332,10 @@ void DirectoryView::set_view_mode_from_string(String const& mode) if (m_mode == Mode::Desktop) return; - if (mode.contains("Table")) { + if (mode.contains("Table"sv)) { set_view_mode(DirectoryView::ViewMode::Table); m_view_as_table_action->set_checked(true); - } else if (mode.contains("Columns")) { + } else if (mode.contains("Columns"sv)) { set_view_mode(DirectoryView::ViewMode::Columns); m_view_as_columns_action->set_checked(true); } else { @@ -462,7 +462,7 @@ void DirectoryView::update_statusbar() if (selected_item_count == 1) { auto& node = this->node(current_view().selection().first()); if (!node.symlink_target.is_empty()) { - builder.append(" → "); + builder.append(" → "sv); builder.append(node.symlink_target); } } @@ -550,37 +550,37 @@ void DirectoryView::handle_selection_change() void DirectoryView::setup_actions() { - m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").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::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); } } }); - m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").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::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } if (rc == 0) { - GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error); return; } int fd = creat(new_file_path.characters(), 0666); if (fd < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } rc = close(fd); @@ -588,7 +588,7 @@ void DirectoryView::setup_actions() } }); - m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { spawn_terminal(path()); }); @@ -605,23 +605,23 @@ void DirectoryView::setup_actions() window()); m_view_as_icons_action = GUI::Action::create_checkable( - "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Icon); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv); }, window()); m_view_as_table_action = GUI::Action::create_checkable( - "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Table); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Table"sv); }, window()); m_view_as_columns_action = GUI::Action::create_checkable( - "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Columns); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Columns"sv); }, window()); diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index 51532cad11..2ecbe80445 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -27,20 +27,20 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation auto& button = *find_descendant_of_type_named<GUI::Button>("button"); auto& file_copy_animation = *find_descendant_of_type_named<GUI::ImageWidget>("file_copy_animation"); - file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif"); + file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif"sv); file_copy_animation.animate(); auto& source_folder_icon = *find_descendant_of_type_named<GUI::ImageWidget>("source_folder_icon"); - source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"); + source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv); auto& destination_folder_icon = *find_descendant_of_type_named<GUI::ImageWidget>("destination_folder_icon"); switch (m_operation) { case FileOperation::Delete: - destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png"); + destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png"sv); break; default: - destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"); + destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv); break; } @@ -129,7 +129,7 @@ void FileOperationProgressWidget::did_error(StringView message) { // FIXME: Communicate more with the user about errors. close_pipe(); - GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); window()->close(); } diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index fdcc66b7dc..f74fc80a0e 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -29,7 +29,7 @@ void delete_paths(Vector<String> const& paths, bool should_confirm, GUI::Window* if (should_confirm) { auto result = GUI::MessageBox::show(parent_window, message, - "Confirm deletion", + "Confirm deletion"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); if (result == GUI::MessageBox::ExecResult::Cancel) @@ -51,17 +51,17 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<String> const& TRY(Core::System::dup2(pipe_fds[1], STDOUT_FILENO)); Vector<StringView> file_operation_args; - file_operation_args.append("/bin/FileOperation"); + file_operation_args.append("/bin/FileOperation"sv); switch (operation) { case FileOperation::Copy: - file_operation_args.append("Copy"); + file_operation_args.append("Copy"sv); break; case FileOperation::Move: - file_operation_args.append("Move"); + file_operation_args.append("Move"sv); break; case FileOperation::Delete: - file_operation_args.append("Delete"); + file_operation_args.append("Delete"sv); break; default: VERIFY_NOT_REACHED(); diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 45a6012f10..2e6e874d76 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -40,7 +40,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind set_rect({ 0, 0, 360, 420 }); set_resizable(false); - set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors()); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors()); auto& tab_widget = main_widget.add<GUI::TabWidget>(); @@ -194,12 +194,12 @@ bool PropertiesWindow::apply_changes() String new_file = make_full_path(new_name).characters(); if (Core::File::exists(new_file)) { - GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error); return false; } if (rename(make_full_path(m_name).characters(), new_file.characters())) { - GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -210,7 +210,7 @@ bool PropertiesWindow::apply_changes() if (m_permissions_dirty) { if (chmod(make_full_path(m_name).characters(), m_mode)) { - GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index ff1d45c46d..5b926e8859 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -135,7 +135,7 @@ void do_copy(Vector<String> const& selected_file_paths, FileOperation file_opera StringBuilder copy_text; if (file_operation == FileOperation::Move) { - copy_text.append("#cut\n"); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish + copy_text.append("#cut\n"sv); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish } for (auto& path : selected_file_paths) { auto url = URL::create_with_file_protocol(path); @@ -186,7 +186,7 @@ void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* wind auto path = selected_file_paths.first(); auto destination = String::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path)); if (auto result = Core::File::link_file(destination, path); result.is_error()) { - GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager", + GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv, GUI::MessageBox::Type::Error); } } @@ -194,7 +194,7 @@ void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* wind void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* window) { String archive_name; - if (GUI::InputBox::show(window, archive_name, "Enter name:", "Create Archive") != GUI::InputBox::ExecResult::OK) + if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK) return; auto output_directory_path = LexicalPath(selected_file_paths.first()); @@ -204,11 +204,11 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w path_builder.append("/"); if (archive_name.is_empty()) { path_builder.append(output_directory_path.parent().basename()); - path_builder.append(".zip"); + path_builder.append(".zip"sv); } else { path_builder.append(archive_name); - if (!archive_name.ends_with(".zip")) - path_builder.append(".zip"); + if (!archive_name.ends_with(".zip"sv)) + path_builder.append(".zip"sv); } auto output_path = path_builder.build(); @@ -239,7 +239,7 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w int status; int rc = waitpid(zip_pid, &status, 0); if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - GUI::MessageBox::show(window, "Could not create archive", "Archive Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Could not create archive"sv, "Archive Error"sv, GUI::MessageBox::Type::Error); } } @@ -265,7 +265,7 @@ void do_unzip_archive(Vector<String> const& selected_file_paths, GUI::Window* wi int status; int rc = waitpid(unzip_pid, &status, 0); if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - GUI::MessageBox::show(window, "Could not extract archive", "Extract Archive Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Could not extract archive"sv, "Extract Archive Error"sv, GUI::MessageBox::Type::Error); } } @@ -362,7 +362,7 @@ ErrorOr<int> run_in_desktop_mode() auto create_archive_action = GUI::Action::create( "Create &Archive", - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) @@ -411,7 +411,7 @@ ErrorOr<int> run_in_desktop_mode() auto desktop_view_context_menu = TRY(GUI::Menu::try_create("Directory View")); - auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { Desktop::Launcher::open(URL::create_with_file_protocol(directory_view->path())); @@ -424,7 +424,7 @@ ErrorOr<int> run_in_desktop_mode() } }); - auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { spawn_terminal(directory_view->path()); @@ -438,7 +438,7 @@ ErrorOr<int> run_in_desktop_mode() } }); - auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings")); }); @@ -488,7 +488,7 @@ ErrorOr<int> run_in_desktop_mode() file_context_menu->add_action(create_archive_action); file_context_menu->add_separator(); - if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) { + if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) { file_context_menu->add_action(unzip_archive_action); file_context_menu->add_separator(); } @@ -514,7 +514,7 @@ ErrorOr<int> run_in_desktop_mode() } } wallpaper_listener; - auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", ""); + auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv); if (!selected_wallpaper.is_empty()) { auto wallpaper_bitmap = TRY(Gfx::Bitmap::try_load_from_file(selected_wallpaper)); GUI::Desktop::the().set_wallpaper(wallpaper_bitmap, {}); @@ -529,11 +529,11 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& auto window = TRY(GUI::Window::try_create()); window->set_title("File Manager"); - auto left = Config::read_i32("FileManager", "Window", "Left", 150); - auto top = Config::read_i32("FileManager", "Window", "Top", 75); - auto width = Config::read_i32("FileManager", "Window", "Width", 640); - auto height = Config::read_i32("FileManager", "Window", "Height", 480); - auto was_maximized = Config::read_bool("FileManager", "Window", "Maximized", false); + auto left = Config::read_i32("FileManager"sv, "Window"sv, "Left"sv, 150); + auto top = Config::read_i32("FileManager"sv, "Window"sv, "Top"sv, 75); + auto width = Config::read_i32("FileManager"sv, "Window"sv, "Width"sv, 640); + auto height = Config::read_i32("FileManager"sv, "Window"sv, "Height"sv, 480); + auto was_maximized = Config::read_bool("FileManager"sv, "Window"sv, "Maximized"sv, false); auto widget = TRY(window->try_set_main_widget<GUI::Widget>()); @@ -628,7 +628,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& auto directory_view_context_menu = TRY(GUI::Menu::try_create("Directory View")); auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create("Tree View Directory")); - auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->open_parent_directory(); }); @@ -637,7 +637,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& RefPtr<GUI::Action> layout_statusbar_action; RefPtr<GUI::Action> layout_folderpane_action; - auto show_toolbar = Config::read_bool("FileManager", "Layout", "ShowToolbar", true); + auto show_toolbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, true); layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) { if (action.is_checked()) { main_toolbar.set_visible(true); @@ -648,12 +648,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& toolbar_container.set_visible(false); } show_toolbar = action.is_checked(); - Config::write_bool("FileManager", "Layout", "ShowToolbar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked()); }); layout_toolbar_action->set_checked(show_toolbar); main_toolbar.set_visible(show_toolbar); - auto show_location = Config::read_bool("FileManager", "Layout", "ShowLocationBar", true); + auto show_location = Config::read_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, true); layout_location_action = GUI::Action::create_checkable("&Location Bar", [&](auto& action) { if (action.is_checked()) { breadcrumb_toolbar.set_visible(true); @@ -666,7 +666,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& toolbar_container.set_visible(false); } show_location = action.is_checked(); - Config::write_bool("FileManager", "Layout", "ShowLocationBar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, action.is_checked()); }); layout_location_action->set_checked(show_location); breadcrumb_toolbar.set_visible(show_location); @@ -675,19 +675,19 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& layout_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) { action.is_checked() ? statusbar.set_visible(true) : statusbar.set_visible(false); - Config::write_bool("FileManager", "Layout", "ShowStatusbar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, action.is_checked()); }); - auto show_statusbar = Config::read_bool("FileManager", "Layout", "ShowStatusbar", true); + auto show_statusbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, true); layout_statusbar_action->set_checked(show_statusbar); statusbar.set_visible(show_statusbar); layout_folderpane_action = GUI::Action::create_checkable("&Folder Pane", { Mod_Ctrl, Key_P }, [&](auto& action) { action.is_checked() ? tree_view.set_visible(true) : tree_view.set_visible(false); - Config::write_bool("FileManager", "Layout", "ShowFolderPane", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, action.is_checked()); }); - auto show_folderpane = Config::read_bool("FileManager", "Layout", "ShowFolderPane", true); + auto show_folderpane = Config::read_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, true); layout_folderpane_action->set_checked(show_folderpane); tree_view.set_visible(show_folderpane); @@ -749,7 +749,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Open in New &Window", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const& action) { Vector<String> paths; if (action.activator() == tree_view_directory_context_menu) @@ -768,7 +768,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Open in &Terminal", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const& action) { Vector<String> paths; if (action.activator() == tree_view_directory_context_menu) @@ -788,7 +788,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Create Desktop &Shortcut", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { @@ -801,7 +801,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& auto create_archive_action = GUI::Action::create( "Create &Archive", - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) @@ -909,12 +909,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& }); focus_dependent_delete_action->set_enabled(false); - auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->mkdir_action().activate(); refresh_tree_view(); }); - auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->touch_action().activate(); refresh_tree_view(); }); @@ -942,10 +942,10 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& directory_view->set_should_show_dotfiles(action.is_checked()); directories_model->set_should_show_dotfiles(action.is_checked()); refresh_tree_view(); - Config::write_bool("FileManager", "DirectoryView", "ShowDotFiles", action.is_checked()); + Config::write_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, action.is_checked()); }); - auto show_dotfiles = Config::read_bool("FileManager", "DirectoryView", "ShowDotFiles", false); + auto show_dotfiles = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false); directory_view->set_should_show_dotfiles(show_dotfiles); show_dotfiles_action->set_checked(show_dotfiles); @@ -968,7 +968,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& TRY(view_menu->try_add_separator()); TRY(view_menu->try_add_action(show_dotfiles_action)); - auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { toolbar_container.set_visible(true); location_toolbar.set_visible(true); breadcrumb_toolbar.set_visible(false); @@ -986,7 +986,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& TRY(go_menu->try_add_action(directory_view->open_terminal_action())); auto help_menu = TRY(window->try_add_menu("&Help")); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager", GUI::Icon::default_icon("app-file-manager"), window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager"sv, GUI::Icon::default_icon("app-file-manager"sv), window))); (void)TRY(main_toolbar.try_add_action(go_back_action)); (void)TRY(main_toolbar.try_add_action(go_forward_action)); @@ -1113,7 +1113,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& || (!directory_view->current_view().selection().is_empty() && access(directory_view->path().characters(), W_OK) == 0)); }; - auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { directory_view->open(directory_view->selected_file_paths().first()); }); @@ -1180,7 +1180,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& file_context_menu->add_action(create_archive_action); file_context_menu->add_separator(); - if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) { + if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) { file_context_menu->add_action(unzip_archive_action); file_context_menu->add_separator(); } @@ -1243,7 +1243,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& if (auto result = Core::File::copy_file_or_directory(url_to_copy.path(), new_path); result.is_error()) { auto error_message = String::formatted("Could not copy {} into {}:\n {}", url_to_copy.to_string(), new_path, static_cast<Error const&>(result.error())); - GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, error_message, "File Manager"sv, GUI::MessageBox::Type::Error); } else { had_accepted_copy = true; } @@ -1288,7 +1288,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& window->show(); - directory_view->set_view_mode_from_string(Config::read_string("FileManager", "DirectoryView", "ViewMode", "Icon")); + directory_view->set_view_mode_from_string(Config::read_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv)); if (!entry_focused_on_init.is_empty()) { auto matches = directory_view->current_view().model()->matches(entry_focused_on_init, GUI::Model::MatchesFlag::MatchFull | GUI::Model::MatchesFlag::FirstMatchOnly); @@ -1298,12 +1298,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const& // Write window position to config file on close request. window->on_close_request = [&] { - Config::write_bool("FileManager", "Window", "Maximized", window->is_maximized()); + Config::write_bool("FileManager"sv, "Window"sv, "Maximized"sv, window->is_maximized()); if (!window->is_maximized()) { - Config::write_i32("FileManager", "Window", "Left", window->x()); - Config::write_i32("FileManager", "Window", "Top", window->y()); - Config::write_i32("FileManager", "Window", "Width", window->width()); - Config::write_i32("FileManager", "Window", "Height", window->height()); + Config::write_i32("FileManager"sv, "Window"sv, "Left"sv, window->x()); + Config::write_i32("FileManager"sv, "Window"sv, "Top"sv, window->y()); + Config::write_i32("FileManager"sv, "Window"sv, "Width"sv, window->width()); + Config::write_i32("FileManager"sv, "Window"sv, "Height"sv, window->height()); } return GUI::Window::CloseRequestDecision::Close; }; |