libnick 2024.12.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
notifyiconmenu.h
Go to the documentation of this file.
1
23#ifdef _WIN32
24#ifndef NOTIFYICONMENU_H
25#define NOTIFYICONMENU_H
26
27#include <functional>
28#include <memory>
29#include <string>
30#include <vector>
31
33{
37 enum class NotifyIconMenuItemType
38 {
39 Action = 0,
40 Separator = 1
41 };
42
46 class NotifyIconMenuItem
47 {
48 public:
53 NotifyIconMenuItem(NotifyIconMenuItemType type);
57 virtual ~NotifyIconMenuItem() = default;
62 NotifyIconMenuItemType getType() const;
63
64 private:
65 NotifyIconMenuItemType m_type;
66 };
67
71 class NotifyIconSeparatorMenuItem : public NotifyIconMenuItem
72 {
73 public:
77 NotifyIconSeparatorMenuItem();
78 };
79
83 class NotifyIconActionMenuItem : public NotifyIconMenuItem
84 {
85 public:
91 NotifyIconActionMenuItem(const std::string& label, const std::function<void()>& action);
96 const std::string& getLabel() const;
100 void invoke() const;
104 void operator()() const;
105
106 private:
107 std::string m_label;
108 std::function<void()> m_action;
109 };
110
114 class NotifyIconMenu
115 {
116 public:
120 NotifyIconMenu() = default;
125 size_t size() const;
130 bool empty() const;
137 const std::shared_ptr<NotifyIconMenuItem>& get(size_t index) const;
142 size_t addSeparator();
148 bool insertSeparator(size_t index);
154 bool removeSeparator(size_t index);
161 size_t addAction(const std::string& label, const std::function<void()>& action);
169 bool insertAction(size_t index, const std::string& label, const std::function<void()>& action);
175 bool removeAction(size_t index);
182 const std::shared_ptr<NotifyIconMenuItem>& operator[](size_t index) const;
183
184 private:
185 std::vector<std::shared_ptr<NotifyIconMenuItem>> m_items;
186 };
187}
188
189#endif //NOTIFYICONMENU_H
190#endif
std::filesystem::path get(UserDirectory directory)
Gets the path of a user directory.
Definition notificationsenteventargs.h:31