mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 07:35:12 -04:00
Imported chat lobby function from branch v0.5-ChatLobby (merged commits 4682-4739)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4740 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
60bb76e3df
26 changed files with 2445 additions and 188 deletions
79
retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp
Normal file
79
retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
/****************************************************************
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QScrollBar>
|
||||
#include <QCloseEvent>
|
||||
#include <QColorDialog>
|
||||
#include <QDateTime>
|
||||
#include <QFontDialog>
|
||||
#include <QDir>
|
||||
#include <QBuffer>
|
||||
#include <QTextCodec>
|
||||
#include <QSound>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "util/misc.h"
|
||||
#include "rshare.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ChatLobbyDialog.h"
|
||||
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id,const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(dialog_id,name,parent,flags),lobby_id(lid)
|
||||
{
|
||||
// remove the avatar widget. Replace it with a friends list.
|
||||
|
||||
ui.avatarWidget->hide() ;
|
||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE) ;
|
||||
|
||||
QObject::connect(this,SIGNAL(close()),this,SLOT(closeAndAsk())) ;
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
ChatLobbyDialog::~ChatLobbyDialog()
|
||||
{
|
||||
// announce leaving of lobby
|
||||
|
||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubscribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes | QMessageBox::No))
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::setNickName(const QString& nick)
|
||||
{
|
||||
rsMsgs->setNickNameForChatLobby(lobby_id,nick.toStdString()) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::updateStatus(const QString &peer_id, int status)
|
||||
{
|
||||
// For now. We need something more efficient to tell when the lobby is disconnected.
|
||||
//
|
||||
}
|
||||
|
66
retroshare-gui/src/gui/chat/ChatLobbyDialog.h
Normal file
66
retroshare-gui/src/gui/chat/ChatLobbyDialog.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2006, crypton
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _CHATLOBBYDIALOG_H
|
||||
#define _CHATLOBBYDIALOG_H
|
||||
|
||||
#include "ui_PopupChatDialog.h"
|
||||
|
||||
class QAction;
|
||||
class QTextEdit;
|
||||
class QTextCharFormat;
|
||||
class AttachFileItem;
|
||||
class ChatInfo;
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/style/RSStyle.h"
|
||||
#include "PopupChatDialog.h"
|
||||
|
||||
class ChatLobbyDialog: public PopupChatDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
/** Default destructor */
|
||||
virtual ~ChatLobbyDialog();
|
||||
|
||||
// virtual void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
// virtual void sendChat();
|
||||
|
||||
friend class PopupChatDialog ;
|
||||
|
||||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual void updateStatus(const QString &peer_id, int status) ; // needs grouped status. Not yet implemented.
|
||||
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
|
||||
private:
|
||||
ChatLobbyId lobby_id ;
|
||||
};
|
||||
|
||||
#endif
|
204
retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp
Normal file
204
retroshare-gui/src/gui/chat/CreateLobbyDialog.cpp
Normal file
|
@ -0,0 +1,204 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2010 Christopher Evi-Parker
|
||||
*
|
||||
* 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.
|
||||
****************************************************************/
|
||||
|
||||
#include "CreateLobbyDialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <algorithm>
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/chat/PopupChatDialog.h"
|
||||
|
||||
CreateLobbyDialog::CreateLobbyDialog(const std::list<std::string>& peer_list,QWidget *parent, Qt::WFlags flags, std::string grpId, int grpType) :
|
||||
QDialog(parent, flags), mGrpId(grpId), mGrpType(grpType)
|
||||
{
|
||||
ui = new Ui::CreateLobbyDialog() ;
|
||||
ui->setupUi(this);
|
||||
|
||||
std::string default_nick ;
|
||||
rsMsgs->getDefaultNickNameForChatLobby(default_nick) ;
|
||||
|
||||
ui->lobbyName_LE->setPlaceholderText(tr("Put a sensible lobby name here")) ;
|
||||
ui->nickName_LE->setPlaceholderText(tr("Your nickname for this lobby (Change default name in options->chat)")) ;
|
||||
ui->nickName_LE->setText(QString::fromStdString(default_nick)) ;
|
||||
|
||||
connect( ui->shareButton, SIGNAL( clicked ( bool ) ), this, SLOT( createLobby( ) ) );
|
||||
connect( ui->cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancel( ) ) );
|
||||
connect( ui->lobbyName_LE, SIGNAL( textChanged ( QString ) ), this, SLOT( checkTextFields( ) ) );
|
||||
connect( ui->nickName_LE, SIGNAL( textChanged ( QString ) ), this, SLOT( checkTextFields( ) ) );
|
||||
|
||||
connect(ui->keyShareList, SIGNAL(itemChanged( QTreeWidgetItem *, int ) ),
|
||||
this, SLOT(togglePersonItem( QTreeWidgetItem *, int ) ));
|
||||
|
||||
setShareList(peer_list);
|
||||
checkTextFields() ;
|
||||
}
|
||||
|
||||
|
||||
CreateLobbyDialog::~CreateLobbyDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::checkTextFields()
|
||||
{
|
||||
if(ui->lobbyName_LE->text() == "" || ui->nickName_LE->text() == "")
|
||||
ui->shareButton->setEnabled(false) ;
|
||||
else
|
||||
ui->shareButton->setEnabled(true) ;
|
||||
}
|
||||
void CreateLobbyDialog::createLobby()
|
||||
{
|
||||
if(mShareList.empty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please select at least one peer"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// create chat lobby !!
|
||||
std::string lobby_name = ui->lobbyName_LE->text().toStdString() ;
|
||||
|
||||
// add to group
|
||||
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, mShareList);
|
||||
|
||||
std::cerr << "gui: Created chat lobby " << std::hex << id << std::endl ;
|
||||
|
||||
// set nick name !
|
||||
|
||||
rsMsgs->setNickNameForChatLobby(id,ui->nickName_LE->text().toStdString()) ;
|
||||
|
||||
// open chat window !!
|
||||
std::string vpid ;
|
||||
|
||||
if(rsMsgs->getVirtualPeerId(id,vpid))
|
||||
PopupChatDialog::chatFriend(vpid) ;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::cancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::setShareList(const std::list<std::string>& friend_list)
|
||||
{
|
||||
if (!rsPeers)
|
||||
{
|
||||
/* not ready yet! */
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> peers;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
mShareList.clear() ;
|
||||
rsPeers->getFriendList(peers);
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *shareWidget = ui->keyShareList;
|
||||
|
||||
QList<QTreeWidgetItem *> items;
|
||||
|
||||
for(it = peers.begin(); it != peers.end(); it++)
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail))
|
||||
{
|
||||
continue; /* BAD */
|
||||
}
|
||||
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
item -> setText(0, PeerDefs::nameWithLocation(detail));
|
||||
if (detail.state & RS_PEER_STATE_CONNECTED) {
|
||||
item -> setTextColor(0,(Qt::darkBlue));
|
||||
}
|
||||
item -> setSizeHint(0, QSize( 17,17 ) );
|
||||
item -> setText(1, QString::fromStdString(detail.id));
|
||||
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
|
||||
item -> setCheckState(0, Qt::Unchecked);
|
||||
|
||||
for(std::list<std::string>::const_iterator it2(friend_list.begin());it2!=friend_list.end();++it2)
|
||||
if(*it == *it2)
|
||||
{
|
||||
item -> setCheckState(0, Qt::Checked);
|
||||
mShareList.push_back(*it) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
}
|
||||
|
||||
/* remove old items */
|
||||
shareWidget->clear();
|
||||
shareWidget->setColumnCount(1);
|
||||
|
||||
/* add the items in! */
|
||||
shareWidget->insertTopLevelItems(0, items);
|
||||
|
||||
shareWidget->update(); /* update display */
|
||||
}
|
||||
|
||||
void CreateLobbyDialog::togglePersonItem( QTreeWidgetItem *item, int /*col*/ )
|
||||
{
|
||||
/* extract id */
|
||||
std::string id = (item -> text(1)).toStdString();
|
||||
|
||||
/* get state */
|
||||
bool checked = (Qt::Checked == item -> checkState(0)); /* alway column 0 */
|
||||
|
||||
/* call control fns */
|
||||
std::list<std::string>::iterator lit = std::find(mShareList.begin(), mShareList.end(), id);
|
||||
|
||||
if(checked && (lit == mShareList.end()))
|
||||
mShareList.push_back(id); // make sure ids not added already
|
||||
else if(lit != mShareList.end())
|
||||
mShareList.erase(lit);
|
||||
|
||||
return;
|
||||
}
|
||||
|
41
retroshare-gui/src/gui/chat/CreateLobbyDialog.h
Normal file
41
retroshare-gui/src/gui/chat/CreateLobbyDialog.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef SHAREKEY_H
|
||||
#define SHAREKEY_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_CreateLobbyDialog.h"
|
||||
|
||||
class CreateLobbyDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*
|
||||
*@param chanId The channel id to send request for
|
||||
*/
|
||||
CreateLobbyDialog(const std::list<std::string>& friends_list,QWidget *parent = 0, Qt::WFlags flags = 0, std::string grpId = "", int grpType = 0);
|
||||
~CreateLobbyDialog();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
private:
|
||||
|
||||
void setShareList(const std::list<std::string>&);
|
||||
|
||||
Ui::CreateLobbyDialog *ui;
|
||||
|
||||
std::string mGrpId;
|
||||
std::list<std::string> mShareList;
|
||||
int mGrpType;
|
||||
|
||||
private slots:
|
||||
|
||||
void createLobby();
|
||||
void checkTextFields();
|
||||
void cancel();
|
||||
void togglePersonItem(QTreeWidgetItem* item, int col);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SHAREKEY_H
|
300
retroshare-gui/src/gui/chat/CreateLobbyDialog.ui
Normal file
300
retroshare-gui/src/gui/chat/CreateLobbyDialog.ui
Normal file
|
@ -0,0 +1,300 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreateLobbyDialog</class>
|
||||
<widget class="QDialog" name="CreateLobbyDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>586</width>
|
||||
<height>532</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Chat Lobby</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>239</width>
|
||||
<height>49</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/user/agt_forum64.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="tlShareKey">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:18pt; font-weight:600; color:#ffffff;">Create Chat Lobby</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">A chat lobby is a decentralized and anonymous chat group. All participants receive all messages. Once the lobby is created you can invite other friends from the Friends tab.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Lobby name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Your nick name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lobbyName_LE"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nickName_LE"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Select the Friends with which you want to group chat.</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="contactsdockWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>52487</width>
|
||||
<height>524287</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>220</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>check peers you would like to share private publish key with</string>
|
||||
</property>
|
||||
<property name="floating">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Invited friends</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="keyShareList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>4</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1677215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Contacts:</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="shareButton">
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -33,6 +33,7 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
#include "PopupChatDialog.h"
|
||||
#include "ChatLobbyDialog.h"
|
||||
#include "PopupChatWindow.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/misc.h"
|
||||
|
@ -125,7 +126,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
|||
|
||||
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus_slot(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
|
||||
|
||||
connect(ui.chattextEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
|
||||
|
@ -261,16 +262,35 @@ void PopupChatDialog::processSettings(bool bLoad)
|
|||
{
|
||||
/* see if it exists already */
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if (popupchatdialog == NULL) {
|
||||
if (chatflags & RS_CHAT_OPEN) {
|
||||
RsPeerDetails sslDetails;
|
||||
if (rsPeers->getPeerDetails(id, sslDetails)) {
|
||||
ChatLobbyId lobby_id ;
|
||||
|
||||
if (rsPeers->getPeerDetails(id, sslDetails))
|
||||
{
|
||||
popupchatdialog = new PopupChatDialog(id, PeerDefs::nameWithLocation(sslDetails));
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
}
|
||||
else if (rsMsgs->isLobbyId(id, lobby_id))
|
||||
{
|
||||
std::list<ChatLobbyInfo> linfos;
|
||||
rsMsgs->getChatLobbyList(linfos) ;
|
||||
|
||||
for(std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());it!=linfos.end();++it)
|
||||
if( (*it).lobby_id == lobby_id)
|
||||
{
|
||||
popupchatdialog = new ChatLobbyDialog(id,lobby_id,QString::fromStdString((*it).lobby_name));
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,6 +357,14 @@ void PopupChatDialog::processSettings(bool bLoad)
|
|||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::closeChat(const std::string& id)
|
||||
{
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if(popupchatdialog != NULL)
|
||||
popupchatdialog->hide() ;
|
||||
}
|
||||
|
||||
void PopupChatDialog::chatFriend(const std::string &id)
|
||||
{
|
||||
if (id.empty()){
|
||||
|
@ -344,10 +372,16 @@ void PopupChatDialog::chatFriend(const std::string &id)
|
|||
}
|
||||
std::cerr<<" popup dialog chat friend 1"<<std::endl;
|
||||
|
||||
ChatLobbyId lid ;
|
||||
if(rsMsgs->isLobbyId(id,lid))
|
||||
{
|
||||
getPrivateChat(id, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
||||
return ;
|
||||
}
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(id, detail)) {
|
||||
if (!rsPeers->getPeerDetails(id, detail))
|
||||
return;
|
||||
}
|
||||
|
||||
std::string firstId;
|
||||
|
||||
|
@ -682,7 +716,8 @@ void PopupChatDialog::sendChat()
|
|||
std::cout << "PopupChatDialog:sendChat " << std::endl;
|
||||
#endif
|
||||
|
||||
if (rsMsgs->sendPrivateChat(dialogId, msg)) {
|
||||
if (sendPrivateChat(msg))
|
||||
{
|
||||
QDateTime currentTime = QDateTime::currentDateTime();
|
||||
addChatMsg(false, QString::fromUtf8(rsPeers->getPeerName(ownId).c_str()), currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL);
|
||||
}
|
||||
|
@ -695,6 +730,11 @@ void PopupChatDialog::sendChat()
|
|||
setFont();
|
||||
}
|
||||
|
||||
bool PopupChatDialog::sendPrivateChat(const std::wstring& msg)
|
||||
{
|
||||
return rsMsgs->sendPrivateChat(dialogId, msg) ;
|
||||
}
|
||||
|
||||
/**
|
||||
Toggles the ToolBox on and off, changes toggle button text
|
||||
*/
|
||||
|
@ -905,6 +945,11 @@ void PopupChatDialog::clearOfflineMessages()
|
|||
manualDelete = false;
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatus_slot(const QString &peer_id, int status)
|
||||
{
|
||||
updateStatus(peer_id,status) ;
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
{
|
||||
std::string stdPeerId = peer_id.toStdString();
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
static PopupChatDialog *getPrivateChat(const std::string &id, uint chatflags);
|
||||
static void cleanupChat();
|
||||
static void chatFriend(const std::string &id);
|
||||
static void closeChat(const std::string &id);
|
||||
static void privateChatChanged(int list, int type);
|
||||
|
||||
void updateStatusString(const QString& peer_id, const QString& statusString);
|
||||
|
@ -58,9 +59,10 @@ public:
|
|||
void activate();
|
||||
bool setStyle();
|
||||
const RSStyle &getStyle();
|
||||
virtual void updateStatus(const QString &peer_id, int status);
|
||||
|
||||
public slots:
|
||||
void updateStatus(const QString &peer_id, int status);
|
||||
void updateStatus_slot(const QString &peer_id, int status);
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
|
@ -142,6 +144,9 @@ private:
|
|||
|
||||
RSStyle style;
|
||||
|
||||
protected:
|
||||
virtual bool sendPrivateChat(const std::wstring& msg) ; // can be derived to send chat to e.g. a chat lobby
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue