mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 13:24:26 -04:00
added unsubscribe protocol, updated GUI
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ChatLobby@4738 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
cc57ab2462
commit
3addb36e4c
12 changed files with 213 additions and 19 deletions
|
@ -62,16 +62,8 @@ ChatLobbyDialog::~ChatLobbyDialog()
|
|||
{
|
||||
// announce leaving of lobby
|
||||
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
std::cerr << "In close event!" << std::endl;
|
||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubsribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes, QMessageBox::No))
|
||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubscribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes | QMessageBox::No))
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
||||
|
||||
PopupChatDialog::closeEvent(e) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::setNickName(const QString& nick)
|
||||
|
|
|
@ -55,7 +55,6 @@ class ChatLobbyDialog: public PopupChatDialog
|
|||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual void updateStatus(const QString &peer_id, int status) ; // needs grouped status. Not yet implemented.
|
||||
virtual void closeEvent(QCloseEvent*) ;
|
||||
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
|
|
|
@ -40,7 +40,7 @@ CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list,QWi
|
|||
rsMsgs->getDefaultNickNameForChatLobby(default_nick) ;
|
||||
|
||||
ui->lobbyName_LE->setPlaceholderText(tr("Put a sensible lobby name here")) ;
|
||||
ui->nickName_LE->setPlaceholderText(tr("Your nickname for this lobby")) ;
|
||||
ui->nickName_LE->setPlaceholderText(tr("Your nickname for this lobby (Change default name in options->chat)")) ;
|
||||
ui->nickName_LE->setText(QString::fromStdString(default_nick)) ;
|
||||
|
||||
connect( ui->shareButton, SIGNAL( clicked ( bool ) ), this, SLOT( createLobby( ) ) );
|
||||
|
|
|
@ -88,6 +88,17 @@ p, li { white-space: pre-wrap; }
|
|||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A chat lobby is a decentralized and anonymous chat group. All participants receive all messages. Once the lobby is created you can invite other friends from the Friends tab.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
|
|
|
@ -359,6 +359,14 @@ void PopupChatDialog::processSettings(bool bLoad)
|
|||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::closeChat(const std::string& id)
|
||||
{
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if(popupchatdialog != NULL)
|
||||
popupchatdialog->hide() ;
|
||||
}
|
||||
|
||||
void PopupChatDialog::chatFriend(const std::string &id)
|
||||
{
|
||||
if (id.empty()){
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
static PopupChatDialog *getPrivateChat(const std::string &id, uint chatflags);
|
||||
static void cleanupChat();
|
||||
static void chatFriend(const std::string &id);
|
||||
static void closeChat(const std::string &id);
|
||||
static void privateChatChanged(int list, int type);
|
||||
|
||||
void updateStatusString(const QString& peer_id, const QString& statusString);
|
||||
|
|
|
@ -336,23 +336,36 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
|
|||
case TYPE_SSL:
|
||||
{
|
||||
contextMnu.addAction(QIcon(IMAGE_CHAT), tr("Chat"), this, SLOT(chatfriendproxy()));
|
||||
QMenu *mnu = contextMnu.addMenu(QIcon(IMAGE_CHAT), tr("Invite to chat lobby")) ;
|
||||
QMenu *mnu = 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;
|
||||
|
||||
QAction* inviteToLobbyAction = new QAction(QString::fromUtf8((*it).lobby_name.c_str()), mnu);
|
||||
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()));
|
||||
mnu->addAction(inviteToLobbyAction);
|
||||
}
|
||||
mnu2->addAction(inviteToLobbyAction);
|
||||
|
||||
mnu->addAction(QIcon(IMAGE_CHAT),tr("create new"),this,SLOT(createchatlobby())) ;
|
||||
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()));
|
||||
|
||||
|
@ -1393,6 +1406,37 @@ void FriendList::configurefriend()
|
|||
ConfCertDialog::showIt(getRsId(getCurrentPeer()), ConfCertDialog::PageDetails);
|
||||
}
|
||||
|
||||
void FriendList::showLobby()
|
||||
{
|
||||
std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString();
|
||||
|
||||
if(lobby_id.empty())
|
||||
return;
|
||||
|
||||
std::string vpeer_id ;
|
||||
|
||||
if(rsMsgs->getVirtualPeerId( ChatLobbyId(QString::fromStdString(lobby_id).toULongLong() ),vpeer_id))
|
||||
PopupChatDialog::chatFriend(vpeer_id) ;
|
||||
}
|
||||
void FriendList::unsubscribeToLobby()
|
||||
{
|
||||
std::string lobby_id = qobject_cast<QAction*>(sender())->data().toString().toStdString();
|
||||
|
||||
if(lobby_id.empty())
|
||||
return;
|
||||
|
||||
std::string vpeer_id ;
|
||||
rsMsgs->getVirtualPeerId( ChatLobbyId(QString::fromStdString(lobby_id).toULongLong() ),vpeer_id) ;
|
||||
|
||||
if(QMessageBox::Ok == QMessageBox::question(this,tr("Unsubscribe to lobby"),tr("You are about to unsubscribe a chat lobby<br>You can only re-enter if your friends invite you again."),QMessageBox::Ok | QMessageBox::Cancel))
|
||||
rsMsgs->unsubscribeChatLobby(ChatLobbyId(QString::fromStdString(lobby_id).toULongLong())) ;
|
||||
|
||||
// we should also close existing windows.
|
||||
|
||||
PopupChatDialog::closeChat(vpeer_id) ;
|
||||
}
|
||||
|
||||
|
||||
void FriendList::inviteToLobby()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
|
|
|
@ -125,6 +125,8 @@ private slots:
|
|||
|
||||
void inviteToLobby();
|
||||
void createchatlobby();
|
||||
void unsubscribeToLobby();
|
||||
void showLobby();
|
||||
};
|
||||
|
||||
#endif // FRIENDLIST_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue