Route dialog work directory picker through platform services

This commit is contained in:
2026-06-04 18:14:02 +02:00
parent 52cf7628da
commit b1acd5118b
11 changed files with 164 additions and 78 deletions

View File

@@ -69,32 +69,28 @@ void NodeDialogBrowse::init_controls()
};
container = find<Node>("files-list");
init_list();
#if defined(_WIN32) || defined(__OSX__)
static char path_buffer[256];
btn_path = find<NodeButton>("btn-path");
btn_path->on_click = [this](Node*){
App::I->pick_dir([this](std::string path){
LOG("change working path to %s", path.c_str());
App::I->work_path = path;
#ifdef _WIN32
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
#else
realpath(path.c_str(), path_buffer);
#endif
working_path->set_text_format("Destination dir: %s", path_buffer);
search_paths = {path};
clear_list();
init_list();
});
};
working_path = find<NodeText>("path");
#ifdef _WIN32
GetFullPathNameA(App::I->work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
#else
realpath(App::I->work_path.c_str(), path_buffer);
#endif
working_path->set_text_format("Working dir: %s", path_buffer);
#endif
if (App::I->supports_working_directory_picker())
{
btn_path = find<NodeButton>("btn-path");
btn_path->on_click = [this](Node*) {
App::I->pick_dir([this](std::string path) {
LOG("change working path to %s", path.c_str());
App::I->work_path = path;
const auto display_path = App::I->format_working_directory_path(path);
working_path->set_text_format(
"Destination dir: %s",
display_path.c_str());
search_paths = { path };
clear_list();
init_list();
});
};
working_path = find<NodeText>("path");
const auto display_path = App::I->format_working_directory_path(App::I->work_path);
working_path->set_text_format(
"Working dir: %s",
display_path.c_str());
}
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))
// {
// first->on_selected(first);