Skip to content

Commit

Permalink
[listprovider] add info dialog support
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Mar 31, 2016
1 parent f9186f1 commit 01260b6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
11 changes: 10 additions & 1 deletion xbmc/guilib/GUIBaseContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,16 @@ bool CGUIBaseContainer::OnAction(const CAction &action)
}
break;
case ACTION_SHOW_INFO:
if (OnInfo())
if (m_listProvider)
{
int selected = GetSelectedItem();
if (selected >= 0 && selected < m_items.size())
{
m_listProvider->OnInfo(m_items[selected]);
return true;
}
}
else if (OnInfo())
return true;
else if (action.GetID())
return OnClick(action.GetID());
Expand Down
24 changes: 24 additions & 0 deletions xbmc/listproviders/DirectoryProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
#include <memory>
#include <utility>

#include "addons/GUIDialogAddonInfo.h"
#include "FileItem.h"
#include "filesystem/Directory.h"
#include "filesystem/FavouritesDirectory.h"
#include "guilib/GUIWindowManager.h"
#include "interfaces/AnnouncementManager.h"
#include "messaging/ApplicationMessenger.h"
#include "music/dialogs/GUIDialogMusicInfo.h"
#include "music/MusicThumbLoader.h"
#include "pictures/PictureThumbLoader.h"
#include "settings/Settings.h"
Expand All @@ -39,6 +41,9 @@
#include "utils/Variant.h"
#include "utils/XMLUtils.h"
#include "video/VideoThumbLoader.h"
#include "video/dialogs/GUIDialogVideoInfo.h"



using namespace XFILE;
using namespace ANNOUNCEMENT;
Expand Down Expand Up @@ -306,6 +311,25 @@ bool CDirectoryProvider::OnClick(const CGUIListItemPtr &item)
return false;
}

bool CDirectoryProvider::OnInfo(const CGUIListItemPtr& item)
{
auto fileItem = std::static_pointer_cast<CFileItem>(item);

if (fileItem->HasAddonInfo())
return CGUIDialogAddonInfo::ShowForItem(fileItem);
else if (fileItem->HasVideoInfoTag())
{
CGUIDialogVideoInfo::ShowFor(*fileItem.get());
return true;
}
else if (fileItem->HasMusicInfoTag())
{
CGUIDialogMusicInfo::ShowFor(*fileItem.get());
return true;
}
return false;
}

bool CDirectoryProvider::IsUpdating() const
{
CSingleLock lock(m_section);
Expand Down
1 change: 1 addition & 0 deletions xbmc/listproviders/DirectoryProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CDirectoryProvider :
virtual void Fetch(std::vector<CGUIListItemPtr> &items) const;
virtual void Reset(bool immediately = false);
virtual bool OnClick(const CGUIListItemPtr &item);
bool OnInfo(const CGUIListItemPtr &item) override;
virtual bool IsUpdating() const;

// callback from directory job
Expand Down
6 changes: 6 additions & 0 deletions xbmc/listproviders/IListProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class IListProvider
*/
virtual bool OnClick(const CGUIListItemPtr &item)=0;

/*! \brief Open the info dialog for an item provided by this IListProvider.
\param item the item that was clicked.
\return true if the dialog was shown, false otherwise.
*/
virtual bool OnInfo(const CGUIListItemPtr &item)=0;

/*! \brief Set the default item to focus. For backwards compatibility.
\param item the item to focus.
\param always whether this item should always be used on first focus.
Expand Down
1 change: 1 addition & 0 deletions xbmc/listproviders/StaticProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CStaticListProvider : public IListProvider
virtual bool Update(bool forceRefresh);
virtual void Fetch(std::vector<CGUIListItemPtr> &items) const;
virtual bool OnClick(const CGUIListItemPtr &item);
bool OnInfo(const CGUIListItemPtr &item) override { return false; }
virtual void SetDefaultItem(int item, bool always);
virtual int GetDefaultItem() const;
virtual bool AlwaysFocusDefaultItem() const;
Expand Down

0 comments on commit 01260b6

Please sign in to comment.