Commit 942e5009 authored by Eike Hein's avatar Eike Hein
Browse files

Add version checks for 4.7.1 for activity/silence monitoring.

I can't begin to tell you how much I wanted to make this a runtime
check instead of build time, but it would have meant non-working
entries in "Configure Notifications" and non-working API on D-Bus.
parent 11192201
......@@ -2,12 +2,14 @@ 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).
* If Yakuake is built against KDE Platform 4.7.1 or newer and the corres-
ponding Konsole version is installed it is 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 confi-
gure what happens when activity or silence are detected in a monitored
session or terminal (by default a desktop notification popup is trigger-
ed for each).
Note that repeated activity in a terminal does not result in repeated
notifications for that terminal: After the first notification, activity
monitoring has to be disabled or reenabled, or the active session
......
......@@ -360,6 +360,7 @@ void MainWindow::setupActions()
connect(action, SIGNAL(triggered(bool)), this, SLOT(handleContextDependentToggleAction(bool)));
m_contextDependentActions << action;
#if KDE_IS_VERSION(4, 7, 1)
action = actionCollection()->addAction("toggle-session-monitor-activity");
action->setText(i18nc("@action", "Monitor for Activity"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A));
......@@ -373,6 +374,7 @@ void MainWindow::setupActions()
action->setCheckable(true);
connect(action, SIGNAL(triggered(bool)), this, SLOT(handleContextDependentToggleAction(bool)));
m_contextDependentActions << action;
#endif
for (uint i = 1; i <= 10; ++i)
{
......@@ -448,11 +450,13 @@ void MainWindow::handleContextDependentToggleAction(bool checked, QAction* actio
m_tabBar->repaint();
}
#if KDE_IS_VERSION(4, 7, 1)
if (action == actionCollection()->action("toggle-session-monitor-activity"))
m_sessionStack->setSessionMonitorActivityEnabled(sessionId, checked);
if (action == actionCollection()->action("toggle-session-monitor-silence"))
m_sessionStack->setSessionMonitorSilenceEnabled(sessionId, checked);
#endif
}
void MainWindow::setContextDependentActionsQuiet(bool quiet)
......@@ -475,6 +479,7 @@ void MainWindow::handleToggleTerminalKeyboardInput(bool checked)
m_sessionStack->setTerminalKeyboardInputEnabled(terminalId, !checked);
}
#if KDE_IS_VERSION(4, 7, 1)
void MainWindow::handleToggleTerminalMonitorActivity(bool checked)
{
QAction* action = qobject_cast<QAction*>(QObject::sender());
......@@ -530,6 +535,7 @@ void MainWindow::handleTerminalSilence(Terminal* terminal)
KNotification::CloseWhenWidgetActivated);
}
}
#endif
void MainWindow::handleSwitchToAction()
{
......
......@@ -74,12 +74,14 @@ 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);
#if KDE_IS_VERSION(4, 7, 1)
void handleToggleTerminalMonitorActivity(bool checked);
void handleToggleTerminalMonitorSilence(bool checked);
void handleTerminalActivity(Terminal* terminal);
void handleTerminalSilence(Terminal* terminal);
#endif
signals:
void windowOpened();
......
......@@ -162,7 +162,9 @@ 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*)));
#if KDE_IS_VERSION(4, 7, 1)
connect(terminal, SIGNAL(silenceDetected(Terminal*)), this, SIGNAL(silenceDetected(Terminal*)));
#endif
connect(terminal, SIGNAL(destroyed(int)), this, SLOT(cleanup(int)));
m_terminals.insert(terminal->id(), terminal);
......@@ -519,6 +521,7 @@ bool Session::hasTerminalsWithKeyboardInputDisabled()
return false;
}
#if KDE_IS_VERSION(4, 7, 1)
bool Session::monitorActivityEnabled()
{
int monitorActivityEnabledCount = 0;
......@@ -614,3 +617,4 @@ void Session::setMonitorSilenceEnabled(int terminalId, bool enabled)
m_terminals.value(terminalId)->setMonitorSilenceEnabled(enabled);
}
#endif
......@@ -26,6 +26,8 @@
#include "splitter.h"
#include <kdeversion.h>
#include <QMap>
#include <QObject>
......@@ -60,6 +62,7 @@ class Session : public QObject
void setKeyboardInputEnabled(int terminalId, bool enabled);
bool hasTerminalsWithKeyboardInputDisabled();
#if KDE_IS_VERSION(4, 7, 1)
bool monitorActivityEnabled();
void setMonitorActivityEnabled(bool enabled);
bool monitorActivityEnabled(int terminalId);
......@@ -69,6 +72,7 @@ class Session : public QObject
void setMonitorSilenceEnabled(bool enabled);
bool monitorSilenceEnabled(int terminalId);
void setMonitorSilenceEnabled(int terminalId, bool enabled);
#endif
bool closable() { return m_closable; }
void setClosable(bool closable) { m_closable = closable; }
......@@ -90,7 +94,9 @@ class Session : public QObject
void manageProfiles();
void editProfile();
#if KDE_IS_VERSION(4, 7, 1)
void reconnectMonitorActivitySignals();
#endif
signals:
......
......@@ -50,9 +50,11 @@ 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*)));
#if KDE_IS_VERSION(4, 7, 1)
connect(session, SIGNAL(activityDetected(Terminal*)), parentWidget(), SLOT(handleTerminalActivity(Terminal*)));
connect(session, SIGNAL(silenceDetected(Terminal*)), parentWidget(), SLOT(handleTerminalSilence(Terminal*)));
connect(parentWidget(), SIGNAL(windowClosed()), session, SLOT(reconnectMonitorActivitySignals()));
#endif
connect(session, SIGNAL(destroyed(int)), this, SLOT(cleanup(int)));
addWidget(session->widget());
......@@ -101,7 +103,9 @@ void SessionStack::raiseSession(int sessionId)
disconnect(oldActiveSession, SIGNAL(titleChanged(QString)),
this, SIGNAL(activeTitleChanged(QString)));
#if KDE_IS_VERSION(4, 7, 1)
oldActiveSession->reconnectMonitorActivitySignals();
#endif
}
m_activeSessionId = sessionId;
......@@ -335,6 +339,7 @@ bool SessionStack::hasUnclosableSessions() const
return false;
}
#if KDE_IS_VERSION(4, 7, 1)
bool SessionStack::isSessionMonitorActivityEnabled(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
......@@ -406,6 +411,7 @@ void SessionStack::setTerminalMonitorSilenceEnabled(int terminalId, bool enabled
m_sessions.value(sessionId)->setMonitorSilenceEnabled(terminalId, enabled);
}
#endif
void SessionStack::editProfile(int sessionId)
{
......
......@@ -93,6 +93,7 @@ class SessionStack : public QStackedWidget
Q_SCRIPTABLE void setSessionClosable(int sessionId, bool closable);
Q_SCRIPTABLE bool hasUnclosableSessions() const;
#if KDE_IS_VERSION(4, 7, 1)
Q_SCRIPTABLE bool isSessionMonitorActivityEnabled(int sessionId);
Q_SCRIPTABLE void setSessionMonitorActivityEnabled(int sessionId, bool enabled);
Q_SCRIPTABLE bool isTerminalMonitorActivityEnabled(int terminalId);
......@@ -102,6 +103,7 @@ class SessionStack : public QStackedWidget
Q_SCRIPTABLE void setSessionMonitorSilenceEnabled(int sessionId, bool enabled);
Q_SCRIPTABLE bool isTerminalMonitorSilenceEnabled(int terminalId);
Q_SCRIPTABLE void setTerminalMonitorSilenceEnabled(int terminalId, bool enabled);
#endif
void handleTerminalHighlightRequest(int terminalId);
......
......@@ -66,8 +66,10 @@ 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);
#if KDE_IS_VERSION(4, 7, 1)
m_toggleMonitorActivityMenu = new KMenu(i18nc("@title:menu", "Monitor for Activity"), this);
m_toggleMonitorSilenceMenu = new KMenu(i18nc("@title:menu", "Monitor for Silence"), this);
#endif
m_sessionMenu = new KMenu(this);
connect(m_sessionMenu, SIGNAL(aboutToShow()), this, SLOT(readySessionMenu()));
......@@ -126,8 +128,10 @@ void TabBar::readyTabContextMenu()
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("rename-session"));
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("toggle-session-prevent-closing"));
m_tabContextMenu->addMenu(m_toggleKeyboardInputMenu);
#if KDE_IS_VERSION(4, 7, 1)
m_tabContextMenu->addMenu(m_toggleMonitorActivityMenu);
m_tabContextMenu->addMenu(m_toggleMonitorSilenceMenu);
#endif
m_tabContextMenu->addSeparator();
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-left"));
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("move-session-right"));
......@@ -176,11 +180,13 @@ void TabBar::updateToggleActions(int sessionId)
toggleAction = actionCollection->action("toggle-session-prevent-closing");
toggleAction->setChecked(!sessionStack->isSessionClosable(sessionId));
#if KDE_IS_VERSION(4, 7, 1)
toggleAction = actionCollection->action("toggle-session-monitor-activity");
toggleAction->setChecked(sessionStack->isSessionMonitorActivityEnabled(sessionId));
toggleAction = actionCollection->action("toggle-session-monitor-silence");
toggleAction->setChecked(sessionStack->isSessionMonitorSilenceEnabled(sessionId));
#endif
}
void TabBar::updateToggleKeyboardInputMenu(int sessionId)
......@@ -231,6 +237,7 @@ void TabBar::updateToggleKeyboardInputMenu(int sessionId)
}
}
#if KDE_IS_VERSION(4, 7, 1)
void TabBar::updateToggleMonitorActivityMenu(int sessionId)
{
if (!m_tabs.contains(sessionId)) return;
......@@ -326,6 +333,7 @@ void TabBar::updateToggleMonitorSilenceMenu(int sessionId)
}
}
}
#endif
void TabBar::contextMenuActionHovered(QAction* action)
{
......@@ -358,8 +366,10 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
int sessionId = sessionAtTab(index);
updateToggleActions(sessionId);
updateToggleKeyboardInputMenu(sessionId);
#if KDE_IS_VERSION(4, 7, 1)
updateToggleMonitorActivityMenu(sessionId);
updateToggleMonitorSilenceMenu(sessionId);
#endif
m_mainWindow->setContextDependentActionsQuiet(true);
......@@ -380,8 +390,10 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
updateMoveActions(m_tabs.indexOf(m_selectedSessionId));
updateToggleActions(m_selectedSessionId);
updateToggleKeyboardInputMenu(m_selectedSessionId);
#if KDE_IS_VERSION(4, 7, 1)
updateToggleMonitorActivityMenu(m_selectedSessionId);
updateToggleMonitorSilenceMenu(m_selectedSessionId);
#endif
}
QWidget::contextMenuEvent(event);
......
......@@ -24,6 +24,8 @@
#define TABBAR_H
#include <kdeversion.h>
#include <QList>
#include <QHash>
#include <QWidget>
......@@ -118,8 +120,10 @@ class TabBar : public QWidget
void updateMoveActions(int index);
void updateToggleActions(int sessionId);
void updateToggleKeyboardInputMenu(int sessionId = -1);
#if KDE_IS_VERSION(4, 7, 1)
void updateToggleMonitorSilenceMenu(int sessionId = -1);
void updateToggleMonitorActivityMenu(int sessionId = -1);
#endif
int drawButton(int x, int y, int index, QPainter& painter);
......@@ -136,8 +140,10 @@ class TabBar : public QWidget
KMenu* m_tabContextMenu;
KMenu* m_toggleKeyboardInputMenu;
#if KDE_IS_VERSION(4, 7, 1)
KMenu* m_toggleMonitorActivityMenu;
KMenu* m_toggleMonitorSilenceMenu;
#endif
KMenu* m_sessionMenu;
KLineEdit* m_lineEdit;
......
......@@ -49,8 +49,10 @@ Terminal::Terminal(QWidget* parent) : QObject(parent)
m_keyboardInputEnabled = true;
#if KDE_IS_VERSION(4, 7, 1)
m_monitorActivityEnabled = false;
m_monitorSilenceEnabled = false;
#endif
m_part = NULL;
m_terminalInterface = NULL;
......@@ -247,6 +249,7 @@ void Terminal::overrideShortcut(QKeyEvent* /* event */, bool& override)
override = false;
}
#if KDE_IS_VERSION(4, 7, 1)
void Terminal::setMonitorActivityEnabled(bool enabled)
{
m_monitorActivityEnabled = enabled;
......@@ -298,3 +301,4 @@ void Terminal::silenceDetected()
{
emit silenceDetected(this);
}
#endif
......@@ -22,7 +22,7 @@
#ifndef TERMINAL_H
#define TERMINAL_H
#include <kdeversion.h>
#include <KParts/Part>
......@@ -58,11 +58,13 @@ class Terminal : public QObject
bool keyboardInputEnabled() { return m_keyboardInputEnabled; }
void setKeyboardInputEnabled(bool enabled) { m_keyboardInputEnabled = enabled; }
#if KDE_IS_VERSION(4, 7, 1)
bool monitorActivityEnabled() { return m_monitorActivityEnabled; }
void setMonitorActivityEnabled(bool enabled);
bool monitorSilenceEnabled() { return m_monitorSilenceEnabled; }
void setMonitorSilenceEnabled(bool enabled);
#endif
void deletePart();
......@@ -72,16 +74,20 @@ class Terminal : public QObject
void activated(int terminalId);
void manuallyActivated(Terminal* terminal);
void keyboardInputBlocked(Terminal* terminal);
#if KDE_IS_VERSION(4, 7, 1)
void activityDetected(Terminal* terminal);
void silenceDetected(Terminal* terminal);
#endif
void destroyed(int terminalId);
private slots:
void setTitle(const QString& title);
void overrideShortcut(QKeyEvent* event, bool& override);
#if KDE_IS_VERSION(4, 7, 1)
void silenceDetected();
void activityDetected();
#endif
private:
......@@ -102,8 +108,10 @@ class Terminal : public QObject
bool m_keyboardInputEnabled;
#if KDE_IS_VERSION(4, 7, 1)
bool m_monitorActivityEnabled;
bool m_monitorSilenceEnabled;
#endif
};
#endif
......@@ -3,4 +3,11 @@ add_subdirectory( skins )
add_subdirectory( updaters )
install(PROGRAMS yakuake.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES yakuake.notifyrc DESTINATION ${DATA_INSTALL_DIR}/yakuake)
macro_ensure_version("4.7.1" ${KDE_VERSION} HAVEKDE4_7_1)
if (HAVEKDE4_7_1)
install(FILES yakuake.notifyrc DESTINATION ${DATA_INSTALL_DIR}/yakuake)
else (HAVEKDE4_7_1)
install(FILES yakuake.notifyrc-pre-4.7.1 DESTINATION ${DATA_INSTALL_DIR}/yakuake RENAME yakuake.notifyrc)
endif (HAVEKDE4_7_1)
[Global]
IconName=yakuake
Comment=Yakuake
[Event/startup]
Name=Startup
Comment=Yakuake has started
Action=Popup
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