IO: Add support for multiple drag-n-drop files #107230
|
@ -770,27 +770,28 @@ const ListBase *WM_drag_asset_list_get(const wmDrag *drag)
|
|||
|
||||
guishe marked this conversation as resolved
Outdated
|
||||
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
Bastien Montagne
commented
There is no reason to use C-strings here. 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.
Bastien Montagne
commented
No final point in our UI strings: 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
This is just
const char*
isn't it? In that caseauto
just hides type information with no real benefit, prefer not using it in such cases.