Commit c1beeb26 authored by Lasath Fernando's avatar Lasath Fernando Committed by David Edmundson
Browse files

UI improvements

parent c38807a2
......@@ -50,6 +50,7 @@ void ConversationTarget::setupContactSignals(Tp::ContactPtr contact)
QIcon ConversationTarget::avatar() const
{
//FIXME: return KIcon("im-user") if avatar is unavailable
return QIcon(d->contact->avatarData().fileName);
}
......@@ -60,11 +61,46 @@ QString ConversationTarget::nick() const
QIcon ConversationTarget::presenceIcon() const
{
return ChatWidget::iconForPresence(d->contact->presence().type());
return KIcon(presenceIconSource());
}
QString ConversationTarget::presenceIconSource() const
{
return iconSourceForPresence(d->contact->presence().type());
}
QString ConversationTarget::iconSourceForPresence(Tp::ConnectionPresenceType presence)
{
QString iconName;
switch (presence) {
case Tp::ConnectionPresenceTypeAvailable:
iconName = QLatin1String("user-online");
break;
case Tp::ConnectionPresenceTypeAway:
iconName = QLatin1String("user-away");
break;
case Tp::ConnectionPresenceTypeExtendedAway:
iconName = QLatin1String("user-away-extended");
break;
case Tp::ConnectionPresenceTypeHidden:
iconName = QLatin1String("user-invisible");
break;
case Tp::ConnectionPresenceTypeBusy:
iconName = QLatin1String("user-busy");
break;
default:
iconName = QLatin1String("user-offline");
break;
}
return iconName;
}
void ConversationTarget::onPresenceChanged(Tp::Presence)
{
Q_EMIT presenceIconSourceChanged(presenceIconSource());
Q_EMIT presenceIconChanged(presenceIcon());
}
......
......@@ -21,10 +21,12 @@
#define CONVERSATION_TARGET_H
#include <QObject>
#include <TelepathyQt4/Contact>
#include <TelepathyQt/Contact>
#include "chat-widget.h"
#include "kdetelepathychat_export.h"
#include "ktpchat_export.h"
class KDE_TELEPATHY_CHAT_EXPORT ConversationTarget : public QObject
{
......@@ -33,6 +35,7 @@ Q_OBJECT
Q_PROPERTY(QIcon avatar READ avatar NOTIFY avatarChanged);
Q_PROPERTY(QString nick READ nick NOTIFY nickChanged);
Q_PROPERTY(QIcon presenceIcon READ presenceIcon NOTIFY presenceIconChanged);
Q_PROPERTY(QString presenceIconSource READ presenceIconSource NOTIFY presenceIconSourceChanged);
//turns out you can't have non QObjects as properties
// Q_PROPERTY(Tp::ContactPtr contact READ contact WRITE setContact NOTIFY contactChanged);
......@@ -41,17 +44,22 @@ public:
ConversationTarget( Tp::ContactPtr contact = Tp::ContactPtr());
virtual ~ConversationTarget();
QIcon avatar() const;
QIcon avatar() const;
QString nick() const;
QIcon presenceIcon() const;
QIcon presenceIcon() const;
QString presenceIconSource() const;
Tp::ContactPtr contact() const;
void setContact(Tp::ContactPtr contact);
static QString iconSourceForPresence(Tp::ConnectionPresenceType presence);
Q_SIGNALS:
void avatarChanged(QIcon avatar);
void nickChanged(QString nick);
void presenceIconChanged(QIcon icon);
void presenceIconSourceChanged(QString source);
void contactChanged(Tp::ContactPtr contact);
......
......@@ -20,11 +20,11 @@
#ifndef CONVERSATION_H
#define CONVERSATION_H
#include "kdetelepathychat_export.h"
#include "ktpchat_export.h"
#include <QObject>
#include <TelepathyQt4/Account>
#include <TelepathyQt4/TextChannel>
#include <TelepathyQt/Account>
#include <TelepathyQt/TextChannel>
// #include "conversation-model.h"
#include <KIcon>
#include "conversation-target.h"
......
......@@ -21,7 +21,9 @@
#define CONVERSATIONS_MODEL_H
#include <QAbstractListModel>
#include "kdetelepathychat_export.h"
#include "ktpchat_export.h"
class Conversation;
......
......@@ -88,7 +88,8 @@ void MessagesModel::setTextChannel(Tp::TextChannelPtr channel)
if(d->textChannel) {
removeChannelSignals(channel);
}
d->textChannel = channel; //FIXME: check if channel is valid
//FIXME: check messageQue for any lost messages
d->textChannel = channel;
textChannelChanged(channel);
}
......
......@@ -20,10 +20,10 @@
#ifndef MESSAGES_MODEL_H
#define MESSAGES_MODEL_H
#include "kdetelepathychat_export.h"
#include "ktpchat_export.h"
#include <QAbstractItemModel>
#include <TelepathyQt4/TextChannel>
#include <TelepathyQt/TextChannel>
class KDE_TELEPATHY_CHAT_EXPORT MessagesModel : public QAbstractListModel
......
......@@ -20,8 +20,9 @@
#ifndef TELEPATHY_TEXT_OBSERVER_H
#define TELEPATHY_TEXT_OBSERVER_H
#include "kdetelepathychat_export.h"
#include <TelepathyQt4/AbstractClient>
#include "ktpchat_export.h"
#include <TelepathyQt/AbstractClient>
class Conversation;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment