Commit e7e79f93 authored by Eike Hein's avatar Eike Hein
Browse files

Revert "Add support for monitoring sessions/terminals for activity/silence."

This reverts commit 4b8e85d7.

Narf, should have gone into a feature branch.
parent 4b8e85d7
Changes since 2.9.8:
* Yakuake now sports a standard KDE "Configure Notifications..." item in
its menu. The startup notification popup configuration has moved there,
and newly-added notification events covered below are found there.
* It's now possible to monitor sessions (or individual terminals within
them) for activity or silence. See the tab context menu or the keyboard
shortcuts to toggle monitoring, and the new "Configure Notifications"
dialog mentioned above to configure what happens when activity or
silence are detected in a monitored session or terminal (by default a
desktop notification is triggered for each).
its menu. The startup notification popup configuration has moved there.
* The addSession* and split* D-Bus calls now return the id of the newly-
created session or terminal, or -1 if creating a new session or terminal
was not possible.
......
......@@ -28,7 +28,6 @@
#include "sessionstack.h"
#include "skin.h"
#include "tabbar.h"
#include "terminal.h"
#include "titlebar.h"
#include "ui_behaviorsettings.h"
......@@ -360,20 +359,6 @@ void MainWindow::setupActions()
connect(action, SIGNAL(triggered(bool)), this, SLOT(handleContextDependentToggleAction(bool)));
m_contextDependentActions << action;
action = actionCollection()->addAction("toggle-session-monitor-silence");
action->setText(i18nc("@action", "Monitor for Silence"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
action->setCheckable(true);
connect(action, SIGNAL(triggered(bool)), this, SLOT(handleContextDependentToggleAction(bool)));
m_contextDependentActions << action;
action = actionCollection()->addAction("toggle-session-monitor-activity");
action->setText(i18nc("@action", "Monitor for Activity"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A));
action->setCheckable(true);
connect(action, SIGNAL(triggered(bool)), this, SLOT(handleContextDependentToggleAction(bool)));
m_contextDependentActions << action;
for (uint i = 1; i <= 10; ++i)
{
action = actionCollection()->addAction(QString("switch-to-session-%1").arg(i));
......@@ -447,12 +432,6 @@ void MainWindow::handleContextDependentToggleAction(bool checked, QAction* actio
// so the lock icon is added to or removed from the tab label.
m_tabBar->repaint();
}
if (action == actionCollection()->action("toggle-session-monitor-silence"))
m_sessionStack->setSessionMonitorSilenceEnabled(sessionId, checked);
if (action == actionCollection()->action("toggle-session-monitor-activity"))
m_sessionStack->setSessionMonitorActivityEnabled(sessionId, checked);
}
void MainWindow::setContextDependentActionsQuiet(bool quiet)
......@@ -475,62 +454,6 @@ void MainWindow::handleToggleTerminalKeyboardInput(bool checked)
m_sessionStack->setTerminalKeyboardInputEnabled(terminalId, !checked);
}
void MainWindow::handleToggleTerminalMonitorSilence(bool checked)
{
QAction* action = qobject_cast<QAction*>(QObject::sender());
if (!action || action->data().isNull()) return;
bool ok = false;
int terminalId = action->data().toInt(&ok);
if (!ok) return;
m_sessionStack->setTerminalMonitorSilenceEnabled(terminalId, checked);
}
void MainWindow::handleToggleTerminalMonitorActivity(bool checked)
{
QAction* action = qobject_cast<QAction*>(QObject::sender());
if (!action || action->data().isNull()) return;
bool ok = false;
int terminalId = action->data().toInt(&ok);
if (!ok) return;
m_sessionStack->setTerminalMonitorActivityEnabled(terminalId, checked);
}
void MainWindow::handleTerminalSilence(Terminal* terminal)
{
Session* session = qobject_cast<Session*>(sender());
if (session)
{
QString message(i18nc("@info", "Silence detected in monitored terminal in session \"%1\".",
m_tabBar->tabTitle(session->id())));
KNotification::event(QLatin1String("silence"), message, QPixmap(), terminal->partWidget(),
KNotification::CloseWhenWidgetActivated);
}
}
void MainWindow::handleTerminalActivity(Terminal* terminal)
{
Session* session = qobject_cast<Session*>(sender());
if (session)
{
disconnect(terminal, SIGNAL(activityDetected(Terminal*)), session, SIGNAL(activityDetected(Terminal*)));
QString message(i18nc("@info", "Activity detected in monitored terminal in session \"%1\".",
m_tabBar->tabTitle(session->id())));
KNotification::event(QLatin1String("activity"), message, QPixmap(), terminal->partWidget(),
KNotification::CloseWhenWidgetActivated);
}
}
void MainWindow::handleSwitchToAction()
{
QAction* action = qobject_cast<QAction*>(QObject::sender());
......@@ -1169,8 +1092,6 @@ void MainWindow::sharedAfterOpenWindow()
if (!Settings::firstRun()) KWindowSystem::forceActiveWindow(winId());
m_listenForActivationChanges = true;
emit windowOpened();
}
void MainWindow::sharedPreHideWindow()
......@@ -1181,8 +1102,6 @@ void MainWindow::sharedPreHideWindow()
void MainWindow::sharedAfterHideWindow()
{
if (Settings::pollMouse()) toggleMousePoll(true);
emit windowClosed();
}
void MainWindow::activate()
......
......@@ -41,7 +41,6 @@ class FirstRunDialog;
class SessionStack;
class Skin;
class TabBar;
class Terminal;
class TitleBar;
class KHelpMenu;
......@@ -74,16 +73,6 @@ class MainWindow : public KMainWindow
void handleContextDependentAction(QAction* action = 0, int sessionId = -1);
void handleContextDependentToggleAction(bool checked, QAction* action = 0, int sessionId = -1);
void handleToggleTerminalKeyboardInput(bool checked);
void handleToggleTerminalMonitorSilence(bool checked);
void handleToggleTerminalMonitorActivity(bool checked);
void handleTerminalSilence(Terminal* terminal);
void handleTerminalActivity(Terminal* terminal);
signals:
void windowOpened();
void windowClosed();
protected:
......
......@@ -162,8 +162,6 @@ Terminal* Session::addTerminal(QWidget* parent)
connect(terminal, SIGNAL(manuallyActivated(Terminal*)), this, SIGNAL(terminalManuallyActivated(Terminal*)));
connect(terminal, SIGNAL(titleChanged(int,QString)), this, SLOT(setTitle(int,QString)));
connect(terminal, SIGNAL(keyboardInputBlocked(Terminal*)), this, SIGNAL(keyboardInputBlocked(Terminal*)));
connect(terminal, SIGNAL(silenceDetected(Terminal*)), this, SIGNAL(silenceDetected(Terminal*)));
connect(terminal, SIGNAL(activityDetected(Terminal*)), this, SIGNAL(activityDetected(Terminal*)));
connect(terminal, SIGNAL(destroyed(int)), this, SLOT(cleanup(int)));
m_terminals.insert(terminal->id(), terminal);
......@@ -523,102 +521,3 @@ bool Session::hasTerminalsWithKeyboardInputDisabled()
return false;
}
bool Session::monitorSilenceEnabled()
{
int monitorSilenceEnabledCount = 0;
QMapIterator<int, Terminal*> i(m_terminals);
while (i.hasNext())
{
i.next();
if (!i.value()->monitorSilenceEnabled())
++monitorSilenceEnabledCount;
}
return m_terminals.count() != monitorSilenceEnabledCount;
}
void Session::setMonitorSilenceEnabled(bool enabled)
{
QMapIterator<int, Terminal*> i(m_terminals);
while (i.hasNext())
{
i.next();
i.value()->setMonitorSilenceEnabled(enabled);
}
}
bool Session::monitorSilenceEnabled(int terminalId)
{
if (!m_terminals.contains(terminalId)) return false;
return m_terminals.value(terminalId)->monitorSilenceEnabled();
}
void Session::setMonitorSilenceEnabled(int terminalId, bool enabled)
{
if (!m_terminals.contains(terminalId)) return;
m_terminals.value(terminalId)->setMonitorSilenceEnabled(enabled);
}
bool Session::monitorActivityEnabled()
{
int monitorActivityEnabledCount = 0;
QMapIterator<int, Terminal*> i(m_terminals);
while (i.hasNext())
{
i.next();
if (!i.value()->monitorActivityEnabled())
++monitorActivityEnabledCount;
}
return m_terminals.count() != monitorActivityEnabledCount;
}
void Session::setMonitorActivityEnabled(bool enabled)
{
QMapIterator<int, Terminal*> i(m_terminals);
while (i.hasNext())
{
i.next();
i.value()->setMonitorActivityEnabled(enabled);
}
}
bool Session::monitorActivityEnabled(int terminalId)
{
if (!m_terminals.contains(terminalId)) return false;
return m_terminals.value(terminalId)->monitorActivityEnabled();
}
void Session::setMonitorActivityEnabled(int terminalId, bool enabled)
{
if (!m_terminals.contains(terminalId)) return;
m_terminals.value(terminalId)->setMonitorActivityEnabled(enabled);
}
void Session::reconnectMonitorActivitySignals()
{
QMapIterator<int, Terminal*> i(m_terminals);
while (i.hasNext())
{
i.next();
connect(i.value(), SIGNAL(activityDetected(Terminal*)), this, SIGNAL(activityDetected(Terminal*)),
Qt::UniqueConnection);
}
}
......@@ -7,7 +7,7 @@
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor appro-
ved by the membership of KDE e.V.), which shall act as a proxy
ved by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
......@@ -60,16 +60,6 @@ class Session : public QObject
void setKeyboardInputEnabled(int terminalId, bool enabled);
bool hasTerminalsWithKeyboardInputDisabled();
bool monitorSilenceEnabled();
void setMonitorSilenceEnabled(bool enabled);
bool monitorSilenceEnabled(int terminalId);
void setMonitorSilenceEnabled(int terminalId, bool enabled);
bool monitorActivityEnabled();
void setMonitorActivityEnabled(bool enabled);
bool monitorActivityEnabled(int terminalId);
void setMonitorActivityEnabled(int terminalId, bool enabled);
bool closable() { return m_closable; }
void setClosable(bool closable) { m_closable = closable; }
......@@ -90,16 +80,12 @@ class Session : public QObject
void manageProfiles();
void editProfile();
void reconnectMonitorActivitySignals();
signals:
void titleChanged(const QString& title);
void titleChanged(int sessionId, const QString& title);
void terminalManuallyActivated(Terminal* terminal);
void keyboardInputBlocked(Terminal* terminal);
void silenceDetected(Terminal* terminal);
void activityDetected(Terminal* terminal);
void destroyed(int sessionId);
......@@ -131,4 +117,4 @@ class Session : public QObject
bool m_closable;
};
#endif
#endif
......@@ -50,9 +50,6 @@ int SessionStack::addSession(Session::SessionType type)
connect(session, SIGNAL(titleChanged(int,QString)), this, SIGNAL(titleChanged(int,QString)));
connect(session, SIGNAL(terminalManuallyActivated(Terminal*)), this, SLOT(handleManualTerminalActivation(Terminal*)));
connect(session, SIGNAL(keyboardInputBlocked(Terminal*)), m_visualEventOverlay, SLOT(indicateKeyboardInputBlocked(Terminal*)));
connect(session, SIGNAL(silenceDetected(Terminal*)), parentWidget(), SLOT(handleTerminalSilence(Terminal*)));
connect(session, SIGNAL(activityDetected(Terminal*)), parentWidget(), SLOT(handleTerminalActivity(Terminal*)));
connect(parentWidget(), SIGNAL(windowClosed()), session, SLOT(reconnectMonitorActivitySignals()));
connect(session, SIGNAL(destroyed(int)), this, SLOT(cleanup(int)));
addWidget(session->widget());
......@@ -100,8 +97,6 @@ void SessionStack::raiseSession(int sessionId)
disconnect(oldActiveSession, SLOT(manageProfiles()));
disconnect(oldActiveSession, SIGNAL(titleChanged(QString)),
this, SIGNAL(activeTitleChanged(QString)));
oldActiveSession->reconnectMonitorActivitySignals();
}
m_activeSessionId = sessionId;
......@@ -335,78 +330,6 @@ bool SessionStack::hasUnclosableSessions() const
return false;
}
bool SessionStack::isSessionMonitorSilenceEnabled(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return false;
if (!m_sessions.contains(sessionId)) return false;
return m_sessions.value(sessionId)->monitorSilenceEnabled();
}
void SessionStack::setSessionMonitorSilenceEnabled(int sessionId, bool enabled)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions.value(sessionId)->setMonitorSilenceEnabled(enabled);
}
bool SessionStack::isTerminalMonitorSilenceEnabled(int terminalId)
{
int sessionId = sessionIdForTerminalId(terminalId);
if (sessionId == -1) return false;
if (!m_sessions.contains(sessionId)) return false;
return m_sessions.value(sessionId)->monitorSilenceEnabled(terminalId);
}
void SessionStack::setTerminalMonitorSilenceEnabled(int terminalId, bool enabled)
{
int sessionId = sessionIdForTerminalId(terminalId);
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions.value(sessionId)->setMonitorSilenceEnabled(terminalId, enabled);
}
bool SessionStack::isSessionMonitorActivityEnabled(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return false;
if (!m_sessions.contains(sessionId)) return false;
return m_sessions.value(sessionId)->monitorActivityEnabled();
}
void SessionStack::setSessionMonitorActivityEnabled(int sessionId, bool enabled)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions.value(sessionId)->setMonitorActivityEnabled(enabled);
}
bool SessionStack::isTerminalMonitorActivityEnabled(int terminalId)
{
int sessionId = sessionIdForTerminalId(terminalId);
if (sessionId == -1) return false;
if (!m_sessions.contains(sessionId)) return false;
return m_sessions.value(sessionId)->monitorActivityEnabled(terminalId);
}
void SessionStack::setTerminalMonitorActivityEnabled(int terminalId, bool enabled)
{
int sessionId = sessionIdForTerminalId(terminalId);
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions.value(sessionId)->setMonitorActivityEnabled(terminalId, enabled);
}
void SessionStack::editProfile(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
......
......@@ -7,7 +7,7 @@
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor appro-
ved by the membership of KDE e.V.), which shall act as a proxy
ved by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
......@@ -93,16 +93,6 @@ class SessionStack : public QStackedWidget
Q_SCRIPTABLE void setSessionClosable(int sessionId, bool closable);
Q_SCRIPTABLE bool hasUnclosableSessions() const;
Q_SCRIPTABLE bool isSessionMonitorSilenceEnabled(int sessionId);
Q_SCRIPTABLE void setSessionMonitorSilenceEnabled(int sessionId, bool enabled);
Q_SCRIPTABLE bool isTerminalMonitorSilenceEnabled(int terminalId);
Q_SCRIPTABLE void setTerminalMonitorSilenceEnabled(int terminalId, bool enabled);
Q_SCRIPTABLE bool isSessionMonitorActivityEnabled(int sessionId);
Q_SCRIPTABLE void setSessionMonitorActivityEnabled(int sessionId, bool enabled);
Q_SCRIPTABLE bool isTerminalMonitorActivityEnabled(int terminalId);
Q_SCRIPTABLE void setTerminalMonitorActivityEnabled(int terminalId, bool enabled);
void handleTerminalHighlightRequest(int terminalId);
......
......@@ -66,8 +66,6 @@ TabBar::TabBar(MainWindow* mainWindow) : QWidget(mainWindow)
connect(m_tabContextMenu, SIGNAL(hovered(QAction*)), this, SLOT(contextMenuActionHovered(QAction*)));
m_toggleKeyboardInputMenu = new KMenu(i18nc("@title:menu", "Disable Keyboard Input"), this);
m_toggleMonitorSilenceMenu = new KMenu(i18nc("@title:menu", "Monitor for Silence"), this);
m_toggleMonitorActivityMenu = new KMenu(i18nc("@title:menu", "Monitor for Activity"), this);
m_sessionMenu = new KMenu(this);
connect(m_sessionMenu, SIGNAL(aboutToShow()), this, SLOT(readySessionMenu()));
......@@ -126,8 +124,6 @@ void TabBar::readyTabContextMenu()
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("rename-session"));
m_tabContextMenu->addMenu(m_toggleKeyboardInputMenu);
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("toggle-session-prevent-closing"));
m_tabContextMenu->addMenu(m_toggleMonitorSilenceMenu);
m_tabContextMenu->addMenu(m_toggleMonitorActivityMenu);
m_tabContextMenu->addSeparator();
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-left"));
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-right"));
......@@ -175,12 +171,6 @@ void TabBar::updateToggleActions(int sessionId)
toggleAction = actionCollection->action("toggle-session-prevent-closing");
toggleAction->setChecked(!sessionStack->isSessionClosable(sessionId));
toggleAction = actionCollection->action("toggle-session-monitor-silence");
toggleAction->setChecked(sessionStack->isSessionMonitorSilenceEnabled(sessionId));
toggleAction = actionCollection->action("toggle-session-monitor-activity");
toggleAction->setChecked(sessionStack->isSessionMonitorActivityEnabled(sessionId));
}
void TabBar::updateToggleKeyboardInputMenu(int sessionId)
......@@ -231,102 +221,6 @@ void TabBar::updateToggleKeyboardInputMenu(int sessionId)
}
}
void TabBar::updateToggleMonitorSilenceMenu(int sessionId)
{
if (!m_tabs.contains(sessionId)) return;
QAction* toggleMonitorSilenceAction = m_mainWindow->actionCollection()->action("toggle-session-monitor-silence");
QAction* anchor = m_toggleMonitorSilenceMenu->menuAction();
SessionStack* sessionStack = m_mainWindow->sessionStack();
QStringList terminalIds = sessionStack->terminalIdsForSessionId(sessionId).split(',', QString::SkipEmptyParts);
m_toggleMonitorSilenceMenu->clear();
if (terminalIds.count() <= 1)
{
toggleMonitorSilenceAction->setText(i18nc("@action", "Monitor for Silence"));
m_tabContextMenu->insertAction(anchor, toggleMonitorSilenceAction);
m_toggleMonitorSilenceMenu->menuAction()->setVisible(false);
}
else
{
toggleMonitorSilenceAction->setText(i18nc("@action", "In This Session"));
m_toggleMonitorSilenceMenu->menuAction()->setVisible(true);
m_tabContextMenu->removeAction(toggleMonitorSilenceAction);
m_toggleMonitorSilenceMenu->addAction(toggleMonitorSilenceAction);
m_toggleMonitorSilenceMenu->addSeparator();
int count = 0;
QStringListIterator i(terminalIds);
while (i.hasNext())
{
int terminalId = i.next().toInt();
++count;
QAction* action = m_toggleMonitorSilenceMenu->addAction(i18nc("@action", "In Terminal %1", count));
action->setCheckable(true);
action->setChecked(sessionStack->isTerminalMonitorSilenceEnabled(terminalId));
action->setData(terminalId);
connect(action, SIGNAL(triggered(bool)), m_mainWindow, SLOT(handleToggleTerminalMonitorSilence(bool)));
}
}
}
void TabBar::updateToggleMonitorActivityMenu(int sessionId)
{
if (!m_tabs.contains(sessionId)) return;
QAction* toggleMonitorActivityAction = m_mainWindow->actionCollection()->action("toggle-session-monitor-activity");
QAction* anchor = m_toggleMonitorActivityMenu->menuAction();
SessionStack* sessionStack = m_mainWindow->sessionStack();
QStringList terminalIds = sessionStack->terminalIdsForSessionId(sessionId).split(',', QString::SkipEmptyParts);
m_toggleMonitorActivityMenu->clear();
if (terminalIds.count() <= 1)
{
toggleMonitorActivityAction->setText(i18nc("@action", "Monitor for Activity"));
m_tabContextMenu->insertAction(anchor, toggleMonitorActivityAction);
m_toggleMonitorActivityMenu->menuAction()->setVisible(false);
}
else
{
toggleMonitorActivityAction->setText(i18nc("@action", "In This Session"));
m_toggleMonitorActivityMenu->menuAction()->setVisible(true);
m_tabContextMenu->removeAction(toggleMonitorActivityAction);
m_toggleMonitorActivityMenu->addAction(toggleMonitorActivityAction);
m_toggleMonitorActivityMenu->addSeparator();
int count = 0;
QStringListIterator i(terminalIds);
while (i.hasNext())
{
int terminalId = i.next().toInt();
++count;
QAction* action = m_toggleMonitorActivityMenu->addAction(i18nc("@action", "In Terminal %1", count));
action->setCheckable(true);
action->setChecked(sessionStack->isTerminalMonitorActivityEnabled(terminalId));
action->setData(terminalId);
connect(action, SIGNAL(triggered(bool)), m_mainWindow, SLOT(handleToggleTerminalMonitorActivity(bool)));
}
}
}
void TabBar::contextMenuActionHovered(QAction* action)
{
bool ok = false;
......@@ -358,8 +252,6 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
int sessionId = sessionAtTab(index);
updateToggleActions(sessionId);
updateToggleKeyboardInputMenu(sessionId);
updateToggleMonitorSilenceMenu(sessionId);
updateToggleMonitorActivityMenu(sessionId);
m_mainWindow->setContextDependentActionsQuiet(true);
......@@ -380,8 +272,6 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
updateMoveActions(m_tabs.indexOf(m_selectedSessionId));
updateToggleActions(m_selectedSessionId);
updateToggleKeyboardInputMenu(m_selectedSessionId);
updateToggleMonitorSilenceMenu(m_selectedSessionId);
updateToggleMonitorActivityMenu(m_selectedSessionId);
}
QWidget::contextMenuEvent(event);
......@@ -479,10 +369,10 @@ int TabBar::drawButton(int x, int y, int index, QPainter& painter)
if (selected)
painter.drawTiledPixmap(x, y,
m_skin->tabBarPreventClosingImagePosition().x() +
m_skin->tabBarPreventClosingImage().width(), height(),
m_skin->tabBarPreventClosingImage().width(), height(),
m_skin->tabBarSelectedBackgroundImage());
else
painter.drawTiledPixmap(x, y,
painter.drawTiledPixmap(x, y,
m_skin->tabBarPreventClosingImagePosition().x() +
m_skin->tabBarPreventClosingImage().width(), height(),
m_skin->tabBarUnselectedBackgroundImage());
......
......@@ -7,7 +7,7 @@
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor appro-
ved by the membership of KDE e.V.), which shall act as a proxy
ved by the membership of KDE e.V.), which shall act as a proxy