Skip to content

Commit

Permalink
Merge pull request #23598 from ksooo/video-fix-default-select-action
Browse files Browse the repository at this point in the history
[Nexus][video] Fix default select action
  • Loading branch information
ksooo committed Aug 8, 2023
2 parents 6054ffa + 6d7ae0a commit 34d2cac
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
3 changes: 3 additions & 0 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -9777,6 +9777,7 @@ msgstr ""
#: xbmc/FileItem.cpp
#: xbmc/GUIInfoManager.cpp
#: xbmc/pvr/PVRManager.cpp
#: xbmc/video/windows/GUIWindowVideoBase.cpp
#: xbmc/utils/SystemInfo.cpp
msgctxt "#19055"
msgid "No information available"
Expand Down Expand Up @@ -12934,6 +12935,8 @@ msgctxt "#20175"
msgid "UPnP server"
msgstr ""

#. Label used for a video info message box
#: xbmc/video/windows/GUIWindowVideoBase.cpp
msgctxt "#20176"
msgid "Show video information"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/VideoInfoScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ namespace VIDEO
if (ProgressCancelled(pDlgProgress, 198, pItem->GetLabel()))
return INFO_CANCELLED;

if (m_database.HasMovieInfo(pItem->GetPath()))
if (m_database.HasMovieInfo(pItem->GetDynPath()))
return INFO_HAVE_ALREADY;

if (m_handle)
Expand Down
27 changes: 11 additions & 16 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message)
return CGUIMediaWindow::OnMessage(message);
}

void CGUIWindowVideoBase::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper)
bool CGUIWindowVideoBase::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper)
{
if (fileItem.IsParentFolder() || fileItem.m_bIsShareOrDrive || fileItem.IsPath("add") ||
(fileItem.IsPlayList() && !URIUtils::HasExtension(fileItem.GetDynPath(), ".strm")))
return;
(fileItem.IsPlayList() && !URIUtils::HasExtension(fileItem.GetDynPath(), ".strm")))
return false;

CFileItem item(fileItem);
bool fromDB = false;
Expand Down Expand Up @@ -265,7 +265,7 @@ void CGUIWindowVideoBase::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPt
if (!bFoundFile)
{
HELPERS::ShowOKDialogText(CVariant{13346}, CVariant{20349});
return;
return false;
}
}
}
Expand All @@ -282,6 +282,7 @@ void CGUIWindowVideoBase::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPt
Refresh();
m_viewControl.SetSelectedItem(itemNumber);
}
return true;
}

// ShowIMDB is called as follows:
Expand Down Expand Up @@ -533,9 +534,7 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, int action, const std::string&
case SELECT_ACTION_PLAY_OR_RESUME:
return OnResumeItem(iItem, player);
case SELECT_ACTION_INFO:
if (OnItemInfo(iItem))
return true;
break;
return OnItemInfo(iItem);
case SELECT_ACTION_MORE:
OnPopupMenu(iItem);
return true;
Expand Down Expand Up @@ -612,23 +611,19 @@ bool CGUIWindowVideoBase::OnItemInfo(int iItem)
scraper = m_database.GetScraperForPath(strDir, settings, foundDirectly);

if (!scraper &&
!(m_database.HasMovieInfo(item->GetPath()) ||
m_database.HasTvShowInfo(strDir) ||
m_database.HasEpisodeInfo(item->GetPath())))
!(m_database.HasMovieInfo(item->GetDynPath()) || m_database.HasTvShowInfo(strDir) ||
m_database.HasEpisodeInfo(item->GetDynPath())))
{
HELPERS::ShowOKDialogText(CVariant{20176}, // Show video information
CVariant{19055}); // no information available
return false;
}

if (scraper && scraper->Content() == CONTENT_TVSHOWS && foundDirectly && !settings.parent_name_root) // dont lookup on root tvshow folder
return true;
}

OnItemInfo(*item, scraper);

// Return whether or not we have information to display.
// Note: This will cause the default select action to start
// playback in case it's set to "Show information".
return item->HasVideoInfoTag();
return OnItemInfo(*item, scraper);
}

void CGUIWindowVideoBase::OnRestartItem(int iItem, const std::string &player)
Expand Down
11 changes: 9 additions & 2 deletions xbmc/video/windows/GUIWindowVideoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse

void PlayMovie(const CFileItem* item, const std::string& player = "");

virtual void OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper);

/*! \brief Gets called to process the "info" action for the given file item
Default implementation shows a dialog containing information for the movie/episode/...
represented by the file item.
\param fileItem the item for which information is to be presented.
\param scraper a scraper addon instance that can be used to obtain additional information for
the given item
\return true if information was presented, false otherwise.
*/
virtual bool OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper);

/*! \brief Show the resume menu for this item (if it has a resume bookmark)
If a resume bookmark is found, we set the item's m_lStartOffset to STARTOFFSET_RESUME.
Expand Down
4 changes: 2 additions & 2 deletions xbmc/video/windows/GUIWindowVideoNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void CGUIWindowVideoNav::PlayItem(int iItem)
CGUIWindowVideoBase::PlayItem(iItem);
}

void CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper)
bool CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper)
{
if (!scraper || scraper->Content() == CONTENT_NONE)
{
Expand All @@ -667,7 +667,7 @@ void CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr
}
m_database.Close();
}
CGUIWindowVideoBase::OnItemInfo(fileItem, scraper);
return CGUIWindowVideoBase::OnItemInfo(fileItem, scraper);
}

void CGUIWindowVideoNav::OnDeleteItem(const CFileItemPtr& pItem)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/windows/GUIWindowVideoNav.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CGUIWindowVideoNav : public CGUIWindowVideoBase
bool OnAction(const CAction &action) override;
bool OnMessage(CGUIMessage& message) override;

void OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr &info) override;
bool OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& info) override;

protected:
bool ApplyWatchedFilter(CFileItemList &items);
Expand Down

0 comments on commit 34d2cac

Please sign in to comment.