| 349 | } |
| 350 | |
| 351 | FileDialog::FileDialog() { |
| 352 | m_isOpen = false; |
| 353 | m_type = 0; |
| 354 | m_calledOpenPopup = false; |
| 355 | m_sortColumn = 0; |
| 356 | m_sortDirection = ImGuiSortDirection_Ascending; |
| 357 | m_filterSelection = 0; |
| 358 | m_inputTextbox[0] = 0; |
| 359 | m_pathBuffer[0] = 0; |
| 360 | m_searchBuffer[0] = 0; |
| 361 | m_newEntryBuffer[0] = 0; |
| 362 | m_selectedFileItem = -1; |
| 363 | m_zoom = 1.0f; |
| 364 | |
| 365 | m_previewLoader = nullptr; |
| 366 | m_previewLoaderRunning = false; |
| 367 | |
| 368 | m_setDirectory(std::filesystem::current_path(), false); |
| 369 | |
| 370 | // favorites are available on every OS |
| 371 | FileTreeNode* quickAccess = new FileTreeNode("Quick Access"); |
| 372 | quickAccess->Read = true; |
| 373 | m_treeCache.push_back(quickAccess); |
| 374 | |
| 375 | #ifdef _WIN32 |
| 376 | wchar_t username[UNLEN + 1] = { 0 }; |
| 377 | DWORD username_len = UNLEN + 1; |
| 378 | GetUserNameW(username, &username_len); |
| 379 | |
| 380 | std::wstring userPath = L"C:\\Users\\" + std::wstring(username) + L"\\"; |
| 381 | |
| 382 | // Quick Access / Bookmarks |
| 383 | quickAccess->Children.push_back(new FileTreeNode(userPath + L"Desktop")); |
| 384 | quickAccess->Children.push_back(new FileTreeNode(userPath + L"Documents")); |
| 385 | quickAccess->Children.push_back(new FileTreeNode(userPath + L"Downloads")); |
| 386 | quickAccess->Children.push_back(new FileTreeNode(userPath + L"Pictures")); |
| 387 | |
| 388 | // OneDrive |
| 389 | FileTreeNode* oneDrive = new FileTreeNode(userPath + L"OneDrive"); |
| 390 | m_treeCache.push_back(oneDrive); |
| 391 | |
| 392 | // This PC |
| 393 | FileTreeNode* thisPC = new FileTreeNode("This PC"); |
| 394 | thisPC->Read = true; |
| 395 | if (std::filesystem::exists(userPath + L"3D Objects")) |
| 396 | thisPC->Children.push_back(new FileTreeNode(userPath + L"3D Objects")); |
| 397 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Desktop")); |
| 398 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Documents")); |
| 399 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Downloads")); |
| 400 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Music")); |
| 401 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Pictures")); |
| 402 | thisPC->Children.push_back(new FileTreeNode(userPath + L"Videos")); |
| 403 | DWORD d = GetLogicalDrives(); |
| 404 | for (int i = 0; i < 26; i++) |
| 405 | if (d & (1 << i)) |
| 406 | thisPC->Children.push_back(new FileTreeNode(std::string(1, 'A' + i) + ":")); |
| 407 | m_treeCache.push_back(thisPC); |
| 408 | #else |
nothing calls this directly
no outgoing calls
no test coverage detected