IO: Add support for multiple drag-n-drop files #107230

Merged
Brecht Van Lommel merged 20 commits from guishe/blender:dragndrop-files into main 2023-12-12 18:46:22 +01:00
1 changed files with 10 additions and 9 deletions
Showing only changes of commit c62bcf21af - Show all commits

View File

@ -770,27 +770,28 @@ const ListBase *WM_drag_asset_list_get(const wmDrag *drag)
guishe marked this conversation as resolved Outdated

This is just const char* isn't it? In that case auto just hides type information with no real benefit, prefer not using it in such cases.

This is just `const char*` isn't it? In that case `auto` just hides type information with no real benefit, prefer not using it in such cases.
wmDragPath *WM_drag_create_path_data(blender::Span<const char *> _paths)
{
const char *ext = BLI_path_extension(_paths[0]);
const char *extension = BLI_path_extension(_paths[0]);
blender::Vector<std::string> paths;
for (auto path : _paths) {
const char *test_ext = BLI_path_extension(path);
if (ext == test_ext || (ext && test_ext && STREQ(ext, test_ext))) {
if (extension == test_ext || (extension && test_ext && STREQ(extension, test_ext))) {
guishe marked this conversation as resolved Outdated

There is no reason to use C-strings here. std::string and fmt::format (extern library we are using since we are not yet on C++20) should be even easier to use.

There is no reason to use C-strings here. `std::string` and `fmt::format` (extern library we are using since we are not yet on C++20) should be even easier to use.
Review

No final point in our UI strings: "Dragging {} files"

No final point in our UI strings: `"Dragging {} files"`
paths.append(path);
}
}
char *tooltip;
const char *tooltip = _paths[0];
char tooltip_buffer[256];
if (_paths.size() == 1) {
tooltip = BLI_strdup(_paths[0]);
}
else {
tooltip = BLI_sprintfN(TIP_("Dragging %d %s files."), paths.size());
BLI_snprintf(tooltip_buffer,
ARRAY_SIZE(tooltip_buffer),
TIP_("Dragging %d %s files."),
paths.size(),
extension ? extension : TIP_("Folder"));
tooltip = tooltip_buffer;
}
wmDragPath *path_data = MEM_new<wmDragPath>(
"wmDragPath", paths, tooltip, ED_path_extension_type(_paths[0]));
MEM_freeN(tooltip);
return path_data;
}