1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/************************************************************************
*
* Copyright (C) 2021-2025 IRCAD France
* Copyright (C) 2021 IHU Strasbourg
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#include "ui/__/dialog/notification_base.hpp"
namespace sight::ui::dialog
{
static const std::string DEFAULT_MESSAGE = "Empty message";
const notification_base::factory_registry_key_t notification_base::REGISTRY_KEY =
"::ui::dialog::notification";
//-----------------------------------------------------------------------------
notification_base::notification_base() :
m_notification({.m_message = DEFAULT_MESSAGE})
{
}
//-----------------------------------------------------------------------------
void notification_base::set_message(std::string _msg)
{
if(_msg.empty())
{
SIGHT_ERROR("Cannot set an empty message to notification, using 'Empty Message'");
m_notification.m_message = DEFAULT_MESSAGE;
}
else
{
m_notification.m_message = std::move(_msg);
}
}
//-----------------------------------------------------------------------------
void notification_base::set_position(notification_base::position _position)
{
m_notification.m_position = _position;
}
//-----------------------------------------------------------------------------
void notification_base::set_type(notification_base::type _type)
{
m_notification.m_type = _type;
}
//-----------------------------------------------------------------------------
void notification_base::set_size(std::array<int, 2> _size)
{
m_notification.m_size = _size;
}
//------------------------------------------------------------------------------
std::array<int, 2> notification_base::size() const
{
return m_notification.m_size;
}
//-----------------------------------------------------------------------------
void notification_base::set_index(unsigned int _index)
{
m_index = _index;
}
//-----------------------------------------------------------------------------
void notification_base::set_duration(std::optional<std::chrono::milliseconds> _duration_in_ms)
{
m_notification.m_duration = _duration_in_ms;
}
//------------------------------------------------------------------------------
void notification_base::set_channel(std::string _channel)
{
m_notification.m_channel = std::move(_channel);
}
//------------------------------------------------------------------------------
std::string notification_base::get_channel() const
{
return m_notification.m_channel;
}
//------------------------------------------------------------------------------
void notification_base::set_closable(std::optional<bool> _closable)
{
m_notification.m_closable = _closable;
}
//------------------------------------------------------------------------------
std::optional<bool> notification_base::is_closable() const
{
return m_notification.m_closable;
}
//------------------------------------------------------------------------------
std::optional<std::chrono::milliseconds> notification_base::get_duration() const
{
return m_notification.m_duration;
}
//------------------------------------------------------------------------------
void notification_base::set_notification(service::notification _notification)
{
m_notification = std::move(_notification);
}
//-----------------------------------------------------------------------------
} // namespace sight::ui::dialog
|