libnick 2025.1.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Notifications::NotifyIconMenu Class Reference

A menu for a NotifyIcon. More...

#include <notifyiconmenu.h>

Public Member Functions

 NotifyIconMenu ()=default
 Constructs a NotifyIconMenu.
 
size_t size () const
 Gets the number of items in the menu.
 
bool empty () const
 Gets whether or not the menu is empty.
 
const std::shared_ptr< NotifyIconMenuItem > & get (size_t index) const
 Gets the NotifyIconMenuItem at a given index in the menu.
 
size_t addSeparator ()
 Adds a separator to the bottom of the menu.
 
bool insertSeparator (size_t index)
 Inserts a separator at a given index in the menu.
 
bool removeSeparator (size_t index)
 Removes a separator at a given index in the menu.
 
size_t addAction (const std::string &label, const std::function< void()> &action)
 Adds an action item to the bottom of the menu.
 
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.
 
bool removeAction (size_t index)
 Removes an action item at a given index in the menu.
 
const std::shared_ptr< NotifyIconMenuItem > & operator[] (size_t index) const
 Gets the NotifyIconMenuItem at a given index in the menu.
 

Detailed Description

A menu for a NotifyIcon.

Constructor & Destructor Documentation

◆ NotifyIconMenu()

Nickvision::Notifications::NotifyIconMenu::NotifyIconMenu ( )
default

Constructs a NotifyIconMenu.

Member Function Documentation

◆ addAction()

size_t Nickvision::Notifications::NotifyIconMenu::addAction ( const std::string & label,
const std::function< void()> & action )

Adds an action item to the bottom of the menu.

Parameters
labelThe label of the action
actionThe callback function of the action
Returns
The index at which the action item was added

◆ addSeparator()

size_t Nickvision::Notifications::NotifyIconMenu::addSeparator ( )

Adds a separator to the bottom of the menu.

Returns
The index at which the separator was added

◆ empty()

bool Nickvision::Notifications::NotifyIconMenu::empty ( ) const

Gets whether or not the menu is empty.

Returns
True if the menu is empty, else false

◆ get()

const std::shared_ptr< NotifyIconMenuItem > & Nickvision::Notifications::NotifyIconMenu::get ( size_t index) const

Gets the NotifyIconMenuItem at a given index in the menu.

Parameters
indexThe index of the item to get
Returns
The NotifyIconMenuItem at the given index
nullptr if the index is invalid

◆ insertAction()

bool Nickvision::Notifications::NotifyIconMenu::insertAction ( size_t index,
const std::string & label,
const std::function< void()> & action )

Inserts an action item at a given index in the menu.

Parameters
indexThe index at which to insert the action item
labelThe label of the action
actionThe callback function of the action
Returns
True if the action item was successfully inserted, else false

◆ insertSeparator()

bool Nickvision::Notifications::NotifyIconMenu::insertSeparator ( size_t index)

Inserts a separator at a given index in the menu.

Parameters
indexThe index at which to insert the separator
Returns
True if the separator was successfully inserted, else false

◆ operator[]()

const std::shared_ptr< NotifyIconMenuItem > & Nickvision::Notifications::NotifyIconMenu::operator[] ( size_t index) const

Gets the NotifyIconMenuItem at a given index in the menu.

Parameters
indexThe index of the item to get
Returns
The NotifyIconMenuItem at the given index
nullptr if the index is invalid

◆ removeAction()

bool Nickvision::Notifications::NotifyIconMenu::removeAction ( size_t index)

Removes an action item at a given index in the menu.

Parameters
indexThe index at which to remove the action item
Returns
True if the action item was successfully removed, else false

◆ removeSeparator()

bool Nickvision::Notifications::NotifyIconMenu::removeSeparator ( size_t index)

Removes a separator at a given index in the menu.

Parameters
indexThe index at which to remove the separator
Returns
True if the separator was successfully removed, else false

◆ size()

size_t Nickvision::Notifications::NotifyIconMenu::size ( ) const

Gets the number of items in the menu.

Returns
The number of items in the menu

The documentation for this class was generated from the following file: