Added new widget to display an avatar with or without the status frame - AvatarWidget.

Changed all existing avatars to AvatarWidget.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4589 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-09-05 21:19:07 +00:00
parent 0ed60eaf86
commit 62b2de63b7
46 changed files with 730 additions and 595 deletions

View file

@ -127,12 +127,17 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
connect(ui.actionSave_Chat_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
connect(ui.chattextEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setId(dialogId, false);
ui.ownAvatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.ownAvatarWidget->setOwnId();
// Create the status bar
resetStatusBar();
@ -164,9 +169,6 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
colorChanged(mCurrentColor);
fontChanged(mCurrentFont);
updateOwnAvatar() ;
updatePeerAvatar(id) ;
// load settings
processSettings(true);
@ -179,11 +181,6 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
rsStatus->getStatus(dialogId, peerStatusInfo);
updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);
StatusInfo ownStatusInfo;
if (rsStatus->getOwnStatus(ownStatusInfo)) {
updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
}
// initialize first custom state string
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(dialogId).c_str());
updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);
@ -413,12 +410,6 @@ void PopupChatDialog::chatFriend(const std::string &id)
}
}
/*static*/ void PopupChatDialog::updateAllAvatars()
{
for(std::map<std::string, PopupChatDialog *>::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it)
it->second->updateOwnAvatar() ;
}
void PopupChatDialog::focusDialog()
{
ui.chattextEdit->setFocus();
@ -845,25 +836,6 @@ void PopupChatDialog::on_actionDelete_Chat_History_triggered()
}
}
void PopupChatDialog::updatePeerAvatar(const std::string& peer_id)
{
#ifdef CHAT_DEBUG
std::cerr << "popupchatDialog::updatePeerAvatar() updating avatar for peer " << peer_id << std::endl ;
std::cerr << "Requesting avatar image for peer " << peer_id << std::endl ;
#endif
QPixmap avatar;
AvatarDefs::getAvatarFromSslId(peer_id, avatar);
ui.avatarlabel->setPixmap(avatar);
}
void PopupChatDialog::updateOwnAvatar()
{
QPixmap avatar;
AvatarDefs::getOwnAvatar(avatar);
ui.myavatarlabel->setPixmap(avatar);
}
void PopupChatDialog::addExtraFile()
{
QString file;
@ -1119,35 +1091,25 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
switch (status) {
case RS_STATUS_OFFLINE:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_offline.png); }");
ui.avatarlabel->setEnabled(false);
ui.infoframe->setVisible(true);
ui.infolabel->setText(dialogName + " " + tr("apears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online"));
break;
case RS_STATUS_INACTIVE:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
ui.avatarlabel->setEnabled(true);
ui.infoframe->setVisible(true);
ui.infolabel->setText(dialogName + " " + tr("is Idle and may not reply"));
break;
case RS_STATUS_ONLINE:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_online.png); }");
ui.avatarlabel->setEnabled(true);
ui.infoframe->setVisible(false);
break;
case RS_STATUS_AWAY:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_away.png); }");
ui.avatarlabel->setEnabled(true);
ui.infolabel->setText(dialogName + " " + tr("is Away and may not reply"));
ui.infoframe->setVisible(true);
break;
case RS_STATUS_BUSY:
ui.avatarlabel->setStyleSheet("QLabel#avatarlabel{ border-image:url(:/images/avatarstatus_bg_busy.png); }");
ui.avatarlabel->setEnabled(true);
ui.infolabel->setText(dialogName + " " + tr("is Busy and may not reply"));
ui.infoframe->setVisible(true);
break;
@ -1166,34 +1128,6 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
return;
}
if (stdPeerId == rsPeers->getOwnId()) {
// my status has changed
switch (status) {
case RS_STATUS_OFFLINE:
ui.myavatarlabel->setStyleSheet("QLabel#myavatarlabel{border-image:url(:/images/avatarstatus_bg_offline.png); }");
break;
case RS_STATUS_INACTIVE:
ui.myavatarlabel->setStyleSheet("QLabel#myavatarlabel{border-image:url(:/images/avatarstatus_bg_away.png); }");
break;
case RS_STATUS_ONLINE:
ui.myavatarlabel->setStyleSheet("QLabel#myavatarlabel{border-image:url(:/images/avatarstatus_bg_online.png); }");
break;
case RS_STATUS_AWAY:
ui.myavatarlabel->setStyleSheet("QLabel#myavatarlabel{border-image:url(:/images/avatarstatus_bg_away.png); }");
break;
case RS_STATUS_BUSY:
ui.myavatarlabel->setStyleSheet("QLabel#myavatarlabel{border-image:url(:/images/avatarstatus_bg_busy.png); }");
break;
}
return;
}
// ignore status change
}

View file

@ -48,11 +48,9 @@ public:
static PopupChatDialog *getPrivateChat(const std::string &id, uint chatflags);
static void cleanupChat();
static void chatFriend(const std::string &id);
static void updateAllAvatars();
static void privateChatChanged(int list, int type);
void updateStatusString(const QString& peer_id, const QString& statusString);
void updatePeerAvatar(const std::string&);
std::string getPeerId() { return dialogId; }
QString getTitle() { return dialogName; }
bool hasNewMessages() { return newMessages; }
@ -81,8 +79,6 @@ protected:
void insertChatMsgs();
void addChatMsg(bool incoming, const std::string &id, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType, bool addToHistory);
void updateOwnAvatar();
private slots:
void pasteLink() ;
void contextMenu(QPoint) ;

View file

@ -139,7 +139,7 @@
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="avatarlabel">
<widget class="AvatarWidget" name="avatarWidget" native="true">
<property name="minimumSize">
<size>
<width>116</width>
@ -152,18 +152,6 @@
<height>116</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{
border-image: url(:/images/avatarstatus_bg.png);
}</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
@ -180,7 +168,7 @@ border-image: url(:/images/avatarstatus_bg.png);
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="myavatarlabel">
<widget class="AvatarWidget" name="ownAvatarWidget" native="true">
<property name="minimumSize">
<size>
<width>116</width>
@ -193,18 +181,6 @@ border-image: url(:/images/avatarstatus_bg.png);
<height>116</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{
border-image: url(:/images/avatarstatus_bg.png);
}</string>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
@ -929,6 +905,14 @@ background: white;}</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>AvatarWidget</class>
<extends>QWidget</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>