1
From 6f5755c6aa3c1a4a837bd7a5221603291a42f518 Mon Sep 17 00:00:00 2001
2
From: Aurelien Gateau <aurelien.gateau@canonical.com>
3
Date: Tue, 29 Sep 2009 15:30:57 +0200
4
Subject: [PATCH 1/2] Initial support for indicators.
8
config-konversation.h.cmake | 3 +-
9
src/CMakeLists.txt | 8 +++-
10
src/notificationhandler.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++
11
src/notificationhandler.h | 19 +++++++-
12
5 files changed, 142 insertions(+), 3 deletions(-)
14
Index: konversation-1.2.1+git20091217/CMakeLists.txt
15
===================================================================
16
--- konversation-1.2.1+git20091217.orig/CMakeLists.txt 2009-12-17 09:58:01.000000000 -0500
17
+++ konversation-1.2.1+git20091217/CMakeLists.txt 2009-12-17 09:58:04.000000000 -0500
19
#atm this gets us FindQt4 and FindX11 (provided that the default cmake FindQt4 doesn't get used)
20
find_package(KDE4 REQUIRED)
21
find_package(KdepimLibs REQUIRED)
22
+find_package(PkgConfig REQUIRED)
25
include(CheckIncludeFile)
27
macro_ensure_version( "4.3.80" ${KDE_VERSION} HAVEKDE4_4 )
28
macro_bool_to_01(HAVEKDE4_4 HAVE_KSTATUSNOTIFIERITEM)
30
+pkg_check_modules(INDICATEQT indicate-qt)
31
+macro_bool_to_01(INDICATEQT_FOUND HAVE_INDICATEQT)
32
+macro_log_feature(INDICATEQT_FOUND "libindicate-qt" "Qt binding for libindicate" "http://launchpad.net/libindicate-qt" FALSE "" "Support for message indicator")
34
configure_file(config-konversation.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-konversation.h )
37
Index: konversation-1.2.1+git20091217/config-konversation.h.cmake
38
===================================================================
39
--- konversation-1.2.1+git20091217.orig/config-konversation.h.cmake 2009-12-17 09:58:01.000000000 -0500
40
+++ konversation-1.2.1+git20091217/config-konversation.h.cmake 2009-12-17 09:58:04.000000000 -0500
42
#cmakedefine HAVE_X11 1
43
#cmakedefine HAVE_XUTIL 1
44
#cmakedefine HAVE_QCA2 1
45
-#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
46
\ No newline at end of file
47
+#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
48
+#cmakedefine HAVE_INDICATEQT 1
49
Index: konversation-1.2.1+git20091217/src/CMakeLists.txt
50
===================================================================
51
--- konversation-1.2.1+git20091217.orig/src/CMakeLists.txt 2009-12-17 09:58:01.000000000 -0500
52
+++ konversation-1.2.1+git20091217/src/CMakeLists.txt 2009-12-17 09:58:16.000000000 -0500
57
+if (INDICATEQT_FOUND)
58
+ include_directories(${INDICATEQT_INCLUDE_DIRS})
59
+ link_directories(${INDICATEQT_LIBRARY_DIRS})
60
+endif (INDICATEQT_FOUND)
64
upnp/upnpdescriptionparser.cpp
67
target_link_libraries(konversation ${KDE4_KIO_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_KPARTS_LIBS}
68
${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KABC_LIBS}
69
- ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS})
70
+ ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS}
71
+ ${INDICATEQT_LIBRARIES})
73
if (X11_FOUND AND X11_Xutil_FOUND)
74
target_link_libraries(konversation ${X11_X11_LIB})
75
Index: konversation-1.2.1+git20091217/src/notificationhandler.cpp
76
===================================================================
77
--- konversation-1.2.1+git20091217.orig/src/notificationhandler.cpp 2009-12-17 09:58:01.000000000 -0500
78
+++ konversation-1.2.1+git20091217/src/notificationhandler.cpp 2009-12-17 09:58:16.000000000 -0500
80
#include "viewcontainer.h"
83
+#include "config-konversation.h"
85
#include <QTextDocument>
87
#include <KNotification>
88
+#include <KWindowSystem>
90
+#ifdef HAVE_INDICATEQT
91
+#include <qindicateindicator.h>
92
+#include <qindicateserver.h>
94
+class Indicator : public QIndicate::Indicator
97
+ Indicator(QIndicate::Server* server)
98
+ : QIndicate::Indicator(server)
101
+ QPointer<ChatWindow> m_chatWin;
105
namespace Konversation
110
m_mainWindow = parent->getMainWindow();
111
+ #ifdef HAVE_INDICATEQT
112
+ m_indicateServer = QIndicate::Server::defaultInstance();
113
+ m_indicateServer->setType("message.irc");
114
+ QString appName = KGlobal::mainComponent().componentName();
115
+ kDebug() << "appName" << appName;
116
+ KService::Ptr service = KService::serviceByDesktopName(appName);
118
+ m_indicateServer->setDesktopFile(service->entryPath());
120
+ kWarning() << "Could not find desktop file for application";
122
+ connect(m_indicateServer, SIGNAL(serverDisplay()),
123
+ SLOT(slotIndicateServerDisplay()));
124
+ m_indicateServer->show();
128
NotificationHandler::~NotificationHandler()
130
if (!chatWin || !chatWin->notificationsEnabled())
133
+ addIndicator(chatWin, fromNick);
135
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
139
if (!chatWin || !chatWin->notificationsEnabled())
142
+ addIndicator(chatWin, fromNick);
144
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
148
if (!chatWin || !chatWin->notificationsEnabled())
151
+ addIndicator(chatWin, fromNick);
153
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
160
+ void NotificationHandler::addIndicator(ChatWindow* chatWin, const QString& nick)
162
+ #ifdef HAVE_INDICATEQT
163
+ ViewContainer* viewContainer = m_mainWindow->getViewContainer();
164
+ if (m_mainWindow->isActiveWindow() && chatWin == viewContainer->getFrontView()) {
165
+ // Do not show indicator if the user is already using this chat
169
+ Indicator* indicator = m_indicatorForChatWindow.value(chatWin);
171
+ indicator = new Indicator(m_indicateServer);
172
+ indicator->m_chatWin = chatWin;
173
+ m_indicatorForChatWindow.insert(chatWin, indicator);
174
+ connect(chatWin, SIGNAL(closing(ChatWindow*)), SLOT(deleteIndicatorForChatWindow(ChatWindow*)));
175
+ connect(viewContainer, SIGNAL(viewChanged(ChatWindow*)), SLOT(slotViewChanged(ChatWindow*)));
177
+ connect(indicator, SIGNAL(display(QIndicate::Indicator*)), SLOT(slotIndicatorDisplay(QIndicate::Indicator*)));
181
+ if (chatWin->getType() == ChatWindow::Query) {
184
+ name = QString("%1 (%2)").arg(chatWin->getName()).arg(nick);
186
+ indicator->setNameProperty(name);
187
+ indicator->setTimeProperty(QDateTime::currentDateTime());
188
+ indicator->setDrawAttentionProperty(true);
192
+ void NotificationHandler::slotIndicatorDisplay(QIndicate::Indicator* _indicator)
194
+ #ifdef HAVE_INDICATEQT
195
+ Indicator* indicator = static_cast<Indicator*>(_indicator);
196
+ ChatWindow* chatWin = indicator->m_chatWin;
197
+ m_indicatorForChatWindow.remove(chatWin);
200
+ m_mainWindow->show();
201
+ KWindowSystem::forceActiveWindow(m_mainWindow->winId());
203
+ m_mainWindow->getViewContainer()->showView(chatWin);
204
+ chatWin->adjustFocus();
209
+ void NotificationHandler::slotIndicateServerDisplay()
211
+ KWindowInfo info = KWindowSystem::windowInfo(m_mainWindow->winId(), NET::WMDesktop);
212
+ if (m_mainWindow->isVisible() && info.isOnCurrentDesktop()) {
213
+ m_mainWindow->hide();
215
+ m_mainWindow->show();
216
+ KWindowSystem::forceActiveWindow(m_mainWindow->winId());
220
+ void NotificationHandler::deleteIndicatorForChatWindow(ChatWindow* chatWin)
222
+ #ifdef HAVE_INDICATEQT
223
+ delete m_indicatorForChatWindow.take(chatWin);
227
+ void NotificationHandler::slotViewChanged(ChatWindow* chatWin)
229
+ #ifdef HAVE_INDICATEQT
230
+ deleteIndicatorForChatWindow(chatWin);
235
#include "notificationhandler.moc"
236
Index: konversation-1.2.1+git20091217/src/notificationhandler.h
237
===================================================================
238
--- konversation-1.2.1+git20091217.orig/src/notificationhandler.h 2009-12-17 09:58:01.000000000 -0500
239
+++ konversation-1.2.1+git20091217/src/notificationhandler.h 2009-12-17 09:58:04.000000000 -0500
241
#ifndef KONVERSATIONNOTIFICATIONHANDLER_H
242
#define KONVERSATIONNOTIFICATIONHANDLER_H
252
-namespace Konversation
260
+namespace Konversation
262
class NotificationHandler : public QObject
266
void startTrayNotification(ChatWindow* chatWin);
267
QString addLineBreaks(const QString& string);
270
+ void slotIndicatorDisplay(QIndicate::Indicator*);
271
+ void slotIndicateServerDisplay();
272
+ void deleteIndicatorForChatWindow(ChatWindow*);
273
+ void slotViewChanged(ChatWindow* chatWin);
276
MainWindow* m_mainWindow;
277
+ QIndicate::Server* m_indicateServer;
278
+ QHash<ChatWindow*, Indicator*> m_indicatorForChatWindow;
280
+ void addIndicator(ChatWindow*, const QString& nick);