mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 07:16:11 -05:00
Merge pull request #1144 from PhenomRetroShare/Fix_DisableYesButtonOnInvite
Disable Yes button on chat room invitation if no Id selected.
This commit is contained in:
commit
b4ff14cd29
@ -1,28 +1,33 @@
|
||||
#include <QTreeWidget>
|
||||
#include <QTextBrowser>
|
||||
#include <QTimer>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
#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 <QGridLayout>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QTextBrowser>
|
||||
#include <QTimer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <algorithm>
|
||||
#include <time.h>
|
||||
|
||||
//#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<ChatLobbyId> subscribed_lobbies ;
|
||||
rsMsgs->getChatLobbyList(subscribed_lobbies) ;
|
||||
|
||||
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
|
||||
{
|
||||
for(std::list<ChatLobbyInvite>::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<QGridLayout*>(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<QGridLayout*>(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)
|
||||
|
@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include "ui_ChatLobbyWidget.h"
|
||||
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "chat/ChatLobbyUserNotify.h"
|
||||
#include "gui/gxs/GxsIdChooser.h"
|
||||
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
@ -25,13 +25,14 @@
|
||||
#include "GxsIdDetails.h"
|
||||
#include "RsGxsUpdateBroadcastBase.h"
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
#include <algorithm>
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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<RsGxsId> ids;
|
||||
|
Loading…
x
Reference in New Issue
Block a user