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() {}
void BaseToastNotification::reject() {
close();
}
void BaseToastNotification::setupCloseButton(QAbstractButton* btn) {
btn->setToolTip(tr("Close this notification"));
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) {
if (event->type() == QEvent::Type::KeyPress) {
return true;
if (event->type() == QEvent::Type::Enter) {
stopTimedClosing();
}
else {
if (event->type() == QEvent::Type::Enter) {
stopTimedClosing();
}
if (event->type() == QEvent::Type::Leave) {
setupTimedClosing();
}
return QDialog::eventFilter(watched, event);
if (event->type() == QEvent::Type::Leave) {
setupTimedClosing();
}
return QDialog::eventFilter(watched, event);
}
void BaseToastNotification::closeEvent(QCloseEvent* event) {
@ -88,8 +87,6 @@ void BaseToastNotification::closeEvent(QCloseEvent* event) {
emit closeRequested(this);
}
void BaseToastNotification::reject() {}
void BaseToastNotification::timerEvent(QTimerEvent* event) {
if (event->timerId() == m_timerId) {
stopTimedClosing();

View File

@ -109,7 +109,9 @@ void ToastNotificationsManager::showNotification(Notification::Event event,
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) {
auto notif_idx = m_activeNotifications.indexOf(notif);
@ -164,11 +166,10 @@ void ToastNotificationsManager::initializeArticleListNotification() {
m_articleListNotification = new ArticleListNotification();
hookNotification(m_articleListNotification);
/*
connect(m_articleListNotification,
&ArticleListNotification::openingArticleInArticleListRequested,
this,
&ArticleListNotification::)*/
&ToastNotificationsManager::openArticleInArticleList);
}
void ToastNotificationsManager::hookNotification(BaseToastNotification* notif) {