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 Sep 2, 2017
1 parent 0f9abae commit cec6cc8
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
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"

This comment has been minimized.

Copy link
@ksooo

ksooo Sep 4, 2017

Member

I would call this "Reset play position".

This comment has been minimized.

Copy link
@razzeee

razzeee Sep 4, 2017

Author Member

What about "Reset resume position"? I think the "resume" vocalbulary is used on multiple other occations already.

This comment has been minimized.

Copy link
@ksooo

ksooo Sep 4, 2017

Member

Yeah, this is better.

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
20 changes: 20 additions & 0 deletions xbmc/video/ContextMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ 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);

This comment has been minimized.

Copy link
@ksooo

ksooo Sep 4, 2017

Member

As PVR recordings also can have resume points I'm not sure this will work for PVR recordings as well. Will check and report back.

}

bool CRemoveResumePoint::Execute(const CFileItemPtr& item) const
{
CVideoDatabase videoDatabase;
if (videoDatabase.Open())
{
videoDatabase.DeleteResumeBookMark(*item);

This comment has been minimized.

Copy link
@ksooo

ksooo Sep 4, 2017

Member

This will definitely not work for PVR recordings as their resume points can be stored on the pvr backend.

}

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
32 changes: 29 additions & 3 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3066,23 +3066,49 @@ bool CVideoDatabase::GetResumeBookMark(const std::string& strFilenameAndPath, CB
return false;
}

void CVideoDatabase::DeleteResumeBookMark(const std::string &strFilenameAndPath)
void CVideoDatabase::DeleteResumeBookMark(const CFileItem& item)
{
if (!m_pDB.get() || !m_pDS.get())
return;

int fileID = GetFileId(strFilenameAndPath);
int fileID = item.GetVideoInfoTag()->m_iFileId;
if (fileID < -1)
return;

try
{
std::string sql = PrepareSQL("delete from bookmark where idFile=%i and type=%i", fileID, CBookmark::RESUME);
m_pDS->exec(sql);

VIDEODB_CONTENT_TYPE iType = static_cast<VIDEODB_CONTENT_TYPE>(item.GetVideoContentType());
std::string content;
switch (iType)
{
case VIDEODB_CONTENT_MOVIES:
content = MediaTypeMovie;
break;
case VIDEODB_CONTENT_EPISODES:
content = MediaTypeEpisode;
break;
case VIDEODB_CONTENT_TVSHOWS:
content = MediaTypeTvShow;
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
content = MediaTypeMusicVideo;
break;
default:
break;
}

if (!content.empty())
{
AnnounceUpdate(content, item.GetVideoInfoTag()->m_iDbId);
}

}
catch(...)
{
CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, strFilenameAndPath.c_str());
CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, item.GetVideoInfoTag()->m_strFileNameAndPath.c_str());
}
}

Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class CVideoDatabase : public CDatabase
void GetBookMarksForFile(const std::string& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type = CBookmark::STANDARD, bool bAppend=false, long partNumber=0);
void AddBookMarkToFile(const std::string& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type = CBookmark::STANDARD);
bool GetResumeBookMark(const std::string& strFilenameAndPath, CBookmark &bookmark);
void DeleteResumeBookMark(const std::string &strFilenameAndPath);
void DeleteResumeBookMark(const CFileItem& item);
void ClearBookMarkOfFile(const std::string& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type = CBookmark::STANDARD);
void ClearBookMarksOfFile(const std::string& strFilenameAndPath, CBookmark::EType type = CBookmark::STANDARD);
void ClearBookMarksOfFile(int idFile, CBookmark::EType type = CBookmark::STANDARD);
Expand Down

0 comments on commit cec6cc8

Please sign in to comment.