enable to close notifications with ESC

This commit is contained in:
Martin Rotter 2023-09-26 12:12:35 +02:00
parent 811f1aadb7
commit c66406e7a5
2 changed files with 14 additions and 16 deletions

View File

@ -33,6 +33,10 @@ BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent),
BaseToastNotification::~BaseToastNotification() {} BaseToastNotification::~BaseToastNotification() {}
void BaseToastNotification::reject() {
close();
}
void BaseToastNotification::setupCloseButton(QAbstractButton* btn) { void BaseToastNotification::setupCloseButton(QAbstractButton* btn) {
btn->setToolTip(tr("Close this notification")); btn->setToolTip(tr("Close this notification"));
btn->setIcon(qApp->icons()->fromTheme(QSL("dialog-close"), QSL("gtk-close"))); btn->setIcon(qApp->icons()->fromTheme(QSL("dialog-close"), QSL("gtk-close")));
@ -67,20 +71,15 @@ void BaseToastNotification::setupTimedClosing() {
} }
bool BaseToastNotification::eventFilter(QObject* watched, QEvent* event) { bool BaseToastNotification::eventFilter(QObject* watched, QEvent* event) {
if (event->type() == QEvent::Type::KeyPress) { if (event->type() == QEvent::Type::Enter) {
return true; stopTimedClosing();
} }
else {
if (event->type() == QEvent::Type::Enter) {
stopTimedClosing();
}
if (event->type() == QEvent::Type::Leave) { if (event->type() == QEvent::Type::Leave) {
setupTimedClosing(); setupTimedClosing();
}
return QDialog::eventFilter(watched, event);
} }
return QDialog::eventFilter(watched, event);
} }
void BaseToastNotification::closeEvent(QCloseEvent* event) { void BaseToastNotification::closeEvent(QCloseEvent* event) {
@ -88,8 +87,6 @@ void BaseToastNotification::closeEvent(QCloseEvent* event) {
emit closeRequested(this); emit closeRequested(this);
} }
void BaseToastNotification::reject() {}
void BaseToastNotification::timerEvent(QTimerEvent* event) { void BaseToastNotification::timerEvent(QTimerEvent* event) {
if (event->timerId() == m_timerId) { if (event->timerId() == m_timerId) {
stopTimedClosing(); stopTimedClosing();

View File

@ -109,7 +109,9 @@ void ToastNotificationsManager::showNotification(Notification::Event event,
m_activeNotifications.prepend(notif); m_activeNotifications.prepend(notif);
} }
void ToastNotificationsManager::openArticleInArticleList(Feed* feed, const Message& msg) {} void ToastNotificationsManager::openArticleInArticleList(Feed* feed, const Message& msg) {
// qApp -, ao
}
void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) { void ToastNotificationsManager::closeNotification(BaseToastNotification* notif, bool delete_from_memory) {
auto notif_idx = m_activeNotifications.indexOf(notif); auto notif_idx = m_activeNotifications.indexOf(notif);
@ -164,11 +166,10 @@ void ToastNotificationsManager::initializeArticleListNotification() {
m_articleListNotification = new ArticleListNotification(); m_articleListNotification = new ArticleListNotification();
hookNotification(m_articleListNotification); hookNotification(m_articleListNotification);
/*
connect(m_articleListNotification, connect(m_articleListNotification,
&ArticleListNotification::openingArticleInArticleListRequested, &ArticleListNotification::openingArticleInArticleListRequested,
this, this,
&ArticleListNotification::)*/ &ToastNotificationsManager::openArticleInArticleList);
} }
void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) { void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) {