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

« back to all changes in this revision

Viewing changes to debian/patches/kubuntu/0001-Initial-support-for-indicators.diff

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-06-07 16:24:06 UTC
  • Revision ID: james.westby@ubuntu.com-20100607162406-vflxoc1nfhxd9t7v
Tags: 1.3-0ubuntu1
* New upstream release:
  - Drop backport_aa233e3_close_buttons_fix.diff, merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
5
 
 
6
---
 
7
 CMakeLists.txt              |    5 ++
 
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(-)
 
13
 
 
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
 
18
@@ -8,6 +8,7 @@
 
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)
 
23
 include(KDE4Defaults)
 
24
 include(MacroLibrary)
 
25
 include(CheckIncludeFile)
 
26
@@ -41,6 +42,10 @@
 
27
 macro_ensure_version( "4.3.80" ${KDE_VERSION} HAVEKDE4_4 )
 
28
 macro_bool_to_01(HAVEKDE4_4 HAVE_KSTATUSNOTIFIERITEM)
 
29
 
 
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")
 
33
+
 
34
 configure_file(config-konversation.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-konversation.h )
 
35
 
 
36
 add_subdirectory(src)
 
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
 
41
@@ -2,4 +2,5 @@
 
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
 
53
@@ -198,6 +198,11 @@
 
54
         cipher.cpp)
 
55
 endif (QCA2_FOUND)
 
56
 
 
57
+if (INDICATEQT_FOUND)
 
58
+    include_directories(${INDICATEQT_INCLUDE_DIRS})
 
59
+    link_directories(${INDICATEQT_LIBRARY_DIRS})
 
60
+endif (INDICATEQT_FOUND)
 
61
+
 
62
 set(upnp_SRCS
 
63
     upnp/soap.cpp
 
64
     upnp/upnpdescriptionparser.cpp
 
65
@@ -230,7 +235,8 @@
 
66
 
 
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})
 
72
 
 
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
 
79
@@ -18,11 +18,27 @@
 
80
 #include "viewcontainer.h"
 
81
 #include "trayicon.h"
 
82
 #include "server.h"
 
83
+#include "config-konversation.h"
 
84
 
 
85
 #include <QTextDocument>
 
86
 
 
87
 #include <KNotification>
 
88
+#include <KWindowSystem>
 
89
 
 
90
+#ifdef HAVE_INDICATEQT
 
91
+#include <qindicateindicator.h>
 
92
+#include <qindicateserver.h>
 
93
+
 
94
+class Indicator : public QIndicate::Indicator
 
95
+{
 
96
+    public:
 
97
+        Indicator(QIndicate::Server* server)
 
98
+        : QIndicate::Indicator(server)
 
99
+        {}
 
100
+
 
101
+        QPointer<ChatWindow> m_chatWin;
 
102
+};
 
103
+#endif
 
104
 
 
105
 namespace Konversation
 
106
 {
 
107
@@ -31,6 +47,21 @@
 
108
         : QObject(parent)
 
109
     {
 
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);
 
117
+        if (service) {
 
118
+            m_indicateServer->setDesktopFile(service->entryPath());
 
119
+        } else {
 
120
+            kWarning() << "Could not find desktop file for application";
 
121
+        }
 
122
+        connect(m_indicateServer, SIGNAL(serverDisplay()),
 
123
+            SLOT(slotIndicateServerDisplay()));
 
124
+        m_indicateServer->show();
 
125
+        #endif
 
126
     }
 
127
 
 
128
     NotificationHandler::~NotificationHandler()
 
129
@@ -42,6 +73,8 @@
 
130
         if (!chatWin || !chatWin->notificationsEnabled())
 
131
             return;
 
132
 
 
133
+        addIndicator(chatWin, fromNick);
 
134
+
 
135
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
 
136
             return;
 
137
 
 
138
@@ -70,6 +103,8 @@
 
139
         if (!chatWin || !chatWin->notificationsEnabled())
 
140
             return;
 
141
 
 
142
+        addIndicator(chatWin, fromNick);
 
143
+
 
144
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
 
145
             return;
 
146
 
 
147
@@ -96,6 +131,8 @@
 
148
         if (!chatWin || !chatWin->notificationsEnabled())
 
149
             return;
 
150
 
 
151
+        addIndicator(chatWin, fromNick);
 
152
+
 
153
         if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
 
154
             return;
 
155
 
 
156
@@ -372,6 +409,79 @@
 
157
         return cutup;
 
158
     }
 
159
 
 
160
+    void NotificationHandler::addIndicator(ChatWindow* chatWin, const QString& nick)
 
161
+    {
 
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
 
166
+            // window
 
167
+            return;
 
168
+        }
 
