Add support for notification title. The notification buffer must contain the title and the message separated by a '\0' character.
If the buffer does not contain any \0, the whole buffer is considered to be the message of the notification. A default title will be displayed in the notification app.
This commit is contained in:
parent
58a2d000c4
commit
03de1c6739
7 changed files with 30 additions and 9 deletions
|
|
@ -87,3 +87,19 @@ size_t NotificationManager::NbNotifications() const {
|
|||
return std::count_if(notifications.begin(), notifications.end(), [](const Notification& n){ return n.valid;});
|
||||
}
|
||||
|
||||
const char* NotificationManager::Notification::Message() const {
|
||||
const char* itField = std::find(message.begin(), message.begin()+size-1, '\0');
|
||||
if(itField != message.begin()+size-1) {
|
||||
const char* ptr = (itField)+1;
|
||||
return ptr;
|
||||
}
|
||||
return const_cast<char*>(message.data());
|
||||
}
|
||||
|
||||
const char* NotificationManager::Notification::Title() const {
|
||||
const char * itField = std::find(message.begin(), message.begin()+size-1, '\0');
|
||||
if(itField != message.begin()+size-1) {
|
||||
return message.data();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue