Added (make functional) the lobby menu in the context menu of the gpg and group item in FriendList.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4858 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-01-27 20:53:17 +00:00
parent 0cf53e993e
commit 6de8541a4e
4 changed files with 241 additions and 209 deletions

View file

@ -314,6 +314,8 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
break; break;
} }
QMenu *lobbyMenu = NULL;
switch (type) { switch (type) {
case TYPE_GROUP: case TYPE_GROUP:
{ {
@ -330,43 +332,14 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup())); action = contextMnu.addAction(QIcon(IMAGE_REMOVE), tr("Remove Group"), this, SLOT(removeGroup()));
action->setDisabled(standard); action->setDisabled(standard);
contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Create chat lobby"), this, SLOT(createchatlobby())); lobbyMenu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Chat lobbies")) ;
} }
break; break;
case TYPE_GPG: case TYPE_GPG:
case TYPE_SSL: case TYPE_SSL:
{ {
contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy())); contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
QMenu *mnu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Chat lobbies")) ; lobbyMenu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Chat lobbies")) ;
mnu->addAction(QIcon(IMAGE_ADDFRIEND),tr("create new"),this,SLOT(createchatlobby())) ;
// Get existing lobbies
//
std::list<ChatLobbyInfo> cl_infos ;
rsMsgs->getChatLobbyList(cl_infos) ;
for(std::list<ChatLobbyInfo>::const_iterator it(cl_infos.begin());it!=cl_infos.end();++it)
{
std::cerr << "Adding meny entry with lobby id " << std::hex << (*it).lobby_id << std::dec << std::endl;
QMenu *mnu2 = mnu->addMenu(QIcon(IMAGE_CHAT), QString::fromUtf8((*it).lobby_name.c_str())) ;
QAction* inviteToLobbyAction = new QAction(tr("Invite this friend"), mnu2);
inviteToLobbyAction->setData(QString::number((*it).lobby_id));
connect(inviteToLobbyAction, SIGNAL(triggered()), this, SLOT(inviteToLobby()));
mnu2->addAction(inviteToLobbyAction);
QAction* showLobbyAction = new QAction(tr("Show"), mnu2);
showLobbyAction->setData(QString::number((*it).lobby_id));
connect(showLobbyAction, SIGNAL(triggered()), this, SLOT(showLobby()));
mnu2->addAction(showLobbyAction);
QAction* unsubscribeToLobbyAction = new QAction(tr("Unsubscribe"), mnu2);
unsubscribeToLobbyAction->setData(QString::number((*it).lobby_id));
connect(unsubscribeToLobbyAction, SIGNAL(triggered()), this, SLOT(unsubscribeToLobby()));
mnu2->addAction(unsubscribeToLobbyAction);
}
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Friend"), this, SLOT(msgfriend())); contextMnu.addAction(QIcon(IMAGE_MSG), tr("Message Friend"), this, SLOT(msgfriend()));
@ -467,6 +440,37 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
} }
} }
} }
if (lobbyMenu) {
lobbyMenu->addAction(QIcon(IMAGE_ADDFRIEND), tr("Create new"), this, SLOT(createchatlobby()));
// Get existing lobbies
//
std::list<ChatLobbyInfo> cl_infos ;
rsMsgs->getChatLobbyList(cl_infos) ;
for(std::list<ChatLobbyInfo>::const_iterator it(cl_infos.begin());it!=cl_infos.end();++it)
{
std::cerr << "Adding meny entry with lobby id " << std::hex << (*it).lobby_id << std::dec << std::endl;
QMenu *mnu2 = lobbyMenu->addMenu(QIcon(IMAGE_CHAT), QString::fromUtf8((*it).lobby_name.c_str())) ;
QAction* inviteToLobbyAction = new QAction((type == TYPE_GROUP) ? tr("Invite this group") : tr("Invite this friend"), mnu2);
inviteToLobbyAction->setData(QString::number((*it).lobby_id));
connect(inviteToLobbyAction, SIGNAL(triggered()), this, SLOT(inviteToLobby()));
mnu2->addAction(inviteToLobbyAction);
QAction* showLobbyAction = new QAction(tr("Show"), mnu2);
showLobbyAction->setData(QString::number((*it).lobby_id));
connect(showLobbyAction, SIGNAL(triggered()), this, SLOT(showLobby()));
mnu2->addAction(showLobbyAction);
QAction* unsubscribeToLobbyAction = new QAction(tr("Unsubscribe"), mnu2);
unsubscribeToLobbyAction->setData(QString::number((*it).lobby_id));
connect(unsubscribeToLobbyAction, SIGNAL(triggered()), this, SLOT(unsubscribeToLobby()));
mnu2->addAction(unsubscribeToLobbyAction);
}
}
} else { } else {
QAction *action = contextMnu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste Friend Link"), this, SLOT(pastePerson())); QAction *action = contextMnu.addAction(QIcon(IMAGE_PASTELINK), tr("Paste Friend Link"), this, SLOT(pastePerson()));
if (RSLinkClipboard::empty(RetroShareLink::TYPE_PERSON)) { if (RSLinkClipboard::empty(RetroShareLink::TYPE_PERSON)) {
@ -1448,6 +1452,7 @@ void FriendList::showLobby()
if (rsMsgs->getVirtualPeerId(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong()), vpeer_id)) if (rsMsgs->getVirtualPeerId(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong()), vpeer_id))
ChatDialog::chatFriend(vpeer_id); ChatDialog::chatFriend(vpeer_id);
} }
void FriendList::unsubscribeToLobby() void FriendList::unsubscribeToLobby()
{ {
std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString(); std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString();
@ -1462,36 +1467,59 @@ void FriendList::unsubscribeToLobby()
rsMsgs->unsubscribeChatLobby(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong())) ; rsMsgs->unsubscribeChatLobby(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong())) ;
// we should also close existing windows. // we should also close existing windows.
ChatDialog::closeChat(vpeer_id); ChatDialog::closeChat(vpeer_id);
} }
void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string> &sslIds)
{
if (item == NULL) {
return;
}
std::string peerId = getRsId(item);
switch (item->type()) {
case TYPE_SSL:
sslIds.push_back(peerId);
break;
case TYPE_GPG:
rsPeers->getAssociatedSSLIds(peerId, sslIds);
break;
case TYPE_GROUP:
{
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(peerId, groupInfo)) {
std::list<std::string>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
}
}
}
break;
}
}
void FriendList::inviteToLobby() void FriendList::inviteToLobby()
{ {
QTreeWidgetItem *c = getCurrentPeer(); QTreeWidgetItem *c = getCurrentPeer();
if (c == NULL) { std::list<std::string> sslIds;
return; getSslIdsFromItem(c, sslIds);
}
if (c->type() != TYPE_SSL) {
// wrong type
return;
}
std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString(); std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString();
if (lobby_id.empty()) if (lobby_id.empty())
return; return;
std::string peer_id = getRsId(c) ; ChatLobbyId lobbyId = QString::fromStdString(lobby_id).toULongLong();
// add to group // add to group
rsMsgs->invitePeerToLobby(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong()), peer_id); std::list<std::string>::iterator it;
for (it = sslIds.begin(); it != sslIds.end(); ++it) {
rsMsgs->invitePeerToLobby(lobbyId, *it);
}
std::string vpeer_id; std::string vpeer_id;
if(rsMsgs->getVirtualPeerId( ChatLobbyId(QString::fromStdString(lobby_id).toULongLong() ),vpeer_id) ) if (rsMsgs->getVirtualPeerId(lobbyId, vpeer_id))
ChatDialog::chatFriend(vpeer_id); ChatDialog::chatFriend(vpeer_id);
} }
@ -1499,15 +1527,10 @@ void FriendList::createchatlobby()
{ {
QTreeWidgetItem *c = getCurrentPeer(); QTreeWidgetItem *c = getCurrentPeer();
if (c == NULL) std::list<std::string> sslIds;
return; getSslIdsFromItem(c, sslIds);
std::list<std::string> friend_list ; CreateLobbyDialog(sslIds).exec();
std::string peer_id = getRsId(c) ;
friend_list.push_back(peer_id) ;
CreateLobbyDialog(friend_list).exec() ;
} }
void FriendList::addToGroup() void FriendList::addToGroup()