169
+        Indicator* indicator = m_indicatorForChatWindow.value(chatWin);
 
170
+        if (!indicator) {
 
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*)));
 
176
+
 
177
+            connect(indicator, SIGNAL(display(QIndicate::Indicator*)), SLOT(slotIndicatorDisplay(QIndicate::Indicator*)));
 
178
+            indicator->show();
 
179
+        }
 
180
+        QString name;
 
181
+        if (chatWin->getType() == ChatWindow::Query) {
 
182
+            name = nick;
 
183
+        } else {
 
184
+            name = QString("%1 (%2)").arg(chatWin->getName()).arg(nick);
 
185
+        }
 
186
+        indicator->setNameProperty(name);
 
187
+        indicator->setTimeProperty(QDateTime::currentDateTime());
 
188
+        indicator->setDrawAttentionProperty(true);
 
189
+        #endif
 
190
+    }
 
191
+
 
192
+    void NotificationHandler::slotIndicatorDisplay(QIndicate::Indicator* _indicator)
 
193
+    {
 
194
+        #ifdef HAVE_INDICATEQT
 
195
+        Indicator* indicator = static_cast<Indicator*>(_indicator);
 
196
+        ChatWindow* chatWin = indicator->m_chatWin;
 
197
+        m_indicatorForChatWindow.remove(chatWin);
 
198
+        delete indicator;
 
199
+
 
200
+        m_mainWindow->show();
 
201
+        KWindowSystem::forceActiveWindow(m_mainWindow->winId());
 
202
+        if (chatWin) {
 
203
+            m_mainWindow->getViewContainer()->showView(chatWin);
 
204
+            chatWin->adjustFocus();
 
205
+        }
 
206
+        #endif
 
207
+    }
 
208
+
 
209
+    void NotificationHandler::slotIndicateServerDisplay()
 
210
+    {
 
211
+        KWindowInfo info = KWindowSystem::windowInfo(m_mainWindow->winId(), NET::WMDesktop);
 
212
+        if (m_mainWindow->isVisible() && info.isOnCurrentDesktop()) {
 
213
+            m_mainWindow->hide();
 
214
+        } else {
 
215
+            m_mainWindow->show();
 
216
+            KWindowSystem::forceActiveWindow(m_mainWindow->winId());
 
217
+        }
 
218
+    }
 
219
+
 
220
+    void NotificationHandler::deleteIndicatorForChatWindow(ChatWindow* chatWin)
 
221
+    {
 
222
+        #ifdef HAVE_INDICATEQT
 
223
+        delete m_indicatorForChatWindow.take(chatWin);
 
224
+        #endif
 
225
+    }
 
226
+
 
227
+    void NotificationHandler::slotViewChanged(ChatWindow* chatWin)
 
228
+    {
 
229
+        #ifdef HAVE_INDICATEQT
 
230
+        deleteIndicatorForChatWindow(chatWin);
 
231
+        #endif
 
232
+    }
 
233
 }
 
234
 
 
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
 
240
@@ -12,6 +12,7 @@
 
241
 #ifndef KONVERSATIONNOTIFICATIONHANDLER_H
 
242
 #define KONVERSATIONNOTIFICATIONHANDLER_H
 
243
 
 
244
+#include <QHash>
 
245
 #include <QObject>
 
246
 
 
247
 
 
248
@@ -19,9 +20,15 @@
 
249
 class Application;
 
250
 class MainWindow;
 
251
 
 
252
-namespace Konversation
 
253
+namespace QIndicate
 
254
 {
 
255
+    class Server;
 
256
+    class Indicator;
 
257
+}
 
258
+class Indicator;
 
259
 
 
260
+namespace Konversation
 
261
+{
 
262
     class NotificationHandler : public QObject
 
263
     {
 
264
         Q_OBJECT
 
265
@@ -55,8 +62,18 @@
 
266
             void startTrayNotification(ChatWindow* chatWin);
 
267
             QString addLineBreaks(const QString& string);
 
268
 
 
269
+        private slots:
 
270
+            void slotIndicatorDisplay(QIndicate::Indicator*);
 
271
+            void slotIndicateServerDisplay();
 
272
+            void deleteIndicatorForChatWindow(ChatWindow*);
 
273
+            void slotViewChanged(ChatWindow* chatWin);
 
274
+
 
275
         private:
 
276
             MainWindow* m_mainWindow;
 
277
+            QIndicate::Server* m_indicateServer;
 
278
+            QHash<ChatWindow*, Indicator*> m_indicatorForChatWindow;
 
279
+
 
280
+            void addIndicator(ChatWindow*, const QString& nick);
 
281
     };
 
282
 
 
283
 }