[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:20:19 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=5d5066b

The following commit has been merged in the master branch:
commit 5d5066bc0eb750d51e76033aff45a3bf2bdd288c
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Oct 15 17:25:20 2011 +0100

    Rewrite "clear unread messages"
    
    Get rid of the complex event filter, that was broken. It is now the responsibility of the app using the chat widget to clear the
    unread message count when it is activated.
    
    REVIEW: 102873
---
 app/chat-window.cpp | 17 ++++++++++++++++-
 app/chat-window.h   |  4 ++++
 lib/chat-widget.cpp | 40 ----------------------------------------
 lib/chat-widget.h   | 10 +++++++---
 4 files changed, 27 insertions(+), 44 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 23f3cf4..42393d3 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -39,12 +39,14 @@
 #include <KNotifyConfigWidget>
 #include <KMenuBar>
 #include <KLineEdit>
+#include <KMenu>
+
+#include <QEvent>
 
 #include <TelepathyQt4/Account>
 #include <TelepathyQt4/ContactCapabilities>
 #include <TelepathyQt4/PendingChannelRequest>
 #include <TelepathyQt4/TextChannel>
-#include <KMenu>
 
 #define PREFERRED_TEXTCHAT_HANDLER "org.freedesktop.Telepathy.Client.KDE.TextUi"
 #define PREFERRED_FILETRANSFER_HANDLER "org.freedesktop.Telepathy.Client.KDE.FileTransfer"
@@ -248,6 +250,7 @@ void ChatWindow::onCurrentIndexChanged(int index)
     }
 
     ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
+    currentChatTab->resetUnreadMessageCount();
     setWindowTitle(currentChatTab->title());
     setWindowIcon(currentChatTab->icon());
 
@@ -594,4 +597,16 @@ void ChatWindow::onUserTypingChanged(bool typing)
     }
 }
 
+bool ChatWindow::event(QEvent *e)
+{
+    if (e->type() == QEvent::WindowActivate) {
+        //when the window is activated reset the message count on the active tab.
+        ChatWidget *currChat =  qobject_cast<ChatWidget*>(m_tabWidget->currentWidget());
+        Q_ASSERT(currChat);
+        currChat->resetUnreadMessageCount();
+    }
+
+    return KXmlGuiWindow::event(e);
+}
+
 #include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index 36f33da..9ebf339 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -66,6 +66,10 @@ Q_SIGNALS:
 public Q_SLOTS:
     void destroyTab(QWidget *chatWidget);
 
+protected:
+    virtual bool event(QEvent *e);
+
+
 private Q_SLOTS:
     void tabBarContextMenu(int  index, const QPoint &  globalPos);
     void closeCurrentTab();
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 3c83b12..5fedbd4 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -72,25 +72,6 @@ Q_SIGNALS:
     void returnKeyPressed();
 };
 
-class WindowEventFilter : public QObject
-{
-    Q_OBJECT
-public:
-    WindowEventFilter(QObject* parent = 0) : QObject(parent) {}
-
-protected:
-    virtual bool eventFilter(QObject *obj, QEvent *event)
-    {
-        if (event->type() == QEvent::ActivationChange) {
-            Q_EMIT windowActivated();
-        }
-        return QObject::eventFilter(obj, event);
-    }
-
-Q_SIGNALS:
-    void windowActivated();
-};
-
 class ChatWidgetPrivate
 {
 public:
@@ -218,10 +199,6 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
     connect(messageBoxEventFilter, SIGNAL(returnKeyPressed()), SLOT(sendMessage()));
     connect(d->ui.sendButton, SIGNAL(clicked()), SLOT(sendMessage()));
 
-    WindowEventFilter *windowEventFilter = new WindowEventFilter(this);
-    this->window()->installEventFilter(windowEventFilter);
-    connect(windowEventFilter, SIGNAL(windowActivated()), SLOT(windowActivated()));
-
     // find text in chat
     connect(d->ui.sendMessageBox, SIGNAL(findTextShortcutPressed()), this, SLOT(toggleSearchBar()));
     connect(d->ui.searchBar, SIGNAL(findTextSignal(QString,QWebPage::FindFlags)), this, SLOT(findTextInChat(QString,QWebPage::FindFlags)));
@@ -339,15 +316,6 @@ Tp::TextChannelPtr ChatWidget::textChannel() const
     return d->channel;
 }
 
-void ChatWidget::showEvent(QShowEvent* e)
-{
-    kDebug();
-
-    resetUnreadMessageCount();
-
-    QWidget::showEvent(e);
-}
-
 void ChatWidget::keyPressEvent(QKeyEvent* e)
 {
     if (e->key() == Qt::Key_Escape && d->ui.searchBar->isVisible()) {
@@ -452,14 +420,6 @@ void ChatWidget::incrementUnreadMessageCount()
     Q_EMIT unreadMessagesChanged(d->unreadMessages);
 }
 
-void ChatWidget::windowActivated()
-{
-    kDebug();
-    if (isOnTop()) {
-        resetUnreadMessageCount();
-    }
-}
-
 void ChatWidget::onHistoryFetched(const QList<AdiumThemeContentInfo> &messages)
 {
     kDebug() << "found" << messages.count() << "messages in history";
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 630538b..61538c9 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -81,10 +81,16 @@ public Q_SLOTS:
     /** toggle the search bar visibility */
     void toggleSearchBar() const;
 
+    /** Clear the list of unread messages
+        call this when the widget is activated by the user.
+      */
+    void resetUnreadMessageCount();
+
+
+
 protected:
     void changeEvent(QEvent *e);
     void resizeEvent(QResizeEvent *);
-    void showEvent(QShowEvent *e);
     void keyPressEvent(QKeyEvent *e);
 
 protected Q_SLOTS:
@@ -143,7 +149,6 @@ private Q_SLOTS:
     void findNextTextInChat(const QString &text, QWebPage::FindFlags flags);
     void findPreviousTextInChat(const QString &text, QWebPage::FindFlags flags);
     void onFormatColorReleased();
-    void windowActivated();
     void onHistoryFetched(const QList<AdiumThemeContentInfo> &messages);
 
 private:
@@ -154,7 +159,6 @@ private:
     void setupContactModelSignals();
 
     void incrementUnreadMessageCount();
-    void resetUnreadMessageCount();
     virtual bool isOnTop() const;
 
     //FIXME this should be in the ktelepathy lib

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list