From c8de865e1a12f5599c58026ff265614341e0e9bd Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 1 Sep 2010 21:54:07 +0000 Subject: [PATCH] Redesign the Message Item feed git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3425 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NewsFeed.cpp | 2 +- retroshare-gui/src/gui/feeds/MsgItem.cpp | 37 ++- retroshare-gui/src/gui/feeds/MsgItem.h | 3 +- retroshare-gui/src/gui/feeds/MsgItem.ui | 360 +++++++++++------------ 4 files changed, 207 insertions(+), 195 deletions(-) diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 43f893754..f479ca2a7 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -397,7 +397,7 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi) void NewsFeed::addFeedItemMessage(RsFeedItem &fi) { /* make new widget */ - MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, false); + MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, fi.mId1, false); /* store in list */ diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 9d5fe6b44..05010cdb1 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -35,8 +35,8 @@ ****/ /** Constructor */ -MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool isHome) -:QWidget(NULL), mParent(parent), mFeedId(feedId), mMsgId(msgId), mIsHome(isHome) +MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string msgId, bool isHome) +:QWidget(NULL), mParent(parent), mFeedId(feedId), mPeerId(peerId), mMsgId(msgId), mIsHome(isHome) { /* Invoke the Qt Designer generated object setup routine */ setupUi(this); @@ -56,6 +56,8 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool is small(); updateItemStatic(); updateItem(); + updateAvatar(QString::fromStdString(mPeerId)); + } @@ -191,10 +193,14 @@ void MsgItem::toggle() if (expandFrame->isHidden()) { expandFrame->show(); + expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); + expandButton->setToolTip(tr("Hide")); } else { expandFrame->hide(); + expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); + expandButton->setToolTip(tr("Expand")); } } @@ -271,8 +277,6 @@ void MsgItem::replyMsg() } } - - void MsgItem::playMedia() { #ifdef DEBUG_ITEM @@ -281,5 +285,30 @@ void MsgItem::playMedia() #endif } +void MsgItem::updateAvatar(const QString &peer_id) +{ + if (peer_id.toStdString() != mPeerId) { + /* it 's not me */ + return; + } + unsigned char *data = NULL; + int size = 0 ; + + rsMsgs->getAvatarData(mPeerId,data,size); + + if(size != 0) + { + // set the image + QPixmap pix ; + pix.loadFromData(data,size,"PNG") ; + avatarlabel->setPixmap(pix); + delete[] data ; + + } + else + { + avatarlabel->setPixmap(QPixmap(":/images/user/personal64.png")); + } +} diff --git a/retroshare-gui/src/gui/feeds/MsgItem.h b/retroshare-gui/src/gui/feeds/MsgItem.h index 2e7f04cc2..a0e1f28d1 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.h +++ b/retroshare-gui/src/gui/feeds/MsgItem.h @@ -34,7 +34,7 @@ class MsgItem : public QWidget, private Ui::MsgItem public: /** Default Constructor */ - MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool isHome); + MsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string msgId, bool isHome); /** Default Destructor */ @@ -52,6 +52,7 @@ private slots: void replyMsg(); void updateItem(); + void updateAvatar(const QString &peer_id); private: FeedHolder *mParent; diff --git a/retroshare-gui/src/gui/feeds/MsgItem.ui b/retroshare-gui/src/gui/feeds/MsgItem.ui index b920df797..c2c7f3fca 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.ui +++ b/retroshare-gui/src/gui/feeds/MsgItem.ui @@ -6,8 +6,8 @@ 0 0 - 917 - 238 + 710 + 168 @@ -37,16 +37,97 @@ border-radius: 10px} QFrame::Raised - - + + 0 - - 0 - - - - + + + + + 64 + 64 + + + + + 64 + 64 + + + + QLabel#avatarlabel{border: 2px solid blue; +background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, +stop: 0 #2291E0, stop: 1 #3EB3FF); +} + + + + + + + + + + + + + 0 + 0 + + + + + 75 + true + true + + + + Connected + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 557 + 18 + + + + + + + + + 0 + 0 + + + + Expand + + + + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + @@ -66,83 +147,7 @@ border-radius: 10px} - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 16 - 26 - - - - - - - - - 0 - 0 - - - - - 75 - true - true - - - - Connected - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 1000 - 20 - - - - - - - - - 0 - 0 - - - - Expand - - - - - - - :/images/add_24x24.png:/images/add_24x24.png - - - - - - - - + @@ -153,113 +158,87 @@ border-radius: 10px} subjectLabel - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 500 - 26 - - - - - - - - Reply to Message - - - - - - - :/images/mail_reply.png:/images/mail_reply.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Delete Message - - - - - - - :/images/mail_delete.png:/images/mail_delete.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Play Media - - - - - - - :/images/startall.png:/images/startall.png + + true - + + + + Reply to Message + + + Reply Message + + + + :/images/mail_reply.png:/images/mail_reply.png + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + Qt::Horizontal + + + + 424 + 20 + + + + + + + + + 0 + 0 + + + + Delete Message + + + + + + + :/images/mail_delete.png:/images/mail_delete.png + + + + + + + + 0 + 0 + + + + Play Media + + + + + + + :/images/startall.png:/images/startall.png + + + + QFrame::StyledPanel @@ -280,6 +259,9 @@ border-radius: 10px} Long message here + + true +