libnick
2025.1.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
include
notifications
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
32
namespace
Nickvision::Notifications
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
Nickvision::Notifications::NotifyIconActionMenuItem
An actionable menu item for a NotifyIcon.
Definition
notifyiconmenu.h:84
Nickvision::Notifications::NotifyIconActionMenuItem::operator()
void operator()() const
Calls the callback function of the menu item.
Nickvision::Notifications::NotifyIconActionMenuItem::NotifyIconActionMenuItem
NotifyIconActionMenuItem(const std::string &label, const std::function< void()> &action)
Constructs a NotifyIconActionMenuItem.
Nickvision::Notifications::NotifyIconActionMenuItem::getLabel
const std::string & getLabel() const
Gets the label for the menu item.
Nickvision::Notifications::NotifyIconActionMenuItem::invoke
void invoke() const
Calls the callback function of the menu item.
Nickvision::Notifications::NotifyIconMenuItem
A generic menu item for a NotifyIcon.
Definition
notifyiconmenu.h:47
Nickvision::Notifications::NotifyIconMenuItem::getType
NotifyIconMenuItemType getType() const
Gets the type of the menu item.
Nickvision::Notifications::NotifyIconMenuItem::~NotifyIconMenuItem
virtual ~NotifyIconMenuItem()=default
Destructs a NotifyIconMenuItem.
Nickvision::Notifications::NotifyIconMenuItem::NotifyIconMenuItem
NotifyIconMenuItem(NotifyIconMenuItemType type)
Constructs a NotifyIconMenuItem.
Nickvision::Notifications::NotifyIconMenu
A menu for a NotifyIcon.
Definition
notifyiconmenu.h:115
Nickvision::Notifications::NotifyIconMenu::removeAction
bool removeAction(size_t index)
Removes an action item at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::empty
bool empty() const
Gets whether or not the menu is empty.
Nickvision::Notifications::NotifyIconMenu::removeSeparator
bool removeSeparator(size_t index)
Removes a separator at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::operator[]
const std::shared_ptr< NotifyIconMenuItem > & operator[](size_t index) const
Gets the NotifyIconMenuItem at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::insertSeparator
bool insertSeparator(size_t index)
Inserts a separator at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::addSeparator
size_t addSeparator()
Adds a separator to the bottom of the menu.
Nickvision::Notifications::NotifyIconMenu::get
const std::shared_ptr< NotifyIconMenuItem > & get(size_t index) const
Gets the NotifyIconMenuItem at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::size
size_t size() const
Gets the number of items in the menu.
Nickvision::Notifications::NotifyIconMenu::addAction
size_t addAction(const std::string &label, const std::function< void()> &action)
Adds an action item to the bottom of the menu.
Nickvision::Notifications::NotifyIconMenu::insertAction
bool insertAction(size_t index, const std::string &label, const std::function< void()> &action)
Inserts an action item at a given index in the menu.
Nickvision::Notifications::NotifyIconMenu::NotifyIconMenu
NotifyIconMenu()=default
Constructs a NotifyIconMenu.
Nickvision::Notifications::NotifyIconSeparatorMenuItem
A separator menu item for a NotifyIcon.
Definition
notifyiconmenu.h:72
Nickvision::Notifications::NotifyIconSeparatorMenuItem::NotifyIconSeparatorMenuItem
NotifyIconSeparatorMenuItem()
Constructs a NotifyIconSeparatorMenuItem.
Nickvision::Notifications
Definition
notificationsenteventargs.h:31
Nickvision::Notifications::NotifyIconMenuItemType
NotifyIconMenuItemType
Types of menu items for a NotifyIcon.
Definition
notifyiconmenu.h:38
Nickvision::Notifications::NotifyIconMenuItemType::Action
@ Action
A menu item that can be clicked.
Nickvision::Notifications::NotifyIconMenuItemType::Separator
@ Separator
A separator menu item.
Generated by
1.12.0