2011-11-27 16:04:10 -05:00
/****************************************************************
*
* RetroShare is distributed under the following license :
*
* Copyright ( C ) 2011 , csoler
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor ,
* Boston , MA 02110 - 1301 , USA .
2016-01-28 10:22:32 -05:00
*
* ccr . 2016 Jan 26
*
* Play sound on incoming messages .
*
2011-11-27 16:04:10 -05:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2015-05-15 16:46:00 -04:00
# include <unistd.h>
2011-11-27 16:04:10 -05:00
# include <QMessageBox>
2012-01-28 10:11:58 -05:00
# include <QInputDialog>
2012-11-14 09:39:08 -05:00
# include <QMenu>
2015-08-29 21:48:45 -04:00
# include <QWidgetAction>
2011-11-27 16:04:10 -05:00
# include "ChatLobbyDialog.h"
2013-02-22 16:42:27 -05:00
# include "gui/ChatLobbyWidget.h"
2012-01-18 15:02:19 -05:00
# include "ChatTabWidget.h"
2012-01-17 15:36:36 -05:00
# include "gui/settings/rsharesettings.h"
# include "gui/settings/RsharePeerSettings.h"
2012-03-30 19:02:52 -04:00
# include "gui/MainWindow.h"
2012-01-18 15:02:19 -05:00
# include "gui/FriendsDialog.h"
2015-09-07 09:13:32 -04:00
# include "gui/msgs/MessageComposer.h"
2012-05-11 16:53:27 -04:00
# include <gui/common/html.h>
2012-11-14 09:39:08 -05:00
# include "gui/common/RSTreeWidgetItem.h"
2013-02-22 16:42:27 -05:00
# include "gui/common/FriendSelectionDialog.h"
2015-03-06 16:13:23 -05:00
# include "gui/gxs/GxsIdTreeWidgetItem.h"
# include "gui/gxs/GxsIdChooser.h"
2015-03-14 15:19:34 -04:00
# include "gui/gxs/GxsIdDetails.h"
2013-07-01 16:35:07 -04:00
# include "util/HandleRichText.h"
2016-01-28 10:22:32 -05:00
# include "gui/SoundManager.h"
2012-01-17 15:36:36 -05:00
# include <retroshare/rsnotify.h>
# include <time.h>
2011-11-27 16:04:10 -05:00
2015-03-06 16:13:23 -05:00
# define COLUMN_ICON 0
# define COLUMN_NAME 1
2013-08-24 11:07:31 -04:00
# define COLUMN_ACTIVITY 2
2015-03-06 16:13:23 -05:00
# define COLUMN_ID 3
# define COLUMN_COUNT 4
2012-11-15 19:53:13 -05:00
2015-12-15 14:20:11 -05:00
# define ROLE_SORT Qt::UserRole + 1
2015-10-21 16:18:43 -04:00
const static uint32_t timeToInactivity = 60 * 10 ; // in seconds
2011-11-27 16:04:10 -05:00
/** Default constructor */
2013-10-18 17:10:33 -04:00
ChatLobbyDialog : : ChatLobbyDialog ( const ChatLobbyId & lid , QWidget * parent , Qt : : WindowFlags flags )
2012-01-17 15:36:36 -05:00
: ChatDialog ( parent , flags ) , lobbyId ( lid )
2011-11-27 16:04:10 -05:00
{
2012-01-17 15:36:36 -05:00
/* Invoke Qt Designer generated QObject setup routine */
ui . setupUi ( this ) ;
2015-06-15 14:21:28 -04:00
lastUpdateListTime = 0 ;
2015-03-06 16:13:23 -05:00
//connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
2013-03-19 17:37:38 -04:00
connect ( ui . participantsList , SIGNAL ( customContextMenuRequested ( QPoint ) ) , this , SLOT ( participantsTreeWidgetCustomPopupMenu ( QPoint ) ) ) ;
2012-11-15 19:53:13 -05:00
connect ( ui . participantsList , SIGNAL ( itemDoubleClicked ( QTreeWidgetItem * , int ) ) , this , SLOT ( participantsTreeWidgetDoubleClicked ( QTreeWidgetItem * , int ) ) ) ;
2012-11-14 09:39:08 -05:00
2015-07-03 16:27:30 -04:00
int S = QFontMetricsF ( font ( ) ) . height ( ) ;
2015-11-04 17:47:12 -05:00
ui . participantsList - > setIconSize ( QSize ( 1.3 * S , 1.3 * S ) ) ;
2015-07-03 16:27:30 -04:00
2015-03-06 16:13:23 -05:00
ui . participantsList - > setColumnCount ( COLUMN_COUNT ) ;
2015-11-04 17:47:12 -05:00
ui . participantsList - > setColumnWidth ( COLUMN_ICON , 1.4 * S ) ;
2013-08-24 11:07:31 -04:00
ui . participantsList - > setColumnHidden ( COLUMN_ACTIVITY , true ) ;
2015-03-06 16:13:23 -05:00
ui . participantsList - > setColumnHidden ( COLUMN_ID , true ) ;
2012-02-09 16:24:51 -05:00
2015-09-07 09:13:32 -04:00
muteAct = new QAction ( QIcon ( ) , tr ( " Mute participant " ) , this ) ;
2016-03-09 21:49:24 -05:00
banAct = new QAction ( QIcon ( " :/icons/yellow_biohazard64.png " ) , tr ( " Ban this person (Sets negative opinion) " ) , this ) ;
2015-09-07 09:13:32 -04:00
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 ) ;
2015-12-17 19:40:39 -05:00
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 ) ;
2015-03-06 16:13:23 -05:00
connect ( muteAct , SIGNAL ( triggered ( ) ) , this , SLOT ( changePartipationState ( ) ) ) ;
connect ( distantChatAct , SIGNAL ( triggered ( ) ) , this , SLOT ( distantChatParticipant ( ) ) ) ;
2015-09-07 09:13:32 -04:00
connect ( sendMessageAct , SIGNAL ( triggered ( ) ) , this , SLOT ( sendMessage ( ) ) ) ;
2016-03-09 21:49:24 -05:00
connect ( banAct , SIGNAL ( triggered ( ) ) , this , SLOT ( banParticipant ( ) ) ) ;
2015-12-17 19:40:39 -05:00
connect ( actionSortByName , SIGNAL ( triggered ( ) ) , this , SLOT ( sortParcipants ( ) ) ) ;
connect ( actionSortByActivity , SIGNAL ( triggered ( ) ) , this , SLOT ( sortParcipants ( ) ) ) ;
2013-02-22 16:42:27 -05:00
// Add a button to invite friends.
//
2013-10-04 08:13:09 -04:00
inviteFriendsButton = new QToolButton ;
2016-08-04 19:00:53 -04:00
inviteFriendsButton - > setMinimumSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
inviteFriendsButton - > setMaximumSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
2013-02-22 16:42:27 -05:00
inviteFriendsButton - > setText ( QString ( ) ) ;
2013-10-04 08:13:09 -04:00
inviteFriendsButton - > setAutoRaise ( true ) ;
2013-02-22 16:42:27 -05:00
inviteFriendsButton - > setToolTip ( tr ( " Invite friends to this lobby " ) ) ;
2015-03-06 16:13:23 -05:00
mParticipantCompareRole = new RSTreeWidgetItemCompareRole ;
2015-12-15 14:20:11 -05:00
mParticipantCompareRole - > setRole ( COLUMN_ACTIVITY , ROLE_SORT ) ;
2015-03-06 16:13:23 -05:00
2013-02-24 17:44:14 -05:00
{
2013-02-22 16:42:27 -05:00
QIcon icon ;
2016-08-04 19:00:53 -04:00
icon . addPixmap ( QPixmap ( " :/icons/png/invite.png " ) ) ;
2013-02-22 16:42:27 -05:00
inviteFriendsButton - > setIcon ( icon ) ;
2016-08-04 19:00:53 -04:00
inviteFriendsButton - > setIconSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
2013-02-24 17:44:14 -05:00
}
2013-02-22 16:42:27 -05:00
connect ( inviteFriendsButton , SIGNAL ( clicked ( ) ) , this , SLOT ( inviteFriends ( ) ) ) ;
2016-06-15 17:32:01 -04:00
getChatWidget ( ) - > addTitleBarWidget ( inviteFriendsButton ) ;
2015-03-06 16:13:23 -05:00
RsGxsId current_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , current_id ) ;
2016-07-30 13:14:59 -04:00
uint32_t idChooserFlag = IDCHOOSER_ID_REQUIRED ;
ChatLobbyInfo lobbyInfo ;
if ( rsMsgs - > getChatLobbyInfo ( lobbyId , lobbyInfo ) ) {
if ( lobbyInfo . lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ) {
idChooserFlag | = IDCHOOSER_NON_ANONYMOUS ;
}
}
2015-03-06 16:13:23 -05:00
ownIdChooser = new GxsIdChooser ( ) ;
2016-07-30 13:14:59 -04:00
ownIdChooser - > loadIds ( idChooserFlag , current_id ) ;
2015-08-29 21:48:45 -04:00
QWidgetAction * checkableAction = new QWidgetAction ( this ) ;
checkableAction - > setDefaultWidget ( ownIdChooser ) ;
ui . chatWidget - > addToolsAction ( checkableAction ) ;
//getChatWidget()->addChatBarWidget(ownIdChooser);
2015-03-06 16:13:23 -05:00
connect ( ownIdChooser , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( changeNickname ( ) ) ) ;
2013-02-24 17:44:14 -05:00
2015-03-06 16:13:23 -05:00
unsubscribeButton = new QToolButton ;
2016-08-04 19:00:53 -04:00
unsubscribeButton - > setMinimumSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
unsubscribeButton - > setMaximumSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
2013-02-24 17:44:14 -05:00
unsubscribeButton - > setText ( QString ( ) ) ;
2013-10-04 08:13:09 -04:00
unsubscribeButton - > setAutoRaise ( true ) ;
2013-02-24 17:44:14 -05:00
unsubscribeButton - > setToolTip ( tr ( " Leave this lobby (Unsubscribe) " ) ) ;
{
QIcon icon ;
2016-08-04 19:00:53 -04:00
icon . addPixmap ( QPixmap ( " :/icons/png/leave.png " ) ) ;
2013-02-24 17:44:14 -05:00
unsubscribeButton - > setIcon ( icon ) ;
2016-08-04 19:00:53 -04:00
unsubscribeButton - > setIconSize ( QSize ( 2.4 * S , 2.4 * S ) ) ;
2013-02-24 17:44:14 -05:00
}
2014-12-13 18:32:23 -05:00
/* Initialize splitter */
ui . splitter - > setStretchFactor ( 0 , 1 ) ;
ui . splitter - > setStretchFactor ( 1 , 0 ) ;
2013-02-24 17:44:14 -05:00
connect ( unsubscribeButton , SIGNAL ( clicked ( ) ) , this , SLOT ( leaveLobby ( ) ) ) ;
2016-06-15 17:32:01 -04:00
getChatWidget ( ) - > addTitleBarWidget ( unsubscribeButton ) ;
2013-02-22 16:42:27 -05:00
}
2013-02-24 17:44:14 -05:00
void ChatLobbyDialog : : leaveLobby ( )
{
emit lobbyLeave ( id ( ) ) ;
}
2013-02-22 16:42:27 -05:00
void ChatLobbyDialog : : inviteFriends ( )
{
std : : cerr < < " Inviting friends " < < std : : endl ;
2015-04-17 17:36:22 -04:00
std : : set < RsPeerId > ids = FriendSelectionDialog : : selectFriends_SSL ( NULL , tr ( " Invite friends " ) , tr ( " Select friends to invite: " ) ) ;
2013-02-22 16:42:27 -05:00
std : : cerr < < " Inviting these friends: " < < std : : endl ;
2014-12-29 16:41:05 -05:00
if ( ! mChatId . isLobbyId ( ) )
2013-02-22 16:42:27 -05:00
return ;
2015-04-17 17:36:22 -04:00
for ( std : : set < RsPeerId > : : const_iterator it ( ids . begin ( ) ) ; it ! = ids . end ( ) ; + + it )
2013-02-22 16:42:27 -05:00
{
std : : cerr < < " " < < * it < < std : : endl ;
2014-12-29 16:41:05 -05:00
rsMsgs - > invitePeerToLobby ( mChatId . toLobbyId ( ) , * it ) ;
2013-02-22 16:42:27 -05:00
}
2012-11-14 09:39:08 -05:00
}
2013-03-19 17:37:38 -04:00
void ChatLobbyDialog : : participantsTreeWidgetCustomPopupMenu ( QPoint )
2012-11-14 09:39:08 -05:00
{
2012-11-15 19:53:13 -05:00
QList < QTreeWidgetItem * > selectedItems = ui . participantsList - > selectedItems ( ) ;
2012-11-14 09:39:08 -05:00
QMenu contextMnu ( this ) ;
2015-03-06 16:13:23 -05:00
contextMnu . addAction ( distantChatAct ) ;
2015-09-07 09:13:32 -04:00
contextMnu . addAction ( sendMessageAct ) ;
contextMnu . addSeparator ( ) ;
2015-12-17 19:40:39 -05:00
contextMnu . addAction ( actionSortByActivity ) ;
contextMnu . addAction ( actionSortByName ) ;
2016-03-09 21:49:24 -05:00
contextMnu . addSeparator ( ) ;
contextMnu . addAction ( muteAct ) ;
contextMnu . addAction ( banAct ) ;
2015-03-06 16:13:23 -05:00
2012-11-14 09:39:08 -05:00
muteAct - > setCheckable ( true ) ;
2012-11-15 19:53:13 -05:00
muteAct - > setEnabled ( false ) ;
2015-09-07 09:13:32 -04:00
muteAct - > setChecked ( false ) ;
2016-03-09 21:49:24 -05:00
banAct - > setEnabled ( false ) ;
2015-03-06 16:13:23 -05:00
if ( selectedItems . size ( ) )
{
RsGxsId nickName ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , nickName ) ;
2013-08-24 11:07:31 -04:00
2015-03-06 16:13:23 -05:00
if ( selectedItems . count ( ) > 1 | | ( RsGxsId ( selectedItems . at ( 0 ) - > text ( COLUMN_ID ) . toStdString ( ) ) ! = nickName ) )
2013-08-24 11:07:31 -04:00
{
2015-03-06 16:13:23 -05:00
muteAct - > setEnabled ( true ) ;
2016-03-09 21:49:24 -05:00
banAct - > setEnabled ( true ) ;
2015-03-06 16:13:23 -05:00
QList < QTreeWidgetItem * > : : iterator item ;
for ( item = selectedItems . begin ( ) ; item ! = selectedItems . end ( ) ; + + item ) {
RsGxsId gxsid ;
if ( dynamic_cast < GxsIdRSTreeWidgetItem * > ( * item ) - > getId ( gxsid ) & & isParticipantMuted ( gxsid ) )
{
muteAct - > setChecked ( true ) ;
break ;
}
}
}
distantChatAct - > setEnabled ( selectedItems . count ( ) = = 1 & & RsGxsId ( selectedItems . front ( ) - > text ( COLUMN_ID ) . toStdString ( ) ) ! = nickName ) ;
2013-08-24 11:07:31 -04:00
}
2012-11-14 09:39:08 -05:00
contextMnu . exec ( QCursor : : pos ( ) ) ;
2012-01-17 15:36:36 -05:00
}
2016-03-09 21:49:24 -05:00
/**
* @ brief Called when the " ban " menu is selected . Sets a negative reputation on the selected user .
*/
void ChatLobbyDialog : : banParticipant ( )
{
QList < QTreeWidgetItem * > selectedItems = ui . participantsList - > selectedItems ( ) ;
if ( selectedItems . isEmpty ( ) ) {
return ;
}
QList < QTreeWidgetItem * > : : iterator item ;
for ( item = selectedItems . begin ( ) ; item ! = selectedItems . end ( ) ; + + item ) {
RsGxsId nickname ;
dynamic_cast < GxsIdRSTreeWidgetItem * > ( * item ) - > getId ( nickname ) ;
RsGxsId gxs_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , gxs_id ) ;
// This test avoids to mute/ban your own identity
if ( gxs_id ! = nickname )
{
std : : cerr < < " Giving negative opinion to GXS id " < < nickname < < std : : endl ;
rsReputations - > setOwnOpinion ( nickname , RsReputations : : OPINION_NEGATIVE ) ;
dynamic_cast < GxsIdRSTreeWidgetItem * > ( * item ) - > forceUpdate ( ) ;
}
}
}
2014-12-29 16:41:05 -05:00
void ChatLobbyDialog : : init ( )
2012-01-17 15:36:36 -05:00
{
2015-03-06 16:13:23 -05:00
ChatLobbyInfo linfo ;
2012-03-20 19:05:17 -04:00
2014-12-29 16:41:05 -05:00
QString title ;
2015-03-06 16:13:23 -05:00
if ( rsMsgs - > getChatLobbyInfo ( lobbyId , linfo ) )
{
title = QString : : fromUtf8 ( linfo . lobby_name . c_str ( ) ) ;
QString msg = tr ( " Welcome to lobby %1 " ) . arg ( RsHtml : : plainText ( linfo . lobby_name ) ) ;
_lobby_name = QString : : fromUtf8 ( linfo . lobby_name . c_str ( ) ) ;
if ( ! linfo . lobby_topic . empty ( ) ) {
msg + = " \n " + tr ( " Topic: %1 " ) . arg ( RsHtml : : plainText ( linfo . lobby_topic ) ) ;
2014-12-29 16:41:05 -05:00
}
2015-03-06 16:13:23 -05:00
ui . chatWidget - > setWelcomeMessage ( msg ) ;
}
2012-03-20 19:05:17 -04:00
2014-12-29 16:41:05 -05:00
ChatDialog : : init ( ChatId ( lobbyId ) , title ) ;
2012-01-17 19:32:15 -05:00
2015-03-06 16:13:23 -05:00
RsGxsId gxs_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , gxs_id ) ;
RsIdentityDetails details ;
2015-05-15 12:15:45 -04:00
// This lets the backend some time to load our own identity in cache.
// It will only loop for at most 1 second the first time.
for ( int i = 0 ; i < 3 ; + + i )
if ( rsIdentity - > getIdDetails ( gxs_id , details ) )
break ;
else
usleep ( 1000 * 300 ) ;
2012-01-17 15:36:36 -05:00
2015-03-06 16:13:23 -05:00
ui . chatWidget - > setName ( QString : : fromUtf8 ( details . mNickname . c_str ( ) ) ) ;
2015-04-13 15:06:24 -04:00
//ui.chatWidget->addToolsAction(ui.actionChangeNickname);
2015-03-06 16:13:23 -05:00
ui . chatWidget - > setDefaultExtraFileFlags ( RS_FILE_REQ_ANONYMOUS_ROUTING ) ;
2012-01-28 10:11:58 -05:00
2015-03-06 16:13:23 -05:00
lastUpdateListTime = 0 ;
2012-01-17 15:36:36 -05:00
2015-03-06 16:13:23 -05:00
// add to window
2013-02-22 16:42:27 -05:00
2015-07-11 20:54:42 -04:00
ChatLobbyWidget * chatLobbyPage = dynamic_cast < ChatLobbyWidget * > ( MainWindow : : getPage ( MainWindow : : ChatLobby ) ) ;
if ( chatLobbyPage ) {
chatLobbyPage - > addChatPage ( this ) ;
}
2012-01-17 15:36:36 -05:00
2015-03-06 16:13:23 -05:00
/** List of muted Participants */
mutedParticipants . clear ( ) ;
// load settings
processSettings ( true ) ;
2011-11-27 16:04:10 -05:00
}
/** Destructor. */
ChatLobbyDialog : : ~ ChatLobbyDialog ( )
{
// announce leaving of lobby
2012-01-11 19:13:25 -05:00
2012-01-06 17:17:08 -05:00
// check that the lobby still exists.
2014-12-29 16:41:05 -05:00
if ( mChatId . isLobbyId ( ) ) {
rsMsgs - > unsubscribeChatLobby ( mChatId . toLobbyId ( ) ) ;
2012-01-11 19:13:25 -05:00
}
2012-01-17 15:36:36 -05:00
// save settings
processSettings ( false ) ;
2012-01-11 19:13:25 -05:00
}
2012-01-06 17:17:08 -05:00
2012-01-17 15:36:36 -05:00
ChatWidget * ChatLobbyDialog : : getChatWidget ( )
2012-01-11 19:13:25 -05:00
{
2012-01-17 15:36:36 -05:00
return ui . chatWidget ;
}
2012-10-27 11:59:12 -04:00
bool ChatLobbyDialog : : notifyBlink ( )
{
return ( Settings - > getChatLobbyFlags ( ) & RS_CHATLOBBY_BLINK ) ;
}
2012-01-17 15:36:36 -05:00
void ChatLobbyDialog : : processSettings ( bool load )
{
Settings - > beginGroup ( QString ( " ChatLobbyDialog " ) ) ;
if ( load ) {
// load settings
2015-05-01 20:22:30 -04:00
// state of splitter
ui . splitter - > restoreState ( Settings - > value ( " splitter " ) . toByteArray ( ) ) ;
2015-12-23 10:55:23 -05:00
// load sorting
actionSortByActivity - > setChecked ( Settings - > value ( " sortbyActivity " , QVariant ( false ) ) . toBool ( ) ) ;
actionSortByName - > setChecked ( Settings - > value ( " sortbyName " , QVariant ( true ) ) . toBool ( ) ) ;
2012-01-17 15:36:36 -05:00
} else {
// save settings
2015-05-01 20:22:30 -04:00
// state of splitter
Settings - > setValue ( " splitter " , ui . splitter - > saveState ( ) ) ;
2015-12-23 10:55:23 -05:00
//save sorting
Settings - > setValue ( " sortbyActivity " , actionSortByActivity - > isChecked ( ) ) ;
Settings - > setValue ( " sortbyName " , actionSortByName - > isChecked ( ) ) ;
2012-01-11 19:13:25 -05:00
}
2012-01-17 15:36:36 -05:00
Settings - > endGroup ( ) ;
2011-12-26 17:43:54 -05:00
}
2012-05-06 18:19:59 -04:00
/**
* Change your Nickname
*
* - send a Message to all Members = > later : send hidden message to clients , so they can actualize there mutedParticipants list
*/
2015-03-06 16:13:23 -05:00
void ChatLobbyDialog : : setIdentity ( const RsGxsId & gxs_id )
2011-11-27 16:04:10 -05:00
{
2015-03-06 16:13:23 -05:00
rsMsgs - > setIdentityForChatLobby ( lobbyId , gxs_id ) ;
2012-05-23 18:33:45 -04:00
2015-05-15 12:15:45 -04:00
// get new nick name
2015-03-06 16:13:23 -05:00
RsGxsId newid ;
if ( rsMsgs - > getIdentityForChatLobby ( lobbyId , newid ) )
{
RsIdentityDetails details ;
rsIdentity - > getIdDetails ( gxs_id , details ) ;
ui . chatWidget - > setName ( QString : : fromUtf8 ( details . mNickname . c_str ( ) ) ) ;
2015-05-15 12:15:45 -04:00
}
2012-01-28 10:11:58 -05:00
}
2012-05-06 18:19:59 -04:00
/**
* Dialog : Change your Nickname in the ChatLobby
*/
2012-01-28 10:11:58 -05:00
void ChatLobbyDialog : : changeNickname ( )
{
2015-03-06 16:13:23 -05:00
RsGxsId current_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , current_id ) ;
2012-01-28 10:11:58 -05:00
2015-03-06 16:13:23 -05:00
RsGxsId new_id ;
ownIdChooser - > getChosenId ( new_id ) ;
2012-01-28 10:11:58 -05:00
2015-03-06 16:13:23 -05:00
if ( ! new_id . isNull ( ) & & new_id ! = current_id )
setIdentity ( new_id ) ;
2011-11-27 16:04:10 -05:00
}
2012-05-05 10:22:21 -04:00
/**
* We get a new Message from a chat participant
*
* - Ignore Messages from muted chat participants
*/
2014-12-29 16:41:05 -05:00
void ChatLobbyDialog : : addChatMsg ( const ChatMessage & msg )
2011-12-28 04:15:28 -05:00
{
2014-12-29 16:41:05 -05:00
QDateTime sendTime = QDateTime : : fromTime_t ( msg . sendTime ) ;
QDateTime recvTime = QDateTime : : fromTime_t ( msg . recvTime ) ;
QString message = QString : : fromUtf8 ( msg . msg . c_str ( ) ) ;
2015-03-06 16:13:23 -05:00
RsGxsId gxs_id = msg . lobby_peer_gxs_id ;
2012-05-06 18:19:59 -04:00
2015-03-07 09:06:10 -05:00
if ( ! isParticipantMuted ( gxs_id ) )
{
// We could change addChatMsg to display the peers icon, passing a ChatId
2015-03-06 16:13:23 -05:00
RsIdentityDetails details ;
QString name ;
if ( rsIdentity - > getIdDetails ( gxs_id , details ) )
name = QString : : fromUtf8 ( details . mNickname . c_str ( ) ) ;
else
name = QString : : fromUtf8 ( msg . peer_alternate_nickname . c_str ( ) ) + " ( " + QString : : fromStdString ( gxs_id . toStdString ( ) ) + " ) " ;
2015-10-28 02:18:20 -04:00
ui . chatWidget - > addChatMsg ( msg . incoming , name , gxs_id , sendTime , recvTime , message , ChatWidget : : MSGTYPE_NORMAL ) ;
2016-01-28 10:22:32 -05:00
emit messageReceived ( msg . incoming , id ( ) , sendTime , name , message ) ;
SoundManager : : play ( SOUND_NEW_LOBBY_MESSAGE ) ;
2015-03-07 09:06:10 -05:00
// This is a trick to translate HTML into text.
QTextEdit editor ;
editor . setHtml ( message ) ;
QString notifyMsg = name + " : " + editor . toPlainText ( ) ;
if ( notifyMsg . length ( ) > 30 )
MainWindow : : displayLobbySystrayMsg ( tr ( " Lobby chat " ) + " : " + _lobby_name , notifyMsg . left ( 30 ) + QString ( " ... " ) ) ;
else
MainWindow : : displayLobbySystrayMsg ( tr ( " Lobby chat " ) + " : " + _lobby_name , notifyMsg ) ;
}
2012-07-30 09:27:40 -04:00
2011-12-29 09:19:53 -05:00
// also update peer list.
2012-01-17 15:36:36 -05:00
time_t now = time ( NULL ) ;
2011-12-29 09:19:53 -05:00
2015-03-06 16:13:23 -05:00
QList < QTreeWidgetItem * > qlFoundParticipants = ui . participantsList - > findItems ( QString : : fromStdString ( gxs_id . toStdString ( ) ) , Qt : : MatchExactly , COLUMN_ID ) ;
2013-08-24 11:07:31 -04:00
if ( qlFoundParticipants . count ( ) ! = 0 ) qlFoundParticipants . at ( 0 ) - > setText ( COLUMN_ACTIVITY , QString : : number ( now ) ) ;
2012-01-17 15:36:36 -05:00
if ( now > lastUpdateListTime ) {
lastUpdateListTime = now ;
updateParticipantsList ( ) ;
2011-12-29 09:19:53 -05:00
}
}
2012-05-05 10:22:21 -04:00
/**
2012-11-14 09:39:08 -05:00
* Regenerate the QTreeWidget participant list of a Chat Lobby
2012-05-05 10:22:21 -04:00
*
2013-03-19 17:37:38 -04:00
* Show yellow icon for muted Participants
2012-05-05 10:22:21 -04:00
*/
2012-01-17 15:36:36 -05:00
void ChatLobbyDialog : : updateParticipantsList ( )
2011-12-29 09:19:53 -05:00
{
2015-03-06 16:13:23 -05:00
ChatLobbyInfo linfo ;
2011-12-29 09:19:53 -05:00
2015-03-06 16:13:23 -05:00
if ( rsMsgs - > getChatLobbyInfo ( lobbyId , linfo ) )
{
ChatLobbyInfo cliInfo = linfo ;
QList < QTreeWidgetItem * > qlOldParticipants = ui . participantsList - > findItems ( " * " , Qt : : MatchWildcard , COLUMN_ID ) ;
2013-08-24 11:07:31 -04:00
2015-03-06 16:13:23 -05:00
foreach ( QTreeWidgetItem * qtwiCur , qlOldParticipants )
if ( cliInfo . gxs_ids . find ( RsGxsId ( ( * qtwiCur ) . text ( COLUMN_ID ) . toStdString ( ) ) ) = = cliInfo . gxs_ids . end ( ) )
2013-08-24 11:07:31 -04:00
{
//Old Participant go out, remove it
2013-08-25 16:13:51 -04:00
int index = ui . participantsList - > indexOfTopLevelItem ( qtwiCur ) ;
delete ui . participantsList - > takeTopLevelItem ( index ) ;
2013-08-24 11:07:31 -04:00
}
2012-05-24 15:26:43 -04:00
2015-03-06 16:13:23 -05:00
for ( std : : map < RsGxsId , time_t > : : const_iterator it2 ( linfo . gxs_ids . begin ( ) ) ; it2 ! = linfo . gxs_ids . end ( ) ; + + it2 )
{
QString participant = QString : : fromUtf8 ( ( it2 - > first ) . toStdString ( ) . c_str ( ) ) ;
2011-12-29 09:19:53 -05:00
2015-03-06 16:13:23 -05:00
QList < QTreeWidgetItem * > qlFoundParticipants = ui . participantsList - > findItems ( participant , Qt : : MatchExactly , COLUMN_ID ) ;
GxsIdRSTreeWidgetItem * widgetitem ;
2012-05-05 10:22:21 -04:00
2013-08-24 11:07:31 -04:00
if ( qlFoundParticipants . count ( ) = = 0 )
{
2015-03-06 16:13:23 -05:00
// TE: Add Wigdet to participantsList with Checkbox, to mute Participant
2015-03-14 15:19:34 -04:00
widgetitem = new GxsIdRSTreeWidgetItem ( mParticipantCompareRole , GxsIdDetails : : ICON_TYPE_AVATAR ) ;
2015-03-09 16:41:14 -04:00
widgetitem - > setId ( it2 - > first , COLUMN_NAME , true ) ;
2015-03-06 16:13:23 -05:00
//widgetitem->setText(COLUMN_NAME, participant);
2015-10-21 16:18:43 -04:00
// set activity time to the oast so that the peer is marked as inactive
widgetitem - > setText ( COLUMN_ACTIVITY , QString : : number ( time ( NULL ) - timeToInactivity ) ) ;
2015-03-06 16:13:23 -05:00
widgetitem - > setText ( COLUMN_ID , QString : : fromStdString ( it2 - > first . toStdString ( ) ) ) ;
2013-08-24 11:07:31 -04:00
ui . participantsList - > addTopLevelItem ( widgetitem ) ;
2015-03-06 16:13:23 -05:00
}
else
widgetitem = dynamic_cast < GxsIdRSTreeWidgetItem * > ( qlFoundParticipants . at ( 0 ) ) ;
2012-05-05 10:22:21 -04:00
2015-03-06 16:13:23 -05:00
if ( isParticipantMuted ( it2 - > first ) ) {
2013-08-24 11:07:31 -04:00
widgetitem - > setTextColor ( COLUMN_NAME , QColor ( 255 , 0 , 0 ) ) ;
2015-03-06 16:13:23 -05:00
} else {
2013-08-24 11:07:31 -04:00
widgetitem - > setTextColor ( COLUMN_NAME , ui . participantsList - > palette ( ) . color ( QPalette : : Active , QPalette : : Text ) ) ;
2015-03-06 16:13:23 -05:00
}
2012-11-15 19:53:13 -05:00
2013-08-24 11:07:31 -04:00
time_t tLastAct = widgetitem - > text ( COLUMN_ACTIVITY ) . toInt ( ) ;
time_t now = time ( NULL ) ;
2015-12-15 14:20:11 -05:00
widgetitem - > setSizeHint ( COLUMN_ICON , QSize ( 20 , 20 ) ) ;
2012-11-14 09:39:08 -05:00
2015-03-06 16:13:23 -05:00
if ( isParticipantMuted ( it2 - > first ) )
2015-11-04 11:05:39 -05:00
widgetitem - > setIcon ( COLUMN_ICON , QIcon ( " :/icons/bullet_red_128.png " ) ) ;
2015-10-21 16:40:49 -04:00
else if ( tLastAct + timeToInactivity < now )
2015-11-04 11:05:39 -05:00
widgetitem - > setIcon ( COLUMN_ICON , QIcon ( " :/icons/bullet_grey_128.png " ) ) ;
2015-10-21 16:18:43 -04:00
else
2015-11-04 11:05:39 -05:00
widgetitem - > setIcon ( COLUMN_ICON , QIcon ( " :/icons/bullet_green_128.png " ) ) ;
2015-03-06 16:13:23 -05:00
RsGxsId gxs_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , gxs_id ) ;
2013-08-24 11:07:31 -04:00
2015-11-04 11:05:39 -05:00
if ( RsGxsId ( participant . toStdString ( ) ) = = gxs_id ) widgetitem - > setIcon ( COLUMN_ICON , QIcon ( " :/icons/bullet_yellow_128.png " ) ) ;
2013-08-24 11:07:31 -04:00
2016-03-09 21:49:24 -05:00
widgetitem - > updateBannedState ( ) ;
2013-08-24 11:07:31 -04:00
QTime qtLastAct = QTime ( 0 , 0 , 0 ) . addSecs ( now - tLastAct ) ;
2015-03-06 16:13:23 -05:00
widgetitem - > setToolTip ( COLUMN_ICON , tr ( " Right click to mute/unmute participants<br/>Double click to address this person<br/> " )
+ tr ( " This participant is not active since: " )
+ qtLastAct . toString ( )
+ tr ( " seconds " )
) ;
}
}
ui . participantsList - > setSortingEnabled ( true ) ;
2015-12-17 19:40:39 -05:00
sortParcipants ( ) ;
2011-12-28 04:15:28 -05:00
}
2012-05-05 10:22:21 -04:00
/**
2012-11-14 09:39:08 -05:00
* Called when a Participant in QTree get Clicked / Changed
2012-05-05 10:22:21 -04:00
*
* Check if the Checkbox altered and Mute User
*
2012-05-06 18:19:59 -04:00
* @ todo auf rsid
*
2012-11-14 09:39:08 -05:00
* @ param QTreeWidgetItem Participant to check
2012-05-05 10:22:21 -04:00
*/
2012-11-14 09:39:08 -05:00
void ChatLobbyDialog : : changePartipationState ( )
2012-05-05 10:22:21 -04:00
{
2015-03-06 16:13:23 -05:00
QList < QTreeWidgetItem * > selectedItems = ui . participantsList - > selectedItems ( ) ;
2014-10-21 18:33:02 -04:00
if ( selectedItems . isEmpty ( ) ) {
2012-11-14 09:39:08 -05:00
return ;
2012-11-15 19:53:13 -05:00
}
2012-11-14 09:39:08 -05:00
2012-11-15 19:53:13 -05:00
QList < QTreeWidgetItem * > : : iterator item ;
2015-03-06 16:13:23 -05:00
for ( item = selectedItems . begin ( ) ; item ! = selectedItems . end ( ) ; + + item ) {
2012-05-05 10:22:21 -04:00
2015-03-06 16:13:23 -05:00
RsGxsId gxs_id ;
dynamic_cast < GxsIdRSTreeWidgetItem * > ( * item ) - > getId ( gxs_id ) ;
std : : cerr < < " check Partipation status for ' " < < gxs_id < < std : : endl ;
2012-11-15 19:53:13 -05:00
if ( muteAct - > isChecked ( ) ) {
2015-03-06 16:13:23 -05:00
muteParticipant ( gxs_id ) ;
2012-11-15 19:53:13 -05:00
} else {
2015-03-06 16:13:23 -05:00
unMuteParticipant ( gxs_id ) ;
2012-11-15 19:53:13 -05:00
}
}
updateParticipantsList ( ) ;
}
void ChatLobbyDialog : : participantsTreeWidgetDoubleClicked ( QTreeWidgetItem * item , int column )
{
if ( ! item ) {
return ;
}
2013-02-22 16:42:27 -05:00
if ( column = = COLUMN_NAME )
{
2013-07-01 16:35:07 -04:00
getChatWidget ( ) - > pasteText ( " @ " + RsHtml : : plainText ( item - > text ( COLUMN_NAME ) ) ) ;
2013-02-22 16:42:27 -05:00
return ;
2012-05-05 10:22:21 -04:00
}
2012-11-15 19:53:13 -05:00
2013-02-22 16:42:27 -05:00
// if (column == COLUMN_ICON) {
// return;
// }
//
// QString nickname = item->text(COLUMN_NAME);
// if (isParticipantMuted(nickname)) {
// unMuteParticipant(nickname);
// } else {
// muteParticipant(nickname);
// }
//
// mutedParticipants->removeDuplicates();
//
// updateParticipantsList();
2012-05-05 10:22:21 -04:00
}
2015-03-06 16:13:23 -05:00
void ChatLobbyDialog : : distantChatParticipant ( )
{
std : : cerr < < " initiating distant chat " < < std : : endl ;
QList < QTreeWidgetItem * > selectedItems = ui . participantsList - > selectedItems ( ) ;
if ( selectedItems . isEmpty ( ) )
return ;
if ( selectedItems . size ( ) ! = 1 )
return ;
GxsIdRSTreeWidgetItem * item = dynamic_cast < GxsIdRSTreeWidgetItem * > ( selectedItems . front ( ) ) ;
if ( ! item )
return ;
RsGxsId gxs_id ;
item - > getId ( gxs_id ) ;
RsGxsId own_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , own_id ) ;
uint32_t error_code ;
2015-11-28 14:55:56 -05:00
DistantChatPeerId tunnel_id ;
2015-03-06 16:13:23 -05:00
2015-11-26 20:40:06 -05:00
if ( ! rsMsgs - > initiateDistantChatConnexion ( gxs_id , own_id , tunnel_id , error_code ) )
2015-03-06 16:13:23 -05:00
{
QString error_str ;
switch ( error_code )
{
case RS_DISTANT_CHAT_ERROR_DECRYPTION_FAILED : error_str = tr ( " Decryption failed. " ) ; break ;
case RS_DISTANT_CHAT_ERROR_SIGNATURE_MISMATCH : error_str = tr ( " Signature mismatch " ) ; break ;
case RS_DISTANT_CHAT_ERROR_UNKNOWN_KEY : error_str = tr ( " Unknown key " ) ; break ;
case RS_DISTANT_CHAT_ERROR_UNKNOWN_HASH : error_str = tr ( " Unknown hash " ) ; break ;
default :
error_str = tr ( " Unknown error. " ) ;
}
2015-06-01 10:20:26 -04:00
QMessageBox : : warning ( NULL , tr ( " Cannot start distant chat " ) , tr ( " Distant chat cannot be initiated: " ) + " " + error_str
2015-03-06 16:13:23 -05:00
+ QString : : number ( error_code ) ) ;
}
2012-05-11 16:53:27 -04:00
}
2015-09-07 09:13:32 -04:00
void ChatLobbyDialog : : sendMessage ( )
{
QList < QTreeWidgetItem * > selectedItems = ui . participantsList - > selectedItems ( ) ;
if ( selectedItems . isEmpty ( ) )
return ;
QList < QTreeWidgetItem * > : : iterator item ;
for ( item = selectedItems . begin ( ) ; item ! = selectedItems . end ( ) ; + + item ) {
RsGxsId gxs_id ;
dynamic_cast < GxsIdRSTreeWidgetItem * > ( * item ) - > getId ( gxs_id ) ;
MessageComposer * nMsgDialog = MessageComposer : : newMsg ( ) ;
if ( nMsgDialog = = NULL ) {
return ;
}
nMsgDialog - > addRecipient ( MessageComposer : : TO , RsGxsId ( gxs_id ) ) ;
nMsgDialog - > show ( ) ;
nMsgDialog - > activateWindow ( ) ;
/* window will destroy itself! */
}
}
2015-03-06 16:13:23 -05:00
void ChatLobbyDialog : : muteParticipant ( const RsGxsId & nickname )
{
std : : cerr < < " Mute " < < std : : endl ;
RsGxsId gxs_id ;
rsMsgs - > getIdentityForChatLobby ( lobbyId , gxs_id ) ;
if ( gxs_id ! = nickname )
mutedParticipants . insert ( nickname ) ;
}
void ChatLobbyDialog : : unMuteParticipant ( const RsGxsId & id )
{
std : : cerr < < " UnMute " < < std : : endl ;
mutedParticipants . erase ( id ) ;
2012-05-11 16:53:27 -04:00
}
/**
* Is this nickName already known in the lobby
*/
2015-03-06 16:13:23 -05:00
bool ChatLobbyDialog : : isNicknameInLobby ( const RsGxsId & nickname )
{
ChatLobbyInfo clinfo ;
2012-05-11 16:53:27 -04:00
2015-03-06 16:13:23 -05:00
if ( ! rsMsgs - > getChatLobbyInfo ( lobbyId , clinfo ) )
return false ;
2012-05-11 16:53:27 -04:00
2015-03-06 16:13:23 -05:00
return clinfo . gxs_ids . find ( nickname ) ! = clinfo . gxs_ids . end ( ) ;
2012-05-11 16:53:27 -04:00
}
2012-05-05 10:22:21 -04:00
/**
* Should Messages from this Nickname be muted ?
*
2012-05-06 18:19:59 -04:00
* At the moment it is not possible to 100 % know which peer sendet the message , and only
* the nickname is available . So this couldn ' t work for 100 % . So , for example , if a peer
* change his name to the name of a other peer , we couldn ' t block him . A real implementation
* will be possible if we transfer a temporary Session ID from the sending Retroshare client
* version 0.6
*
2012-05-05 10:22:21 -04:00
* @ param QString nickname to check
*/
2015-03-06 16:13:23 -05:00
bool ChatLobbyDialog : : isParticipantMuted ( const RsGxsId & participant )
2012-05-05 10:22:21 -04:00
{
2012-05-11 16:53:27 -04:00
// nickname in Mute list
2015-03-06 16:13:23 -05:00
return mutedParticipants . find ( participant ) ! = mutedParticipants . end ( ) ;
2012-05-05 10:22:21 -04:00
}
2015-03-06 16:13:23 -05:00
QString ChatLobbyDialog : : getParticipantName ( const RsGxsId & gxs_id ) const
2012-01-06 17:17:08 -05:00
{
2015-03-06 16:13:23 -05:00
RsIdentityDetails details ;
QString name ;
if ( rsIdentity - > getIdDetails ( gxs_id , details ) )
name = QString : : fromUtf8 ( details . mNickname . c_str ( ) ) ;
else
name = QString : : fromUtf8 ( " [Unknown] ( " ) + QString : : fromStdString ( gxs_id . toStdString ( ) ) + " ) " ;
return name ;
}
void ChatLobbyDialog : : displayLobbyEvent ( int event_type , const RsGxsId & gxs_id , const QString & str )
{
RsGxsId qsParticipant ;
QString name = getParticipantName ( gxs_id ) ;
switch ( event_type )
{
case RS_CHAT_LOBBY_EVENT_PEER_LEFT :
qsParticipant = gxs_id ;
ui . chatWidget - > addChatMsg ( true , tr ( " Lobby management " ) , QDateTime : : currentDateTime ( ) , QDateTime : : currentDateTime ( ) , tr ( " %1 has left the lobby. " ) . arg ( RsHtml : : plainText ( name ) ) , ChatWidget : : MSGTYPE_SYSTEM ) ;
emit peerLeft ( id ( ) ) ;
break ;
case RS_CHAT_LOBBY_EVENT_PEER_JOINED :
qsParticipant = gxs_id ;
ui . chatWidget - > addChatMsg ( true , tr ( " Lobby management " ) , QDateTime : : currentDateTime ( ) , QDateTime : : currentDateTime ( ) , tr ( " %1 joined the lobby. " ) . arg ( RsHtml : : plainText ( name ) ) , ChatWidget : : MSGTYPE_SYSTEM ) ;
emit peerJoined ( id ( ) ) ;
break ;
case RS_CHAT_LOBBY_EVENT_PEER_STATUS :
{
qsParticipant = gxs_id ;
ui . chatWidget - > updateStatusString ( RsHtml : : plainText ( name ) + " %1 " , RsHtml : : plainText ( str ) ) ;
if ( ! isParticipantMuted ( gxs_id ) )
emit typingEventReceived ( id ( ) ) ;
}
break ;
case RS_CHAT_LOBBY_EVENT_PEER_CHANGE_NICKNAME :
{
qsParticipant = gxs_id ;
QString newname = getParticipantName ( RsGxsId ( str . toStdString ( ) ) ) ;
ui . chatWidget - > addChatMsg ( true , tr ( " Lobby management " ) , QDateTime : : currentDateTime ( ) ,
QDateTime : : currentDateTime ( ) ,
2015-08-31 10:38:28 -04:00
tr ( " %1 changed his name to: %2 " ) . arg ( RsHtml : : plainText ( name ) ) . arg ( RsHtml : : plainText ( newname ) ) ,
2015-03-06 16:13:23 -05:00
ChatWidget : : MSGTYPE_SYSTEM ) ;
// TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby
if ( isParticipantMuted ( gxs_id ) )
muteParticipant ( RsGxsId ( str . toStdString ( ) ) ) ;
}
break ;
case RS_CHAT_LOBBY_EVENT_KEEP_ALIVE :
//std::cerr << "Received keep alive packet from " << nickname.toStdString() << " in lobby " << getPeerId() << std::endl;
break ;
default :
std : : cerr < < " ChatLobbyDialog::displayLobbyEvent() Unhandled lobby event type " < < event_type < < std : : endl ;
}
if ( ! qsParticipant . isNull ( ) )
{
QList < QTreeWidgetItem * > qlFoundParticipants = ui . participantsList - > findItems ( QString : : fromStdString ( qsParticipant . toStdString ( ) ) , Qt : : MatchExactly , COLUMN_ID ) ;
2013-08-24 11:07:31 -04:00
2015-03-06 16:13:23 -05:00
if ( qlFoundParticipants . count ( ) ! = 0 )
qlFoundParticipants . at ( 0 ) - > setText ( COLUMN_ACTIVITY , QString : : number ( time ( NULL ) ) ) ;
2013-08-24 11:07:31 -04:00
}
2015-03-06 16:13:23 -05:00
updateParticipantsList ( ) ;
2012-01-06 17:17:08 -05:00
}
2012-01-11 19:13:25 -05:00
bool ChatLobbyDialog : : canClose ( )
{
// check that the lobby still exists.
2014-12-29 16:41:05 -05:00
/* TODO
2012-01-11 19:13:25 -05:00
ChatLobbyId lid ;
2012-01-17 15:36:36 -05:00
if ( ! rsMsgs - > isLobbyId ( getPeerId ( ) , lid ) ) {
2012-01-11 19:13:25 -05:00
return true ;
}
2014-12-29 16:41:05 -05:00
*/
2012-01-11 19:13:25 -05:00
2012-01-17 15:36:36 -05:00
if ( QMessageBox : : Yes = = QMessageBox : : question ( this , tr ( " Unsubscribe to lobby " ) , tr ( " Do you want to unsubscribe to this chat lobby? " ) , QMessageBox : : Yes | QMessageBox : : No ) ) {
2012-01-11 19:13:25 -05:00
return true ;
}
return false ;
}
2012-01-17 15:36:36 -05:00
void ChatLobbyDialog : : showDialog ( uint chatflags )
{
2013-02-24 17:44:14 -05:00
if ( chatflags & RS_CHAT_FOCUS )
{
2013-02-22 16:42:27 -05:00
MainWindow : : showWindow ( MainWindow : : ChatLobby ) ;
2013-02-24 17:44:14 -05:00
dynamic_cast < ChatLobbyWidget * > ( MainWindow : : getPage ( MainWindow : : ChatLobby ) ) - > setCurrentChatPage ( this ) ;
2012-01-17 15:36:36 -05:00
}
}
2015-12-17 19:40:39 -05:00
void ChatLobbyDialog : : sortParcipants ( )
{
if ( actionSortByActivity - > isChecked ( ) ) {
ui . participantsList - > sortItems ( COLUMN_ACTIVITY , Qt : : DescendingOrder ) ;
} else if ( actionSortByName - > isChecked ( ) ) {
ui . participantsList - > sortItems ( COLUMN_NAME , Qt : : AscendingOrder ) ;
}
}