void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !item->GetProperty("pluginreplacecontextitems").asBoolean()) { if (item && !item->IsParentFolder()) { if (item->CanQueue() && !item->IsAddonsPath()) { buttons.Add(CONTEXT_BUTTON_QUEUE_ITEM, 13347); //queue // allow a folder to be ad-hoc queued and played by the default player if (item->m_bIsFolder || (item->IsPlayList() && !g_advancedSettings.m_playlistAsFolders)) { buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 208); // Play } else { // check what players we have, if we have multiple display play with option VECPLAYERCORES vecCores; CPlayerCoreFactory::GetInstance().GetPlayers(*item, vecCores); if (vecCores.size() >= 1) buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With... } if (item->IsSmartPlayList()) { buttons.Add(CONTEXT_BUTTON_PLAY_PARTYMODE, 15216); // Play in Partymode } if (item->IsSmartPlayList() || m_vecItems->IsSmartPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT_SMART_PLAYLIST, 586); else if (item->IsPlayList() || m_vecItems->IsPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT, 586); } } } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); }
void CGUIMediaWindow::GetFilteredItems(const CStdString &filter, CFileItemList &items) { CStdString trimmedFilter(filter); trimmedFilter.TrimLeft().ToLower(); if (trimmedFilter.IsEmpty()) { items.Append(*m_unfilteredItems); return; } bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter); for (int i = 0; i < m_unfilteredItems->Size(); i++) { CFileItemPtr item = m_unfilteredItems->Get(i); if (item->IsParentFolder()) { items.Add(item); continue; } // TODO: Need to update this to get all labels, ideally out of the displayed info (ie from m_layout and m_focusedLayout) // though that isn't practical. Perhaps a better idea would be to just grab the info that we should filter on based on // where we are in the library tree. // Another idea is tying the filter string to the current level of the tree, so that going deeper disables the filter, // but it's re-enabled on the way back out. CStdString match; /* if (item->GetFocusedLayout()) match = item->GetFocusedLayout()->GetAllText(); else if (item->GetLayout()) match = item->GetLayout()->GetAllText(); else*/ match = item->GetLabel(); // Filter label only for now if (numericMatch) StringUtils::WordToDigits(match); size_t pos = StringUtils::FindWords(match.c_str(), trimmedFilter.c_str()); if (pos != CStdString::npos) items.Add(item); } }
void CGUIWindowFileManager::OnSelectAll(int iList) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ for (int i = 0; i < m_vecItems[iList]->Size();++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); if (!pItem->IsParentFolder()) { pItem->Select(true); } } }
bool CPluginDirectory::HasPlugins(const CStdString &type) { CStdString path = _P("U:\\plugins\\"); CUtil::AddFileToFolder(path, type, path); CFileItemList items; if (CDirectory::GetDirectory(path, items, "/", false)) { for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; if (item->m_bIsFolder && !item->IsParentFolder() && !item->m_bIsShareOrDrive) { CStdString defaultPY; CUtil::AddFileToFolder(item->m_strPath, "default.py", defaultPY); if (XFILE::CFile::Exists(defaultPY)) return true; } } } return false; }
bool CGUIWindowScripts::GetDirectory(const CStdString& strDirectory, CFileItemList& items) { if (!CGUIMediaWindow::GetDirectory(strDirectory,items)) return false; // flatten any folders for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; if (item->m_bIsFolder && !item->IsParentFolder() && !item->m_bIsShareOrDrive && !item->GetLabel().Left(1).Equals(".")) { // folder item - let's check for a default.py file, and flatten if we have one CStdString defaultPY; CUtil::AddFileToFolder(item->m_strPath, "default.py", defaultPY); if (!CFile::Exists(defaultPY)) { CUtil::AddFileToFolder(item->m_strPath, "Default.py", defaultPY); if (!CFile::Exists(defaultPY)) { CUtil::AddFileToFolder(item->m_strPath, "DEFAULT.PY", defaultPY); } } if (CFile::Exists(defaultPY)) { // yes, format the item up item->m_strPath = defaultPY; item->m_bIsFolder = false; item->FillInDefaultIcon(); item->SetLabelPreformated(true); } } if (item->GetLabel().Equals("autoexec.py") || (item->GetLabel().Left(1).Equals(".") && !item->IsParentFolder())) { items.Remove(i); i--; } } items.SetProgramThumbs(); return true; }
void CGUIMediaWindow::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr(); if (!item) return; // user added buttons CStdString label; CStdString action; for (int i = CONTEXT_BUTTON_USER1; i <= CONTEXT_BUTTON_USER10; i++) { label.Format("contextmenulabel(%i)", i - CONTEXT_BUTTON_USER1); if (item->GetProperty(label).empty()) break; action.Format("contextmenuaction(%i)", i - CONTEXT_BUTTON_USER1); if (item->GetProperty(action).empty()) break; buttons.Add((CONTEXT_BUTTON)i, item->GetProperty(label).asString()); } if (item->GetProperty("pluginreplacecontextitems").asBoolean()) return; // TODO: FAVOURITES Conditions on masterlock and localisation if (!item->IsParentFolder() && !item->GetPath().Equals("add") && !item->GetPath().Equals("newplaylist://") && !item->GetPath().Left(19).Equals("newsmartplaylist://") && !item->IsAddonsPath()) { if (CFavourites::IsFavourite(item.get(), GetID())) buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite else buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites; } }
// \brief With this function you can react on a users click in the list/thumb panel. // It returns true, if the click is handled. // This function calls OnPlayMedia() bool CGUIMediaWindow::OnClick(int iItem) { if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return true; CFileItemPtr pItem = m_vecItems->Get(iItem); if (pItem->IsParentFolder()) { GoParentFolder(); return true; } else if (pItem->m_bIsFolder) { if ( pItem->m_bIsShareOrDrive ) { const CStdString& strLockType=m_guiState->GetLockType(); ASSERT(g_settings.m_vecProfiles.size() > 0); if (g_settings.m_vecProfiles[0].getLockMode() != LOCK_MODE_EVERYONE) if (!strLockType.IsEmpty() && !g_passwordManager.IsItemUnlocked(pItem.get(), strLockType)) return true; if (!HaveDiscOrConnection(pItem->m_strPath, pItem->m_iDriveType)) return true; } // remove the directory cache if the folder is not normally cached CFileItemList items(pItem->m_strPath); if (!items.AlwaysCache()) items.RemoveDiscCache(); CFileItem directory(*pItem); if (!Update(directory.m_strPath)) ShowShareErrorMessage(&directory); return true; } else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") != "true") { return DIRECTORY::CPluginDirectory::RunScriptWithParams(pItem->m_strPath); } else { m_iSelectedItem = m_viewControl.GetSelectedItem(); if (pItem->m_strPath == "newplaylist://") { m_vecItems->RemoveDiscCache(); m_gWindowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR,"newplaylist://"); return true; } else if (pItem->m_strPath.Left(19).Equals("newsmartplaylist://")) { m_vecItems->RemoveDiscCache(); if (CGUIDialogSmartPlaylistEditor::NewPlaylist(pItem->m_strPath.Mid(19))) Update(m_vecItems->m_strPath); return true; } if (m_guiState.get() && m_guiState->AutoPlayNextItem() && !g_partyModeManager.IsEnabled() && !pItem->IsPlayList()) { // TODO: music videos! if (pItem->m_strPath == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026) && m_guiState->GetPlaylist() == PLAYLIST_MUSIC) // 'add source button' in empty root { if (CGUIDialogMediaSource::ShowAndAddMediaSource("music")) { Update(""); return true; } return false; } //play and add current directory to temporary playlist int iPlaylist=m_guiState->GetPlaylist(); if (iPlaylist != PLAYLIST_NONE) { g_playlistPlayer.ClearPlaylist(iPlaylist); g_playlistPlayer.Reset(); int songToPlay = 0; CFileItemList queueItems; for ( int i = 0; i < m_vecItems->Size(); i++ ) { CFileItemPtr item = m_vecItems->Get(i); if (item->m_bIsFolder) continue; if (!item->IsPlayList() && !item->IsZIP() && !item->IsRAR()) queueItems.Add(item); if (item == pItem) { // item that was clicked songToPlay = queueItems.Size() - 1; } } g_playlistPlayer.Add(iPlaylist, queueItems); // Save current window and directory to know where the selected item was if (m_guiState.get()) m_guiState->SetPlaylistDirectory(m_vecItems->m_strPath); // figure out where we start playback if (g_playlistPlayer.IsShuffled(iPlaylist)) { int iIndex = g_playlistPlayer.GetPlaylist(iPlaylist).FindOrder(songToPlay); g_playlistPlayer.GetPlaylist(iPlaylist).Swap(0, iIndex); songToPlay = 0; } // play g_playlistPlayer.SetCurrentPlaylist(iPlaylist); g_playlistPlayer.Play(songToPlay); } return true; } else { return OnPlayMedia(iItem); } } return false; }
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */) { if (list < 0 || list > 2) return ; bool bDeselect = SelectItem(list, item); // calculate the position for our menu float posX = 200; float posY = 100; const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list); if (pList) { posX = pList->GetXPosition() + pList->GetWidth() / 2; posY = pList->GetYPosition() + pList->GetHeight() / 2; } CFileItemPtr pItem = m_vecItems[list]->Get(item); if (!pItem.get()) return; if (m_Directory[list]->IsVirtualDirectoryRoot()) { if (item < 0) { // TODO: We should add the option here for shares to be added if there aren't any return ; } // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { m_rootDir.SetSources(g_settings.m_fileSources); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else Refresh(list); return ; } pItem->Select(false); return ; } // popup the context menu CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU); if (pMenu) { bool showEntry = false; if (item >= m_vecItems[list]->Size()) item = -1; if (item >= 0) showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0)); // determine available players VECPLAYERCORES vecCores; CPlayerCoreFactory::GetPlayers(*pItem, vecCores); // load our menu pMenu->Initialize(); // add the needed buttons int btn_SelectAll = pMenu->AddButton(188); // SelectAll int btn_HandleFavourite; // Add/Remove Favourite if (CFavourites::IsFavourite(pItem.get(), GetID())) btn_HandleFavourite = pMenu->AddButton(14077); else btn_HandleFavourite = pMenu->AddButton(14076); int btn_PlayUsing = pMenu->AddButton(15213); // Play Using .. int btn_Rename = pMenu->AddButton(118); // Rename int btn_Delete = pMenu->AddButton(117); // Delete int btn_Copy = pMenu->AddButton(115); // Copy int btn_Move = pMenu->AddButton(116); // Move int btn_NewFolder = pMenu->AddButton(20309); // New Folder int btn_Size = pMenu->AddButton(13393); // Calculate Size int btn_Settings = pMenu->AddButton(5); // Settings int btn_GoToRoot = pMenu->AddButton(20128); // Go To Root int btn_Switch = pMenu->AddButton(523); // switch media pMenu->EnableButton(btn_SelectAll, item >= 0); pMenu->EnableButton(btn_HandleFavourite, item >=0 && !pItem->IsParentFolder()); pMenu->EnableButton(btn_PlayUsing, item >= 0 && vecCores.size() > 1); pMenu->EnableButton(btn_Rename, item >= 0 && CanRename(list) && !pItem->IsParentFolder()); pMenu->EnableButton(btn_Delete, item >= 0 && CanDelete(list) && showEntry); pMenu->EnableButton(btn_Copy, item >= 0 && CanCopy(list) && showEntry); pMenu->EnableButton(btn_Move, item >= 0 && CanMove(list) && showEntry); pMenu->EnableButton(btn_NewFolder, CanNewFolder(list)); pMenu->EnableButton(btn_Size, item >=0 && pItem->m_bIsFolder && !pItem->IsParentFolder()); // position it correctly pMenu->OffsetPosition(posX, posY); pMenu->DoModal(); int btnid = pMenu->GetButton(); if (btnid == btn_SelectAll) { OnSelectAll(list); bDeselect=false; } if (btnid == btn_HandleFavourite) { CFavourites::AddOrRemove(pItem.get(), GetID()); return; } if (btnid == btn_PlayUsing) { VECPLAYERCORES vecCores; CPlayerCoreFactory::GetPlayers(*pItem, vecCores); g_application.m_eForcedNextPlayer = CPlayerCoreFactory::SelectPlayerDialog(vecCores); if (g_application.m_eForcedNextPlayer != EPC_NONE) OnStart(pItem.get()); } if (btnid == btn_Rename) OnRename(list); if (btnid == btn_Delete) OnDelete(list); if (btnid == btn_Copy) OnCopy(list); if (btnid == btn_Move) OnMove(list); if (btnid == btn_NewFolder) OnNewFolder(list); if (btnid == btn_Size) { // setup the progress dialog, and show it CGUIDialogProgress *progress = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(13394); for (int i=0; i < 3; i++) progress->SetLine(i, ""); progress->StartModal(); } // Calculate folder size for each selected item for (int i=0; i<m_vecItems[list]->Size(); ++i) { CFileItemPtr pItem2=m_vecItems[list]->Get(i); if (pItem2->m_bIsFolder && pItem2->IsSelected()) { __int64 folderSize = CalculateFolderSize(pItem2->m_strPath, progress); if (folderSize >= 0) { pItem2->m_dwSize = folderSize; if (folderSize == 0) pItem2->SetLabel2(StringUtils::SizeToString(folderSize)); else pItem2->SetFileSizeLabel(); } } } if (progress) progress->Close(); } if (btnid == btn_Settings) { m_gWindowManager.ActivateWindow(WINDOW_SETTINGS_MENU); return; } if (btnid == btn_GoToRoot) { Update(list,""); return; } if (btnid == btn_Switch) { CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->m_strPath); return; } if (bDeselect && item >= 0 && item < m_vecItems[list]->Size()) { // deselect item as we didn't do anything pItem->Select(false); } } }
// \brief Set window to a specific directory // \param strDirectory The directory to be displayed in list/thumb control // This function calls OnPrepareFileItems() and OnFinalizeFileItems() bool CGUIMediaWindow::Update(const CStdString &strDirectory) { // get selected item int iItem = m_viewControl.GetSelectedItem(); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); } } CStdString strOldDirectory = m_vecItems->m_strPath; m_history.SetSelectedItem(strSelectedItem, strOldDirectory); ClearFileItems(); m_vecItems->ClearProperties(); m_vecItems->SetThumbnailImage(""); if (!GetDirectory(strDirectory, *m_vecItems)) { CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str()); // if the directory is the same as the old directory, then we'll return // false. Else, we assume we can get the previous directory if (strDirectory.Equals(strOldDirectory)) return false; // We assume, we can get the parent // directory again, but we have to // return false to be able to eg. show // an error message. CStdString strParentPath = m_history.GetParentPath(); m_history.RemoveParentPath(); Update(strParentPath); return false; } // if we're getting the root source listing // make sure the path history is clean if (strDirectory.IsEmpty()) m_history.ClearPathHistory(); int iWindow = GetID(); bool bOkay = (iWindow == WINDOW_MUSIC_FILES || iWindow == WINDOW_VIDEO_FILES || iWindow == WINDOW_FILES || iWindow == WINDOW_PICTURES || iWindow == WINDOW_PROGRAMS); if (strDirectory.IsEmpty() && bOkay && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button' { CStdString strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->m_strPath = "add"; pItem->SetThumbnailImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); m_vecItems->Add(pItem); } m_iLastControl = GetFocusedControlID(); // Ask the derived class if it wants to load additional info // for the fileitems like media info or additional // filtering on the items, setting thumbs. OnPrepareFileItems(*m_vecItems); m_vecItems->FillInDefaultIcons(); m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); FormatAndSort(*m_vecItems); // Ask the devived class if it wants to do custom list operations, // eg. changing the label OnFinalizeFileItems(*m_vecItems); UpdateButtons(); m_viewControl.SetItems(*m_vecItems); strSelectedItem = m_history.GetSelectedItem(m_vecItems->m_strPath); bool bSelectedFound = false; //int iSongInDirectory = -1; for (int i = 0; i < m_vecItems->Size(); ++i) { CFileItemPtr pItem = m_vecItems->Get(i); // Update selected item if (!bSelectedFound) { CStdString strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { m_viewControl.SetSelectedItem(i); bSelectedFound = true; } } } // if we haven't found the selected item, select the first item if (!bSelectedFound) m_viewControl.SetSelectedItem(0); m_history.AddPath(m_vecItems->m_strPath); //m_history.DumpPathHistory(); return true; }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetProperty("pluginreplacecontextitems").asBoolean()) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath()); if (!item) { // nothing to do here } else if (m_vecItems->IsPath("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); // add scan button somewhere here if (g_application.IsVideoScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath()); if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) { buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } else { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::VideoPlaylistsLocation()) || m_vecItems->IsPath("special://videoplaylists/"); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_artist.empty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_artist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (info && info->Content() == CONTENT_MOVIES) buttons.Add(CONTEXT_BUTTON_INFO, 13346); // can we update the database? if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() && item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" && !StringUtils::StartsWith(item->GetPath(), "newsmartplaylist://") && !StringUtils::StartsWith(item->GetPath(), "newplaylist://") && !StringUtils::StartsWith(item->GetPath(), "newtag://")) { if (item->m_bIsFolder) { // Have both options for folders since we don't know whether all childs are watched/unwatched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } else { if (item->GetOverlayImage() == "OverlayWatched.png") buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && (item->GetVideoInfoTag()->m_type == MediaTypeMovie || // movies item->GetVideoInfoTag()->m_type == MediaTypeTvShow || // tvshows item->GetVideoInfoTag()->m_type == MediaTypeSeason || // seasons item->GetVideoInfoTag()->m_type == MediaTypeEpisode || // episodes item->GetVideoInfoTag()->m_type == MediaTypeMusicVideo || // musicvideos item->GetVideoInfoTag()->m_type == "tag" || // tags item->GetVideoInfoTag()->m_type == MediaTypeVideoCollection)) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } if (node == NODE_TYPE_TITLE_TVSHOWS) { if (g_application.IsVideoScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder) { if (StringUtils::StartsWithNoCase(m_vecItems->GetPath(), "videodb://musicvideos")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if ((CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } CContextMenuManager::GetInstance().AddVisibleItems(item, buttons); } }
bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ // get selected item int iItem = GetSelectedItem(iList); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size()) { CFileItemPtr pItem = m_vecItems[iList]->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->GetPath()); } } CStdString strOldDirectory=m_Directory[iList]->GetPath(); m_Directory[iList]->SetPath(strDirectory); CFileItemList items; if (!GetDirectory(iList, m_Directory[iList]->GetPath(), items)) { m_Directory[iList]->SetPath(strOldDirectory); return false; } m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory); ClearFileItems(iList); m_vecItems[iList]->Append(items); m_vecItems[iList]->SetPath(items.GetPath()); CStdString strParentPath; URIUtils::GetParentPath(strDirectory, strParentPath); if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || g_guiSettings.GetBool("filelists.showaddsourcebuttons"))) { // add 'add source button' CStdString strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetIconImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); pItem->m_bIsFolder = true; pItem->SetSpecialSort(SORT_ON_BOTTOM); m_vecItems[iList]->Add(pItem); } else if (items.IsEmpty() || g_guiSettings.GetBool("filelists.showparentdiritems")) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(m_rootDir.IsSource(strDirectory) ? "" : strParentPath); pItem->m_bIsFolder = true; pItem->m_bIsShareOrDrive = false; m_vecItems[iList]->AddFront(pItem, 0); } m_strParentPath[iList] = (m_rootDir.IsSource(strDirectory) ? "" : strParentPath); if (strDirectory.IsEmpty()) { CFileItemPtr pItem(new CFileItem("special://profile/", true)); pItem->SetLabel(g_localizeStrings.Get(20070)); pItem->SetThumbnailImage("DefaultFolder.png"); pItem->SetLabelPreformated(true); m_vecItems[iList]->Add(pItem); } // if we have a .tbn file, use itself as the thumb for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); CStdString strExtension; URIUtils::GetExtension(pItem->GetPath(), strExtension); if (pItem->IsHD() && strExtension == ".tbn") { pItem->SetThumbnailImage(pItem->GetPath()); } } m_vecItems[iList]->FillInDefaultIcons(); OnSort(iList); UpdateButtons(); int item = 0; strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->GetPath()); for (int i = 0; i < m_vecItems[iList]->Size(); ++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); CStdString strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { item = i; break; } } UpdateControl(iList, item); return true; }
bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) { bool listchanged = false; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(items.GetPath()); // now filter watched items as necessary bool filterWatched=false; if (node == NODE_TYPE_EPISODES || node == NODE_TYPE_SEASONS || node == NODE_TYPE_SETS || node == NODE_TYPE_TAGS || node == NODE_TYPE_TITLE_MOVIES || node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_TITLE_MUSICVIDEOS || node == NODE_TYPE_RECENTLY_ADDED_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_MOVIES || node == NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) filterWatched = true; if (!items.IsVideoDb()) filterWatched = true; if (items.GetContent() == "tvshows" && (items.IsSmartPlayList() || items.IsLibraryFolder())) node = NODE_TYPE_TITLE_TVSHOWS; // so that the check below works int watchMode = CMediaSettings::GetInstance().GetWatchedMode(m_vecItems->GetContent()); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items.Get(i); if(item->HasVideoInfoTag() && (node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_SEASONS)) { if (watchMode == WatchedModeUnwatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("unwatchedepisodes").asInteger(); if (watchMode == WatchedModeWatched) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("watchedepisodes").asInteger(); if (watchMode == WatchedModeAll) item->GetVideoInfoTag()->m_iEpisode = (int)item->GetProperty("totalepisodes").asInteger(); item->SetProperty("numepisodes", item->GetVideoInfoTag()->m_iEpisode); listchanged = true; } if (filterWatched) { if(!item->IsParentFolder() && // Don't delete the go to parent folder ((watchMode == WatchedModeWatched && item->GetVideoInfoTag()->GetPlayCount() == 0) || (watchMode == WatchedModeUnwatched && item->GetVideoInfoTag()->GetPlayCount() > 0))) { items.Remove(i); i--; listchanged = true; } } } // Remove the parent folder icon, if it's the only thing in the folder. This is needed for hiding seasons. if (items.GetObjectCount() == 0 && items.GetFileCount() > 0 && items.Get(0)->IsParentFolder()) items.Remove(0); if(node == NODE_TYPE_TITLE_TVSHOWS || node == NODE_TYPE_SEASONS) { // the watched filter may change the "numepisodes" property which is reflected in the TV_SHOWS and SEASONS nodes // therefore, the items labels have to be refreshed, and possibly the list needs resorting as well. items.ClearSortState(); // this is needed to force resorting even if sort method did not change FormatAndSort(items); } return listchanged; }
/// \brief Add unique file and folders and its subfolders to playlist /// \param pItem The file item to add void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItemList &queuedItems) { if (!pItem->CanQueue() || pItem->IsRAR() || pItem->IsZIP() || pItem->IsParentFolder()) // no zip/rar enques thank you! return; // fast lookup is needed here queuedItems.SetFastLookup(true); if (pItem->IsMusicDb() && pItem->m_bIsFolder && !pItem->IsParentFolder()) { // we have a music database folder, just grab the "all" item underneath it CMusicDatabaseDirectory dir; if (!dir.ContainsSongs(pItem->GetPath())) { // grab the ALL item in this category // Genres will still require 2 lookups, and queuing the entire Genre folder // will require 3 lookups (genre, artist, album) CMusicDbUrl musicUrl; musicUrl.FromString(pItem->GetPath()); musicUrl.AppendPath("-1/"); CFileItemPtr item(new CFileItem(musicUrl.ToString(), true)); item->SetCanQueue(true); // workaround for CanQueue() check above AddItemToPlayList(item, queuedItems); return; } } if (pItem->m_bIsFolder || (g_windowManager.GetActiveWindow() == WINDOW_MUSIC_NAV && pItem->IsPlayList())) { // Check if we add a locked share if ( pItem->m_bIsShareOrDrive ) { CFileItem item = *pItem; if ( !g_passwordManager.IsItemUnlocked( &item, "music" ) ) return ; } // recursive CFileItemList items; GetDirectory(pItem->GetPath(), items); //OnRetrieveMusicInfo(items); FormatAndSort(items); for (int i = 0; i < items.Size(); ++i) AddItemToPlayList(items[i], queuedItems); } else { if (pItem->IsPlayList()) { auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(*pItem)); if (pPlayList.get()) { // load it if (!pPlayList->Load(pItem->GetPath())) { CGUIDialogOK::ShowAndGetInput(6, 0, 477, 0); return; //hmmm unable to load playlist? } CPlayList playlist = *pPlayList; for (int i = 0; i < (int)playlist.size(); ++i) { AddItemToPlayList(playlist[i], queuedItems); } return; } } else if(pItem->IsInternetStream()) { // just queue the internet stream, it will be expanded on play queuedItems.Add(pItem); } else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") == "true") { // python files can be played queuedItems.Add(pItem); } else if (!pItem->IsNFO() && pItem->IsAudio()) { CFileItemPtr itemCheck = queuedItems.Get(pItem->GetPath()); if (!itemCheck || itemCheck->m_lStartOffset != pItem->m_lStartOffset) { // add item CFileItemPtr item(new CFileItem(*pItem)); m_musicdatabase.SetPropertiesForFileItem(*item); queuedItems.Add(item); } } } }
bool CGUIWindowFileManager::Update(int iList, const std::string &strDirectory) { // get selected item int iItem = GetSelectedItem(iList); std::string strSelectedItem = ""; if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size()) { CFileItemPtr pItem = m_vecItems[iList]->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->GetPath()); } } std::string strOldDirectory=m_Directory[iList]->GetPath(); m_Directory[iList]->SetPath(strDirectory); CFileItemList items; if (!GetDirectory(iList, m_Directory[iList]->GetPath(), items)) { if (strDirectory != strOldDirectory && GetDirectory(iList, strOldDirectory, items)) m_Directory[iList]->SetPath(strOldDirectory); // Fallback to old (previous) path) else Update(iList, ""); // Fallback to root return false; } m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory); ClearFileItems(iList); m_vecItems[iList]->Append(items); m_vecItems[iList]->SetPath(items.GetPath()); std::string strParentPath; URIUtils::GetParentPath(strDirectory, strParentPath); if (strDirectory.empty() && (m_vecItems[iList]->Size() == 0 || CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWADDSOURCEBUTTONS))) { // add 'add source button' std::string strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetIconImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); pItem->m_bIsFolder = true; pItem->SetSpecialSort(SortSpecialOnBottom); m_vecItems[iList]->Add(pItem); } else if (items.IsEmpty() || CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWPARENTDIRITEMS)) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(m_rootDir.IsSource(strDirectory) ? "" : strParentPath); pItem->m_bIsFolder = true; pItem->m_bIsShareOrDrive = false; m_vecItems[iList]->AddFront(pItem, 0); } m_strParentPath[iList] = (m_rootDir.IsSource(strDirectory) ? "" : strParentPath); if (strDirectory.empty()) { CFileItemPtr pItem(new CFileItem("special://profile/", true)); pItem->SetLabel(g_localizeStrings.Get(20070)); pItem->SetArt("thumb", "DefaultFolder.png"); pItem->SetLabelPreformated(true); m_vecItems[iList]->Add(pItem); } // if we have a .tbn file, use itself as the thumb for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); if (pItem->IsHD() && URIUtils::HasExtension(pItem->GetPath(), ".tbn")) { pItem->SetArt("thumb", pItem->GetPath()); } } m_vecItems[iList]->FillInDefaultIcons(); OnSort(iList); UpdateButtons(); int item = 0; strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->GetPath()); for (int i = 0; i < m_vecItems[iList]->Size(); ++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); std::string strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { item = i; break; } } UpdateControl(iList, item); return true; }
// \brief Set window to a specific directory // \param strDirectory The directory to be displayed in list/thumb control // This function calls OnPrepareFileItems() and OnFinalizeFileItems() bool CGUIMediaWindow::Update(const CStdString &strDirectory) { // TODO: OnInitWindow calls Update() before window path has been set properly. if (strDirectory == "?") return false; // get selected item int iItem = m_viewControl.GetSelectedItem(); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); } } CStdString strOldDirectory = m_vecItems->GetPath(); m_history.SetSelectedItem(strSelectedItem, strOldDirectory); CFileItemList items; if (!GetDirectory(strDirectory, items)) { CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str()); // if the directory is the same as the old directory, then we'll return // false. Else, we assume we can get the previous directory if (strDirectory.Equals(strOldDirectory)) return false; // We assume, we can get the parent // directory again, but we have to // return false to be able to eg. show // an error message. CStdString strParentPath = m_history.GetParentPath(); m_history.RemoveParentPath(); Update(strParentPath); return false; } if (items.GetLabel().IsEmpty()) items.SetLabel(CUtil::GetTitleFromPath(items.GetPath(), true)); ClearFileItems(); m_vecItems->Copy(items); // if we're getting the root source listing // make sure the path history is clean if (strDirectory.IsEmpty()) m_history.ClearPathHistory(); int iWindow = GetID(); int showLabel = 0; if (strDirectory.IsEmpty() && (iWindow == WINDOW_MUSIC_FILES || iWindow == WINDOW_FILES || iWindow == WINDOW_PICTURES || iWindow == WINDOW_PROGRAMS)) showLabel = 1026; if (strDirectory.Equals("sources://video/")) showLabel = 999; if (showLabel && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button' { CStdString strLabel = g_localizeStrings.Get(showLabel); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->SetPath("add"); pItem->SetIconImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); pItem->m_bIsFolder = true; pItem->SetSpecialSort(SORT_ON_BOTTOM); m_vecItems->Add(pItem); } m_iLastControl = GetFocusedControlID(); // Ask the derived class if it wants to load additional info // for the fileitems like media info or additional // filtering on the items, setting thumbs. OnPrepareFileItems(*m_vecItems); // The idea here is to ensure we have something to focus if our file list // is empty. As such, this check MUST be last and ignore the hide parent // fileitems settings. if (m_vecItems->IsEmpty()) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(m_history.GetParentPath()); pItem->m_bIsFolder = true; pItem->m_bIsShareOrDrive = false; m_vecItems->AddFront(pItem, 0); } m_vecItems->FillInDefaultIcons(); m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); FormatAndSort(*m_vecItems); // Ask the devived class if it wants to do custom list operations, // eg. changing the label OnFinalizeFileItems(*m_vecItems); UpdateButtons(); m_viewControl.SetItems(*m_vecItems); strSelectedItem = m_history.GetSelectedItem(m_vecItems->GetPath()); bool bSelectedFound = false; //int iSongInDirectory = -1; for (int i = 0; i < m_vecItems->Size(); ++i) { CFileItemPtr pItem = m_vecItems->Get(i); // Update selected item if (!bSelectedFound) { CStdString strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { m_viewControl.SetSelectedItem(i); bSelectedFound = true; } } } // if we haven't found the selected item, select the first item if (!bSelectedFound) m_viewControl.SetSelectedItem(0); if (iWindow != WINDOW_PVR || (iWindow == WINDOW_PVR && m_vecItems->GetPath().Left(17) == "pvr://recordings/")) m_history.AddPath(m_vecItems->GetPath()); //m_history.DumpPathHistory(); return true; }
bool CMusicInfoScanner::DoScan(const std::string& strDirectory) { if (m_handle) m_handle->SetText(Prettify(strDirectory)); std::set<std::string>::const_iterator it = m_seenPaths.find(strDirectory); if (it != m_seenPaths.end()) return true; m_seenPaths.insert(strDirectory); // Discard all excluded files defined by m_musicExcludeRegExps const std::vector<std::string> ®exps = g_advancedSettings.m_audioExcludeFromScanRegExps; if (IsExcluded(strDirectory, regexps)) return true; // load subfolder CFileItemList items; CDirectory::GetDirectory(strDirectory, items, g_advancedSettings.GetMusicExtensions() + "|.jpg|.tbn|.lrc|.cdg"); // sort and get the path hash. Note that we don't filter .cue sheet items here as we want // to detect changes in the .cue sheet as well. The .cue sheet items only need filtering // if we have a changed hash. items.Sort(SortByLabel, SortOrderAscending); std::string hash; GetPathHash(items, hash); // check whether we need to rescan or not std::string dbHash; if ((m_flags & SCAN_RESCAN) || !m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash) { // path has changed - rescan if (dbHash.empty()) CLog::Log(LOGDEBUG, "%s Scanning dir '%s' as not in the database", __FUNCTION__, CURL::GetRedacted(strDirectory).c_str()); else CLog::Log(LOGDEBUG, "%s Rescanning dir '%s' due to change", __FUNCTION__, CURL::GetRedacted(strDirectory).c_str()); // filter items in the sub dir (for .cue sheet support) items.FilterCueItems(); items.Sort(SortByLabel, SortOrderAscending); // and then scan in the new information if (RetrieveMusicInfo(strDirectory, items) > 0) { if (m_handle) OnDirectoryScanned(strDirectory); } // save information about this folder m_musicDatabase.SetPathHash(strDirectory, hash); } else { // path is the same - no need to rescan CLog::Log(LOGDEBUG, "%s Skipping dir '%s' due to no change", __FUNCTION__, CURL::GetRedacted(strDirectory).c_str()); m_currentItem += CountFiles(items, false); // false for non-recursive // updated the dialog with our progress if (m_handle) { if (m_itemCount>0) m_handle->SetPercentage(m_currentItem/(float)m_itemCount*100); OnDirectoryScanned(strDirectory); } } // now scan the subfolders for (int i = 0; i < items.Size(); ++i) { CFileItemPtr pItem = items[i]; if (m_bStop) break; // if we have a directory item (non-playlist) we then recurse into that folder if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList()) { std::string strPath=pItem->GetPath(); if (!DoScan(strPath)) { m_bStop = true; } } } return !m_bStop; }
void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item) { // are we in the playlists location? bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->GetPath().Equals("special://musicplaylists/"); if (m_vecItems->IsVirtualDirectoryRoot() || m_vecItems->GetPath() == "sources://music/") { // get the usual music shares, and anything for all media windows CGUIDialogContextMenu::GetContextButtons("music", item, buttons); #ifdef HAS_DVD_DRIVE // enable Rip CD an audio disc if (g_mediaManager.IsDiscInDrive() && item->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) { if (CJobManager::GetInstance().IsProcessing("cdrip")) buttons.Add(CONTEXT_BUTTON_CANCEL_RIP_CD, 14100); else buttons.Add(CONTEXT_BUTTON_RIP_CD, 600); } } #endif CGUIMediaWindow::GetContextButtons(itemNumber, buttons); } else { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); if (item->GetProperty("pluginreplacecontextitems").asBoolean()) return; if (!item->IsPlayList() && !item->IsPlugin() && !item->IsScript()) { if (item->IsAudio()) buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info else if (!item->IsParentFolder() && !StringUtils::StartsWithNoCase(item->GetPath(), "new") && item->m_bIsFolder) { #if 0 if (m_musicdatabase.GetAlbumIdByPath(item->GetPath()) > -1) #endif buttons.Add(CONTEXT_BUTTON_INFO, 13351); // Album Info } } #ifdef HAS_DVD_DRIVE // enable Rip CD Audio or Track button if we have an audio disc if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) buttons.Add(CONTEXT_BUTTON_RIP_TRACK, 610); } #endif // enable CDDB lookup if the current dir is CDDA if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA() && (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_CDDB, 16002); } if (!item->IsParentFolder() && !item->IsReadOnly()) { // either we're at the playlist location or its been explicitly allowed if (inPlaylists || CSettings::Get().GetBool("filelists.allowfiledeletion")) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } } // Add the scan button(s) if (g_application.IsMusicScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!inPlaylists && !m_vecItems->IsInternetStream() && !item->GetPath().Equals("add") && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://") && (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_SCAN, 13352); } if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } if (!m_vecItems->IsVirtualDirectoryRoot() && !m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item) { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) || m_vecItems->IsPath("special://musicplaylists/"); if (m_vecItems->IsPath("sources://music/")) { // get the usual music shares, and anything for all media windows CGUIDialogContextMenu::GetContextButtons("music", item, buttons); #ifdef HAS_DVD_DRIVE // enable Rip CD an audio disc if (g_mediaManager.IsDiscInDrive() && item->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! MEDIA_DETECT::CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) { if (CJobManager::GetInstance().IsProcessing("cdrip")) buttons.Add(CONTEXT_BUTTON_CANCEL_RIP_CD, 14100); else buttons.Add(CONTEXT_BUTTON_RIP_CD, 600); } } #endif // Add the scan button(s) if (g_application.IsMusicScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!inPlaylists && !m_vecItems->IsInternetStream() && !item->IsPath("add") && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://") && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_SCAN, 13352); } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); } else { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CMusicDatabaseDirectory dir; // enable query all albums button only in album view if (item->IsAlbum() && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in artist view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; if(m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS)) { if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->IsPath(CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW))) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (!CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW).empty()) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20195); } if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetArtistString().empty()) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetArtistString().empty() && !item->GetMusicInfoTag()->GetAlbum().empty() && !item->GetMusicInfoTag()->GetTitle().empty()) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString(), item->GetMusicInfoTag()->GetAlbum(), item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if ((CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp" && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (!item->IsReadOnly() && CSettings::GetInstance().GetBool("filelists.allowfiledeletion")) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } } // noncontextual buttons CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIDialogFileBrowser::Update(const std::string &strDirectory) { const CURL pathToUrl(strDirectory); if (m_browsingForImages && m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); // get selected item int iItem = m_viewControl.GetSelectedItem(); std::string strSelectedItem; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = (*m_vecItems)[iItem]; if (!pItem->IsParentFolder()) { strSelectedItem = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(strSelectedItem); m_history.SetSelectedItem(strSelectedItem, m_Directory->GetPath().empty()?"empty":m_Directory->GetPath()); } } if (!m_singleList) { CFileItemList items; std::string strParentPath; if (!m_rootDir.GetDirectory(pathToUrl, items, m_useFileDirectories, false)) { CLog::Log(LOGERROR,"CGUIDialogFileBrowser::GetDirectory(%s) failed", pathToUrl.GetRedacted().c_str()); // We assume, we can get the parent // directory again std::string strParentPath = m_history.GetParentPath(); m_history.RemoveParentPath(); Update(strParentPath); return; } // check if current directory is a root share if (!m_rootDir.IsSource(strDirectory)) { if (URIUtils::GetParentPath(strDirectory, strParentPath)) { CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(strParentPath); pItem->m_bIsFolder = true; pItem->m_bIsShareOrDrive = false; items.AddFront(pItem, 0); } } else { // yes, this is the root of a share // add parent path to the virtual directory CFileItemPtr pItem(new CFileItem("..")); pItem->SetPath(""); pItem->m_bIsShareOrDrive = false; pItem->m_bIsFolder = true; items.AddFront(pItem, 0); strParentPath = ""; } ClearFileItems(); m_vecItems->Copy(items); m_Directory->SetPath(strDirectory); m_strParentPath = strParentPath; } // if we're getting the root source listing // make sure the path history is clean if (strDirectory.empty()) m_history.ClearPathHistory(); // some evil stuff don't work with the '/' mask, e.g. shoutcast directory - make sure no files are in there if (m_browsingForFolders) { for (int i=0;i<m_vecItems->Size();++i) if (!(*m_vecItems)[i]->m_bIsFolder) { m_vecItems->Remove(i); i--; } } // No need to set thumbs m_vecItems->FillInDefaultIcons(); OnSort(); if (m_Directory->GetPath().empty() && m_addNetworkShareEnabled && (CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE || CServiceBroker::GetSettingsComponent()->GetProfileManager()->IsMasterProfile() || g_passwordManager.bMasterUser)) { // we are in the virtual directory - add the "Add Network Location" item CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(1032))); pItem->SetPath("net://"); pItem->m_bIsFolder = true; m_vecItems->Add(pItem); } if (m_Directory->GetPath().empty() && !m_addSourceType.empty()) { CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(21359))); pItem->SetPath("source://"); pItem->m_bIsFolder = true; m_vecItems->Add(pItem); } m_viewControl.SetItems(*m_vecItems); m_viewControl.SetCurrentView((m_browsingForImages && CAutoSwitch::ByFileCount(*m_vecItems)) ? CONTROL_THUMBS : CONTROL_LIST); std::string strPath2 = m_Directory->GetPath(); URIUtils::RemoveSlashAtEnd(strPath2); strSelectedItem = m_history.GetSelectedItem(strPath2==""?"empty":strPath2); bool bSelectedFound = false; for (int i = 0; i < m_vecItems->Size(); ++i) { CFileItemPtr pItem = (*m_vecItems)[i]; strPath2 = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(strPath2); if (strPath2 == strSelectedItem) { m_viewControl.SetSelectedItem(i); bSelectedFound = true; break; } } // if we haven't found the selected item, select the first item if (!bSelectedFound) m_viewControl.SetSelectedItem(0); m_history.AddPath(m_Directory->GetPath()); if (m_browsingForImages) m_thumbLoader.Load(*m_vecItems); }
bool CGUIWindowMusicNav::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_RESET: m_vecItems->SetPath("?"); break; case GUI_MSG_WINDOW_INIT: { /* We don't want to show Autosourced items (ie removable pendrives, memorycards) in Library mode */ m_rootDir.AllowNonLocalSources(false); // is this the first time the window is opened? if (m_vecItems->GetPath() == "?" && message.GetStringParam().empty()) message.SetStringParam(CServiceBroker::GetSettings()->GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW)); if (!CGUIWindowMusicBase::OnMessage(message)) return false; if (message.GetStringParam(0) != "") { CURL url(message.GetStringParam(0)); int i = 0; for (; i < m_vecItems->Size(); i++) { CFileItemPtr pItem = m_vecItems->Get(i); // skip ".." if (pItem->IsParentFolder()) continue; if (URIUtils::PathEquals(pItem->GetPath(), message.GetStringParam(0), true, true)) { m_viewControl.SetSelectedItem(i); i = -1; if (url.GetOption("showinfo") == "true") OnItemInfo(i); break; } } } return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNPARTYMODE) { if (g_partyModeManager.IsEnabled()) g_partyModeManager.Disable(); else { if (!g_partyModeManager.Enable()) { SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE,false); return false; } // Playlist directory is the root of the playlist window if (m_guiState.get()) m_guiState->SetPlaylistDirectory("playlistmusic://"); return true; } UpdateButtons(); } else if (iControl == CONTROL_SEARCH) { if (m_searchWithEdit) { // search updated - reset timer m_searchTimer.StartZero(); // grab our search string CGUIMessage selected(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_SEARCH); OnMessage(selected); SetProperty("search", selected.GetLabel()); return true; } std::string search(GetProperty("search").asString()); CGUIKeyboardFactory::ShowAndGetFilter(search, true); SetProperty("search", search); return true; } else if (iControl == CONTROL_UPDATE_LIBRARY) { if (!g_application.IsMusicScanning()) g_application.StartMusicScan(""); else g_application.StopMusicScan(); return true; } } break; case GUI_MSG_PLAYBACK_STOPPED: case GUI_MSG_PLAYBACK_ENDED: case GUI_MSG_PLAYLISTPLAYER_STOPPED: case GUI_MSG_PLAYBACK_STARTED: { SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); } break; case GUI_MSG_NOTIFY_ALL: { if (message.GetParam1() == GUI_MSG_SEARCH_UPDATE && IsActive()) { // search updated - reset timer m_searchTimer.StartZero(); SetProperty("search", message.GetStringParam()); } } } return CGUIWindowMusicBase::OnMessage(message); }
bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) { if (m_handle) m_handle->SetText(Prettify(strDirectory)); /* * remove this path from the list we're processing. This must be done prior to * the check for file or folder exclusion to prevent an infinite while loop * in Process(). */ set<CStdString>::iterator it = m_pathsToScan.find(strDirectory); if (it != m_pathsToScan.end()) m_pathsToScan.erase(it); // Discard all excluded files defined by m_musicExcludeRegExps CStdStringArray regexps = g_advancedSettings.m_audioExcludeFromScanRegExps; if (CUtil::ExcludeFileOrFolder(strDirectory, regexps)) return true; // load subfolder CFileItemList items; CDirectory::GetDirectory(strDirectory, items, g_settings.m_musicExtensions + "|.jpg|.tbn|.lrc|.cdg"); // sort and get the path hash. Note that we don't filter .cue sheet items here as we want // to detect changes in the .cue sheet as well. The .cue sheet items only need filtering // if we have a changed hash. items.Sort(SORT_METHOD_LABEL, SortOrderAscending); CStdString hash; GetPathHash(items, hash); // check whether we need to rescan or not CStdString dbHash; if ((m_flags & SCAN_RESCAN) || !m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash) { // path has changed - rescan if (dbHash.IsEmpty()) CLog::Log(LOGDEBUG, "%s Scanning dir '%s' as not in the database", __FUNCTION__, strDirectory.c_str()); else CLog::Log(LOGDEBUG, "%s Rescanning dir '%s' due to change", __FUNCTION__, strDirectory.c_str()); // filter items in the sub dir (for .cue sheet support) items.FilterCueItems(); items.Sort(SORT_METHOD_LABEL, SortOrderAscending); // and then scan in the new information if (RetrieveMusicInfo(items, strDirectory) > 0) { if (m_handle) OnDirectoryScanned(strDirectory); } // save information about this folder m_musicDatabase.SetPathHash(strDirectory, hash); } else { // path is the same - no need to rescan CLog::Log(LOGDEBUG, "%s Skipping dir '%s' due to no change", __FUNCTION__, strDirectory.c_str()); m_currentItem += CountFiles(items, false); // false for non-recursive // updated the dialog with our progress if (m_handle) { if (m_itemCount>0) m_handle->SetPercentage(m_currentItem/(float)m_itemCount*100); OnDirectoryScanned(strDirectory); } } // now scan the subfolders for (int i = 0; i < items.Size(); ++i) { CFileItemPtr pItem = items[i]; if (m_bStop) break; // if we have a directory item (non-playlist) we then recurse into that folder if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList()) { CStdString strPath=pItem->GetPath(); if (!DoScan(strPath)) { m_bStop = true; } } } return !m_bStop; }
bool CGUIWindowFileManager::Update(int iList, const CStdString &strDirectory) { // get selected item int iItem = GetSelectedItem(iList); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < (int)m_vecItems[iList]->Size()) { CFileItemPtr pItem = m_vecItems[iList]->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); m_history[iList].SetSelectedItem(strSelectedItem, m_Directory[iList]->m_strPath); } } CStdString strOldDirectory=m_Directory[iList]->m_strPath; m_Directory[iList]->m_strPath = strDirectory; CFileItemList items; if (!GetDirectory(iList, m_Directory[iList]->m_strPath, items)) { m_Directory[iList]->m_strPath = strOldDirectory; return false; } m_history[iList].SetSelectedItem(strSelectedItem, strOldDirectory); ClearFileItems(iList); m_vecItems[iList]->Append(items); m_vecItems[iList]->m_strPath = items.m_strPath; if (strDirectory.IsEmpty() && (m_vecItems[iList]->Size() == 0 || !g_guiSettings.GetBool("filelists.disableaddsourcebuttons"))) { // add 'add source button' CStdString strLabel = g_localizeStrings.Get(1026); CFileItemPtr pItem(new CFileItem(strLabel)); pItem->m_strPath = "add"; pItem->SetThumbnailImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); m_vecItems[iList]->Add(pItem); } // if we have a .tbn file, use itself as the thumb for (int i = 0; i < (int)m_vecItems[iList]->Size(); i++) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); CStdString strExtension; CUtil::GetExtension(pItem->m_strPath, strExtension); if (pItem->IsHD() && strExtension == ".tbn") { pItem->SetThumbnailImage(pItem->m_strPath); } } m_vecItems[iList]->FillInDefaultIcons(); OnSort(iList); UpdateButtons(); int item = 0; strSelectedItem = m_history[iList].GetSelectedItem(m_Directory[iList]->m_strPath); for (int i = 0; i < m_vecItems[iList]->Size(); ++i) { CFileItemPtr pItem = m_vecItems[iList]->Get(i); CStdString strHistory; GetDirectoryHistoryString(pItem.get(), strHistory); if (strHistory == strSelectedItem) { item = i; break; } } UpdateControl(iList, item); return true; }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && (item->GetExtraInfo().Find("lastfm") < 0)) { // are we in the playlists location? bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->GetPath().Equals("special://musicplaylists/"); CMusicDatabaseDirectory dir; // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLastFM() && !item->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (item->GetPath().Left(14).Equals("videodb://3/4/") && item->GetPath().size() > 14 && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())|| dir.IsArtistDir(item->GetPath()) ) && !dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() && !item->IsLastFM() && !item->IsPlugin() && !item->IsScript() && !item->GetPath().Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->GetPath())) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsLastFM() && !item->IsPlugin() && !item->GetPath().Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS); if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->GetPath().Equals(g_settings.m_defaultMusicLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultMusicLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if ((g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode.xsp") && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } // noncontextual buttons if (musicScan && musicScan->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (musicScan) buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://more/")) { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) || m_vecItems->IsPath("special://musicplaylists/"); CMusicDatabaseDirectory dir; // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/") && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())|| dir.IsArtistDir(item->GetPath()) ) && !dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() && !item->IsPlugin() && !item->IsScript() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { if (dir.IsArtistDir(item->GetPath())) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS); if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->IsPath(CSettings::Get().GetString("mymusic.defaultlibview"))) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (!CSettings::Get().GetString("mymusic.defaultlibview").empty()) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if ((CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp" && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } // noncontextual buttons CGUIWindowMusicBase::GetNonContextButtons(buttons); CContextMenuManager::Get().AddVisibleItems(item, buttons); }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath()); if (!item) { // nothing to do here } else if (m_vecItems->IsPath("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath()); if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) { buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } else { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::VideoPlaylistsLocation()) || m_vecItems->IsPath("special://videoplaylists/"); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_artist.empty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strAlbum.empty()) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strAlbum.empty() && !item->GetVideoInfoTag()->m_artist.empty() && !item->GetVideoInfoTag()->m_strTitle.empty()) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); // can we update the database? if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && (item->GetVideoInfoTag()->m_type == MediaTypeMovie || // movies item->GetVideoInfoTag()->m_type == MediaTypeTvShow || // tvshows item->GetVideoInfoTag()->m_type == MediaTypeSeason || // seasons item->GetVideoInfoTag()->m_type == MediaTypeEpisode || // episodes item->GetVideoInfoTag()->m_type == MediaTypeMusicVideo || // musicvideos item->GetVideoInfoTag()->m_type == "tag" || // tags item->GetVideoInfoTag()->m_type == MediaTypeVideoCollection)) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } if (node == NODE_TYPE_TITLE_TVSHOWS) { buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder) { if (StringUtils::StartsWithNoCase(m_vecItems->GetPath(), "videodb://musicvideos")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if ((CServiceBroker::GetSettings().GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } if ((!item->HasVideoInfoTag() || item->GetVideoInfoTag()->m_iDbId == -1) && info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN_TO_LIBRARY, 21845); } } }
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ if (list < 0 || list > 2) return ; bool bDeselect = SelectItem(list, item); // calculate the position for our menu float posX = 200; float posY = 100; const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list); if (pList) { posX = pList->GetXPosition() + pList->GetWidth() / 2; posY = pList->GetYPosition() + pList->GetHeight() / 2; } CFileItemPtr pItem = m_vecItems[list]->Get(item); if (!pItem.get()) return; if (m_Directory[list]->IsVirtualDirectoryRoot()) { if (item < 0) { // TODO: We should add the option here for shares to be added if there aren't any return ; } // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { m_rootDir.SetSources(g_settings.m_fileSources); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else Refresh(list); return ; } pItem->Select(false); return ; } // popup the context menu bool showEntry = false; if (item >= m_vecItems[list]->Size()) item = -1; if (item >= 0) showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0)); // determine available players VECPLAYERCORES vecCores; CPlayerCoreFactory::GetPlayers(*pItem, vecCores); // add the needed buttons CContextButtons choices; if (item >= 0) { choices.Add(1, 188); // SelectAll if (!pItem->IsParentFolder()) choices.Add(2, CFavourites::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite if (vecCores.size() > 1) choices.Add(3, 15213); // Play Using... if (CanRename(list) && !pItem->IsParentFolder()) choices.Add(4, 118); // Rename if (CanDelete(list) && showEntry) choices.Add(5, 117); // Delete if (CanCopy(list) && showEntry) choices.Add(6, 115); // Copy if (CanMove(list) && showEntry) choices.Add(7, 116); // Move } if (CanNewFolder(list)) choices.Add(8, 20309); // New Folder if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder()) choices.Add(9, 13393); // Calculate Size choices.Add(10, 5); // Settings choices.Add(11, 20128); // Go To Root choices.Add(12, 523); // switch media int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices); if (btnid == 1) { OnSelectAll(list); bDeselect=false; } if (btnid == 2) { CFavourites::AddOrRemove(pItem.get(), GetID()); return; } if (btnid == 3) { VECPLAYERCORES vecCores; CPlayerCoreFactory::GetPlayers(*pItem, vecCores); g_application.m_eForcedNextPlayer = CPlayerCoreFactory::SelectPlayerDialog(vecCores); if (g_application.m_eForcedNextPlayer != EPC_NONE) OnStart(pItem.get()); } if (btnid == 4) OnRename(list); if (btnid == 5) OnDelete(list); if (btnid == 6) OnCopy(list); if (btnid == 7) OnMove(list); if (btnid == 8) OnNewFolder(list); if (btnid == 9) { // setup the progress dialog, and show it CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(13394); for (int i=0; i < 3; i++) progress->SetLine(i, ""); progress->StartModal(); } // Calculate folder size for each selected item for (int i=0; i<m_vecItems[list]->Size(); ++i) { CFileItemPtr pItem2=m_vecItems[list]->Get(i); if (pItem2->m_bIsFolder && pItem2->IsSelected()) { int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress); if (folderSize >= 0) { pItem2->m_dwSize = folderSize; if (folderSize == 0) pItem2->SetLabel2(StringUtils::SizeToString(folderSize)); else pItem2->SetFileSizeLabel(); } } } if (progress) progress->Close(); } if (btnid == 10) { g_windowManager.ActivateWindow(WINDOW_SETTINGS_MENU); return; } if (btnid == 11) { Update(list,""); return; } if (btnid == 12) { CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath()); return; } if (bDeselect && item >= 0 && item < m_vecItems[list]->Size()) { // deselect item as we didn't do anything pItem->Select(false); } }
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */) { if (list < 0 || list >= 2) return ; bool bDeselect = SelectItem(list, item); // calculate the position for our menu float posX = 200; float posY = 100; const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list); if (pList) { posX = pList->GetXPosition() + pList->GetWidth() / 2; posY = pList->GetYPosition() + pList->GetHeight() / 2; } CFileItemPtr pItem = m_vecItems[list]->Get(item); if (!pItem.get()) return; if (m_Directory[list]->IsVirtualDirectoryRoot()) { if (item < 0) { // TODO: We should add the option here for shares to be added if there aren't any return ; } // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { m_rootDir.SetSources(*CMediaSourceSettings::GetInstance().GetSources("files")); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else Refresh(list); return ; } pItem->Select(false); return ; } // popup the context menu bool showEntry = false; if (item >= m_vecItems[list]->Size()) item = -1; if (item >= 0) showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0)); // determine available players std::vector<std::string>players; CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players); // add the needed buttons CContextButtons choices; if (item >= 0) { //The ".." item is not selectable. Take that into account when figuring out if all items are selected int notSelectable = CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWPARENTDIRITEMS) ? 1 : 0; if (NumSelected(list) < m_vecItems[list]->Size() - notSelectable) choices.Add(CONTROL_BTNSELECTALL, 188); // SelectAll if (!pItem->IsParentFolder()) choices.Add(CONTROL_BTNFAVOURITES, XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite if (players.size() > 1) choices.Add(CONTROL_BTNPLAYWITH, 15213); if (CanRename(list) && !pItem->IsParentFolder()) choices.Add(CONTROL_BTNRENAME, 118); if (CanDelete(list) && showEntry) choices.Add(CONTROL_BTNDELETE, 117); if (CanCopy(list) && showEntry) choices.Add(CONTROL_BTNCOPY, 115); if (CanMove(list) && showEntry) choices.Add(CONTROL_BTNMOVE, 116); } if (CanNewFolder(list)) choices.Add(CONTROL_BTNNEWFOLDER, 20309); if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder()) choices.Add(CONTROL_BTNCALCSIZE, 13393); choices.Add(CONTROL_BTNGOTOROOT, 20128); choices.Add(CONTROL_BTNSWITCHMEDIA, 523); if (CJobManager::GetInstance().IsProcessing("filemanager")) choices.Add(CONTROL_BTNCANCELJOB, 167); int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices); if (btnid == CONTROL_BTNSELECTALL) { OnSelectAll(list); bDeselect=false; } if (btnid == CONTROL_BTNFAVOURITES) { XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID()); return; } if (btnid == CONTROL_BTNPLAYWITH) { std::vector<std::string>players; CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players); std::string player = CPlayerCoreFactory::GetInstance().SelectPlayerDialog(players); if (!player.empty()) OnStart(pItem.get(), player); } if (btnid == CONTROL_BTNRENAME) OnRename(list); if (btnid == CONTROL_BTNDELETE) OnDelete(list); if (btnid == CONTROL_BTNCOPY) OnCopy(list); if (btnid == CONTROL_BTNMOVE) OnMove(list); if (btnid == CONTROL_BTNNEWFOLDER) OnNewFolder(list); if (btnid == CONTROL_BTNCALCSIZE) { // setup the progress dialog, and show it CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{13394}); for (int i=0; i < 3; i++) progress->SetLine(i, CVariant{""}); progress->Open(); } // Calculate folder size for each selected item for (int i=0; i<m_vecItems[list]->Size(); ++i) { CFileItemPtr pItem2=m_vecItems[list]->Get(i); if (pItem2->m_bIsFolder && pItem2->IsSelected()) { int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress); if (folderSize >= 0) { pItem2->m_dwSize = folderSize; if (folderSize == 0) pItem2->SetLabel2(StringUtils::SizeToString(folderSize)); else pItem2->SetFileSizeLabel(); } } } if (progress) progress->Close(); } if (btnid == CONTROL_BTNGOTOROOT) { Update(list,""); return; } if (btnid == CONTROL_BTNSWITCHMEDIA) { CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath()); return; } if (btnid == CONTROL_BTNCANCELJOB) CancelJobs(); if (bDeselect && item >= 0 && item < m_vecItems[list]->Size()) { // deselect item as we didn't do anything pItem->Select(false); } }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetPropertyBOOL("pluginreplacecontextitems")) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->m_strPath); if (!item) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } else { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (!item->m_bIsFolder && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) buttons.Add(CONTEXT_BUTTON_INFO, 13346); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strArtist.IsEmpty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(item->GetVideoInfoTag()->m_strArtist) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_strArtist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(item->GetVideoInfoTag()->m_strArtist, item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { // can we update the database? if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (node == NODE_TYPE_TITLE_TVSHOWS) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); } if ((info && info->Content() == CONTENT_TVSHOWS && item->m_bIsFolder) || (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) { if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount == 0) buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (node != NODE_TYPE_SEASONS) buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && item->GetVideoInfoTag()->m_strArtist.IsEmpty()) // movie entry { if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_THUMB, 20371); if (item->m_strPath.Left(14).Equals("videodb://1/7/") && item->m_strPath.size() > 14 && item->m_bIsFolder) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_THUMB, 20435); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder) { if (m_vecItems->m_strPath.Left(11).Equals("videodb://3")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) { if (info && info->Content() == CONTENT_TVSHOWS) { if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && item->GetVideoInfoTag()->m_iBookmarkId != 0) { buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); } } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } // this should ideally be non-contextual (though we need some context for non-tv show node I guess) CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) { if (node != NODE_TYPE_TITLE_TVSHOWS) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); } else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } //Set default and/or clear default NODE_TYPE nodetype = CVideoDatabaseDirectory::GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !m_vecItems->m_strPath.Equals("special://videoplaylists/") && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TVSHOWS_OVERVIEW || nodetype == NODE_TYPE_MOVIES_OVERVIEW || nodetype == NODE_TYPE_MUSICVIDEOS_OVERVIEW)) { if (!item->m_strPath.Equals(g_settings.m_defaultVideoLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultVideoLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } if ((CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MOVIES || CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MUSICVIDEOS || item->m_strPath.Equals("videodb://1/") || item->m_strPath.Equals("videodb://4/") || item->m_strPath.Equals("videodb://6/")) && nodetype != NODE_TYPE_RECENTLY_ADDED_MOVIES) { buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched } if (m_vecItems->m_strPath.Equals("special://videoplaylists/")) { // video playlists, file operations are allowed if (!item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); }
// \brief With this function you can react on a users click in the list/thumb panel. // It returns true, if the click is handled. // This function calls OnPlayMedia() bool CGUIMediaWindow::OnClick(int iItem) { if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return true; CFileItemPtr pItem = m_vecItems->Get(iItem); if (pItem->IsParentFolder()) { GoParentFolder(); return true; } if (pItem->GetPath() == "add" || pItem->GetPath() == "sources://add/") // 'add source button' in empty root { OnContextButton(iItem, CONTEXT_BUTTON_ADD_SOURCE); return true; } if (!pItem->m_bIsFolder && pItem->IsFileFolder()) { XFILE::IFileDirectory *pFileDirectory = NULL; pFileDirectory = XFILE::CFactoryFileDirectory::Create(pItem->GetPath(), pItem.get(), ""); if(pFileDirectory) pItem->m_bIsFolder = true; else if(pItem->m_bIsFolder) pItem->m_bIsFolder = false; delete pFileDirectory; } if (pItem->IsScript()) { // execute the script CURL url(pItem->GetPath()); AddonPtr addon; if (CAddonMgr::Get().GetAddon(url.GetHostName(), addon)) { #ifdef HAS_PYTHON if (!g_pythonParser.StopScript(addon->LibPath())) g_pythonParser.evalFile(addon->LibPath(),addon); #endif return true; } } if (pItem->m_bIsFolder) { if ( pItem->m_bIsShareOrDrive ) { const CStdString& strLockType=m_guiState->GetLockType(); if (g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE) if (!strLockType.IsEmpty() && !g_passwordManager.IsItemUnlocked(pItem.get(), strLockType)) return true; if (!HaveDiscOrConnection(pItem->GetPath(), pItem->m_iDriveType)) return true; } // check for the partymode playlist items - they may not exist yet if ((pItem->GetPath() == g_settings.GetUserDataItem("PartyMode.xsp")) || (pItem->GetPath() == g_settings.GetUserDataItem("PartyMode-Video.xsp"))) { // party mode playlist item - if it doesn't exist, prompt for user to define it if (!XFILE::CFile::Exists(pItem->GetPath())) { m_vecItems->RemoveDiscCache(GetID()); if (CGUIDialogSmartPlaylistEditor::EditPlaylist(pItem->GetPath())) Update(m_vecItems->GetPath()); return true; } } // remove the directory cache if the folder is not normally cached CFileItemList items(pItem->GetPath()); if (!items.AlwaysCache()) items.RemoveDiscCache(GetID()); CFileItem directory(*pItem); if (!Update(directory.GetPath())) ShowShareErrorMessage(&directory); return true; } else if (pItem->IsPlugin() && !pItem->GetProperty("isplayable").asBoolean()) { return XFILE::CPluginDirectory::RunScriptWithParams(pItem->GetPath()); } else { m_iSelectedItem = m_viewControl.GetSelectedItem(); if (pItem->GetPath() == "newplaylist://") { m_vecItems->RemoveDiscCache(GetID()); g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST_EDITOR,"newplaylist://"); return true; } else if (pItem->GetPath().Left(19).Equals("newsmartplaylist://")) { m_vecItems->RemoveDiscCache(GetID()); if (CGUIDialogSmartPlaylistEditor::NewPlaylist(pItem->GetPath().Mid(19))) Update(m_vecItems->GetPath()); return true; } else if (pItem->GetPath().Left(14).Equals("addons://more/")) { CBuiltins::Execute("ActivateWindow(AddonBrowser,addons://all/xbmc.addon." + pItem->GetPath().Mid(14) + ",return)"); return true; } // If karaoke song is being played AND popup autoselector is enabled, the playlist should not be added bool do_not_add_karaoke = g_guiSettings.GetBool("karaoke.enabled") && g_guiSettings.GetBool("karaoke.autopopupselector") && pItem->IsKaraoke(); bool autoplay = m_guiState.get() && m_guiState->AutoPlayNextItem(); if (pItem->IsPlugin()) { CURL url(pItem->GetPath()); AddonPtr addon; if (CAddonMgr::Get().GetAddon(url.GetHostName(),addon)) { PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addon); if (plugin && plugin->Provides(CPluginSource::AUDIO) && pItem->IsAudio()) { autoplay = g_guiSettings.GetBool("musicplayer.autoplaynextitem"); } } } if (autoplay && !g_partyModeManager.IsEnabled() && !pItem->IsPlayList() && !do_not_add_karaoke) { return OnPlayAndQueueMedia(pItem); } else { return OnPlayMedia(iItem); } } return false; }
void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !item->GetProperty("pluginreplacecontextitems").asBoolean()) { if (item && !item->IsParentFolder()) { if (!m_vecItems->IsPlugin() && (item->IsPlugin() || item->IsScript())) buttons.Add(CONTEXT_BUTTON_INFO,24003); // Add-on info if (item->CanQueue() && !item->IsAddonsPath() && !item->IsScript()) { buttons.Add(CONTEXT_BUTTON_QUEUE_ITEM, 13347); //queue // allow a folder to be ad-hoc queued and played by the default player if (item->m_bIsFolder || (item->IsPlayList() && !g_advancedSettings.m_playlistAsFolders)) { buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 208); // Play } else { // check what players we have, if we have multiple display play with option VECPLAYERCORES vecCores; CPlayerCoreFactory::GetInstance().GetPlayers(*item, vecCores); if (vecCores.size() >= 1) buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With... } if (item->IsSmartPlayList()) { buttons.Add(CONTEXT_BUTTON_PLAY_PARTYMODE, 15216); // Play in Partymode } if (item->IsSmartPlayList() || m_vecItems->IsSmartPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT_SMART_PLAYLIST, 586); else if (item->IsPlayList() || m_vecItems->IsPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT, 586); } // Add the scan button(s) if (g_application.IsMusicScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!m_vecItems->IsMusicDb() && !m_vecItems->IsInternetStream() && !item->IsPath("add") && !item->IsParentFolder() && !item->IsPlugin() && !item->IsMusicDb() && !item->IsLibraryFolder() && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://") && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_SCAN, 13352); } #ifdef HAS_DVD_DRIVE // enable Rip CD Audio or Track button if we have an audio disc if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! MEDIA_DETECT::CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) buttons.Add(CONTEXT_BUTTON_RIP_TRACK, 610); } #endif } // enable CDDB lookup if the current dir is CDDA if (g_mediaManager.IsDiscInDrive() && m_vecItems->IsCDDA() && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_CDDB, 16002); } } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); }