Skip to content

Commit

Permalink
Add contextmenu option to remove resume points
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Aug 22, 2017
1 parent 0f9abae commit 9b89488
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -20625,7 +20625,13 @@ msgctxt "#38208"
msgid "If EXIF information exists (date, time, camera used, etc.), it will be displayed."
msgstr ""

#empty strings from id 38209 to 38999
#. Contextmenu entry to remove the resume point of the currently selected item
#: xbmc/video/ContextMenus.h
msgctxt "#38209"
msgid "Remove resume point"
msgstr ""

#empty strings from id 38210 to 38999

#: system/settings/settings.xml
msgctxt "#39000"
Expand Down
1 change: 1 addition & 0 deletions xbmc/ContextMenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ void CContextMenuManager::Init()
std::make_shared<CONTEXTMENU::CSongInfo>(),
std::make_shared<CONTEXTMENU::CMarkWatched>(),
std::make_shared<CONTEXTMENU::CMarkUnWatched>(),
std::make_shared<CONTEXTMENU::CRemoveResumePoint>(),
std::make_shared<CONTEXTMENU::CEjectDisk>(),
std::make_shared<CONTEXTMENU::CEjectDrive>(),
std::make_shared<CONTEXTMENU::CRemoveFavourite>(),
Expand Down
26 changes: 26 additions & 0 deletions xbmc/video/ContextMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ bool CVideoInfo::Execute(const CFileItemPtr& item) const
return true;
}

bool CRemoveResumePoint::IsVisible(const CFileItem& itemIn) const
{
CFileItem item(itemIn.GetItemToPlay());
if (item.IsDeleted()) // e.g. trashed pvr recording
return false;

return CGUIWindowVideoBase::HasResumeItemOffset(&item);
}

bool CRemoveResumePoint::Execute(const CFileItemPtr& item) const
{
// Remove the actual value
CVideoDatabase videoDatabase;
if (videoDatabase.Open())
{
videoDatabase.DeleteResumeBookMark(item->GetVideoInfoTag()->m_strFileNameAndPath);
}
// Remove the one we're showing in the frontend
auto videoInfoTag = item->GetVideoInfoTag();
CBookmark resumePoint(videoInfoTag->GetResumePoint());
resumePoint.timeInSeconds = 0;
videoInfoTag->SetResumePoint(resumePoint);

return true;
}

bool CMarkWatched::IsVisible(const CFileItem& item) const
{
if (item.IsDeleted()) // e.g. trashed pvr recording
Expand Down
7 changes: 7 additions & 0 deletions xbmc/video/ContextMenus.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ struct CMovieInfo : CVideoInfo
CMovieInfo() : CVideoInfo(MediaTypeMovie) {}
};

struct CRemoveResumePoint : CStaticContextMenuAction
{
CRemoveResumePoint() : CStaticContextMenuAction(38209) {}
bool IsVisible(const CFileItem& item) const override;
bool Execute(const CFileItemPtr& item) const override;
};

struct CMarkWatched : CStaticContextMenuAction
{
CMarkWatched() : CStaticContextMenuAction(16103) {}
Expand Down

0 comments on commit 9b89488

Please sign in to comment.