~ubuntu-branches/ubuntu/raring/konversation/raring-proposed

« back to all changes in this revision

Viewing changes to debian/patches/kubuntu/0001-Adds-support-for-Message-Indicator.diff

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-08-11 17:53:27 UTC
  • Revision ID: james.westby@ubuntu.com-20100811175327-vj8gal6554f0cdck
Tags: 1.3.1-1ubuntu2
* Add back correct debian/patches/series file, adds back in
  kubuntu_01_default_channels.diff message-indicator/0001-Adds-
  support-for-Message-Indicator.diff LP: #616422
* Remove obsolete debian/patches/kubuntu/ directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
 
 
6
 
---
7
 
 CMakeLists.txt                        |    5 ++
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
17
 
 
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
22
 
@@ -8,6 +8,7 @@
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)
27
 
 include(KDE4Defaults)
28
 
 include(MacroLibrary)
29
 
 include(CheckIncludeFile)
30
 
@@ -37,6 +38,10 @@
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")
33
 
 
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")
37
 
+
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
45
 
@@ -2,4 +2,5 @@
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
57
 
@@ -126,6 +126,7 @@
58
 
     config/theme_configui.ui
59
 
     config/warnings_configui.ui
60
 
     config/watchednicknames_configui.ui
61
 
+    config/messageindicator_config.ui
62
 
 )
63
 
 
64
 
     #=== Viewer
65
 
@@ -198,6 +199,11 @@
66
 
         cipher.cpp)
67
 
 endif (QCA2_FOUND)
68
 
 
69
 
+if (INDICATEQT_FOUND)
70
 
+    include_directories(${INDICATEQT_INCLUDE_DIRS})
71
 
+    link_directories(${INDICATEQT_LIBRARY_DIRS})
72
 
+endif (INDICATEQT_FOUND)
73
 
+
74
 
 set(upnp_SRCS
75
 
     upnp/soap.cpp
76
 
     upnp/upnpdescriptionparser.cpp
77
 
@@ -230,7 +236,8 @@
78
 
 
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})
84
 
 
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
91
 
@@ -518,6 +518,23 @@
92
 
       <whatsthis></whatsthis>
93
 
     </entry>
94
 
   </group>
95
 
+  <group name="MessageIndicator">
96
 
+    <entry key="MessageIndicatorShowOwnNick" type="Bool">
97
 
+      <default>true</default>
98
 
+      <label></label>
99
 
+      <whatsthis></whatsthis>
100
 
+    </entry>
101
 
+    <entry key="MessageIndicatorShowChannel" type="Bool">
102
 
+      <default>false</default>
103
 
+      <label></label>
104
 
+      <whatsthis></whatsthis>
105
 
+    </entry>
106
 
+    <entry key="MessageIndicatorShowQuery" type="Bool">
107
 
+      <default>true</default>
108
 
+      <label></label>
109
 
+      <whatsthis></whatsthis>
110
 
+    </entry>
111
 
+  </group>
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
119
 
@@ -0,0 +1,69 @@
120
 
+<?xml version="1.0" encoding="UTF-8"?>
121
 
+<ui version="4.0">
122
 
+ <class>MessageIndicator_Config</class>
123
 
+ <widget class="QWidget" name="MessageIndicator_Config">
124
 
+  <property name="geometry">
125
 
+   <rect>
126
 
+    <x>0</x>
127
 
+    <y>0</y>
128
 
+    <width>400</width>
129
 
+    <height>155</height>
130
 
+   </rect>
131
 
+  </property>
132
 
+  <property name="windowTitle">
133
 
+   <string>Form</string>
134
 
+  </property>
135
 
+  <layout class="QVBoxLayout" name="verticalLayout">
136
 
+   <item>
137
 
+    <widget class="QGroupBox" name="groupBox">
138
 
+     <property name="title">
139
 
+      <string>Use Message Indicator</string>
140
 
+     </property>
141
 
+     <layout class="QVBoxLayout" name="verticalLayout_2">
142
 
+      <item>
143
 
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowOwnNick">
144
 
+        <property name="text">
145
 
+         <string>If own nick appears in channel message</string>
146
 
+        </property>
147
 
+       </widget>
148
 
+      </item>
149
 
+      <item>
150
 
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowChannel">
151
 
+        <property name="text">
152
 
+         <string>On any channel message</string>
153
 
+        </property>
154
 
+       </widget>
155
 
+      </item>
156
 
+      <item>
157
 
+       <widget class="QCheckBox" name="kcfg_MessageIndicatorShowQuery">
158
 
+        <property name="text">
159
 
+         <string>On query activity</string>
160
 
+        </property>
161
 
+       </widget>
162
 
+      </item>
163
 
+     </layout>
164
 
+    </widget>
165
 
+   </item>
166
 
+   <item>
167
 
+    <spacer name="verticalSpacer">
168
 
+     <property name="orientation">
169
 
+      <enum>Qt::Vertical</enum>
170
 
+     </property>
171
 
+     <property name="sizeHint" stdset="0">
172
 
+      <size>
173
 
+       <width>20</width>
174
 
+       <height>40</height>
175
 
+      </size>
176
 
+     </property>
177
 
+    </spacer>
178
 
+   </item>
179
 
+  </layout>
180
 
+ </widget>
181
 
+ <tabstops>
182
 
+  <tabstop>kcfg_MessageIndicatorShowOwnNick</tabstop>
183
 
+  <tabstop>kcfg_MessageIndicatorShowChannel</tabstop>
184
 
+  <tabstop>kcfg_MessageIndicatorShowQuery</tabstop>
185
 
+ </tabstops>
186
 
+ <resources/>
187
 
+ <connections/>
188
 
+</ui>
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
193
 
@@ -10,6 +10,7 @@
194
 
   Copyright (C) 2006 Eike Hein <hein@kde.org>
195
 
 */
196
 
 
197
 
+#include "config-konversation.h"
198
 
 #include "settingsdialog.h"
199
 
 #include "configdialog.h"
200
 
 #include "preferences.h"
201
 
@@ -36,6 +37,10 @@
202
 
 
203
 
 #include <config-konversation.h>
204
 
 
205
 
+#ifdef HAVE_INDICATEQT
206
 
+#include "ui_messageindicator_config.h"
207
 
+#endif
208
 
+
209
 
 
210
 
 KonviSettingsDialog::KonviSettingsDialog( QWidget *parent) :
211
 
     KonviConfigDialog( parent, "settings", Preferences::self(), KPageDialog::Tree)
212
 
@@ -176,6 +181,14 @@
213
 
   //no modified connection needed - it's all kcfg widgets
214
 
   m_pages.append(m_confOSDWdg);
215
 
 
216
 
+  #ifdef HAVE_INDICATEQT
217
 
+  //Notification/Message Indicator
218
 
+  Ui::MessageIndicator_Config confMessageIndicator;
219
 
+  w = new QWidget();
220
 
+  confMessageIndicator.setupUi(w);
221
 
+  addPage(w, notificationGroup, "mail-unread-new", i18n("Message Indicator"));
222
 
+  #endif
223
 
+
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
231
 
@@ -18,11 +18,27 @@
232
 
 #include "viewcontainer.h"
233
 
 #include "trayicon.h"
234
 
 #include "server.h"
235
 
+#include "config-konversation.h"
236
 
 
237
 
 #include <QTextDocument>
238
 
 
239
 
 #include <KNotification>
240
 
+#include <KWindowSystem>
241
 
 
242
 
+#ifdef HAVE_INDICATEQT
243
 
+#include <qindicateindicator.h>
244
 
+#include <qindicateserver.h>
245
 
+
246
 
+class Indicator : public QIndicate::Indicator
247
 
+{
248
 
+    public:
249
 
+        Indicator(QIndicate::Server* server)
250
 
+        : QIndicate::Indicator(server)
251
 
+        {}
252
 
+
253
 
+        QPointer<ChatWindow> m_chatWin;
254
 
+};
255
 
+#endif
256
 
 
257
 
 namespace Konversation
258
 
 {
259
 
@@ -31,6 +47,23 @@
260
 
         : QObject(parent)
261
 
     {
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);
269
 
+        if (service) {
270
 
+            m_indicateServer->setDesktopFile(service->entryPath());
271
 
+        } else {
272
 
+            kWarning() << "Could not find desktop file for application";
273
 
+        }
274
 
+        connect(m_indicateServer, SIGNAL(serverDisplay()),
275
 
+            SLOT(slotIndicateServerDisplay()));
276
 
+        m_indicateServer->show();
277
 
+
278
 
+        m_mainWindow->installEventFilter(this);
279
 
+        #endif
280
 
     }
281
 
 
282
 
     NotificationHandler::~NotificationHandler()
283
 
@@ -48,6 +81,9 @@
284
 
         if (!chatWin || !chatWin->notificationsEnabled())
285
 
             return;
286
 
 
287
 
+        if (Preferences::self()->messageIndicatorShowChannel())
288
 
+            addIndicator(chatWin, fromNick);
289
 
+
290
 
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
291
 
             return;
292
 
 
293
 
@@ -76,6 +112,9 @@
294
 
         if (!chatWin || !chatWin->notificationsEnabled())
295
 
             return;
296
 
 
297
 
+        if (Preferences::self()->messageIndicatorShowOwnNick())
298
 
+            addIndicator(chatWin, fromNick);
299
 
+
300
 
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
301
 
             return;
302
 
 
303
 
@@ -102,6 +141,9 @@
304
 
         if (!chatWin || !chatWin->notificationsEnabled())
305
 
             return;
306
 
 
307
 
+        if (Preferences::self()->messageIndicatorShowQuery())
308
 
+            addIndicator(chatWin, fromNick);
309
 
+
310
 
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
311
 
             return;
312
 
 
313
 
@@ -378,6 +420,90 @@
314
 
         return cutup;
315
 
     }
316
 
 
317
 
+    void NotificationHandler::addIndicator(ChatWindow* chatWin, const QString& nick)
318
 
+    {
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
323
 
+            // window
324
 
+            return;
325
 
+        }
326
 
