Subject: [PATCH] Revert "Merge pull request #24394 from CrystalP/add-itemdir" This reverts commit c0dccda294fcf15629c680083f1c74ac661c1fac, reversing changes made to b7b8322e4ba45836345ca5e3cce5b2587cd63f60. --- xbmc/video/dialogs/GUIDialogVideoManager.cpp | 15 ------------- xbmc/video/dialogs/GUIDialogVideoManager.h | 1 - .../dialogs/GUIDialogVideoManagerExtras.cpp | 22 +++++++++++++++++-- .../dialogs/GUIDialogVideoManagerExtras.h | 5 +++++ .../dialogs/GUIDialogVideoManagerVersions.cpp | 1 - 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.cpp b/xbmc/video/dialogs/GUIDialogVideoManager.cpp index 6f80a2ad0c..46bbddab54 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManager.cpp @@ -14,7 +14,6 @@ #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogSelect.h" #include "dialogs/GUIDialogYesNo.h" -#include "filesystem/Directory.h" #include "guilib/GUIComponent.h" #include "guilib/GUIKeyboardFactory.h" #include "guilib/GUIWindowManager.h" @@ -22,7 +21,6 @@ #include "input/Key.h" #include "playlists/PlayListTypes.h" #include "utils/StringUtils.h" -#include "utils/URIUtils.h" #include "utils/log.h" #include "video/VideoManagerTypes.h" #include "video/VideoThumbLoader.h" @@ -422,16 +420,3 @@ int CGUIDialogVideoManager::ChooseVideoAsset(const std::shared_ptr& i return assetId; } - -void CGUIDialogVideoManager::AppendItemFolderToFileBrowserSources( - std::vector& sources) -{ - const std::string itemDir{URIUtils::GetParentPath(m_videoAsset->GetDynPath())}; - if (!itemDir.empty() && XFILE::CDirectory::Exists(itemDir)) - { - CMediaSource itemSource{}; - itemSource.strName = g_localizeStrings.Get(36041); // * Item folder - itemSource.strPath = itemDir; - sources.emplace_back(itemSource); - } -} diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.h b/xbmc/video/dialogs/GUIDialogVideoManager.h index 052de1f38b..e2c2ffebd2 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.h +++ b/xbmc/video/dialogs/GUIDialogVideoManager.h @@ -51,7 +51,6 @@ protected: void UpdateControls(); static int ChooseVideoAsset(const std::shared_ptr& item, VideoAssetType assetType); - void AppendItemFolderToFileBrowserSources(std::vector& sources); CVideoDatabase m_database; std::shared_ptr m_videoAsset; diff --git a/xbmc/video/dialogs/GUIDialogVideoManagerExtras.cpp b/xbmc/video/dialogs/GUIDialogVideoManagerExtras.cpp index a9c0090bd5..958e33837f 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManagerExtras.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManagerExtras.cpp @@ -16,6 +16,7 @@ #include "dialogs/GUIDialogFileBrowser.h" #include "dialogs/GUIDialogOK.h" #include "dialogs/GUIDialogYesNo.h" +#include "filesystem/Directory.h" #include "guilib/GUIComponent.h" #include "guilib/GUIWindowManager.h" #include "guilib/LocalizeStrings.h" @@ -93,9 +94,9 @@ void CGUIDialogVideoManagerExtras::AddVideoExtra() CServiceBroker::GetMediaManager().GetLocalDrives(sources); CServiceBroker::GetMediaManager().GetNetworkLocations(sources); - AppendItemFolderToFileBrowserSources(sources); - std::string path; + std::string path{GetLikelyExtrasPath()}; + if (CGUIDialogFileBrowser::ShowAndGetFile( sources, CServiceBroker::GetFileExtensionProvider().GetVideoExtensions(), g_localizeStrings.Get(40015), path)) @@ -208,3 +209,20 @@ std::string CGUIDialogVideoManagerExtras::GenerateVideoExtra(const std::string& // trim the string return StringUtils::Trim(extrasVersion); } + +std::string CGUIDialogVideoManagerExtras::GetLikelyExtrasPath() +{ + std::string path{URIUtils::GetDirectory(m_videoAsset->GetDynPath())}; + CFileItemList items; + + if (!XFILE::CDirectory::GetDirectory(path, items, "", XFILE::DIR_FLAG_DEFAULTS)) + return path; + + for (const auto& item : items) + { + if (item->m_bIsFolder && item->IsVideoExtras()) + return item->GetPath(); + } + + return path; +} diff --git a/xbmc/video/dialogs/GUIDialogVideoManagerExtras.h b/xbmc/video/dialogs/GUIDialogVideoManagerExtras.h index cbb6d48474..9aa1d9a864 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManagerExtras.h +++ b/xbmc/video/dialogs/GUIDialogVideoManagerExtras.h @@ -40,4 +40,9 @@ protected: private: void AddVideoExtra(); static std::string GenerateVideoExtra(const std::string& extrasPath); + /*! + * \brief Return a likely location for extras related to the movie + * \return path of the location + */ + std::string GetLikelyExtrasPath(); }; diff --git a/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp b/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp index 6fa548ea52..15a06f2514 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp @@ -536,7 +536,6 @@ bool CGUIDialogVideoManagerVersions::AddVideoVersionFilePicker() CServiceBroker::GetMediaManager().GetLocalDrives(sources); CServiceBroker::GetMediaManager().GetNetworkLocations(sources); - AppendItemFolderToFileBrowserSources(sources); std::string path; if (CGUIDialogFileBrowser::ShowAndGetFile( -- 2.43.0