2 * Copyright (C) 2015-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
21 class CContextMenuAddon
;
29 class IContextMenuItem
32 virtual ~IContextMenuItem() = default;
33 virtual bool IsVisible(const CFileItem
& item
) const = 0;
34 virtual bool Execute(const std::shared_ptr
<CFileItem
>& item
) const = 0;
35 virtual std::string
GetLabel(const CFileItem
& item
) const = 0;
36 virtual bool IsGroup() const { return false; }
37 virtual bool HasParent() const { return false; }
41 class CStaticContextMenuAction
: public IContextMenuItem
44 explicit CStaticContextMenuAction(uint32_t label
) : m_label(label
) {}
45 std::string
GetLabel(const CFileItem
& item
) const final
;
46 bool IsGroup() const final
{ return false; }
48 const uint32_t m_label
;
52 class CContextMenuItem
: public IContextMenuItem
55 CContextMenuItem() = default;
57 std::string
GetLabel(const CFileItem
& item
) const override
{ return m_label
; }
58 bool IsVisible(const CFileItem
& item
) const override
;
59 bool IsParentOf(const CContextMenuItem
& menuItem
) const;
60 bool IsGroup() const override
;
61 bool HasParent() const override
;
62 bool Execute(const std::shared_ptr
<CFileItem
>& item
) const override
;
63 bool operator==(const CContextMenuItem
& other
) const;
64 std::string
ToString() const;
66 static CContextMenuItem
CreateGroup(
67 const std::string
& label
,
68 const std::string
& parent
,
69 const std::string
& groupId
,
70 const std::string
& addonId
);
72 static CContextMenuItem
CreateItem(
73 const std::string
& label
,
74 const std::string
& parent
,
75 const std::string
& library
,
76 const std::string
& condition
,
77 const std::string
& addonId
,
78 const std::vector
<std::string
>& args
= std::vector
<std::string
>());
80 friend class ADDON::CContextMenuAddon
;
85 std::string m_groupId
;
86 std::string m_library
;
87 std::string m_addonId
; // The owner of this menu item
88 std::vector
<std::string
> m_args
;
90 std::string m_visibilityCondition
;
91 mutable std::shared_ptr
<INFO::InfoBool
> m_infoBool
;
92 mutable bool m_infoBoolRegistered
{false};