+        Indicator* indicator = m_indicatorForChatWindow.value(chatWin);
327
 
+        if (!indicator) {
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*)));
333
 
+
334
 
+            connect(indicator, SIGNAL(display(QIndicate::Indicator*)), SLOT(slotIndicatorDisplay(QIndicate::Indicator*)));
335
 
+            indicator->show();
336
 
+        }
337
 
+        QString name;
338
 
+        if (chatWin->getType() == ChatWindow::Query) {
339
 
+            name = nick;
340
 
+        } else {
341
 
+            name = QString("%1 (%2)").arg(chatWin->getName()).arg(nick);
342
 
+        }
343
 
+        indicator->setNameProperty(name);
344
 
+        indicator->setTimeProperty(QDateTime::currentDateTime());
345
 
+        indicator->setDrawAttentionProperty(true);
346
 
+        #endif
347
 
+    }
348
 
+
349
 
+    void NotificationHandler::slotIndicatorDisplay(QIndicate::Indicator* _indicator)
350
 
+    {
351
 
+        #ifdef HAVE_INDICATEQT
352
 
+        Indicator* indicator = static_cast<Indicator*>(_indicator);
353
 
+        ChatWindow* chatWin = indicator->m_chatWin;
354
 
+        m_indicatorForChatWindow.remove(chatWin);
355
 
+        delete indicator;
356
 
+
357
 
+        m_mainWindow->show();
358
 
+        KWindowSystem::forceActiveWindow(m_mainWindow->winId());
359
 
+        if (chatWin) {
360
 
+            m_mainWindow->getViewContainer()->showView(chatWin);
361
 
+            chatWin->adjustFocus();
362
 
+        }
363
 
+        #endif
364
 
+    }
365
 
+
366
 
+    void NotificationHandler::slotIndicateServerDisplay()
367
 
+    {
368
 
+        m_mainWindow->show();
369
 
+        KWindowSystem::forceActiveWindow(m_mainWindow->winId());
370
 
+    }
371
 
+
372
 
+    void NotificationHandler::deleteIndicatorForChatWindow(ChatWindow* chatWin)
373
 
+    {
374
 
+        #ifdef HAVE_INDICATEQT
375
 
+        delete m_indicatorForChatWindow.take(chatWin);
376
 
+        #endif
377
 
+    }
378
 
+
379
 
+    void NotificationHandler::slotViewChanged(ChatWindow* chatWin)
380
 
+    {
381
 
+        #ifdef HAVE_INDICATEQT
382
 
+        deleteIndicatorForChatWindow(chatWin);
383
 
+        #endif
384
 
+    }
385
 
+
386
 
+    bool NotificationHandler::eventFilter(QObject*, QEvent* event)
387
 
+    {
388
 
+        #ifdef HAVE_INDICATEQT
389
 
+        if (event->type() == QEvent::WindowActivate) {
390
 
+            ViewContainer* viewContainer = m_mainWindow->getViewContainer();
391
 
+            QPointer<ChatWindow> chatWin = viewContainer->getFrontView();
392
 
+            if (chatWin) {
393
 
+                deleteIndicatorForChatWindow(chatWin);
394
 
+            }
395
 
+        }
396
 
+        #else
397
 
+        Q_UNUSED(event);
398
 
+        #endif
399
 
+        return false;
400
 
+    }
401
 
 }
402
 
 
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
408
 
@@ -12,6 +12,7 @@
409
 
 #ifndef KONVERSATIONNOTIFICATIONHANDLER_H
410
 
 #define KONVERSATIONNOTIFICATIONHANDLER_H
411
 
 
412
 
+#include <QHash>
413
 
 #include <QObject>
414
 
 
415
 
 
416
 
@@ -19,9 +20,15 @@
417
 
 class Application;
418
 
 class MainWindow;
419
 
 
420
 
-namespace Konversation
421
 
+namespace QIndicate
422
 
 {
423
 
+    class Server;
424
 
+    class Indicator;
425
 
+}
426
 
+class Indicator;
427
 
 
428
 
+namespace Konversation
429
 
+{
430
 
     class NotificationHandler : public QObject
431
 
     {
432
 
         Q_OBJECT
433
 
@@ -54,9 +61,20 @@
434
 
         protected:
435
 
             void startTrayNotification(ChatWindow* chatWin);
436
 
             QString addLineBreaks(const QString& string);
437
 
+            virtual bool eventFilter(QObject*, QEvent*);
438
 
+
439
 
+        private slots:
440
 
+            void slotIndicatorDisplay(QIndicate::Indicator*);
441
 
+            void slotIndicateServerDisplay();
442
 
+            void deleteIndicatorForChatWindow(ChatWindow*);
443
 
+            void slotViewChanged(ChatWindow* chatWin);
444
 
 
445
 
         private:
446
 
             MainWindow* m_mainWindow;
447
 
+            QIndicate::Server* m_indicateServer;
448
 
+            QHash<ChatWindow*, Indicator*> m_indicatorForChatWindow;
449
 
+
450
 
+            void addIndicator(ChatWindow*, const QString& nick);
451
 
     };
452
 
 
453
 
 }