diff --git a/src/librssguard/gui/notifications/basetoastnotification.cpp b/src/librssguard/gui/notifications/basetoastnotification.cpp index c0dc3075b..e01f13f68 100644 --- a/src/librssguard/gui/notifications/basetoastnotification.cpp +++ b/src/librssguard/gui/notifications/basetoastnotification.cpp @@ -7,6 +7,10 @@ #include #include +#include + +using namespace std::chrono_literals; + BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent) { setAttribute(Qt::WidgetAttribute::WA_ShowWithoutActivating); setFixedWidth(NOTIFICATIONS_WIDTH); @@ -23,7 +27,6 @@ BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent) Qt::WindowType::FramelessWindowHint | Qt::WindowType::WindowStaysOnTopHint | Qt::WindowType::WindowSystemMenuHint); setStyleSheet(QSL("BaseToastNotification { border: 1px solid black; }")); - installEventFilter(this); } @@ -36,7 +39,7 @@ void BaseToastNotification::setupCloseButton(QAbstractButton* btn) { } void BaseToastNotification::setupTimedClosing() { - QTimer::singleShot(15000, this, &BaseToastNotification::close); + QTimer::singleShot(15s, this, &BaseToastNotification::close); } bool BaseToastNotification::eventFilter(QObject* watched, QEvent* event) { diff --git a/src/librssguard/gui/notifications/toastnotification.cpp b/src/librssguard/gui/notifications/toastnotification.cpp index 5312e409f..e6317ec4b 100644 --- a/src/librssguard/gui/notifications/toastnotification.cpp +++ b/src/librssguard/gui/notifications/toastnotification.cpp @@ -15,8 +15,16 @@ ToastNotification::ToastNotification(Notification::Event event, : BaseToastNotification(parent) { m_ui.setupUi(this); + auto fon = m_ui.m_lblTitle->font(); + + fon.setBold(true); + // fon.s + + m_ui.m_lblTitle->setFont(fon); + setupCloseButton(m_ui.m_btnClose); setupTimedClosing(); + loadNotification(event, msg, action); } @@ -27,4 +35,25 @@ bool ToastNotification::alwaysOnTop() const { void ToastNotification::loadNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action) { m_ui.m_lblTitle->setText(msg.m_title); m_ui.m_lblBody->setText(msg.m_message); + + m_ui.m_lblIcon->setPixmap(iconForType(msg.m_type) + .pixmap({ + 32, + 32, + })); +} + +QIcon ToastNotification::iconForType(QSystemTrayIcon::MessageIcon icon) const { + switch (icon) { + case QSystemTrayIcon::Warning: + return qApp->icons()->fromTheme(QSL("dialog-warning")); + + case QSystemTrayIcon::Critical: + return qApp->icons()->fromTheme(QSL("dialog-error")); + + case QSystemTrayIcon::Information: + case QSystemTrayIcon::NoIcon: + default: + return qApp->icons()->fromTheme(QSL("dialog-information")); + } } diff --git a/src/librssguard/gui/notifications/toastnotification.h b/src/librssguard/gui/notifications/toastnotification.h index 3e2e1d2c5..5a127e045 100644 --- a/src/librssguard/gui/notifications/toastnotification.h +++ b/src/librssguard/gui/notifications/toastnotification.h @@ -22,6 +22,7 @@ class ToastNotification : public BaseToastNotification { private: void loadNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action); + QIcon iconForType(QSystemTrayIcon::MessageIcon icon) const; private: Ui::ToastNotification m_ui; diff --git a/src/librssguard/gui/notifications/toastnotification.ui b/src/librssguard/gui/notifications/toastnotification.ui index ea69e8e28..0455c3e22 100644 --- a/src/librssguard/gui/notifications/toastnotification.ui +++ b/src/librssguard/gui/notifications/toastnotification.ui @@ -36,7 +36,7 @@ - + 0