summaryrefslogtreecommitdiffstats
path: root/xbmc/ContextMenuItem.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/ContextMenuItem.h
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/ContextMenuItem.h')
-rw-r--r--xbmc/ContextMenuItem.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/xbmc/ContextMenuItem.h b/xbmc/ContextMenuItem.h
new file mode 100644
index 0000000..4e04a06
--- /dev/null
+++ b/xbmc/ContextMenuItem.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2015-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+class CFileItem;
+
+namespace ADDON
+{
+ class CContextMenuAddon;
+}
+
+namespace INFO
+{
+class InfoBool;
+}
+
+class IContextMenuItem
+{
+public:
+ virtual ~IContextMenuItem() = default;
+ virtual bool IsVisible(const CFileItem& item) const = 0;
+ virtual bool Execute(const std::shared_ptr<CFileItem>& item) const = 0;
+ virtual std::string GetLabel(const CFileItem& item) const = 0;
+ virtual bool IsGroup() const { return false; }
+};
+
+
+class CStaticContextMenuAction : public IContextMenuItem
+{
+public:
+ explicit CStaticContextMenuAction(uint32_t label) : m_label(label) {}
+ std::string GetLabel(const CFileItem& item) const final;
+ bool IsGroup() const final { return false; }
+private:
+ const uint32_t m_label;
+};
+
+
+class CContextMenuItem : public IContextMenuItem
+{
+public:
+ CContextMenuItem() = default;
+
+ std::string GetLabel(const CFileItem& item) const override { return m_label; }
+ bool IsVisible(const CFileItem& item) const override ;
+ bool IsParentOf(const CContextMenuItem& menuItem) const;
+ bool IsGroup() const override ;
+ bool Execute(const std::shared_ptr<CFileItem>& item) const override;
+ bool operator==(const CContextMenuItem& other) const;
+ std::string ToString() const;
+
+ static CContextMenuItem CreateGroup(
+ const std::string& label,
+ const std::string& parent,
+ const std::string& groupId,
+ const std::string& addonId);
+
+ static CContextMenuItem CreateItem(
+ const std::string& label,
+ const std::string& parent,
+ const std::string& library,
+ const std::string& condition,
+ const std::string& addonId,
+ const std::vector<std::string>& args = std::vector<std::string>());
+
+ friend class ADDON::CContextMenuAddon;
+
+private:
+ std::string m_label;
+ std::string m_parent;
+ std::string m_groupId;
+ std::string m_library;
+ std::string m_addonId; // The owner of this menu item
+ std::vector<std::string> m_args;
+
+ std::string m_visibilityCondition;
+ mutable std::shared_ptr<INFO::InfoBool> m_infoBool;
+ mutable bool m_infoBoolRegistered{false};
+};