View file

@ -92,6 +92,7 @@ private:
static bool filterItem(QTreeWidgetItem *pItem, const QString &sPattern); static bool filterItem(QTreeWidgetItem *pItem, const QString &sPattern);
void updateHeader(); void updateHeader();
void initializeHeader(bool afterLoadSettings); void initializeHeader(bool afterLoadSettings);
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<std::string> &sslIds);
private slots: private slots:
void groupsChanged(); void groupsChanged();

View file

@ -996,13 +996,13 @@ p, li { white-space: pre-wrap; }
<translation>Abonnieren</translation> <translation>Abonnieren</translation>
</message> </message>
<message> <message>
<location line="+164"/> <location line="+181"/>
<location line="+3"/> <location line="+3"/>
<source>Set all as read</source> <source>Set all as read</source>
<translation>Alle als gelesen markieren</translation> <translation>Alle als gelesen markieren</translation>
</message> </message>
<message> <message>
<location line="-238"/> <location line="-255"/>
<source>Unsubcribe To Channel</source> <source>Unsubcribe To Channel</source>
<translation>Kanal abbestellen</translation> <translation>Kanal abbestellen</translation>
</message> </message>
@ -1073,7 +1073,7 @@ p, li { white-space: pre-wrap; }
<translation>Deaktiviere Auto-Download</translation> <translation>Deaktiviere Auto-Download</translation>
</message> </message>
<message> <message>
<location filename="../gui/ChannelFeed.ui" line="+127"/> <location filename="../gui/ChannelFeed.ui" line="+144"/>
<location line="+3"/> <location line="+3"/>
<location filename="../gui/ChannelFeed.cpp" line="+2"/> <location filename="../gui/ChannelFeed.cpp" line="+2"/>
<source>Enable Auto-Download</source> <source>Enable Auto-Download</source>
@ -1088,7 +1088,7 @@ p, li { white-space: pre-wrap; }
<context> <context>
<name>ChatDialog</name> <name>ChatDialog</name>
<message> <message>
<location filename="../gui/chat/ChatDialog.cpp" line="+226"/> <location filename="../gui/chat/ChatDialog.cpp" line="+237"/>
<source>Friend not Online</source> <source>Friend not Online</source>
<translation>Freund ist nicht online</translation> <translation>Freund ist nicht online</translation>
</message> </message>
@ -1194,7 +1194,7 @@ p, li { white-space: pre-wrap; }
<translation>Abonnieren</translation> <translation>Abonnieren</translation>
</message> </message>
<message> <message>
<location line="+248"/> <location line="+240"/>
<source>Invitation to chat lobby</source> <source>Invitation to chat lobby</source>
<translation>Einladung zur Chat Lobby</translation> <translation>Einladung zur Chat Lobby</translation>
</message> </message>
@ -4744,7 +4744,7 @@ p, li { white-space: pre-wrap; }
<translation>Standort</translation> <translation>Standort</translation>
</message> </message>
<message> <message>
<location line="+9"/> <location line="+11"/>
<source>Message Group</source> <source>Message Group</source>
<translation>Gruppe anschreiben</translation> <translation>Gruppe anschreiben</translation>
</message> </message>
@ -4764,27 +4764,26 @@ p, li { white-space: pre-wrap; }
<translation>Gruppe entfernen</translation> <translation>Gruppe entfernen</translation>
</message> </message>
<message> <message>
<location line="+3"/>
<source>Create chat lobby</source> <source>Create chat lobby</source>
<translation>Erstelle Chat Lobby</translation> <translation type="obsolete">Erstelle Chat Lobby</translation>
</message> </message>
<message> <message>
<location line="+6"/> <location line="+9"/>
<source>Chat</source> <source>Chat</source>
<translation>Chat</translation> <translation>Chat</translation>
</message> </message>
<message> <message>
<location line="+1"/> <location line="-6"/>
<location line="+7"/>
<source>Chat lobbies</source> <source>Chat lobbies</source>
<translation>Chat Lobbies</translation> <translation>Chat Lobbies</translation>
</message> </message>
<message> <message>
<location line="+2"/>
<source>create new</source> <source>create new</source>
<translation>Erstellen</translation> <translation type="obsolete">Erstellen</translation>
</message> </message>
<message> <message>
<location line="+13"/> <location line="+116"/>
<source>Invite this friend</source> <source>Invite this friend</source>
<translation>Lade diesen Freund ein</translation> <translation>Lade diesen Freund ein</translation>
</message> </message>
@ -4799,7 +4798,7 @@ p, li { white-space: pre-wrap; }
<translation>Abbestellen</translation> <translation>Abbestellen</translation>
</message> </message>
<message> <message>
<location line="+6"/> <location line="-124"/>
<source>Message Friend</source> <source>Message Friend</source>
<translation>Freund anschreiben</translation> <translation>Freund anschreiben</translation>
</message> </message>
@ -4830,12 +4829,12 @@ p, li { white-space: pre-wrap; }
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<location line="+79"/> <location line="+110"/>
<source>Paste Friend Link</source> <source>Paste Friend Link</source>
<translation>RetroShare Link einfügen</translation> <translation>RetroShare Link einfügen</translation>
</message> </message>
<message> <message>
<location line="-73"/> <location line="-104"/>
<source>Deny Friend</source> <source>Deny Friend</source>
<translation>Blockiere Freund</translation> <translation>Blockiere Freund</translation>
</message> </message>
@ -4870,7 +4869,17 @@ p, li { white-space: pre-wrap; }
<translation>Aus allen Gruppen entfernen</translation> <translation>Aus allen Gruppen entfernen</translation>
</message> </message>
<message> <message>
<location line="+17"/> <location line="+10"/>
<source>Create new</source>
<translation>Erstellen</translation>
</message>
<message>
<location line="+13"/>
<source>Invite this group</source>
<translation>Lade diesen Gruppe ein</translation>
</message>
<message>
<location line="+25"/>
<source>Expand all</source> <source>Expand all</source>
<translation>Alle erweitern</translation> <translation>Alle erweitern</translation>
</message> </message>
@ -4891,7 +4900,7 @@ p, li { white-space: pre-wrap; }
<translation>Möchtest du diesen Freund entfernen?</translation> <translation>Möchtest du diesen Freund entfernen?</translation>
</message> </message>
<message> <message>
<location line="+68"/> <location line="+69"/>
<source>Unsubscribe to lobby</source> <source>Unsubscribe to lobby</source>
<translation>Lobby abbestellen</translation> <translation>Lobby abbestellen</translation>
</message> </message>
@ -4901,7 +4910,7 @@ p, li { white-space: pre-wrap; }
<translation>Du bestellst die Lobby ab.&lt;br&gt;Du kannst nur wieder teilnehmen, wenn deine Freunde dich wieder einladen.</translation> <translation>Du bestellst die Lobby ab.&lt;br&gt;Du kannst nur wieder teilnehmen, wenn deine Freunde dich wieder einladen.</translation>
</message> </message>
<message> <message>
<location line="+402"/> <location line="+420"/>
<source>Sort by</source> <source>Sort by</source>
<translation>Sortiere nach</translation> <translation>Sortiere nach</translation>
</message> </message>
@ -4918,7 +4927,7 @@ p, li { white-space: pre-wrap; }
<translation type="obsolete">Formular</translation> <translation type="obsolete">Formular</translation>
</message> </message>
<message> <message>
<location filename="../gui/common/FriendSelectionWidget.ui" line="+28"/> <location filename="../gui/common/FriendSelectionWidget.ui" line="+31"/>
<source>Search for Name:</source> <source>Search for Name:</source>
<translation>Suche Name:</translation> <translation>Suche Name:</translation>
</message> </message>
@ -10631,21 +10640,21 @@ p, li { white-space: pre-wrap; }
</message> </message>
<message> <message>
<location line="+120"/> <location line="+120"/>
<location line="+269"/> <location line="+262"/>
<location line="+242"/> <location line="+242"/>
<source>Next &gt;</source> <source>Next &gt;</source>
<translation>Weiter &gt;</translation> <translation>Weiter &gt;</translation>
</message> </message>
<message> <message>
<location line="-501"/> <location line="-494"/>
<location line="+269"/> <location line="+262"/>
<location line="+242"/> <location line="+242"/>
<location line="+205"/> <location line="+205"/>
<source>Exit</source> <source>Exit</source>
<translation>Beenden</translation> <translation>Beenden</translation>
</message> </message>
<message> <message>
<location line="-656"/> <location line="-649"/>
<source>For best performance, RetroShare needs to know a little about your connection to the internet.</source> <source>For best performance, RetroShare needs to know a little about your connection to the internet.</source>
<translation>Für die beste Leistung muß RetroShare ein wenig über Deine Internetverbindung wissen.</translation> <translation>Für die beste Leistung muß RetroShare ein wenig über Deine Internetverbindung wissen.</translation>
</message> </message>
@ -10666,7 +10675,7 @@ p, li { white-space: pre-wrap; }
<translation>Wählen Sie Ihre maximale Downloadgeschwindigkeit: </translation> <translation>Wählen Sie Ihre maximale Downloadgeschwindigkeit: </translation>
</message> </message>
<message> <message>
<location line="+59"/> <location line="+62"/>
<source>Connection :</source> <source>Connection :</source>
<translation>Verbindung :</translation> <translation>Verbindung :</translation>
</message> </message>
@ -10691,7 +10700,7 @@ p, li { white-space: pre-wrap; }
<translation>Entdeckung :</translation> <translation>Entdeckung :</translation>
</message> </message>
<message> <message>
<location line="+94"/> <location line="+84"/>
<location line="+242"/> <location line="+242"/>
<location line="+205"/> <location line="+205"/>
<source>&lt; Back</source> <source>&lt; Back</source>
@ -10809,7 +10818,7 @@ p, li { white-space: pre-wrap; }
<translation>Fertigstellen</translation> <translation>Fertigstellen</translation>
</message> </message>
<message> <message>
<location filename="../gui/QuickStartWizard.cpp" line="+205"/> <location filename="../gui/QuickStartWizard.cpp" line="+202"/>
<source>Select A Folder To Share</source> <source>Select A Folder To Share</source>
<translation>Wählen Sie ein Ordner zum Freigeben</translation> <translation>Wählen Sie ein Ordner zum Freigeben</translation>
</message> </message>
@ -10829,7 +10838,7 @@ p, li { white-space: pre-wrap; }
<translation>Warnung!</translation> <translation>Warnung!</translation>
</message> </message>
<message> <message>
<location filename="../gui/QuickStartWizard.ui" line="-782"/> <location filename="../gui/QuickStartWizard.ui" line="-775"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
@ -10866,7 +10875,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;img src=&quot;:/images/list_bullet_arrow.png&quot; /&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; beim Start von RetroShare.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation> &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;img src=&quot;:/images/list_bullet_arrow.png&quot; /&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; beim Start von RetroShare.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message> </message>
<message> <message>
<location line="+242"/> <location line="+245"/>
<source>Public: DHT &amp; Discovery</source> <source>Public: DHT &amp; Discovery</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -10886,9 +10895,8 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+8"/>
<source>Dynamic DNS:</source> <source>Dynamic DNS:</source>
<translation>Dynamisches DNS:</translation> <translation type="obsolete">Dynamisches DNS:</translation>
</message> </message>
</context> </context>
<context> <context>