Skip to content

Commit

Permalink
Merge pull request xbmc#17926 from ksooo/pvr-categories-ctx-menu
Browse files Browse the repository at this point in the history
[PVR] Home screen widgets context menu fixes/improvements
  • Loading branch information
ksooo authored and Maven85 committed Aug 4, 2020
1 parent b63e4b2 commit 16324ea
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 36 deletions.
14 changes: 13 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -11113,7 +11113,19 @@ msgctxt "#19326"
msgid "Navigate..."
msgstr ""

#empty strings from id 19327 to 19498
#. Label for a context menu entry to delete alle watched recordings contained in a folder
#: xbmc/pvr/PVRContextMenus.cpp
msgctxt "#19327"
msgid "Delete watched"
msgstr ""

#. delete multiple recordings confirmation message box text
#: xbmc/pvr/PVRGUIActions.cpp
msgctxt "#19328"
msgid "Delete all watched recordings in this folder?"
msgstr ""

#empty strings from id 19329 to 19498

#. label for epg genre value
#: xbmc/pvr/epg/Epg.cpp
Expand Down
23 changes: 13 additions & 10 deletions xbmc/ContextMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ std::string CAddRemoveFavourite::GetLabel(const CFileItem& item) const

bool CAddRemoveFavourite::IsVisible(const CFileItem& item) const
{
return !item.IsParentFolder() &&
!item.IsPath("add") &&
!item.IsPath("newplaylist://") &&
!URIUtils::IsProtocol(item.GetPath(), "favourites") &&
!URIUtils::IsProtocol(item.GetPath(), "newsmartplaylist") &&
!URIUtils::IsProtocol(item.GetPath(), "newtag") &&
!URIUtils::IsProtocol(item.GetPath(), "musicsearch") &&
!StringUtils::StartsWith(item.GetPath(), "pvr://guide/") &&
!StringUtils::StartsWith(item.GetPath(), "pvr://timers/") &&
!item.GetPath().empty();
return (!item.GetPath().empty() && !item.IsParentFolder() && !item.IsPath("add") &&
!item.IsPath("newplaylist://") && !URIUtils::IsProtocol(item.GetPath(), "favourites") &&
!URIUtils::IsProtocol(item.GetPath(), "newsmartplaylist") &&
!URIUtils::IsProtocol(item.GetPath(), "newtag") &&
!URIUtils::IsProtocol(item.GetPath(), "musicsearch") &&
// hide this item for all PVR timers/EPG except timer/timer rules/EPG root folders
!StringUtils::StartsWith(item.GetPath(), "pvr://guide/") &&
!StringUtils::StartsWith(item.GetPath(), "pvr://timers/")) ||
item.GetPath() == "pvr://guide/tv/" || item.GetPath() == "pvr://guide/radio/" ||
item.GetPath() == "pvr://timers/tv/timers/" ||
item.GetPath() == "pvr://timers/radio/timers/" ||
item.GetPath() == "pvr://timers/tv/rules/" ||
item.GetPath() == "pvr://timers/radio/rules/";
}

bool CAddRemoveFavourite::Execute(const CFileItemPtr& item) const
Expand Down
62 changes: 40 additions & 22 deletions xbmc/pvr/PVRContextMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace PVR
DECL_STATICCONTEXTMENUITEM(RenameRecording);
DECL_CONTEXTMENUITEM(DeleteRecording);
DECL_STATICCONTEXTMENUITEM(UndeleteRecording);
DECL_STATICCONTEXTMENUITEM(DeleteWatchedRecordings);
DECL_CONTEXTMENUITEM(ToggleTimerState);
DECL_STATICCONTEXTMENUITEM(RenameTimer);
DECL_STATICCONTEXTMENUITEM(AddReminder);
Expand Down Expand Up @@ -375,7 +376,7 @@ namespace PVR
if (item.m_bIsFolder)
{
const CPVRRecordingsPath path(item.GetPath());
return path.IsValid();
return path.IsValid() && !path.IsRecordingsRoot();
}

return false;
Expand Down Expand Up @@ -403,6 +404,23 @@ namespace PVR
return CServiceBroker::GetPVRManager().GUIActions()->UndeleteRecording(item);
}

///////////////////////////////////////////////////////////////////////////////
// Delete watched recordings

bool DeleteWatchedRecordings::IsVisible(const CFileItem& item) const
{
// recordings folder?
if (item.m_bIsFolder)
return CPVRRecordingsPath(item.GetPath()).IsValid();

return false;
}

bool DeleteWatchedRecordings::Execute(const std::shared_ptr<CFileItem>& item) const
{
return CServiceBroker::GetPVRManager().GUIActions()->DeleteWatchedRecordings(item);
}

///////////////////////////////////////////////////////////////////////////////
// Add reminder

Expand Down Expand Up @@ -678,27 +696,27 @@ namespace PVR

CPVRContextMenuManager::CPVRContextMenuManager()
{
m_items =
{
std::make_shared<CONTEXTMENUITEM::PlayEpgTag>(19190), /* Play programme */
std::make_shared<CONTEXTMENUITEM::PlayRecording>(19687), /* Play recording */
std::make_shared<CONTEXTMENUITEM::ShowInformation>(),
std::make_shared<CONTEXTMENUITEM::ShowChannelGuide>(19686), /* Channel guide */
std::make_shared<CONTEXTMENUITEM::FindSimilar>(19003), /* Find similar */
std::make_shared<CONTEXTMENUITEM::ToggleTimerState>(),
std::make_shared<CONTEXTMENUITEM::AddTimerRule>(19061), /* Add timer */
std::make_shared<CONTEXTMENUITEM::EditTimerRule>(),
std::make_shared<CONTEXTMENUITEM::DeleteTimerRule>(19295), /* Delete timer rule */
std::make_shared<CONTEXTMENUITEM::EditTimer>(),
std::make_shared<CONTEXTMENUITEM::RenameTimer>(118), /* Rename */
std::make_shared<CONTEXTMENUITEM::DeleteTimer>(),
std::make_shared<CONTEXTMENUITEM::StartRecording>(264), /* Record */
std::make_shared<CONTEXTMENUITEM::StopRecording>(19059), /* Stop recording */
std::make_shared<CONTEXTMENUITEM::EditRecording>(21450), /* Edit */
std::make_shared<CONTEXTMENUITEM::RenameRecording>(118), /* Rename */
std::make_shared<CONTEXTMENUITEM::DeleteRecording>(),
std::make_shared<CONTEXTMENUITEM::UndeleteRecording>(19290), /* Undelete */
std::make_shared<CONTEXTMENUITEM::AddReminder>(826), /* Set reminder */
m_items = {
std::make_shared<CONTEXTMENUITEM::PlayEpgTag>(19190), /* Play programme */
std::make_shared<CONTEXTMENUITEM::PlayRecording>(19687), /* Play recording */
std::make_shared<CONTEXTMENUITEM::ShowInformation>(),
std::make_shared<CONTEXTMENUITEM::ShowChannelGuide>(19686), /* Channel guide */
std::make_shared<CONTEXTMENUITEM::FindSimilar>(19003), /* Find similar */
std::make_shared<CONTEXTMENUITEM::ToggleTimerState>(),
std::make_shared<CONTEXTMENUITEM::AddTimerRule>(19061), /* Add timer */
std::make_shared<CONTEXTMENUITEM::EditTimerRule>(),
std::make_shared<CONTEXTMENUITEM::DeleteTimerRule>(19295), /* Delete timer rule */
std::make_shared<CONTEXTMENUITEM::EditTimer>(),
std::make_shared<CONTEXTMENUITEM::RenameTimer>(118), /* Rename */
std::make_shared<CONTEXTMENUITEM::DeleteTimer>(),
std::make_shared<CONTEXTMENUITEM::StartRecording>(264), /* Record */
std::make_shared<CONTEXTMENUITEM::StopRecording>(19059), /* Stop recording */
std::make_shared<CONTEXTMENUITEM::EditRecording>(21450), /* Edit */
std::make_shared<CONTEXTMENUITEM::RenameRecording>(118), /* Rename */
std::make_shared<CONTEXTMENUITEM::DeleteRecording>(),
std::make_shared<CONTEXTMENUITEM::UndeleteRecording>(19290), /* Undelete */
std::make_shared<CONTEXTMENUITEM::DeleteWatchedRecordings>(19327), /* Delete watched */
std::make_shared<CONTEXTMENUITEM::AddReminder>(826), /* Set reminder */
};
}

Expand Down
2 changes: 2 additions & 0 deletions xbmc/pvr/epg/EpgDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ std::shared_ptr<CPVREpgInfoTag> CPVREpgDatabase::CreateEpgTag(

newTag->SetGenre(m_pDS->fv("iGenreType").get_asInt(), m_pDS->fv("iGenreSubType").get_asInt(),
m_pDS->fv("sGenre").get_asString().c_str());
newTag->UpdatePath();

return newTag;
}
return {};
Expand Down
37 changes: 34 additions & 3 deletions xbmc/pvr/guilib/PVRGUIActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ namespace PVR

class AsyncDeleteRecording : public AsyncRecordingAction
{
public:
explicit AsyncDeleteRecording(bool bWatchedOnly = false) : m_bWatchedOnly(bWatchedOnly) {}

private:
bool DoRun(const std::shared_ptr<CFileItem>& item) override
{
Expand All @@ -153,13 +156,13 @@ namespace PVR
bool bReturn = true;
for (const auto& itemToDelete : items)
{
if (itemToDelete->IsUsablePVRRecording())
if (itemToDelete->IsUsablePVRRecording() &&
(!m_bWatchedOnly || itemToDelete->GetPVRRecordingInfoTag()->GetPlayCount() > 0))
bReturn &= itemToDelete->GetPVRRecordingInfoTag()->Delete();
else
CLog::LogF(LOGERROR, "Cannot delete item '%s': no valid recording tag", itemToDelete->GetPath().c_str());
}
return bReturn;
}
bool m_bWatchedOnly = false;
};

class AsyncEmptyRecordingsTrash : public AsyncRecordingAction
Expand Down Expand Up @@ -1117,6 +1120,34 @@ namespace PVR
CVariant{item->GetLabel()});
}

bool CPVRGUIActions::DeleteWatchedRecordings(const std::shared_ptr<CFileItem>& item) const
{
if (!item->m_bIsFolder || item->IsParentFolder())
return false;

if (!ConfirmDeleteWatchedRecordings(item))
return false;

if (!AsyncDeleteRecording(true).Execute(item))
{
HELPERS::ShowOKDialogText(
CVariant{257},
CVariant{
19111}); // "Error", "PVR backend error. Check the log for more information about this message."
return false;
}

return true;
}

bool CPVRGUIActions::ConfirmDeleteWatchedRecordings(const std::shared_ptr<CFileItem>& item) const
{
return CGUIDialogYesNo::ShowAndGetInput(
CVariant{122}, // "Confirm delete"
CVariant{19328}, // "Delete all watched recordings in this folder?"
CVariant{""}, CVariant{item->GetLabel()});
}

bool CPVRGUIActions::DeleteAllRecordingsFromTrash() const
{
if (!ConfirmDeleteAllRecordingsFromTrash())
Expand Down
14 changes: 14 additions & 0 deletions xbmc/pvr/guilib/PVRGUIActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ namespace PVR
*/
bool DeleteRecording(const std::shared_ptr<CFileItem>& item) const;

/*!
* @brief Delete all watched recordings contained in the given folder, always showing a confirmation dialog.
* @param item containing a recording folder containing the items to delete.
* @return true, if the recordings were deleted successfully, false otherwise.
*/
bool DeleteWatchedRecordings(const std::shared_ptr<CFileItem>& item) const;

/*!
* @brief Delete all recordings from trash, always showing a confirmation dialog.
* @return true, if the recordings were permanently deleted successfully, false otherwise.
Expand Down Expand Up @@ -486,6 +493,13 @@ namespace PVR
*/
bool ConfirmDeleteRecording(const std::shared_ptr<CFileItem>& item) const;

/*!
* @brief Open a dialog to confirm delete all watched recordings contained in the given folder.
* @param item containing a recording folder containing the items to delete.
* @return true, to proceed with delete, false otherwise.
*/
bool ConfirmDeleteWatchedRecordings(const std::shared_ptr<CFileItem>& item) const;

/*!
* @brief Open a dialog to confirm to permanently remove all deleted recordings.
* @return true, to proceed with delete, false otherwise.
Expand Down

0 comments on commit 16324ea

Please sign in to comment.