mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
plasma: catch even child events to cancel auto-hide in notifications applet
continue from:
ff687e99e7
a bit expensive but gets the job done
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ff687e99e7
commit
fa5715aba4
1 changed files with 21 additions and 5 deletions
|
@ -54,7 +54,7 @@ public:
|
||||||
NotificationsWidget(NotificationsApplet* notifications);
|
NotificationsWidget(NotificationsApplet* notifications);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) final;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) final;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void slotCountChanged();
|
void slotCountChanged();
|
||||||
|
@ -79,6 +79,8 @@ NotificationsWidget::NotificationsWidget(NotificationsApplet* notifications)
|
||||||
setMinimumSize(s_minimumsize);
|
setMinimumSize(s_minimumsize);
|
||||||
// makes it truly passive popup
|
// makes it truly passive popup
|
||||||
setWindowFlags(windowFlags() | Qt::X11BypassWindowManagerHint);
|
setWindowFlags(windowFlags() | Qt::X11BypassWindowManagerHint);
|
||||||
|
// the easy way to cancel auto-hide on activity
|
||||||
|
setFiltersChildEvents(true);
|
||||||
|
|
||||||
m_jobsscrollwidget = new Plasma::ScrollWidget(this);
|
m_jobsscrollwidget = new Plasma::ScrollWidget(this);
|
||||||
m_jobsscrollwidget->setMinimumSize(s_minimumsize);
|
m_jobsscrollwidget->setMinimumSize(s_minimumsize);
|
||||||
|
@ -101,13 +103,26 @@ NotificationsWidget::NotificationsWidget(NotificationsApplet* notifications)
|
||||||
addTab(KIcon("dialog-information"), i18n("Notifications"), m_applicationsscrollwidget);
|
addTab(KIcon("dialog-information"), i18n("Notifications"), m_applicationsscrollwidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
bool NotificationsWidget::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
Plasma::TabBar::mousePressEvent(event);
|
const bool result = Plasma::TabBar::sceneEventFilter(watched, event);
|
||||||
if (m_automaticpopup) {
|
if (m_automaticpopup) {
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
case QEvent::MouseButtonPress:
|
||||||
|
case QEvent::GraphicsSceneMousePress:
|
||||||
|
case QEvent::GraphicsSceneWheel: {
|
||||||
// stop auto-hide timer of the popup
|
// stop auto-hide timer of the popup
|
||||||
|
m_automaticpopup = false;
|
||||||
m_notifications->showPopup(0);
|
m_notifications->showPopup(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsWidget::slotCountChanged()
|
void NotificationsWidget::slotCountChanged()
|
||||||
|
@ -145,6 +160,7 @@ NotificationsApplet::NotificationsApplet(QObject *parent, const QVariantList &ar
|
||||||
setPopupIcon(kNotificationIcon(this, false));
|
setPopupIcon(kNotificationIcon(this, false));
|
||||||
setStatus(Plasma::ItemStatus::PassiveStatus);
|
setStatus(Plasma::ItemStatus::PassiveStatus);
|
||||||
m_notificationswidget = new NotificationsWidget(this);
|
m_notificationswidget = new NotificationsWidget(this);
|
||||||
|
installEventFilter(m_notificationswidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationsApplet::~NotificationsApplet()
|
NotificationsApplet::~NotificationsApplet()
|
||||||
|
|
Loading…
Add table
Reference in a new issue