示例#1
0
/** Default constructor */
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
	: ChatDialog(parent, flags), lobbyId(lid)
{
	/* Invoke Qt Designer generated QObject setup routine */
	ui.setupUi(this);

	connect(ui.participantsFrameButton, SIGNAL(toggled(bool)), this, SLOT(showParticipantsFrame(bool)));
	connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
	connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
	connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));

	ui.participantsList->setColumnCount(COLUMN_COUNT);
	ui.participantsList->setColumnWidth(COLUMN_ICON, 20);
    ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true);

	muteAct = new QAction(QIcon(), tr("Mute participant"), this);
	connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));

	// Add a button to invite friends.
	//
	inviteFriendsButton = new QToolButton ;
	inviteFriendsButton->setMinimumSize(QSize(28,28)) ;
	inviteFriendsButton->setMaximumSize(QSize(28,28)) ;
	inviteFriendsButton->setText(QString()) ;
	inviteFriendsButton->setAutoRaise(true) ;
	inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));

	{
	QIcon icon ;
	icon.addPixmap(QPixmap(":/images/edit_add24.png")) ;
	inviteFriendsButton->setIcon(icon) ;
	inviteFriendsButton->setIconSize(QSize(22,22)) ;
	}

	connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));

	getChatWidget()->addChatBarWidget(inviteFriendsButton) ;

	unsubscribeButton = new QToolButton ;
	unsubscribeButton->setMinimumSize(QSize(28,28)) ;
	unsubscribeButton->setMaximumSize(QSize(28,28)) ;
	unsubscribeButton->setText(QString()) ;
	unsubscribeButton->setAutoRaise(true) ;
	unsubscribeButton->setToolTip(tr("Leave this lobby (Unsubscribe)"));

	{
	QIcon icon ;
	icon.addPixmap(QPixmap(":/images/exit_32.png")) ;
	unsubscribeButton->setIcon(icon) ;
	unsubscribeButton->setIconSize(QSize(22,22)) ;
	}

	connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));

	getChatWidget()->addChatBarWidget(unsubscribeButton) ;
}
void ChatLobbyDialog::participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column)
{
	if (!item) {
		return;
	}

	if(column == COLUMN_NAME)
	{
		getChatWidget()->pasteText("@" + RsHtml::plainText(item->text(COLUMN_NAME))) ;
		return ;
	}

//	if (column == COLUMN_ICON) {
//		return;
//	}
//
//	QString nickname = item->text(COLUMN_NAME);
//	if (isParticipantMuted(nickname)) {
//		unMuteParticipant(nickname);
//	} else {
//		muteParticipant(nickname);
//	}
//
//	mutedParticipants->removeDuplicates();
//
//	updateParticipantsList();
}
示例#3
0
void ChatDialog::focusDialog()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->focusDialog();
	}
}
示例#4
0
void ChatDialog::removeFromParent(QWidget *oldParent)
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->removeFromParent(oldParent);
	}
}
示例#5
0
void ChatDialog::addToParent(QWidget *newParent)
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->addToParent(newParent);
	}
}
示例#6
0
const RSStyle *ChatDialog::getStyle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getStyle();
	}

	return NULL;
}
示例#7
0
bool ChatDialog::setStyle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->setStyle();
	}

	return false;
}
示例#8
0
QString ChatDialog::getTitle()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getTitle();
	}

	return "";
}
示例#9
0
int ChatDialog::getPeerStatus()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->getPeerStatus();
	}

	return 0;
}
示例#10
0
bool ChatDialog::hasNewMessages()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->hasNewMessages();
	}

	return false;
}
示例#11
0
bool ChatDialog::isTyping()
{
	ChatWidget *cw = getChatWidget();
	if (cw) {
		return cw->isTyping();
	}

	return false;
}
示例#12
0
void ChatDialog::init(const std::string &peerId, const QString &title)
{
	this->peerId = peerId;

	ChatWidget *cw = getChatWidget();
	if (cw) {
		cw->init(peerId, title);

		connect(cw, SIGNAL(infoChanged(ChatWidget*)), this, SLOT(chatInfoChanged(ChatWidget*)));
		connect(cw, SIGNAL(newMessage(ChatWidget*)), this, SLOT(chatNewMessage(ChatWidget*)));
	}
}
PopupDistantChatDialog::PopupDistantChatDialog(QWidget *parent, Qt::WindowFlags flags)
	: PopupChatDialog(parent,flags)
{
	_status_label = new QToolButton ;
	_update_timer = new QTimer ;
	
	_status_label->setAutoRaise(true);
	_status_label->setIconSize(QSize(24,24));

	_update_timer->setInterval(1000) ;
	QObject::connect(_update_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ;

	_update_timer->start() ;

	getChatWidget()->addChatBarWidget(_status_label) ;
	updateDisplay() ;
}
示例#14
0
/** Default constructor */
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
    : ChatDialog(parent, flags), lobbyId(lid)
{
    /* Invoke Qt Designer generated QObject setup routine */
    ui.setupUi(this);

    lastUpdateListTime = 0;

    //connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
    connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
    connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));

    int S = QFontMetricsF(font()).height() ;
    ui.participantsList->setIconSize(QSize(1.3*S,1.3*S));

    ui.participantsList->setColumnCount(COLUMN_COUNT);
    ui.participantsList->setColumnWidth(COLUMN_ICON, 1.4*S);
    ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true);
    ui.participantsList->setColumnHidden(COLUMN_ID,true);

    muteAct = new QAction(QIcon(), tr("Mute participant"), this);
    distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
    sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);

    QActionGroup *sortgrp = new QActionGroup(this);
    actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this);
    actionSortByName->setCheckable(true);
    actionSortByName->setChecked(true);
    actionSortByName->setActionGroup(sortgrp);

    actionSortByActivity = new QAction(QIcon(), tr("Sort by Activity"), this);
    actionSortByActivity->setCheckable(true);
    actionSortByActivity->setChecked(false);
    actionSortByActivity->setActionGroup(sortgrp);


    connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
    connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
    connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));

    connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
    connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));

    // Add a button to invite friends.
    //
    inviteFriendsButton = new QToolButton ;
    inviteFriendsButton->setMinimumSize(QSize(2*S,2*S)) ;
    inviteFriendsButton->setMaximumSize(QSize(2*S,2*S)) ;
    inviteFriendsButton->setText(QString()) ;
    inviteFriendsButton->setAutoRaise(true) ;
    inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));

    mParticipantCompareRole = new RSTreeWidgetItemCompareRole;
    mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT);

    {
        QIcon icon ;
        icon.addPixmap(QPixmap(":/images/edit_add24.png")) ;
        inviteFriendsButton->setIcon(icon) ;
        inviteFriendsButton->setIconSize(QSize(2*S,2*S)) ;
    }

    connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));

    getChatWidget()->addChatBarWidget(inviteFriendsButton) ;

    RsGxsId current_id;
    rsMsgs->getIdentityForChatLobby(lobbyId, current_id);

    ownIdChooser = new GxsIdChooser() ;
    ownIdChooser->loadIds(IDCHOOSER_ID_REQUIRED,current_id) ;

    QWidgetAction *checkableAction = new QWidgetAction(this);
    checkableAction->setDefaultWidget(ownIdChooser);

    ui.chatWidget->addToolsAction(checkableAction);
    //getChatWidget()->addChatBarWidget(ownIdChooser);



    connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ;

    unsubscribeButton = new QToolButton ;
    unsubscribeButton->setMinimumSize(QSize(2*S,2*S)) ;
    unsubscribeButton->setMaximumSize(QSize(2*S,2*S)) ;
    unsubscribeButton->setText(QString()) ;
    unsubscribeButton->setAutoRaise(true) ;
    unsubscribeButton->setToolTip(tr("Leave this lobby (Unsubscribe)"));

    {
        QIcon icon ;
        icon.addPixmap(QPixmap(":/images/door_in.png")) ;
        unsubscribeButton->setIcon(icon) ;
        unsubscribeButton->setIconSize(QSize(1.5*S,1.5*S)) ;
    }

    /* Initialize splitter */
    ui.splitter->setStretchFactor(0, 1);
    ui.splitter->setStretchFactor(1, 0);

    connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));

    getChatWidget()->addChatBarWidget(unsubscribeButton) ;
}
示例#15
0
void ChatDialog::setPeerStatus(uint32_t status)
{
	ChatWidget *cw = getChatWidget();
	if (cw) 
		cw->updateStatus(QString::fromStdString(getPeerId()), status);
}
void PopupDistantChatDialog::updateDisplay()
{
	if(RsAutoUpdatePage::eventsLocked())	// we need to do that by end, because it's not possible to derive from both PopupChatDialog and RsAutoUpdatePage 
		return ;										// which both derive from QObject. Signals-slot connexions won't work anymore.

	if(!isVisible())
		return ;

	//std::cerr << "Checking tunnel..." ;
	// make sure about the tunnel status
	//
	
	uint32_t status= RS_DISTANT_CHAT_STATUS_UNKNOWN;
    rsMsgs->getDistantChatStatus(_pid,status) ;

        ui.avatarWidget->setId(ChatId(_pid));

    QString msg;
	switch(status)
	{
        case RS_DISTANT_CHAT_STATUS_UNKNOWN: //std::cerr << "Unknown hash. Error!" << std::endl;
            _status_label->setIcon(QIcon(IMAGE_GRY_LED)) ;
            msg = tr("Hash Error. No tunnel.");
            _status_label->setToolTip(msg) ;
            getChatWidget()->updateStatusString("%1", msg, true);
            getChatWidget()->blockSending(tr("Can't send message, because there is no tunnel."));
            setPeerStatus(RS_STATUS_OFFLINE) ;
            break ;
        case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl;
            _status_label->setIcon(QIcon(IMAGE_RED_LED)) ;
            _status_label->setToolTip(QObject::tr("Distant peer has closed the chat")) ;

            getChatWidget()->updateStatusString("%1", tr("The person you're talking to has deleted the secured chat tunnel. You may remove the chat window now."), true);
            getChatWidget()->blockSending(tr("Can't send message, because the chat partner deleted the secure tunnel."));
            setPeerStatus(RS_STATUS_OFFLINE) ;

            break ;
		case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: //std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
            _status_label->setIcon(QIcon(IMAGE_RED_LED)) ;
            msg = QObject::tr("Tunnel is pending...");
            _status_label->setToolTip(msg) ;
            getChatWidget()->updateStatusString("%1", msg, true);
            getChatWidget()->blockSending(msg);
            setPeerStatus(RS_STATUS_OFFLINE) ;
            break ;
		case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: //std::cerr << "Tunnel is ok. " << std::endl;
            _status_label->setIcon(QIcon(IMAGE_YEL_LED)) ;
            msg = QObject::tr("Secured tunnel established. Waiting for ACK...");
            _status_label->setToolTip(msg) ;
            getChatWidget()->updateStatusString("%1", msg, true);
            getChatWidget()->blockSending(msg);
            setPeerStatus(RS_STATUS_ONLINE) ;
            break ;
		case RS_DISTANT_CHAT_STATUS_CAN_TALK: //std::cerr << "Tunnel is ok and data is transmitted." << std::endl;
            _status_label->setIcon(QIcon(IMAGE_GRN_LED)) ;
            msg = QObject::tr("Secured tunnel is working. You can talk!");
            _status_label->setToolTip(msg) ;
            getChatWidget()->unblockSending();
            setPeerStatus(RS_STATUS_ONLINE) ;
            break ;
	}
}