diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 5fc3436e1..8bfb80a98 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -1,28 +1,33 @@ -#include -#include -#include -#include -#include -#include -#include + #include "ChatLobbyWidget.h" -#include "chat/CreateLobbyDialog.h" -#include "chat/ChatTabWidget.h" -#include "common/RSTreeWidgetItem.h" + #include "notifyqt.h" #include "chat/ChatLobbyDialog.h" #include "chat/ChatLobbyUserNotify.h" -#include "util/HandleRichText.h" -#include "util/QtVersion.h" -#include "gui/settings/rsharesettings.h" +#include "chat/ChatTabWidget.h" +#include "chat/CreateLobbyDialog.h" +#include "common/RSTreeWidgetItem.h" #include "gui/gxs/GxsIdDetails.h" #include "gui/Identity/IdEditDialog.h" +#include "gui/settings/rsharesettings.h" +#include "util/HandleRichText.h" +#include "util/QtVersion.h" #include "retroshare/rsmsgs.h" #include "retroshare/rspeers.h" #include "retroshare/rsnotify.h" #include "retroshare/rsidentity.h" +#include +#include +#include +#include +#include +#include + +#include +#include + //#define CHAT_LOBBY_GUI_DEBUG 1 #define COLUMN_NAME 0 @@ -61,6 +66,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) m_bProcessSettings = false; myChatLobbyUserNotify = NULL; + myInviteYesButton = NULL; + myInviteIdChooser = NULL; QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&))); @@ -1081,8 +1088,8 @@ void ChatLobbyWidget::readChatLobbyInvites() std::list subscribed_lobbies ; rsMsgs->getChatLobbyList(subscribed_lobbies) ; - for(std::list::const_iterator it(invites.begin());it!=invites.end();++it) - { + for(std::list::const_iterator it(invites.begin());it!=invites.end();++it) + { // first check if the lobby is already subscribed. If so, just ignore the request. bool found = false ; @@ -1097,8 +1104,8 @@ void ChatLobbyWidget::readChatLobbyInvites() QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0); - QLabel *label ; - GxsIdChooser *idchooser = new GxsIdChooser ; + QLabel *label; + GxsIdChooser *idchooser = new GxsIdChooser; if( (*it).lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ) { @@ -1110,18 +1117,24 @@ void ChatLobbyWidget::readChatLobbyInvites() idchooser->loadIds(IDCHOOSER_ID_REQUIRED,default_id) ; label = new QLabel(tr("Choose an identity for this chat room:")); } + myInviteYesButton = mb.button(QMessageBox::Yes); + myInviteIdChooser = idchooser; + connect(idchooser, SIGNAL(currentIndexChanged(int)), this, SLOT(idChooserCurrentIndexChanged(int))); + idChooserCurrentIndexChanged(0); - QGridLayout* layout = qobject_cast(mb.layout()); - if (layout) { - layout->addWidget(label, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignHCenter ) ; - layout->addWidget(idchooser, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignRight ) ; - } else { - //Not QGridLayout so add at end - mb.layout()->addWidget(label) ; - mb.layout()->addWidget(idchooser) ; - } + QGridLayout* layout = qobject_cast(mb.layout()); + if (layout) { + layout->addWidget(label, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignHCenter ) ; + layout->addWidget(idchooser, layout->rowCount(), 0, 1, layout->columnCount(), Qt::AlignRight ) ; + } else { + //Not QGridLayout so add at end + mb.layout()->addWidget(label) ; + mb.layout()->addWidget(idchooser) ; + } - int res = mb.exec() ; + int res = mb.exec(); + myInviteYesButton = NULL; + myInviteIdChooser = NULL; if (res == QMessageBox::No) { @@ -1144,6 +1157,28 @@ void ChatLobbyWidget::readChatLobbyInvites() std::cerr << "Can't join chat room with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl; } + + myInviteYesButton = NULL; + myInviteIdChooser = NULL; +} + +void ChatLobbyWidget::idChooserCurrentIndexChanged(int /*index*/) +{ + if (myInviteYesButton && myInviteIdChooser) + { + RsGxsId chosen_id; + switch (myInviteIdChooser->getChosenId(chosen_id)) + { + case GxsIdChooser::KnowId: + case GxsIdChooser::UnKnowId: + myInviteYesButton->setEnabled(true); + break; + case GxsIdChooser::NoId: + case GxsIdChooser::None: + default: ; + myInviteYesButton->setEnabled(false); + } + } } void ChatLobbyWidget::filterColumnChanged(int) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index dff4a9206..32b149dfb 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -1,10 +1,16 @@ #pragma once -#include -#include #include "ui_ChatLobbyWidget.h" + #include "RsAutoUpdatePage.h" #include "chat/ChatLobbyUserNotify.h" +#include "gui/gxs/GxsIdChooser.h" + + +#include + +#include +#include #define IMAGE_CHATLOBBY ":/icons/png/chat-lobbies.png" @@ -82,6 +88,7 @@ private slots: void setShowSubscribeColumn(bool show); void updateNotify(ChatLobbyId id, unsigned int count) ; + void idChooserCurrentIndexChanged(int index); private: void autoSubscribeLobby(QTreeWidgetItem *item); @@ -114,6 +121,9 @@ private: ChatLobbyUserNotify* myChatLobbyUserNotify; + QAbstractButton* myInviteYesButton; + GxsIdChooser* myInviteIdChooser; + /* UI - from Designer */ Ui::ChatLobbyWidget ui; }; diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 303169182..e72da2c81 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -25,13 +25,14 @@ #include "GxsIdDetails.h" #include "RsGxsUpdateBroadcastBase.h" #include "gui/Identity/IdEditDialog.h" +#include "util/misc.h" + +#include #include #include #include -#include - #include #define ROLE_SORT Qt::UserRole + 1 // Qt::UserRole is reserved for data @@ -247,7 +248,10 @@ uint32_t GxsIdChooser::countEnabledEntries() const void GxsIdChooser::loadPrivateIds() { if (mFirstLoad) { + //whileBlocking doesn't work here. + bool prev = this->blockSignals(true); clear(); + this->blockSignals(prev); } std::list ids;