[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:19:00 UTC 2016


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

The following commit has been merged in the master branch:
commit 7929a026fd7cc3d210ee231fcb06d6899c68e7ca
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sun Mar 6 17:32:03 2011 +0000

    Tidied up to keep public API in the ChatWidget as resusable and sensible
    as possible.
---
 app/CMakeLists.txt        |  1 +
 app/chat-window.cpp       | 34 ++++------------------
 app/chat-window.h         |  3 +-
 app/telepathy-chat-ui.cpp |  1 -
 app/telepathy-chat-ui.h   |  2 --
 lib/chat-widget.cpp       | 73 ++++++++++++++++++++++++++++-------------------
 lib/chat-widget.h         | 40 ++++++++++----------------
 7 files changed, 67 insertions(+), 87 deletions(-)

diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index bd59e96..e1fda0a 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -7,6 +7,7 @@ set(telepathy_chat_handler_SRCS
         telepathy-chat-ui.cpp
         chat-window.cpp
         chattab.cpp
+        chat-window.cpp
 )
 
 kde4_add_executable(telepathy-chat-handler ${telepathy_chat_handler_SRCS})
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 01f6e84..12af8bc 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -148,19 +148,6 @@ void ChatWindow::onCurrentIndexChanged(int index)
 
 }
 
-void ChatWindow::onUserTypingChanged(bool isTyping)
-{
-    QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
-    if (sender) {
-        int tabIndex = m_tabWidget->indexOf(sender);
-        if (isTyping) {
-            setTabTextColor(tabIndex, ChatTab::colorForRole(ChatTab::CurrentlyTyping));
-        } else {
-            setTabTextColor(tabIndex, ChatTab::colorForRole(ChatTab::Default));
-        }
-    }
-}
-
 void ChatWindow::onContactPresenceChanged(const Tp::Presence& presence)
 {
     kDebug();
@@ -174,25 +161,17 @@ void ChatWindow::onContactPresenceChanged(const Tp::Presence& presence)
     }
 }
 
-void ChatWindow::onUnreadMessagesChanged()
+void ChatWindow::onTabStateChanged()
 {
     kDebug();
 
     ChatTab* sender = qobject_cast<ChatTab*>(QObject::sender());
     if (sender) {
-        int tabIndexToChange = m_tabWidget->indexOf(sender);
-        if(sender->unreadMessages() > 0) {
-            kDebug() << "New unread messages";
-            // only change tab color if the widget is hidden
-            // the slot is also triggered if the window is not active
-            if(!sender->isVisible()) {
-                setTabTextColor(tabIndexToChange, ChatTab::colorForRole(ChatTab::UnreadMessages));
-            }
-        } else {
-            kDebug() << "No unread messages anymore";
-            setTabTextColor(tabIndexToChange, sender->titleColor());
-        }
-
+        int tabIndex = m_tabWidget->indexOf(sender);
+        setTabTextColor(tabIndex, sender->titleColor());
+    }
+    else {
+        kDebug() << "AAARGH";
     }
 }
 
@@ -214,5 +193,4 @@ void ChatWindow::showNotificationsDialog()
     KNotifyConfigWidget::configure(this, "ktelepathy");
 }
 
-
 #include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index ded4114..76598d0 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -50,9 +50,8 @@ public:
 public slots:
     void removeTab(QWidget *chatWidget);
     void onCurrentIndexChanged(int index);
-    void onUserTypingChanged(bool isTyping);
     void onContactPresenceChanged(const Tp::Presence &presence);
-    void onUnreadMessagesChanged();
+    void onTabStateChanged();
 
 protected slots:
     void showSettingsDialog();
diff --git a/app/telepathy-chat-ui.cpp b/app/telepathy-chat-ui.cpp
index fca178b..c8947fc 100644
--- a/app/telepathy-chat-ui.cpp
+++ b/app/telepathy-chat-ui.cpp
@@ -73,7 +73,6 @@ void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & co
 
     // create new chat
     m_chatWindow->startChat(textChannel);
-
     context->setFinished();
 }
 
diff --git a/app/telepathy-chat-ui.h b/app/telepathy-chat-ui.h
index a84b39c..3d20015 100644
--- a/app/telepathy-chat-ui.h
+++ b/app/telepathy-chat-ui.h
@@ -43,9 +43,7 @@ public:
     virtual bool bypassApproval() const;
 
 private:
-    typedef QPair<Tp::TextChannelPtr, ChatTab*> ChannelWidgetPair;
     ChatWindow *m_chatWindow;
-    QList<ChannelWidgetPair> m_channelWidgetMap;
 };
 
 #endif // TELEPATHYCHATUI_H
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index d49b52d..6bafc76 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -18,6 +18,7 @@
  ***************************************************************************/
 
 #include "chat-widget.h"
+
 #include "ui_chat-widget.h"
 #include "adium-theme-header-info.h"
 #include "adium-theme-content-info.h"
@@ -32,14 +33,15 @@
 #include <KNotification>
 #include <KAboutData>
 #include <KComponentData>
+#include <KDebug>
+#include <KColorScheme>
 
 #include <TelepathyQt4/Message>
 #include <TelepathyQt4/Types>
 #include <TelepathyQt4/AvatarData>
 #include <TelepathyQt4/Connection>
 #include <TelepathyQt4/Presence>
-#include <KDebug>
-#include <KColorScheme>
+
 
 class MessageBoxEventFilter : public QObject
 {
@@ -74,10 +76,12 @@ public:
     ChatWidgetPrivate()
     {
         isGroupChat = false;
+        remoteContactIsTyping = false;
         unreadMessages = 0;
     }
     /** Stores whether the channel is ready with all contacts upgraded*/
     bool chatviewlInitialised;
+    bool remoteContactIsTyping;
     QAction *showFormatToolbarAction;
     bool isGroupChat;
     int unreadMessages;
@@ -239,7 +243,7 @@ void ChatWidget::showEvent(QShowEvent* e)
 {
     kDebug();
 
-    resetUnreadMessages();
+    resetUnreadMessageCount();
 
     QWidget::showEvent(e);
 }
@@ -267,50 +271,66 @@ KIcon ChatWidget::icon() const
 
 QColor ChatWidget::titleColor() const
 {
+    /*return a color to set the tab text as in order of importance
+
+    typing
+    unread messages
+    user offline
+
+    */
+
+    KColorScheme scheme(QPalette::Active, KColorScheme::Window);
+
+    if (d->remoteContactIsTyping) {
+        kDebug() << "remote is typing";
+        return scheme.foreground(KColorScheme::PositiveText).color();
+    }
+
+    if (d->unreadMessages > 0) {
+        kDebug() << "unread messages";
+        return scheme.foreground(KColorScheme::ActiveText).color();
+    }
+
     //normal chat - self and one other person.
     if (!d->isGroupChat) {
         //find the other contact which isn't self.
         foreach(const Tp::ContactPtr & contact, d->channel->groupContacts()) {
             if (contact != d->channel->groupSelfContact()) {
-                return colorForPresence(contact->presence().type());
+                if (contact->presence().type() == Tp::ConnectionPresenceTypeOffline ||
+                    contact->presence().type() == Tp::ConnectionPresenceTypeHidden) {
+                    return scheme.foreground(KColorScheme::InactiveText).color();
+                }
             }
         }
     }
 
-    //group chat
-    return colorForPresence(Tp::ConnectionPresenceTypeAvailable);
-}
-
-bool ChatWidget::isNewMessageUnread()
-{
-    kDebug() << !isOnTop();
-    return !isOnTop();
+    return scheme.foreground(KColorScheme::NormalText).color();
 }
 
-int ChatWidget::unreadMessages() const
+int ChatWidget::unreadMessageCount() const
 {
     kDebug() << title() << d->unreadMessages;
 
     return d->unreadMessages;
 }
 
-void ChatWidget::incrementUnreadMessages()
+void ChatWidget::incrementUnreadMessageCount()
 {
     kDebug();
 
     d->unreadMessages++;
 
     kDebug() << "emit" << d->unreadMessages;
-    emit unreadMessagesChanged(d->unreadMessages);
+    Q_EMIT unreadMessagesChanged(d->unreadMessages);
 }
 
-void ChatWidget::resetUnreadMessages()
+void ChatWidget::resetUnreadMessageCount()
 {
     kDebug();
 
     if(d->unreadMessages > 0) {
         d->unreadMessages = 0;
-        emit unreadMessagesChanged(d->unreadMessages);
+        Q_EMIT unreadMessagesChanged(d->unreadMessages);
     }
 }
 
@@ -321,13 +341,6 @@ bool ChatWidget::isOnTop() const
     return ( isActiveWindow() && isVisible() );
 }
 
-void ChatWidget::showOnTop()
-{
-    kDebug() << "isOnTop:" << isOnTop();
-
-    activateWindow();
-}
-
 void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
 {
     kDebug() << title() << message.text();
@@ -354,11 +367,11 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
         d->ui.chatArea->addContentMessage(messageInfo);
         d->channel->acknowledge(QList<Tp::ReceivedMessage>() << message);
 
-        if(isNewMessageUnread()) {
-            incrementUnreadMessages();
+        if(!isOnTop()) {
+            incrementUnreadMessageCount();
         }
 
-        emit messageReceived();
+        Q_EMIT messageReceived();
     }
 
     //if the window isn't ready, we don't acknowledge the mesage. We process them as soon as we are ready.
@@ -489,7 +502,6 @@ void ChatWidget::onChatStatusChanged(const Tp::ContactPtr & contact, Tp::Channel
         qDebug() << QString("Unknown case %1").arg(state);
     }
 
-
     if (!contactIsTyping) {
         //In a multiperson chat just because this user is no longer typing it doesn't mean that no-one is.
         //loop through each contact, check no-one is in composing mode.
@@ -504,7 +516,10 @@ void ChatWidget::onChatStatusChanged(const Tp::ContactPtr & contact, Tp::Channel
         }
     }
 
-    emit userTypingChanged(contactIsTyping);
+    if (contactIsTyping != d->remoteContactIsTyping) {
+        d->remoteContactIsTyping = contactIsTyping;
+        Q_EMIT userTypingChanged(contactIsTyping);
+    }
 }
 
 
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index d6fcc60..e4f500d 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -39,15 +39,14 @@ class KDE_TELEPATHY_CHAT_EXPORT ChatWidget : public QWidget
     Q_OBJECT
 
 public:
-    enum TitleColor {
-        Default = KColorScheme::NormalText,
-        Offline = KColorScheme::InactiveText,
-        UnreadMessages = KColorScheme::ActiveText,
-        UnreadStatus = KColorScheme::NeutralText,
-        UnauthorizedContact = KColorScheme::NegativeText,
-        CurrentlyTyping = KColorScheme::PositiveText
-    };
-    static QColor colorForRole(ChatWidget::TitleColor role);
+//    enum TitleColor {
+//        Default = KColorScheme::NormalText,
+//        Offline = KColorScheme::InactiveText,
+//        UnreadMessages = KColorScheme::ActiveText,
+//        UnreadStatus = KColorScheme::NeutralText,
+//        UnauthorizedContact = KColorScheme::NegativeText,
+//        CurrentlyTyping = KColorScheme::PositiveText
+//    };
 
     explicit ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
     virtual ~ChatWidget();
@@ -61,29 +60,16 @@ public:
     /** Returns the icon of this chat window */
     KIcon icon() const;
 
-
+    /** Returns the suggested color for the title of the window*/
     QColor titleColor() const;
 
-    // unread messages methods
-    /** Queried by standard isNewMessageUnread() **/
-    virtual bool isOnTop() const;
-
-    /** Decides whether a currently processed message should increment the unread messages counter **/
-    virtual bool isNewMessageUnread();
-
-    int unreadMessages() const;
-    void incrementUnreadMessages();
-    void resetUnreadMessages();
+    int unreadMessageCount() const;
 
 protected:
     void changeEvent(QEvent *e);
     void resizeEvent(QResizeEvent *);
     void showEvent(QShowEvent *e);
 
-
-public slots:
-    virtual void showOnTop();
-
 protected slots:
     /** Show the received message in the chat window*/
     void handleIncomingMessage(const Tp::ReceivedMessage & message);
@@ -130,9 +116,13 @@ private slots:
     void onFormatColorReleased();
 
 private:
+    void resetUnreadMessageCount();
+    void incrementUnreadMessageCount();
+
+    virtual bool isOnTop() const;
+
     //FIXME this should be in the ktelepathy lib
     static KIcon iconForPresence(Tp::ConnectionPresenceType presence);
-    static QColor colorForPresence(Tp::ConnectionPresenceType presence);
 
     ChatWidgetPrivate * const d;
 };

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list