diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index aff45a225..cab4c6277 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -19,6 +19,7 @@ #define ROLE_SORT Qt::UserRole #define ROLE_ID Qt::UserRole + 1 #define ROLE_SUBSCRIBED Qt::UserRole + 2 +#define ROLE_PRIVACYLEVEL Qt::UserRole + 3 #define TYPE_FOLDER 0 #define TYPE_LOBBY 1 @@ -65,11 +66,13 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags) privateLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER); privateLobbyItem->setText(COLUMN_NAME, tr("Private Lobbies")); privateLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "1"); + privateLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE); lobbyTreeWidget->insertTopLevelItem(0, privateLobbyItem); publicLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER); publicLobbyItem->setText(COLUMN_NAME, tr("Public Lobbies")); publicLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "2"); + publicLobbyItem->setData(COLUMN_DATA, ROLE_PRIVACYLEVEL, RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC); lobbyTreeWidget->insertTopLevelItem(1, publicLobbyItem); lobbyTreeWidget->expandAll(); @@ -83,11 +86,15 @@ ChatLobbyWidget::~ChatLobbyWidget() void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu() { + QTreeWidgetItem *item = lobbyTreeWidget->currentItem(); + QMenu contextMnu(this); - contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat lobby"), this, SLOT(createChatLobby())); + if (item && item->type() == TYPE_FOLDER) { + QAction *action = contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat lobby"), this, SLOT(createChatLobby())); + action->setData(item->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt()); + } - QTreeWidgetItem *item = lobbyTreeWidget->currentItem(); if (item && item->type() == TYPE_LOBBY) { if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) { contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeItem())); @@ -96,6 +103,10 @@ void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu() } } + if (contextMnu.children().count() == 0) { + return; + } + contextMnu.exec(QCursor::pos()); } @@ -272,8 +283,14 @@ void ChatLobbyWidget::updateDisplay() void ChatLobbyWidget::createChatLobby() { + int privacyLevel = 0; + QAction *action = qobject_cast(sender()); + if (action) { + privacyLevel = action->data().toInt(); + } + std::list friends; - CreateLobbyDialog(friends).exec(); + CreateLobbyDialog(friends, privacyLevel).exec(); } static void subscribeLobby(QTreeWidgetItem *item) diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp index 57ca1ba20..16e0c7093 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp @@ -30,7 +30,7 @@ #include "gui/common/PeerDefs.h" #include "ChatDialog.h" -CreateLobbyDialog::CreateLobbyDialog(const std::list& peer_list,QWidget *parent, Qt::WFlags flags) : +CreateLobbyDialog::CreateLobbyDialog(const std::list& peer_list, int privacyLevel, QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags) { ui = new Ui::CreateLobbyDialog() ; @@ -56,6 +56,10 @@ CreateLobbyDialog::CreateLobbyDialog(const std::list& peer_list,QWi ui->keyShareList->start(); ui->keyShareList->setSelectedSslIds(peer_list, false); + if (privacyLevel) { + ui->security_CB->setCurrentIndex((privacyLevel == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? 0 : 1); + } + checkTextFields(); } diff --git a/retroshare-gui/src/gui/chat/CreateLobbyDialog.h b/retroshare-gui/src/gui/chat/CreateLobbyDialog.h index a560f3e7b..6bf600c1b 100644 --- a/retroshare-gui/src/gui/chat/CreateLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/CreateLobbyDialog.h @@ -7,11 +7,12 @@ class CreateLobbyDialog : public QDialog { Q_OBJECT + public: /* *@param chanId The channel id to send request for */ - CreateLobbyDialog(const std::list& friends_list,QWidget *parent = 0, Qt::WFlags flags = 0); + CreateLobbyDialog(const std::list& friends_list, int privacyLevel = 0, QWidget *parent = 0, Qt::WFlags flags = 0); ~CreateLobbyDialog(); protected: