void NotificationWidget::setNotification(const Notification& notification)
{
    bool is_error = notification.error != ErrorState::ErrorLevel::NONE;
    bool was_error = notification_.error != ErrorState::ErrorLevel::NONE;

    notification_ = notification;
    {
        std::string msg = notification.getMessage();
        if (!msg.empty()) {
            notification_msg_ = msg;
        }
    }

    if (is_error) {
        QString s = getText();
        label_->setText(s);

        if (notification.error == ErrorState::ErrorLevel::ERROR) {
            icon_->setText("<img src=':error.png' />");
        } else {
            icon_->setText("<img src=':help.png' />");
        }

        setToolTip(s);

    } else if (!was_error) {
        icon_->setText("<img src=':error.png' />");
    }

    layout()->activate();
    adjustSize();

    timer_->stop();
    if (notification_.error == ErrorState::ErrorLevel::NONE) {
        timer_->start(1 * 1000);
    }
}
Beispiel #2
0
	void DataSender::send(const Notification & ntf) {
		client.DataCollector().SendNotification(ntf.getLevel(), ntf.getSource(), ntf.getMessage());
	}