Redesign the Message Item feed

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3425 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-09-01 21:54:07 +00:00
parent ea810034c9
commit c8de865e1a
4 changed files with 207 additions and 195 deletions

View File

@ -397,7 +397,7 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi)
void NewsFeed::addFeedItemMessage(RsFeedItem &fi) void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
{ {
/* make new widget */ /* 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 */ /* store in list */

View File

@ -35,8 +35,8 @@
****/ ****/
/** Constructor */ /** Constructor */
MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool isHome) MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string peerId, std::string msgId, bool isHome)
:QWidget(NULL), mParent(parent), mFeedId(feedId), mMsgId(msgId), mIsHome(isHome) :QWidget(NULL), mParent(parent), mFeedId(feedId), mPeerId(peerId), mMsgId(msgId), mIsHome(isHome)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); setupUi(this);
@ -56,6 +56,8 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, std::string msgId, bool is
small(); small();
updateItemStatic(); updateItemStatic();
updateItem(); updateItem();
updateAvatar(QString::fromStdString(mPeerId));
} }
@ -191,10 +193,14 @@ void MsgItem::toggle()
if (expandFrame->isHidden()) if (expandFrame->isHidden())
{ {
expandFrame->show(); expandFrame->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip(tr("Hide"));
} }
else else
{ {
expandFrame->hide(); expandFrame->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip(tr("Expand"));
} }
} }
@ -271,8 +277,6 @@ void MsgItem::replyMsg()
} }
} }
void MsgItem::playMedia() void MsgItem::playMedia()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
@ -281,5 +285,30 @@ void MsgItem::playMedia()
#endif #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"));
}
}

View File

@ -34,7 +34,7 @@ class MsgItem : public QWidget, private Ui::MsgItem
public: public:
/** Default Constructor */ /** 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 */ /** Default Destructor */
@ -52,6 +52,7 @@ private slots:
void replyMsg(); void replyMsg();
void updateItem(); void updateItem();
void updateAvatar(const QString &peer_id);
private: private:
FeedHolder *mParent; FeedHolder *mParent;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>917</width> <width>710</width>
<height>238</height> <height>168</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -37,16 +37,97 @@ border-radius: 10px}</string>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <item row="0" column="0">
<number>0</number> <widget class="QLabel" name="avatarlabel">
</property> <property name="minimumSize">
<item> <size>
<layout class="QHBoxLayout"> <width>64</width>
<item> <height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel#avatarlabel{border: 2px solid blue;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #2291E0, stop: 1 #3EB3FF);
}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1" colspan="4">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Connected</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>557</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="clearButton"> <widget class="QPushButton" name="clearButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -66,83 +147,7 @@ border-radius: 10px}</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="0" colspan="4">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Connected</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_24x24.png</normaloff>:/images/add_24x24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="subjectLabel"> <widget class="QLabel" name="subjectLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
@ -153,113 +158,87 @@ border-radius: 10px}</string>
<property name="text"> <property name="text">
<string>subjectLabel</string> <string>subjectLabel</string>
</property> </property>
</widget> <property name="wordWrap">
</item> <bool>true</bool>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>500</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="replyButton">
<property name="toolTip">
<string>Reply to Message</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete Message</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="playButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Play Media</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/startall.png</normaloff>:/images/startall.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item row="1" column="1">
<widget class="QToolButton" name="replyButton">
<property name="toolTip">
<string>Reply to Message</string>
</property>
<property name="text">
<string>Reply Message</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>424</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="deleteButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Delete Message</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_delete.png</normaloff>:/images/mail_delete.png</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="playButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Play Media</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/startall.png</normaloff>:/images/startall.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QFrame" name="expandFrame"> <widget class="QFrame" name="expandFrame">
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::StyledPanel</enum> <enum>QFrame::StyledPanel</enum>
@ -280,6 +259,9 @@ border-radius: 10px}</string>
<string>Long <string>Long
message here</string> message here</string>
</property> </property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>