Fix file dialog on windows

This commit is contained in:
Nikita Lisitsa 2023-01-05 19:12:44 +03:00
parent b9939ba10e
commit 9a5206ebf9

View file

@ -110,6 +110,7 @@ namespace psemek::ui
std::string escape(std::string str)
{
str = replace(std::move(str), "\\", "\\\\");
str = replace(std::move(str), "[", "\\[");
str = replace(std::move(str), "]", "\\]");
return str;
@ -233,10 +234,12 @@ namespace psemek::ui
int index = 0;
for (auto const & component : new_path)
{
if (component.string() != "/")
path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]/";
else
path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]";
if (!new_path.root_name().empty() && component == new_path.root_directory())
continue;
path_str += "[link:" + util::to_string(++index) + "]" + escape(component.string()) + "[/link]";
if (!new_path.root_name().empty() || component != new_path.root_directory())
path_str += escape(std::string(1, char(std::filesystem::path::preferred_separator)));
}
current_path_label->set_tagged_text(std::move(path_str));