19#include "ui_desktopnotification.h"
27 , m_settingPosition(setPosition)
29 , m_timer(new QTimer(this))
32 setAttribute(Qt::WA_DeleteOnClose);
33 setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
35 m_timer->setSingleShot(
true);
36 connect(m_timer, &QTimer::timeout,
this, &QWidget::close);
38 if (m_settingPosition) {
39 setCursor(Qt::OpenHandCursor);
45 ui->icon->setPixmap(m_icon);
46 ui->icon->setVisible(!m_icon.isNull());
47 ui->heading->setText(m_heading);
48 ui->text->setText(m_text);
50 if (!m_settingPosition) {
51 m_timer->setInterval(m_timeout);
58void DesktopNotification::mousePressEvent(QMouseEvent* e)
60 if (!m_settingPosition) {
65 if (e->buttons() == Qt::LeftButton) {
66 m_dragPosition = e->globalPosition().toPoint() - frameGeometry().topLeft();
71void DesktopNotification::mouseMoveEvent(QMouseEvent* e)
73 if (e->buttons() & Qt::LeftButton) {
74 move(e->globalPosition().toPoint() - m_dragPosition);
DesktopNotification(bool setPosition=false)
~DesktopNotification() override