Fixed start of chat with right or double click on a friend item (not location) in friend list.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7633 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-10-25 12:26:09 +00:00
parent 26f93c2a55
commit a3af37c7e4
4 changed files with 75 additions and 48 deletions

View File

@ -206,22 +206,22 @@ void ChatDialog::init(const RsPeerId &peerId, const QString &title)
/*static*/ void ChatDialog::chatFriend(const RsPeerId &peerId, const bool forceFocus)
{
if (peerId.isNull()){
if (peerId.isNull()){
return;
}
RsGxsId distant_chat_gxs_id ;
RsGxsId distant_chat_gxs_id ;
uint32_t distant_peer_status ;
if(rsMsgs->getDistantChatStatus(peerId,distant_chat_gxs_id,distant_peer_status))
if(rsMsgs->getDistantChatStatus(peerId,distant_chat_gxs_id,distant_peer_status))
{
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN ); // use own flags
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN ); // use own flags
return ;
}
ChatLobbyId lid;
if (rsMsgs->isLobbyId(peerId, lid)) {
getChat(peerId, (forceFocus ? (RS_CHAT_OPEN | RS_CHAT_FOCUS) : RS_CHAT_OPEN));
getChat(peerId, (forceFocus ? (RS_CHAT_OPEN | RS_CHAT_FOCUS) : RS_CHAT_OPEN));
}
RsPeerDetails detail;
@ -229,37 +229,55 @@ void ChatDialog::init(const RsPeerId &peerId, const QString &title)
return;
if (detail.isOnlyGPGdetail) {
std::list<RsPeerId> onlineIds;
//let's get the ssl child details
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
if (sslIds.size() == 1) {
// chat with the one ssl id (online or offline)
getChat(sslIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
return;
}
// more than one ssl ids available, check for online
for (std::list<RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) {
if (rsPeers->isOnline(*it)) {
onlineIds.push_back(*it);
}
}
if (onlineIds.size() == 1) {
// chat with the online ssl id
getChat(onlineIds.front(), forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
return;
}
// more than one ssl ids online or all offline
QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok);
mb.exec();
} else {
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
/* Should not happen */
//chatFriend(detail.gpg_id, forceFocus);
return;
}
getChat(peerId, forceFocus ? RS_CHAT_OPEN | RS_CHAT_FOCUS : RS_CHAT_OPEN);
}
/*static*/ void ChatDialog::chatFriend(const RsPgpId &gpgId, const bool forceFocus)
{
if (gpgId.isNull()){
return;
}
RsPeerDetails detail;
if (!rsPeers->getGPGDetails(gpgId, detail))
return;
if (!detail.isOnlyGPGdetail) {
return;
}
//let's get the ssl child details
std::list<RsPeerId> sslIds;
rsPeers->getAssociatedSSLIds(detail.gpg_id, sslIds);
if (sslIds.size() == 1) {
// chat with the one ssl id (online or offline)
chatFriend(sslIds.front(), forceFocus);
return;
}
// more than one ssl ids available, check for online
std::list<RsPeerId> onlineIds;
for (std::list<RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); ++it) {
if (rsPeers->isOnline(*it)) {
onlineIds.push_back(*it);
}
}
if (onlineIds.size() == 1) {
// chat with the online ssl id
chatFriend(onlineIds.front(), forceFocus);
return;
}
// more than one ssl ids online or all offline
QMessageBox mb(QMessageBox::Warning, "RetroShare", tr("Your friend has more than one locations.\nPlease choose one of it to chat with."), QMessageBox::Ok);
mb.exec();
}
void ChatDialog::addToParent(QWidget *newParent)

View File

@ -34,11 +34,12 @@ class ChatDialog : public QWidget
Q_OBJECT
public:
static ChatDialog *getExistingChat(const RsPeerId &peerId);
static ChatDialog *getChat(const RsPeerId &peerId, uint chatflags);
static ChatDialog *getExistingChat(const RsPeerId &peerId);
static ChatDialog *getChat(const RsPeerId &peerId, uint chatflags);
static void cleanupChat();
static void chatFriend(const RsPeerId &peerId, bool forceFocus = true);
static void closeChat(const RsPeerId &peerId);
static void chatFriend(const RsPeerId &peerId, bool forceFocus = true);
static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true);
static void closeChat(const RsPeerId &peerId);
static void chatChanged(int list, int type);
virtual void showDialog(uint /*chatflags*/) {}
@ -50,7 +51,7 @@ public:
void addToParent(QWidget *newParent);
void removeFromParent(QWidget *oldParent);
RsPeerId getPeerId() { return peerId; }
RsPeerId getPeerId() { return peerId; }
QString getTitle();
bool hasNewMessages();
bool isTyping();
@ -80,14 +81,14 @@ protected:
void closeEvent(QCloseEvent *event);
virtual bool canClose() { return true; }
virtual QString getPeerName(const RsPeerId &sslid) const ; // can be overloaded for chat dialogs that have specific peers
virtual QString getPeerName(const RsPeerId &sslid) const ; // can be overloaded for chat dialogs that have specific peers
virtual void init(const RsPeerId &peerId, const QString &title);
virtual void init(const RsPeerId &peerId, const QString &title);
virtual void onChatChanged(int /*list*/, int /*type*/) {}
virtual void addIncomingChatMsg(const ChatInfo& info) = 0;
RsPeerId peerId;
RsPeerId peerId;
};
#endif // CHATDIALOG_H

View File

@ -1278,14 +1278,22 @@ void FriendList::chatfriendproxy()
*
* @param pPeer the gpg or ssl QTreeWidgetItem to chat with
*/
void FriendList::chatfriend(QTreeWidgetItem *pPeer)
void FriendList::chatfriend(QTreeWidgetItem *item)
{
if (pPeer == NULL) {
if (item == NULL) {
return;
}
std::string id = getRsId(pPeer);
ChatDialog::chatFriend(RsPeerId(id));
switch (item->type()) {
case TYPE_GROUP:
break;
case TYPE_GPG:
ChatDialog::chatFriend(RsPgpId(getRsId(item)));
break;
case TYPE_SSL:
ChatDialog::chatFriend(RsPeerId(getRsId(item)));
break;
}
}
void FriendList::addFriend()

View File

@ -138,7 +138,7 @@ private slots:
void connectfriend();
void configurefriend();
void chatfriend(QTreeWidgetItem *);
void chatfriend(QTreeWidgetItem *item);
void chatfriendproxy();
//void copyLink();
void copyFullCertificate();