[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=78c3f15

The following commit has been merged in the master branch:
commit 78c3f1507dee24b217a0a92799357fd2df67a29e
Author: Dominik Schmidt <dev at dominik-schmidt.de>
Date:   Thu Mar 3 22:11:59 2011 +0000

    Implement unread messages in the lib and show the status in the app
---
 app/CMakeLists.txt                    |   1 +
 app/chat-window.cpp                   |  98 +++++++++++++++++---------
 app/chat-window.h                     |   9 ++-
 config/main.cpp => app/chattab.cpp    |  44 +++++++-----
 lib/chat-text-edit.h => app/chattab.h |  46 +++++++------
 app/telepathy-chat-ui.cpp             |   5 +-
 app/telepathy-chat-ui.h               |   2 +
 lib/chat-widget.cpp                   | 126 ++++++++++++++++++++++++++++++++--
 lib/chat-widget.h                     |  40 ++++++++++-
 9 files changed, 292 insertions(+), 79 deletions(-)

diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index a1e4c61..bd59e96 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -6,6 +6,7 @@ set(telepathy_chat_handler_SRCS
         main.cpp
         telepathy-chat-ui.cpp
         chat-window.cpp
+        chattab.cpp
 )
 
 kde4_add_executable(telepathy-chat-handler ${telepathy_chat_handler_SRCS})
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 3ebe1c0..01f6e84 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -18,7 +18,8 @@
 
 
 #include "chat-window.h"
-#include "chat-widget.h"
+
+#include "chattab.h"
 
 #include <KStandardAction>
 #include <KIcon>
@@ -71,7 +72,7 @@ void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
     for(int index = 0; index < m_tabWidget->count() && !duplicateTab; index++) {
 
         // get chatWidget object
-        ChatWidget *auxChatWidget = qobject_cast<ChatWidget*>(m_tabWidget->widget(index));
+        ChatTab *auxChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
 
         // this should never happen
         if(!auxChatWidget)
@@ -85,13 +86,13 @@ void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
 
     // got new chat, create it
     if(!duplicateTab) {
-        ChatWidget *chatWidget = new ChatWidget(incomingTextChannel, m_tabWidget);
-        connect(chatWidget, SIGNAL(titleChanged(QString)), this, SLOT(updateTabText(QString)));
-        connect(chatWidget, SIGNAL(iconChanged(KIcon)), this, SLOT(updateTabIcon(KIcon)));
-        connect(chatWidget, SIGNAL(userTypingChanged(bool)), this, SLOT(onUserTypingChanged(bool)));
+        ChatTab *chatTab = new ChatWidget(incomingTextChannel, m_tabWidget);
+        connect(chatTab, SIGNAL(titleChanged(QString)), this, SLOT(updateTabText(QString)));
+        connect(chatTab, SIGNAL(iconChanged(KIcon)), this, SLOT(updateTabIcon(KIcon)));
+        connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onUserTypingChanged(bool)));
 
-        m_tabWidget->addTab(chatWidget, chatWidget->icon(), chatWidget->title());
-        m_tabWidget->setCurrentWidget(chatWidget);
+        m_tabWidget->addTab(chatTab, chatTab->icon(), chatTab->title());
+        m_tabWidget->setCurrentWidget(chatTab);
 
         if(m_tabWidget->isTabBarHidden()) {
             if(m_tabWidget->count() > 1) {
@@ -99,8 +100,6 @@ void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
             }
         }
     }
-
-    activateWindow();
 }
 
 void ChatWindow::removeTab(QWidget* chatWidget)
@@ -109,30 +108,30 @@ void ChatWindow::removeTab(QWidget* chatWidget)
     delete chatWidget;
 }
 
-void ChatWindow::updateTabText(const QString & newTitle)
+void ChatWindow::setTabText(int index, const QString &newTitle)
 {
-    //find out which widget made the call, and update the correct tab.
-    QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
-    if (sender) {
-        int tabIndexToChange = m_tabWidget->indexOf(sender);
-        m_tabWidget->setTabText(tabIndexToChange, newTitle);
+    m_tabWidget->setTabText(index, newTitle);
 
-        if (tabIndexToChange == m_tabWidget->currentIndex()) {
-            onCurrentIndexChanged(tabIndexToChange);
-        }
+    // this updates the window title and icon if the updated tab is the current one
+    if (index == m_tabWidget->currentIndex()) {
+        onCurrentIndexChanged(index);
     }
 }
 
-void ChatWindow::updateTabIcon(const KIcon & newIcon)
+void ChatWindow::setTabIcon(int index, const KIcon & newIcon)
 {
-    //find out which widget made the call, and update the correct tab.
-    QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
-    if (sender) {
-        int tabIndexToChange = m_tabWidget->indexOf(sender);
-        m_tabWidget->setTabIcon(tabIndexToChange, newIcon);
+    m_tabWidget->setTabIcon(index, newIcon);
+
+    // this updates the window title and icon if the updated tab is the current one
+    if (index == m_tabWidget->currentIndex()) {
+        onCurrentIndexChanged(index);
     }
 }
 
+void ChatWindow::setTabTextColor(int index, const QColor& color)
+{
+    m_tabWidget->setTabTextColor(index, color);
+}
 
 void ChatWindow::onCurrentIndexChanged(int index)
 {
@@ -143,25 +142,60 @@ void ChatWindow::onCurrentIndexChanged(int index)
         return;
     }
 
-    ChatWidget* currentChatWidget = qobject_cast<ChatWidget*>(m_tabWidget->widget(index));
-    setWindowTitle(currentChatWidget->title());
-    setWindowIcon(currentChatWidget->icon());
+    ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
+    setWindowTitle(currentChatTab->title());
+    setWindowIcon(currentChatTab->icon());
+
 }
 
 void ChatWindow::onUserTypingChanged(bool isTyping)
 {
     QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
     if (sender) {
-        KColorScheme scheme(QPalette::Active, KColorScheme::Window);
         int tabIndex = m_tabWidget->indexOf(sender);
         if (isTyping) {
-            m_tabWidget->setTabTextColor(tabIndex, scheme.foreground(KColorScheme::PositiveText).color());
+            setTabTextColor(tabIndex, ChatTab::colorForRole(ChatTab::CurrentlyTyping));
         } else {
-            m_tabWidget->setTabTextColor(tabIndex, scheme.foreground(KColorScheme::NormalText).color());
+            setTabTextColor(tabIndex, ChatTab::colorForRole(ChatTab::Default));
         }
     }
 }
 
+void ChatWindow::onContactPresenceChanged(const Tp::Presence& presence)
+{
+    kDebug();
+
+    ChatTab* sender = qobject_cast<ChatTab*>(QObject::sender());
+    if (sender) {
+        int tabIndexToChange = m_tabWidget->indexOf(sender);
+        setTabIcon(tabIndexToChange, sender->icon());
+        setTabText(tabIndexToChange, sender->title());
+        setTabTextColor(tabIndexToChange, sender->titleColor());
+    }
+}
+
+void ChatWindow::onUnreadMessagesChanged()
+{
+    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());
+        }
+
+    }
+}
+
 void ChatWindow::showSettingsDialog()
 {
     kDebug();
@@ -181,4 +215,4 @@ void ChatWindow::showNotificationsDialog()
 }
 
 
-#include "chat-window.moc"
\ No newline at end of file
+#include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index e921d12..ded4114 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -26,6 +26,7 @@
 #include <KTabWidget>
 
 class KIcon;
+class ChatTab;
 
 class ChatWindow : public KXmlGuiWindow
 {
@@ -41,13 +42,17 @@ public:
      * @param incomingTextChannel new text channel
      */
     void startChat(Tp::TextChannelPtr incomingTextChannel);
+    void removeTab(ChatTab *chatWidget);
+    void setTabText(int index, const QString &newTitle);
+    void setTabIcon(int index, const KIcon &newIcon);
+    void setTabTextColor(int index,const QColor &color);
 
 public slots:
     void removeTab(QWidget *chatWidget);
     void onCurrentIndexChanged(int index);
-    void updateTabText(const QString &newTitle);
-    void updateTabIcon(const KIcon &newIcon);
     void onUserTypingChanged(bool isTyping);
+    void onContactPresenceChanged(const Tp::Presence &presence);
+    void onUnreadMessagesChanged();
 
 protected slots:
     void showSettingsDialog();
diff --git a/config/main.cpp b/app/chattab.cpp
similarity index 66%
copy from config/main.cpp
copy to app/chattab.cpp
index c47f493..d53467f 100644
--- a/config/main.cpp
+++ b/app/chattab.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by David Edmundson <kde at davidedmundson.co.uk>      *
+ *   Copyright (C) 2011 by Dominik Schmidt <kde at dominik-schmidt.de>        *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -17,27 +17,39 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
+#include "chattab.h"
+#include "chatwidget.h"
 
-#include "main-window.h"
-
-#include <KApplication>
-#include <KAboutData>
-#include <KCmdLineArgs>
+#include <KTabWidget>
+#include <KDebug>
+#include <QStackedWidget>
+#include <KDE/KColorScheme>
 
+ChatTab::ChatTab(const Tp::TextChannelPtr & channel, QWidget *parent)
+    : ChatWidget(channel, parent)
+{
+}
 
-int main(int argc, char *argv[])
+ChatTab::~ChatTab()
 {
-    KAboutData aboutData("telepathy-chat-window-config",
-                         0,
-                         ki18n("Telepathy Chat Window Config"),
-                         "0.1");
+}
 
-    KCmdLineArgs::init(argc, argv, &aboutData);
+void ChatTab::setTabWidget(KTabWidget* tabWidget)
+{
+    m_tabWidget = tabWidget;
+}
 
-    KApplication app;
+KTabWidget* ChatTab::tabWidget() const
+{
+    return m_tabWidget;
+}
 
-    MainWindow w;
-    w.show();
+void ChatTab::showOnTop()
+{
+    kDebug() << "Show this widget on top" << title();
+    if(m_tabWidget) {
+        m_tabWidget->setCurrentWidget(this);
+    }
 
-    return app.exec();
+    activateWindow();
 }
diff --git a/lib/chat-text-edit.h b/app/chattab.h
similarity index 68%
copy from lib/chat-text-edit.h
copy to app/chattab.h
index e1a32d3..a32cbe1 100644
--- a/lib/chat-text-edit.h
+++ b/app/chattab.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2011 by David Edmundson <kde at davidedmundson.co.uk>      *
+ *   Copyright (C) 2011 by Dominik Schmidt <kde at dominik-schmidt.de>        *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -17,33 +17,37 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef CHATTEXTEDIT_H
-#define CHATTEXTEDIT_H
+#ifndef CHATTAB_H
+#define CHATTAB_H
 
-#include <QtGui/QTextEdit>
+#include "chatwidget.h"
 
-class ChatTextEdit : public QTextEdit
+#include <QtCore/QString>
+#include <QtGui/QWidget>
+#include <KIcon>
+#include <KColorScheme>
+
+
+class KTabWidget;
+class ChatWidgetPrivate;
+class QShowEvent;
+
+class ChatTab : public ChatWidget
 {
     Q_OBJECT
-public:
-    explicit ChatTextEdit(QWidget *parent = 0);
 
-    // reimplemented
-    QSize minimumSizeHint() const;
-    QSize sizeHint() const;
-
-protected:
-    // reimplemented
-    void resizeEvent(QResizeEvent*);
-    void contextMenuEvent(QContextMenuEvent *);
+public:
+    explicit ChatTab(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
+    virtual ~ChatTab();
 
-private slots:
-    void recalculateSize();
-    void updateScrollBar();
+    void setTabWidget(KTabWidget *tabWidget);
+    KTabWidget* tabWidget() const;
 
 public slots:
-    /** wraps setFontWeight to a simple on/off bold) */
-    void setFontBold(bool);
+    void showOnTop();
+
+private:
+    KTabWidget *m_tabWidget;
 };
 
-#endif // CHATTEXTEDIT_H
+#endif // CHATWIDGET_H
diff --git a/app/telepathy-chat-ui.cpp b/app/telepathy-chat-ui.cpp
index 0845892..fca178b 100644
--- a/app/telepathy-chat-ui.cpp
+++ b/app/telepathy-chat-ui.cpp
@@ -17,7 +17,7 @@
 */
 
 #include "telepathy-chat-ui.h"
-#include "chat-widget.h"
+#include "chat-tab.h"
 #include "chat-window.h"
 
 #include <KDebug>
@@ -68,13 +68,12 @@ void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & co
             break;
         }
     }
+
     Q_ASSERT(textChannel);
 
     // create new chat
     m_chatWindow->startChat(textChannel);
 
-    m_chatWindow->show();
-
     context->setFinished();
 }
 
diff --git a/app/telepathy-chat-ui.h b/app/telepathy-chat-ui.h
index 3d20015..a84b39c 100644
--- a/app/telepathy-chat-ui.h
+++ b/app/telepathy-chat-ui.h
@@ -43,7 +43,9 @@ 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 48bf0b6..d49b52d 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -38,6 +38,8 @@
 #include <TelepathyQt4/AvatarData>
 #include <TelepathyQt4/Connection>
 #include <TelepathyQt4/Presence>
+#include <KDebug>
+#include <KColorScheme>
 
 class MessageBoxEventFilter : public QObject
 {
@@ -69,13 +71,20 @@ Q_SIGNALS:
 class ChatWidgetPrivate
 {
 public:
+    ChatWidgetPrivate()
+    {
+        isGroupChat = false;
+        unreadMessages = 0;
+    }
     /** Stores whether the channel is ready with all contacts upgraded*/
     bool chatviewlInitialised;
     QAction *showFormatToolbarAction;
     bool isGroupChat;
+    int unreadMessages;
     QString title;
     Tp::TextChannelPtr channel;
     Ui::ChatWidget ui;
+    KIcon icon;
 
     KComponentData telepathyComponentData();
 };
@@ -149,6 +158,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent)
     //set up anything related to 'self'
     info.setOutgoingIconPath(d->channel->groupSelfContact()->avatarData().fileName);
     info.setTimeOpened(QDateTime::currentDateTime());
+    connect(d->ui.chatArea, SIGNAL(loadFinished(bool)), SLOT(chatViewReady()), Qt::QueuedConnection);
     d->ui.chatArea->initialise(info);
 
     //set the title of this chat.
@@ -180,8 +190,6 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent)
     connect(d->channel.data(), SIGNAL(chatStateChanged(Tp::ContactPtr,Tp::ChannelChatState)),
             SLOT(onChatStatusChanged(Tp::ContactPtr,Tp::ChannelChatState)));
 
-    connect(d->ui.chatArea, SIGNAL(loadFinished(bool)), SLOT(chatViewReady()));
-
     connect(d->ui.sendMessageBox, SIGNAL(textChanged()), SLOT(onInputBoxChanged()));
 
     // make the sendMessageBox a focus proxy for the chatview
@@ -227,6 +235,15 @@ Tp::TextChannelPtr ChatWidget::textChannel() const
     return d->channel;
 }
 
+void ChatWidget::showEvent(QShowEvent* e)
+{
+    kDebug();
+
+    resetUnreadMessages();
+
+    QWidget::showEvent(e);
+}
+
 QString ChatWidget::title() const
 {
     return d->title;
@@ -248,8 +265,72 @@ KIcon ChatWidget::icon() const
     return iconForPresence(Tp::ConnectionPresenceTypeAvailable);
 }
 
+QColor ChatWidget::titleColor() const
+{
+    //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());
+            }
+        }
+    }
+
+    //group chat
+    return colorForPresence(Tp::ConnectionPresenceTypeAvailable);
+}
+
+bool ChatWidget::isNewMessageUnread()
+{
+    kDebug() << !isOnTop();
+    return !isOnTop();
+}
+
+int ChatWidget::unreadMessages() const
+{
+    kDebug() << title() << d->unreadMessages;
+
+    return d->unreadMessages;
+}
+
+void ChatWidget::incrementUnreadMessages()
+{
+    kDebug();
+
+    d->unreadMessages++;
+
+    kDebug() << "emit" << d->unreadMessages;
+    emit unreadMessagesChanged(d->unreadMessages);
+}
+
+void ChatWidget::resetUnreadMessages()
+{
+    kDebug();
+
+    if(d->unreadMessages > 0) {
+        d->unreadMessages = 0;
+        emit unreadMessagesChanged(d->unreadMessages);
+    }
+}
+
+
+bool ChatWidget::isOnTop() const
+{
+    kDebug() << ( isActiveWindow() && isVisible() );
+    return ( isActiveWindow() && isVisible() );
+}
+
+void ChatWidget::showOnTop()
+{
+    kDebug() << "isOnTop:" << isOnTop();
+
+    activateWindow();
+}
+
 void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
 {
+    kDebug() << title() << message.text();
     if (d->chatviewlInitialised) {
         AdiumThemeContentInfo messageInfo(AdiumThemeMessageInfo::RemoteToLocal);
 
@@ -273,6 +354,10 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
         d->ui.chatArea->addContentMessage(messageInfo);
         d->channel->acknowledge(QList<Tp::ReceivedMessage>() << message);
 
+        if(isNewMessageUnread()) {
+            incrementUnreadMessages();
+        }
+
         emit messageReceived();
     }
 
@@ -287,6 +372,11 @@ void ChatWidget::notifyAboutIncomingMessage(const Tp::ReceivedMessage & message)
     //options are:
     // kde_telepathy_contact_incoming
     // kde_telepathy_contact_incoming_active_window - TODO - requires information not available yet.
+    //FIXME: until the above is available, simply deactivate the event
+    if(isOnTop()) {
+        kDebug() << "Widget is on top, not doing anything";
+        return;
+    }
     // kde_telepathy_contact_highlight (contains your name)
     // kde_telepathy_info_event
 
@@ -317,6 +407,7 @@ void ChatWidget::notifyAboutIncomingMessage(const Tp::ReceivedMessage & message)
 
     notification->setActions(QStringList(i18n("View")));
     connect(notification, SIGNAL(activated(unsigned int)), notification, SLOT(raiseWidget()));
+    connect(notification, SIGNAL(activated(unsigned int)), this, SLOT(showOnTop()));
 
     notification->sendEvent();
 }
@@ -468,9 +559,11 @@ void ChatWidget::onContactPresenceChange(const Tp::ContactPtr & contact, const T
 
     //if in a non-group chat situation, and the other contact has changed state...
     if (!d->isGroupChat && !isYou) {
-        KIcon icon = iconForPresence(presence.type());
-        Q_EMIT iconChanged(icon);
+        d->icon = iconForPresence(presence.type());
+        Q_EMIT iconChanged(d->icon);
     }
+
+    Q_EMIT contactPresenceChanged(presence);
 }
 
 void ChatWidget::onContactAliasChanged(const Tp::ContactPtr & contact, const QString& alias)
@@ -550,6 +643,31 @@ KIcon ChatWidget::iconForPresence(Tp::ConnectionPresenceType presence)
     return KIcon(iconName);
 }
 
+QColor ChatWidget::colorForPresence(Tp::ConnectionPresenceType presence)
+{
+    TitleColor role;
+
+    switch (presence) {
+        case Tp::ConnectionPresenceTypeAvailable:
+        case Tp::ConnectionPresenceTypeAway:
+        case Tp::ConnectionPresenceTypeExtendedAway:
+        case Tp::ConnectionPresenceTypeHidden:
+        case Tp::ConnectionPresenceTypeBusy:
+            role = Default;
+            break;
+        default:
+            role = Offline;
+            break;
+    }
+
+    return colorForRole(role);
+}
+
+QColor ChatWidget::colorForRole(ChatWidget::TitleColor role)
+{
+    KColorScheme scheme(QPalette::Active, KColorScheme::Window);
+    return scheme.foreground(static_cast<KColorScheme::ForegroundRole>(role)).color();
+}
 
 
 #include "chat-widget.moc" //for MessageBoxEventFilter
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index ca24bc7..d6fcc60 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -20,21 +20,35 @@
 #ifndef CHATWIDGET_H
 #define CHATWIDGET_H
 
+#include "kdetelepathychat_export.h"
+
 #include <QtCore/QString>
 #include <QtGui/QWidget>
 #include <KIcon>
+#include <KColorScheme>
 
 #include <TelepathyQt4/ReceivedMessage>
 
-#include "kdetelepathychat_export.h"
+
 
 class ChatWidgetPrivate;
+class QShowEvent;
 
 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);
+
     explicit ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
     virtual ~ChatWidget();
 
@@ -47,9 +61,28 @@ public:
     /** Returns the icon of this chat window */
     KIcon icon() const;
 
+
+    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();
+
 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*/
@@ -89,12 +122,17 @@ signals:
     /** Emitted when another contact in the channel starts/stops typing (if supported by the protocol)*/
     void userTypingChanged(bool);
 
+    void contactPresenceChanged(Tp::Presence presence);
+
+    void unreadMessagesChanged(int messages);
+
 private slots:
     void onFormatColorReleased();
 
 private:
     //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