mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-04 20:34:26 -04:00
merged with latest upstream trunk
This commit is contained in:
commit
0c1e6301b3
295 changed files with 17456 additions and 12859 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/FriendsDialog.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include <gui/common/html.h>
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "gui/common/FriendSelectionDialog.h"
|
||||
|
@ -52,6 +53,8 @@
|
|||
#define COLUMN_ID 3
|
||||
#define COLUMN_COUNT 4
|
||||
|
||||
const static uint32_t timeToInactivity = 60 * 10; // in seconds
|
||||
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
|
||||
: ChatDialog(parent, flags), lobbyId(lid)
|
||||
|
@ -66,18 +69,20 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||
connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));
|
||||
|
||||
int S = QFontMetricsF(font()).height() ;
|
||||
ui.participantsList->setIconSize(QSize(S,S));
|
||||
ui.participantsList->setIconSize(QSize(1.3*S,1.3*S));
|
||||
|
||||
ui.participantsList->setColumnCount(COLUMN_COUNT);
|
||||
ui.participantsList->setColumnWidth(COLUMN_ICON, 1.25*S);
|
||||
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(), tr("Start private chat"), this);
|
||||
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);
|
||||
|
||||
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
|
||||
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
||||
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||
|
||||
// Add a button to invite friends.
|
||||
//
|
||||
|
@ -170,12 +175,15 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
|||
|
||||
QMenu contextMnu(this);
|
||||
|
||||
contextMnu.addAction(muteAct);
|
||||
contextMnu.addAction(distantChatAct);
|
||||
contextMnu.addAction(sendMessageAct);
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(muteAct);
|
||||
|
||||
|
||||
muteAct->setCheckable(true);
|
||||
muteAct->setEnabled(false);
|
||||
muteAct->setChecked(false);
|
||||
muteAct->setChecked(false);
|
||||
|
||||
if (selectedItems.size())
|
||||
{
|
||||
|
@ -362,7 +370,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
|
|||
else
|
||||
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
|
||||
|
||||
ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
|
||||
ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
|
||||
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
|
||||
|
||||
// This is a trick to translate HTML into text.
|
||||
|
@ -425,7 +433,8 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||
widgetitem = new GxsIdRSTreeWidgetItem(mParticipantCompareRole,GxsIdDetails::ICON_TYPE_AVATAR);
|
||||
widgetitem->setId(it2->first,COLUMN_NAME, true) ;
|
||||
//widgetitem->setText(COLUMN_NAME, participant);
|
||||
widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
|
||||
// set activity time to the oast so that the peer is marked as inactive
|
||||
widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL) - timeToInactivity));
|
||||
widgetitem->setText(COLUMN_ID,QString::fromStdString(it2->first.toStdString()));
|
||||
|
||||
ui.participantsList->addTopLevelItem(widgetitem);
|
||||
|
@ -443,16 +452,16 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||
time_t now = time(NULL);
|
||||
|
||||
if(isParticipantMuted(it2->first))
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_red_64.png"));
|
||||
else if (tLastAct<now-60*30)
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_grey_64.png"));
|
||||
else
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_green_64.png"));
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_red_128.png"));
|
||||
else if (tLastAct + timeToInactivity < now)
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_grey_128.png"));
|
||||
else
|
||||
widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_green_128.png"));
|
||||
|
||||
RsGxsId gxs_id;
|
||||
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
|
||||
|
||||
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_64.png"));
|
||||
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, QIcon(":/icons/bullet_yellow_128.png"));
|
||||
|
||||
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
|
||||
widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants<br/>Double click to address this person<br/>")
|
||||
|
@ -571,6 +580,36 @@ void ChatLobbyDialog::distantChatParticipant()
|
|||
}
|
||||
}
|
||||
|
||||
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! */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ChatLobbyDialog::muteParticipant(const RsGxsId& nickname)
|
||||
{
|
||||
|
|
|
@ -77,6 +77,7 @@ protected slots:
|
|||
void changePartipationState();
|
||||
void distantChatParticipant();
|
||||
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void sendMessage();
|
||||
|
||||
private:
|
||||
void updateParticipantsList();
|
||||
|
@ -101,9 +102,10 @@ private:
|
|||
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
|
||||
std::set<RsGxsId> mutedParticipants;
|
||||
|
||||
QAction *muteAct;
|
||||
QAction *muteAct;
|
||||
QAction *distantChatAct;
|
||||
QWidgetAction *checkableAction;
|
||||
QAction *sendMessageAct;
|
||||
|
||||
GxsIdChooser *ownIdChooser ;
|
||||
};
|
||||
|
|
|
@ -351,11 +351,14 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||
Q_UNUSED(flag);
|
||||
#endif
|
||||
|
||||
QString formatMsg = style.replace("%name%", RsHtml::plainText(name))
|
||||
.replace("%date%", DateTime::formatDate(timestamp.date()))
|
||||
.replace("%time%", DateTime::formatTime(timestamp.time()))
|
||||
QString strName = RsHtml::plainText(name).prepend(QString("<a name=\"name\">")).append(QString("</a>"));
|
||||
QString strDate = DateTime::formatDate(timestamp.date()).prepend(QString("<a name=\"date\">")).append(QString("</a>"));
|
||||
QString strTime = DateTime::formatTime(timestamp.time()).prepend(QString("<a name=\"time\">")).append(QString("</a>"));
|
||||
QString formatMsg = style.replace("%name%", strName)
|
||||
.replace("%date%", strDate)
|
||||
.replace("%time%", strTime)
|
||||
#ifdef COLORED_NICKNAMES
|
||||
.replace("%color%", color.name())
|
||||
.replace("%color%", color.name())
|
||||
#endif
|
||||
.replace("%message%", messageBody ) ;
|
||||
if ( !styleOptimized.isEmpty() ) {
|
||||
|
|
|
@ -214,7 +214,7 @@ void ChatWidget::setDefaultExtraFileFlags(TransferRequestFlags fl)
|
|||
|
||||
void ChatWidget::addChatHorizontalWidget(QWidget *w)
|
||||
{
|
||||
ui->verticalLayout_2->addWidget(w) ;
|
||||
ui->vl_Plugins->addWidget(w) ;
|
||||
update() ;
|
||||
}
|
||||
|
||||
|
@ -223,9 +223,15 @@ void ChatWidget::addChatBarWidget(QWidget *w)
|
|||
ui->pluginButtonFrame->layout()->addWidget(w) ;
|
||||
}
|
||||
|
||||
void ChatWidget::addVOIPBarWidget(QWidget *w)
|
||||
void ChatWidget::addTitleBarWidget(QWidget *w)
|
||||
{
|
||||
ui->titleBarFrame->layout()->addWidget(w) ;
|
||||
ui->pluginTitleFrame->layout()->addWidget(w) ;
|
||||
}
|
||||
|
||||
void ChatWidget::hideChatText(bool hidden)
|
||||
{
|
||||
ui->frame_ChatText->setHidden(hidden); ;
|
||||
ui->searchframe->setVisible(ui->actionSearch_History->isChecked() && !hidden); ;
|
||||
}
|
||||
|
||||
RSButtonOnText* ChatWidget::getNewButtonOnTextBrowser()
|
||||
|
@ -488,10 +494,10 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent) {
|
||||
if (notify && keyEvent->key() == Qt::Key_Delete) {
|
||||
if (keyEvent->key() == Qt::Key_Delete) {
|
||||
// Delete key pressed
|
||||
if (ui->textBrowser->textCursor().selectedText().length() > 0) {
|
||||
if (chatType() == CHATTYPE_LOBBY) {
|
||||
if (notify && chatType() == CHATTYPE_LOBBY) {
|
||||
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||
rx.setMinimal(true);
|
||||
QString sel=ui->textBrowser->textCursor().selection().toHtml();
|
||||
|
@ -839,6 +845,13 @@ void ChatWidget::setWelcomeMessage(QString &text)
|
|||
}
|
||||
|
||||
void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType)
|
||||
{
|
||||
addChatMsg(incoming, name, RsGxsId(), sendTime, recvTime, message, chatType);
|
||||
}
|
||||
|
||||
void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId
|
||||
, const QDateTime &sendTime, const QDateTime &recvTime
|
||||
, const QString &message, MsgType chatType)
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cout << "ChatWidget::addChatMsg message : " << message.toStdString() << std::endl;
|
||||
|
@ -870,6 +883,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
|
|||
if (!Settings->valueFromGroup("Chat", "EnableCustomFontSize", true).toBool()) {
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_REMOVE_FONT_SIZE;
|
||||
}
|
||||
int desiredMinimumFontSize = Settings->valueFromGroup("Chat", "MinimumFontSize", 10).toInt();
|
||||
if (!Settings->valueFromGroup("Chat", "EnableBold", true).toBool()) {
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_REMOVE_FONT_WEIGHT;
|
||||
}
|
||||
|
@ -893,13 +907,20 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
|
|||
formatFlag |= CHAT_FORMATMSG_SYSTEM;
|
||||
}
|
||||
|
||||
QString formattedMessage = RsHtml().formatText(ui->textBrowser->document(), message, formatTextFlag, backgroundColor, desiredContrast);
|
||||
QString formattedMessage = RsHtml().formatText(ui->textBrowser->document(), message, formatTextFlag, backgroundColor, desiredContrast, desiredMinimumFontSize);
|
||||
QDateTime dtTimestamp=incoming ? sendTime : recvTime;
|
||||
QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag);
|
||||
QString timeStamp = dtTimestamp.toString(Qt::ISODate);
|
||||
|
||||
formatMsg.prepend(QString("<a name=\"%1\"/>").arg(timeStamp));
|
||||
//To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name));
|
||||
//replace Date and Time anchors
|
||||
formatMsg.replace(QString("<a name=\"date\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||
formatMsg.replace(QString("<a name=\"time\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||
//replace Name anchors with GXS Id
|
||||
QString strGxsId = "";
|
||||
if (!gxsId.isNull())
|
||||
strGxsId = QString::fromStdString(gxsId.toStdString());
|
||||
formatMsg.replace(QString("<a name=\"name\">"),QString("<a name=\"%1\">").arg(strGxsId));
|
||||
|
||||
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
||||
textCursor.movePosition(QTextCursor::End);
|
||||
textCursor.setBlockFormat(QTextBlockFormat ());
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
|
||||
void setWelcomeMessage(QString &text);
|
||||
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
|
||||
void addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
|
||||
void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false);
|
||||
|
||||
void addToolsAction(QAction *action);
|
||||
|
@ -108,9 +109,8 @@ public:
|
|||
// Adds one widget in the chat bar. Used to add e.g. new buttons. The widget should be
|
||||
// small enough in size.
|
||||
void addChatBarWidget(QWidget *w) ;
|
||||
|
||||
|
||||
void addVOIPBarWidget(QWidget *w);
|
||||
void addTitleBarWidget(QWidget *w);
|
||||
void hideChatText(bool hidden);
|
||||
RSButtonOnText* getNewButtonOnTextBrowser();
|
||||
RSButtonOnText* getNewButtonOnTextBrowser(QString text);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -46,8 +46,11 @@ PopupDistantChatDialog::~PopupDistantChatDialog()
|
|||
PopupDistantChatDialog::PopupDistantChatDialog(QWidget *parent, Qt::WindowFlags flags)
|
||||
: PopupChatDialog(parent,flags)
|
||||
{
|
||||
_status_label = new QLabel ;
|
||||
_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())) ;
|
||||
|
@ -94,7 +97,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
switch(status)
|
||||
{
|
||||
case RS_DISTANT_CHAT_STATUS_UNKNOWN: //std::cerr << "Unknown hash. Error!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRY_LED)) ;
|
||||
_status_label->setIcon(QIcon(IMAGE_GRY_LED)) ;
|
||||
msg = tr("Hash Error. No tunnel.");
|
||||
_status_label->setToolTip(msg) ;
|
||||
getChatWidget()->updateStatusString("%1", msg, true);
|
||||
|
@ -102,7 +105,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
setPeerStatus(RS_STATUS_OFFLINE) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
_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);
|
||||
|
@ -111,7 +114,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: //std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
_status_label->setIcon(QIcon(IMAGE_RED_LED)) ;
|
||||
msg = QObject::tr("Tunnel is pending...");
|
||||
_status_label->setToolTip(msg) ;
|
||||
getChatWidget()->updateStatusString("%1", msg, true);
|
||||
|
@ -119,7 +122,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
setPeerStatus(RS_STATUS_OFFLINE) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: //std::cerr << "Tunnel is ok. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_YEL_LED)) ;
|
||||
_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);
|
||||
|
@ -127,7 +130,7 @@ void PopupDistantChatDialog::updateDisplay()
|
|||
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->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||
_status_label->setIcon(QIcon(IMAGE_GRN_LED)) ;
|
||||
msg = QObject::tr("Secured tunnel is working. You can talk!");
|
||||
_status_label->setToolTip(msg) ;
|
||||
getChatWidget()->unblockSending();
|
||||
|
|
|
@ -49,7 +49,7 @@ class PopupDistantChatDialog: public PopupChatDialog
|
|||
private:
|
||||
QTimer *_update_timer ;
|
||||
RsGxsId _pid ;
|
||||
QLabel *_status_label ;
|
||||
QToolButton *_status_label ;
|
||||
|
||||
friend class ChatDialog;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue