Skip to content

Commit

Permalink
[video][music] Hide play-related context menu items for non-existing …
Browse files Browse the repository at this point in the history
…party mode playlists.
  • Loading branch information
ksooo committed Oct 13, 2023
1 parent d8b3970 commit 05fddad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xbmc/music/MusicUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,19 @@ bool GetItemsForPlayList(const std::shared_ptr<CFileItem>& item, CFileItemList&
true); // can be cancelled
}

namespace
{
bool IsNonExistingUserPartyModePlaylist(const CFileItem& item)
{
if (!item.IsSmartPlayList())
return false;

const std::string path{item.GetPath()};
const auto profileManager{CServiceBroker::GetSettingsComponent()->GetProfileManager()};
return ((profileManager->GetUserDataItem("PartyMode.xsp") == path) && !CFileUtils::Exists(path));
}
} // unnamed namespace

bool IsItemPlayable(const CFileItem& item)
{
// Exclude all parent folders
Expand Down Expand Up @@ -894,6 +907,9 @@ bool IsItemPlayable(const CFileItem& item)
}
}

if (IsNonExistingUserPartyModePlaylist(item))
return false;

if (item.m_bIsFolder &&
(item.IsMusicDb() || StringUtils::StartsWithNoCase(item.GetPath(), "library://music/")))
{
Expand Down
19 changes: 19 additions & 0 deletions xbmc/video/VideoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
#include "guilib/LocalizeStrings.h"
#include "playlists/PlayList.h"
#include "playlists/PlayListFactory.h"
#include "profiles/ProfileManager.h"
#include "settings/MediaSettings.h"
#include "settings/SettingUtils.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "threads/IRunnable.h"
#include "utils/FileUtils.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/log.h"
Expand Down Expand Up @@ -518,6 +520,20 @@ bool GetItemsForPlayList(const std::shared_ptr<CFileItem>& item, CFileItemList&
true); // can be cancelled
}

namespace
{
bool IsNonExistingUserPartyModePlaylist(const CFileItem& item)
{
if (!item.IsSmartPlayList())
return false;

const std::string path{item.GetPath()};
const auto profileManager{CServiceBroker::GetSettingsComponent()->GetProfileManager()};
return ((profileManager->GetUserDataItem("PartyMode-Video.xsp") == path) &&
!CFileUtils::Exists(path));
}
} // unnamed namespace

bool IsItemPlayable(const CFileItem& item)
{
if (item.IsParentFolder())
Expand Down Expand Up @@ -574,6 +590,9 @@ bool IsItemPlayable(const CFileItem& item)
}
}

if (IsNonExistingUserPartyModePlaylist(item))
return false;

if (item.m_bIsFolder &&
(item.IsVideoDb() || StringUtils::StartsWithNoCase(item.GetPath(), "library://video/")))
{
Expand Down

0 comments on commit 05fddad

Please sign in to comment.