| 701 | } |
| 702 | |
| 703 | void BrowserLayout::UpdateElements(const int idx) { |
| 704 | g_Settings.ApplyToMenu(this->browse_menu); |
| 705 | const auto contents = this->cur_exp->GetContents(); |
| 706 | this->browse_menu->ClearItems(); |
| 707 | this->ResetMenuHead(); |
| 708 | this->browse_menu->SetVisible(!contents.empty()); |
| 709 | this->empty_dir_text->SetVisible(contents.empty()); |
| 710 | if(!contents.empty()) { |
| 711 | for(const auto &item: contents) { |
| 712 | if(g_Settings.json_settings.fs.value().ignore_hidden_files.value() && IsHiddenContent(item)) { |
| 713 | continue; |
| 714 | } |
| 715 | |
| 716 | auto menu_item = pu::ui::elm::MenuItem::New(item); |
| 717 | menu_item->SetColor(g_Settings.GetColorScheme().text); |
| 718 | if(this->cur_exp->IsDirectory(item)) { |
| 719 | menu_item->SetIcon(this->cur_exp->IsDirectoryEmpty(item) ? GetCommonIcon(CommonIconKind::DirectoryEmpty) : GetCommonIcon(CommonIconKind::Directory)); |
| 720 | } |
| 721 | else { |
| 722 | const auto ext = LowerCaseString(fs::GetExtension(item)); |
| 723 | menu_item->SetIcon(GetCommonIconForExtension(ext)); |
| 724 | } |
| 725 | menu_item->AddOnKey(std::bind(&BrowserLayout::fsItems_DefaultKey, this, item)); |
| 726 | menu_item->AddOnKey(std::bind(&BrowserLayout::fsItems_Y, this, item), HidNpadButton_Y); |
| 727 | this->browse_menu->AddItem(menu_item); |
| 728 | } |
| 729 | u32 tmp_idx = 0; |
| 730 | if(idx < 0) { |
| 731 | if(!g_EntryIndexStack.empty()) { |
| 732 | tmp_idx = g_EntryIndexStack.top(); |
| 733 | g_EntryIndexStack.pop(); |
| 734 | } |
| 735 | } |
| 736 | else { |
| 737 | tmp_idx = static_cast<u32>(idx); |
| 738 | if(tmp_idx >= contents.size()) { |
| 739 | tmp_idx = 0; |
| 740 | } |
| 741 | } |
| 742 | this->browse_menu->SetSelectedIndex(tmp_idx); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | void BrowserLayout::ResetMenuHead() { |
| 747 | g_MainApplication->LoadMenuHead(this->cur_exp->GetPresentableCwd()); |
no test coverage detected