1
From 425d2ba6f75053784b1b304646aea745fc4aeb94 Mon Sep 17 00:00:00 2001
2
From: Aurelien Gateau <aurelien.gateau@canonical.com>
3
Date: Fri, 22 Jan 2010 15:12:15 +0100
4
Subject: [PATCH] Adds support for Message Indicator
8
config-konversation.h.cmake | 3 +-
9
src/CMakeLists.txt | 9 ++-
10
src/config/konversation.kcfg | 17 +++++
11
src/config/messageindicator_config.ui | 69 ++++++++++++++++++
12
src/config/settingsdialog.cpp | 13 ++++
13
src/notificationhandler.cpp | 126 +++++++++++++++++++++++++++++++++
14
src/notificationhandler.h | 20 +++++-
15
8 files changed, 259 insertions(+), 3 deletions(-)
16
create mode 100644 src/config/messageindicator_config.ui
18
Index: konversation-1.2.2/CMakeLists.txt
19
===================================================================
20
--- konversation-1.2.2.orig/CMakeLists.txt 2010-02-11 12:59:25.000000000 -0500
21
+++ konversation-1.2.2/CMakeLists.txt 2010-02-11 14:53:29.109599658 -0500
23
#atm this gets us FindQt4 and FindX11 (provided that the default cmake FindQt4 doesn't get used)
24
find_package(KDE4 REQUIRED)
25
find_package(KdepimLibs REQUIRED)
26
+find_package(PkgConfig REQUIRED)
29
include(CheckIncludeFile)
31
macro_bool_to_01(QCA2_FOUND HAVE_QCA2)
32
macro_log_feature(QCA2_FOUND "QCA" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca" FALSE "2.0.0" "Required for using encryption in IRC")
34
+pkg_check_modules(INDICATEQT indicate-qt)
35
+macro_bool_to_01(INDICATEQT_FOUND HAVE_INDICATEQT)
36
+macro_log_feature(INDICATEQT_FOUND "libindicate-qt" "Qt binding for libindicate" "http://launchpad.net/libindicate-qt" FALSE "" "Support for message indicator")
38
#check for greater than 4.3.80
39
macro_ensure_version( "4.3.80" ${KDE_VERSION} HAVEKDE4_4 )
40
macro_bool_to_01(HAVEKDE4_4 HAVE_KSTATUSNOTIFIERITEM)
41
Index: konversation-1.2.2/config-konversation.h.cmake
42
===================================================================
43
--- konversation-1.2.2.orig/config-konversation.h.cmake 2010-02-11 12:57:29.000000000 -0500
44
+++ konversation-1.2.2/config-konversation.h.cmake 2010-02-11 14:53:29.109599658 -0500
46
#cmakedefine HAVE_X11 1
47
#cmakedefine HAVE_XUTIL 1
48
#cmakedefine HAVE_QCA2 1
49
-#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
50
\ No newline at end of file
51
+#cmakedefine HAVE_KSTATUSNOTIFIERITEM 1
52
+#cmakedefine HAVE_INDICATEQT 1
53
Index: konversation-1.2.2/src/CMakeLists.txt
54
===================================================================
55
--- konversation-1.2.2.orig/src/CMakeLists.txt 2010-02-11 12:57:29.000000000 -0500
56
+++ konversation-1.2.2/src/CMakeLists.txt 2010-02-11 14:53:29.113601913 -0500
58
config/theme_configui.ui
59
config/warnings_configui.ui
60
config/watchednicknames_configui.ui
61
+ config/messageindicator_config.ui
69
+if (INDICATEQT_FOUND)
70
+ include_directories(${INDICATEQT_INCLUDE_DIRS})
71
+ link_directories(${INDICATEQT_LIBRARY_DIRS})
72
+endif (INDICATEQT_FOUND)
76
upnp/upnpdescriptionparser.cpp
79
target_link_libraries(konversation ${KDE4_KIO_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_KPARTS_LIBS}
80
${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KABC_LIBS}
81
- ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS})
82
+ ${KDE4_KNOTIFYCONFIG_LIBRARY} ${PHONON_LIBRARY} ${KDE4_SOLID_LIBS}
83
+ ${INDICATEQT_LIBRARIES})
85
if (X11_FOUND AND X11_Xutil_FOUND)
86
target_link_libraries(konversation ${X11_X11_LIB})
87
Index: konversation-1.2.2/src/config/konversation.kcfg
88
===================================================================
89
--- konversation-1.2.2.orig/src/config/konversation.kcfg 2010-02-11 12:57:29.000000000 -0500
90
+++ konversation-1.2.2/src/config/konversation.kcfg 2010-02-11 14:53:29.113601913 -0500
92
<whatsthis></whatsthis>
95
+ <group name="MessageIndicator">
96
+ <entry key="MessageIndicatorShowOwnNick" type="Bool">
97
+ <default>true</default>
99
+ <whatsthis></whatsthis>
101
+ <entry key="MessageIndicatorShowChannel" type="Bool">
102
+ <default>false</default>
104
+ <whatsthis></whatsthis>
106
+ <entry key="MessageIndicatorShowQuery" type="Bool">
107
+ <default>true</default>
109
+ <whatsthis></whatsthis>
112
<group name="Notify List">
113
<entry key="NotifyDelay" type="Int">
114
<default>20</default>
115
Index: konversation-1.2.2/src/config/messageindicator_config.ui
116
===================================================================
117
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
118
+++ konversation-1.2.2/src/config/messageindicator_config.ui 2010-02-11 14:53:29.113601913 -0500
120
+<?xml version="1.0" encoding="UTF-8"?>
122
+ <class>MessageIndicator_Config</class>
123
+ <widget class="QWidget" name="MessageIndicator_Config">
124
+ <property name="geometry">
129
+ <height>155</height>
132
+ <property name="windowTitle">
133
+ <string>Form</string>
135
+ <layout class="QVBoxLayout" name="verticalLayout">
137
+ <widget class="QGroupBox" name="groupBox">
138
+ <property name="title">
139
+ <string>Use Message Indicator</string>
141
+ <layout class="QVBoxLayout" name="verticalLayout_2">
143
+ <widget class="QCheckBox" name="kcfg_MessageIndicatorShowOwnNick">
144
+ <property name="text">
145
+ <string>If own nick appears in channel message</string>
150
+ <widget class="QCheckBox" name="kcfg_MessageIndicatorShowChannel">
151
+ <property name="text">
152
+ <string>On any channel message</string>
157
+ <widget class="QCheckBox" name="kcfg_MessageIndicatorShowQuery">
158
+ <property name="text">
159
+ <string>On query activity</string>
167
+ <spacer name="verticalSpacer">
168
+ <property name="orientation">
169
+ <enum>Qt::Vertical</enum>
171
+ <property name="sizeHint" stdset="0">
174
+ <height>40</height>
182
+ <tabstop>kcfg_MessageIndicatorShowOwnNick</tabstop>
183
+ <tabstop>kcfg_MessageIndicatorShowChannel</tabstop>
184
+ <tabstop>kcfg_MessageIndicatorShowQuery</tabstop>
189
Index: konversation-1.2.2/src/config/settingsdialog.cpp
190
===================================================================
191
--- konversation-1.2.2.orig/src/config/settingsdialog.cpp 2010-02-11 12:57:29.000000000 -0500
192
+++ konversation-1.2.2/src/config/settingsdialog.cpp 2010-02-11 14:53:29.117600745 -0500
194
Copyright (C) 2006 Eike Hein <hein@kde.org>
197
+#include "config-konversation.h"
198
#include "settingsdialog.h"
199
#include "configdialog.h"
200
#include "preferences.h"
203
#include <config-konversation.h>
205
+#ifdef HAVE_INDICATEQT
206
+#include "ui_messageindicator_config.h"
210
KonviSettingsDialog::KonviSettingsDialog( QWidget *parent) :
211
KonviConfigDialog( parent, "settings", Preferences::self(), KPageDialog::Tree)
213
//no modified connection needed - it's all kcfg widgets
214
m_pages.append(m_confOSDWdg);
216
+ #ifdef HAVE_INDICATEQT
217
+ //Notification/Message Indicator
218
+ Ui::MessageIndicator_Config confMessageIndicator;
220
+ confMessageIndicator.setupUi(w);
221
+ addPage(w, notificationGroup, "mail-unread-new", i18n("Message Indicator"));
224
//Notification/Warning Dialogs
225
m_confWarningsWdg = new Warnings_Config( this, "Warnings" );
226
addPage ( m_confWarningsWdg, notificationGroup, "dialog-warning", i18n("Warning Dialogs") );
227
Index: konversation-1.2.2/src/notificationhandler.cpp
228
===================================================================
229
--- konversation-1.2.2.orig/src/notificationhandler.cpp 2010-02-11 12:57:29.000000000 -0500
230
+++ konversation-1.2.2/src/notificationhandler.cpp 2010-02-11 14:53:29.117600745 -0500
232
#include "viewcontainer.h"
233
#include "trayicon.h"
235
+#include "config-konversation.h"
237
#include <QTextDocument>
239
#include <KNotification>
240
+#include <KWindowSystem>
242
+#ifdef HAVE_INDICATEQT
243
+#include <qindicateindicator.h>
244
+#include <qindicateserver.h>
246
+class Indicator : public QIndicate::Indicator
249
+ Indicator(QIndicate::Server* server)
250
+ : QIndicate::Indicator(server)
253
+ QPointer<ChatWindow> m_chatWin;
257
namespace Konversation
262
m_mainWindow = parent->getMainWindow();
263
+ #ifdef HAVE_INDICATEQT
264
+ m_indicateServer = QIndicate::Server::defaultInstance();
265
+ m_indicateServer->setType("message.irc");
266
+ QString appName = KGlobal::mainComponent().componentName();
267
+ kDebug() << "appName" << appName;
268
+ KService::Ptr service = KService::serviceByDesktopName(appName);
270
+ m_indicateServer->setDesktopFile(service->entryPath());
272
+ kWarning() << "Could not find desktop file for application";
274
+ connect(m_indicateServer, SIGNAL(serverDisplay()),
275
+ SLOT(slotIndicateServerDisplay()));
276
+ m_indicateServer->show();
278
+ m_mainWindow->installEventFilter(this);
282
NotificationHandler::~NotificationHandler()
284
if (!chatWin || !chatWin->notificationsEnabled())
287
+ if (Preferences::self()->messageIndicatorShowChannel())
288
+ addIndicator(chatWin, fromNick);
290
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
294
if (!chatWin || !chatWin->notificationsEnabled())
297
+ if (Preferences::self()->messageIndicatorShowOwnNick())
298
+ addIndicator(chatWin, fromNick);
300
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
304
if (!chatWin || !chatWin->notificationsEnabled())
307
+ if (Preferences::self()->messageIndicatorShowQuery())
308
+ addIndicator(chatWin, fromNick);
310
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
317
+ void NotificationHandler::addIndicator(ChatWindow* chatWin, const QString& nick)
319
+ #ifdef HAVE_INDICATEQT
320
+ ViewContainer* viewContainer = m_mainWindow->getViewContainer();
321
+ if (m_mainWindow->isActiveWindow() && chatWin == viewContainer->getFrontView()) {
322
+ // Do not show indicator if the user is already using this chat
326
+ Indicator* indicator = m_indicatorForChatWindow.value(chatWin);
328
+ indicator = new Indicator(m_indicateServer);
329
+ indicator->m_chatWin = chatWin;
330
+ m_indicatorForChatWindow.insert(chatWin, indicator);
331
+ connect(chatWin, SIGNAL(closing(ChatWindow*)), SLOT(deleteIndicatorForChatWindow(ChatWindow*)));
332
+ connect(viewContainer, SIGNAL(viewChanged(ChatWindow*)), SLOT(slotViewChanged(ChatWindow*)));
334
+ connect(indicator, SIGNAL(display(QIndicate::Indicator*)), SLOT(slotIndicatorDisplay(QIndicate::Indicator*)));
338
+ if (chatWin->getType() == ChatWindow::Query) {
341
+ name = QString("%1 (%2)").arg(chatWin->getName()).arg(nick);
343
+ indicator->setNameProperty(name);
344
+ indicator->setTimeProperty(QDateTime::currentDateTime());
345
+ indicator->setDrawAttentionProperty(true);
349
+ void NotificationHandler::slotIndicatorDisplay(QIndicate::Indicator* _indicator)
351
+ #ifdef HAVE_INDICATEQT
352
+ Indicator* indicator = static_cast<Indicator*>(_indicator);
353
+ ChatWindow* chatWin = indicator->m_chatWin;
354
+ m_indicatorForChatWindow.remove(chatWin);
357
+ m_mainWindow->show();
358
+ KWindowSystem::forceActiveWindow(m_mainWindow->winId());
360
+ m_mainWindow->getViewContainer()->showView(chatWin);
361
+ chatWin->adjustFocus();
366
+ void NotificationHandler::slotIndicateServerDisplay()
368
+ m_mainWindow->show();
369
+ KWindowSystem::forceActiveWindow(m_mainWindow->winId());
372
+ void NotificationHandler::deleteIndicatorForChatWindow(ChatWindow* chatWin)
374
+ #ifdef HAVE_INDICATEQT
375
+ delete m_indicatorForChatWindow.take(chatWin);
379
+ void NotificationHandler::slotViewChanged(ChatWindow* chatWin)
381
+ #ifdef HAVE_INDICATEQT
382
+ deleteIndicatorForChatWindow(chatWin);
386
+ bool NotificationHandler::eventFilter(QObject*, QEvent* event)
388
+ #ifdef HAVE_INDICATEQT
389
+ if (event->type() == QEvent::WindowActivate) {
390
+ ViewContainer* viewContainer = m_mainWindow->getViewContainer();
391
+ QPointer<ChatWindow> chatWin = viewContainer->getFrontView();
393
+ deleteIndicatorForChatWindow(chatWin);
403
#include "notificationhandler.moc"
404
Index: konversation-1.2.2/src/notificationhandler.h
405
===================================================================
406
--- konversation-1.2.2.orig/src/notificationhandler.h 2010-02-11 12:57:29.000000000 -0500
407
+++ konversation-1.2.2/src/notificationhandler.h 2010-02-11 14:53:29.117600745 -0500
409
#ifndef KONVERSATIONNOTIFICATIONHANDLER_H
410
#define KONVERSATIONNOTIFICATIONHANDLER_H
420
-namespace Konversation
428
+namespace Konversation
430
class NotificationHandler : public QObject
435
void startTrayNotification(ChatWindow* chatWin);
436
QString addLineBreaks(const QString& string);
437
+ virtual bool eventFilter(QObject*, QEvent*);
440
+ void slotIndicatorDisplay(QIndicate::Indicator*);
441
+ void slotIndicateServerDisplay();
442
+ void deleteIndicatorForChatWindow(ChatWindow*);
443
+ void slotViewChanged(ChatWindow* chatWin);
446
MainWindow* m_mainWindow;
447
+ QIndicate::Server* m_indicateServer;
448
+ QHash<ChatWindow*, Indicator*> m_indicatorForChatWindow;
450
+ void addIndicator(ChatWindow*, const QString& nick);