Don't show activity/silence notifications when the terminal is active

REVIEW: 128239
BUG: 257752
parent 43744097
......@@ -426,6 +426,11 @@ Comment[zh_TW]=非可見工作階段中的響鈴行為
Sound=Oxygen-Sys-App-Message.ogg
Action=Popup
[Event/ActivityHidden]
Name=Activity in Hidden Monitored Session
Comment=Activity detected in a hidden monitored session
Action=Popup
[Event/Activity]
Name=Activity in Monitored Session
Name[af]=Aktiwiteit in gemonitorde sessie
......@@ -591,6 +596,10 @@ Comment[zh_CN]=被监视会话中检测到的活动
Comment[zh_TW]=監控工作階段中偵測到的活動
Action=Popup
[Event/SilenceHidden]
Name=Silence in Hidden Monitored Session
Comment=Silence detected in a hidden monitored session
Action=Popup
[Event/Silence]
Name=Silence in Monitored Session
......
......@@ -598,14 +598,24 @@ void Session::silenceTimerDone()
//when any of the views of the session becomes active
//FIXME: Make message text for this notification and the activity notification more descriptive.
if (_monitorSilence) {
KNotification::event("Silence", i18n("Silence in session '%1'", _nameTitle), QPixmap(),
QApplication::activeWindow(),
KNotification::CloseWhenWidgetActivated);
emit stateChanged(NOTIFYSILENCE);
} else {
if (!_monitorSilence) {
emit stateChanged(NOTIFYNORMAL);
return;
}
bool hasFocus = false;
for (TerminalDisplay *display : _views) {
if (display->hasFocus()) {
hasFocus = true;
break;
}
}
KNotification::event(hasFocus ? "Silence" : "SilenceHidden",
i18n("Silence in session '%1'", _nameTitle), QPixmap(),
QApplication::activeWindow(),
KNotification::CloseWhenWidgetActivated);
emit stateChanged(NOTIFYSILENCE);
}
void Session::activityTimerDone()
......@@ -652,8 +662,18 @@ void Session::activityStateSet(int state)
if (state == NOTIFYBELL) {
emit bellRequest(i18n("Bell in session '%1'", _nameTitle));
} else if (state == NOTIFYACTIVITY) {
// Don't notify if the terminal is active
bool hasFocus = false;
for (TerminalDisplay *display : _views) {
if (display->hasFocus()) {
hasFocus = true;
break;
}
}
if (_monitorActivity && !_notifiedActivity) {
KNotification::event("Activity", i18n("Activity in session '%1'", _nameTitle), QPixmap(),
KNotification::event(hasFocus ? "Activity" : "ActivityHidden",
i18n("Activity in session '%1'", _nameTitle), QPixmap(),
QApplication::activeWindow(),
KNotification::CloseWhenWidgetActivated);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment