| 1 | #ifndef AVATARS_H
|
|---|
| 2 | #define AVATARS_H
|
|---|
| 3 |
|
|---|
| 4 | //#define AVATARS
|
|---|
| 5 |
|
|---|
| 6 | #include <qpixmap.h>
|
|---|
| 7 | #include <qstring.h>
|
|---|
| 8 |
|
|---|
| 9 | #include "xmpp.h"
|
|---|
| 10 |
|
|---|
| 11 | using namespace XMPP;
|
|---|
| 12 |
|
|---|
| 13 | class PsiAccount;
|
|---|
| 14 | class Avatar;
|
|---|
| 15 | class VCardAvatar;
|
|---|
| 16 | class FileAvatar;
|
|---|
| 17 | class ClientAvatar;
|
|---|
| 18 |
|
|---|
| 19 | //------------------------------------------------------------------------------
|
|---|
| 20 |
|
|---|
| 21 | class AvatarFactory : public QObject
|
|---|
| 22 | {
|
|---|
| 23 | Q_OBJECT
|
|---|
| 24 |
|
|---|
| 25 | public:
|
|---|
| 26 | AvatarFactory(PsiAccount* pa);
|
|---|
| 27 |
|
|---|
| 28 | QPixmap getAvatar(const Jid& jid, const QString& client);
|
|---|
| 29 | PsiAccount* account() const
|
|---|
| 30 | { return pa_; }
|
|---|
| 31 | QPixmap getSelfAvatar();
|
|---|
| 32 |
|
|---|
| 33 | void importManualAvatar(const Jid& j, const QString& fileName);
|
|---|
| 34 | void removeManualAvatar(const Jid& j);
|
|---|
| 35 | bool hasManualAvatar(const Jid& j);
|
|---|
| 36 |
|
|---|
| 37 | static QString getAvatarsDir();
|
|---|
| 38 | static QString getManualDir();
|
|---|
| 39 |
|
|---|
| 40 | signals:
|
|---|
| 41 | void avatarChanged(const Jid&);
|
|---|
| 42 |
|
|---|
| 43 | public slots:
|
|---|
| 44 | void updateAvatar(const Jid&);
|
|---|
| 45 |
|
|---|
| 46 | protected:
|
|---|
| 47 | Avatar* retrieveAvatar(const Jid& jid, const QString& resource);
|
|---|
| 48 |
|
|---|
| 49 | private:
|
|---|
| 50 | QMap<QString,Avatar*> active_avatars_;
|
|---|
| 51 | QMap<QString,FileAvatar*> file_avatars_;
|
|---|
| 52 | QMap<QString,ClientAvatar*> client_avatars_;
|
|---|
| 53 | QMap<QString,VCardAvatar*> vcard_avatars_;
|
|---|
| 54 | PsiAccount* pa_;
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | //------------------------------------------------------------------------------
|
|---|
| 58 |
|
|---|
| 59 | class Avatar
|
|---|
| 60 | {
|
|---|
| 61 | public:
|
|---|
| 62 | Avatar();
|
|---|
| 63 | virtual ~Avatar();
|
|---|
| 64 | virtual QPixmap getPixmap()
|
|---|
| 65 | { return pixmap(); }
|
|---|
| 66 | virtual bool isEmpty()
|
|---|
| 67 | { return getPixmap().isNull(); }
|
|---|
| 68 | static int maxSize();
|
|---|
| 69 |
|
|---|
| 70 | protected:
|
|---|
| 71 | virtual const QPixmap& pixmap() const
|
|---|
| 72 | { return pixmap_; }
|
|---|
| 73 |
|
|---|
| 74 | virtual void setImage(const QImage&);
|
|---|
| 75 | virtual void setImage(const QByteArray&);
|
|---|
| 76 | virtual void setImage(const QPixmap&);
|
|---|
| 77 | virtual void resetImage();
|
|---|
| 78 |
|
|---|
| 79 | private:
|
|---|
| 80 | QPixmap pixmap_;
|
|---|
| 81 | };
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | #endif
|
|---|