mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-20 19:06:09 -05:00
Add a notification when GxsId come back in lobby.
This can be setted even if GxsId is offline by using its name in TextBrowser.
This commit is contained in:
parent
91dd22d8d3
commit
dac82bf672
6 changed files with 176 additions and 62 deletions
|
|
@ -81,10 +81,11 @@ void SoundManager::soundEvents(SoundEvents &events)
|
||||||
|
|
||||||
/* add standard events */
|
/* add standard events */
|
||||||
events.addEvent(tr("Friend"), tr("Go Online"), SOUND_USER_ONLINE, QFileInfo(baseDir, "online1.wav").absoluteFilePath());
|
events.addEvent(tr("Friend"), tr("Go Online"), SOUND_USER_ONLINE, QFileInfo(baseDir, "online1.wav").absoluteFilePath());
|
||||||
events.addEvent(tr("Chatmessage"), tr("New Msg"), SOUND_NEW_CHAT_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
|
events.addEvent(tr("Chat Message"), tr("New Msg"), SOUND_NEW_CHAT_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
|
||||||
events.addEvent(tr("Message"), tr("Message arrived"), SOUND_MESSAGE_ARRIVED, QFileInfo(baseDir, "receive.wav").absoluteFilePath());
|
events.addEvent(tr("Message"), tr("Message arrived"), SOUND_MESSAGE_ARRIVED, QFileInfo(baseDir, "receive.wav").absoluteFilePath());
|
||||||
events.addEvent(tr("Download"), tr("Download complete"), SOUND_DOWNLOAD_COMPLETE, QFileInfo(baseDir, "ft_complete.wav").absoluteFilePath());
|
events.addEvent(tr("Download"), tr("Download complete"), SOUND_DOWNLOAD_COMPLETE, QFileInfo(baseDir, "ft_complete.wav").absoluteFilePath());
|
||||||
events.addEvent(tr("Lobby"), tr("Message arrived"), SOUND_NEW_LOBBY_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
|
events.addEvent(tr("Chat Room"), tr("Message arrived"), SOUND_NEW_LOBBY_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
|
||||||
|
events.addEvent(tr("Chat Room"), tr("Specific User incoming in Chat Room"), SOUND_LOBBY_INCOMING, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
|
||||||
|
|
||||||
/* add plugin events */
|
/* add plugin events */
|
||||||
int pluginCount = rsPlugins->nbPlugins();
|
int pluginCount = rsPlugins->nbPlugins();
|
||||||
|
|
@ -116,7 +117,7 @@ QString SoundManager::defaultFilename(const QString &event, bool check)
|
||||||
return convertFilename(filename);
|
return convertFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QFileInfo(filename).exists()) {
|
if (QFileInfo::exists(filename)) {
|
||||||
return convertFilename(filename);
|
return convertFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +133,7 @@ void SoundManager::initDefault()
|
||||||
foreach (event, events.mEventInfos.keys()) {
|
foreach (event, events.mEventInfos.keys()) {
|
||||||
SoundEvents::SoundEventInfo &eventInfo = events.mEventInfos[event];
|
SoundEvents::SoundEventInfo &eventInfo = events.mEventInfos[event];
|
||||||
|
|
||||||
if (QFileInfo(eventInfo.mDefaultFilename).exists()) {
|
if (QFileInfo::exists(eventInfo.mDefaultFilename)) {
|
||||||
setEventFilename(event, convertFilename(eventInfo.mDefaultFilename));
|
setEventFilename(event, convertFilename(eventInfo.mDefaultFilename));
|
||||||
setEventEnabled(event, true);
|
setEventEnabled(event, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,12 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
#define SOUND_NEW_CHAT_MESSAGE "NewChatMessage"
|
|
||||||
#define SOUND_USER_ONLINE "User_go_Online"
|
#define SOUND_USER_ONLINE "User_go_Online"
|
||||||
|
#define SOUND_NEW_CHAT_MESSAGE "NewChatMessage"
|
||||||
#define SOUND_MESSAGE_ARRIVED "MessageArrived"
|
#define SOUND_MESSAGE_ARRIVED "MessageArrived"
|
||||||
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
|
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
|
||||||
#define SOUND_NEW_LOBBY_MESSAGE "NewLobbyMessage"
|
#define SOUND_NEW_LOBBY_MESSAGE "NewLobbyMessage"
|
||||||
|
#define SOUND_LOBBY_INCOMING "LobbyIncoming"
|
||||||
|
|
||||||
class SoundEvents
|
class SoundEvents
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +69,7 @@ public:
|
||||||
static void create();
|
static void create();
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
static QString soundDetectPlayer();
|
static QString soundDetectPlayer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void initDefault();
|
static void initDefault();
|
||||||
|
|
@ -88,7 +89,7 @@ public:
|
||||||
|
|
||||||
static QString eventFilename(const QString &event);
|
static QString eventFilename(const QString &event);
|
||||||
static void setEventFilename(const QString &event, const QString &filename);
|
static void setEventFilename(const QString &event, const QString &filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SoundManager();
|
SoundManager();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,9 @@
|
||||||
#include "gui/msgs/MessageComposer.h"
|
#include "gui/msgs/MessageComposer.h"
|
||||||
#include "gui/settings/RsharePeerSettings.h"
|
#include "gui/settings/RsharePeerSettings.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "gui/SoundManager.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
|
#include "util/misc.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
|
|
||||||
#include "retroshare/rsnotify.h"
|
#include "retroshare/rsnotify.h"
|
||||||
|
|
@ -63,17 +65,21 @@ const static uint32_t timeToInactivity2 = 60 * 5; // in seconds
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
|
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WindowFlags flags)
|
||||||
: ChatDialog(parent, flags), lobbyId(lid), mWindowedSetted(false), mPCWindow(nullptr),
|
: ChatDialog(parent, flags), lobbyId(lid), mWindowedSetted(false), mPCWindow(nullptr)
|
||||||
bullet_red_128(":/icons/bullet_red_128.png"), bullet_grey_128(":/icons/bullet_grey_128.png"),
|
, bullet_red_128(":/icons/bullet_red_128.png"), bullet_grey_128(":/icons/bullet_grey_128.png")
|
||||||
bullet_green_128(":/icons/bullet_green_128.png"), bullet_yellow_128(":/icons/bullet_yellow_128.png"),
|
, bullet_yellow_128(":/icons/bullet_yellow_128.png"), bullet_green_128(":/icons/bullet_green_128.png")
|
||||||
bullet_blue_128(":/icons/bullet_blue_128.png")
|
, bullet_blue_128(":/icons/bullet_blue_128.png")
|
||||||
|
, bullet_red_128_star( misc::mergeIcon(":/icons/bullet_red_128.png" ,":/icons/star_overlay_128.png"))
|
||||||
|
, bullet_grey_128_star( misc::mergeIcon(":/icons/bullet_grey_128.png" ,":/icons/star_overlay_128.png"))
|
||||||
|
, bullet_yellow_128_star(misc::mergeIcon(":/icons/bullet_yellow_128.png",":/icons/star_overlay_128.png"))
|
||||||
|
, bullet_green_128_star( misc::mergeIcon(":/icons/bullet_green_128.png" ,":/icons/star_overlay_128.png"))
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
lastUpdateListTime = 0;
|
lastUpdateListTime = 0;
|
||||||
|
|
||||||
//connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
|
//connect(ui.actionChangeNickname, SIGNAL(triggered()), this, SLOT(changeNickname()));
|
||||||
connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
|
connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
|
||||||
connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));
|
connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));
|
||||||
|
|
||||||
|
|
@ -91,6 +97,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||||
QHeaderView * header = ui.participantsList->header();
|
QHeaderView * header = ui.participantsList->header();
|
||||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch);
|
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch);
|
||||||
|
|
||||||
|
notifyNewArrivalAct = new QAction(QIcon(), tr("Notify (sound) when come back"), this);
|
||||||
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
muteAct = new QAction(QIcon(), tr("Mute participant"), this);
|
||||||
voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this);
|
voteNegativeAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Ban this person (Sets negative opinion)"), this);
|
||||||
voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this);
|
voteNeutralAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Give neutral opinion"), this);
|
||||||
|
|
@ -110,7 +117,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||||
actionSortByActivity->setChecked(false);
|
actionSortByActivity->setChecked(false);
|
||||||
actionSortByActivity->setActionGroup(sortgrp);
|
actionSortByActivity->setActionGroup(sortgrp);
|
||||||
|
|
||||||
|
connect(notifyNewArrivalAct, SIGNAL(triggered()), this, SLOT(changeNotifyForParticipant()));
|
||||||
connect(muteAct, SIGNAL(triggered()), this, SLOT(changeParticipationState()));
|
connect(muteAct, SIGNAL(triggered()), this, SLOT(changeParticipationState()));
|
||||||
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
|
||||||
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
|
||||||
|
|
@ -138,7 +145,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||||
undockButton->setAutoRaise(true);
|
undockButton->setAutoRaise(true);
|
||||||
connect(undockButton, SIGNAL(clicked()), this , SLOT(toggleWindowed()));
|
connect(undockButton, SIGNAL(clicked()), this , SLOT(toggleWindowed()));
|
||||||
|
|
||||||
getChatWidget()->addTitleBarWidget(undockButton) ;
|
ChatLobbyDialog::getChatWidget()->addTitleBarWidget(undockButton) ;
|
||||||
|
|
||||||
// Add a button to invite friends.
|
// Add a button to invite friends.
|
||||||
//
|
//
|
||||||
|
|
@ -161,7 +168,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||||
|
|
||||||
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
||||||
|
|
||||||
getChatWidget()->addTitleBarWidget(inviteFriendsButton) ;
|
ChatLobbyDialog::getChatWidget()->addTitleBarWidget(inviteFriendsButton) ;
|
||||||
|
|
||||||
RsGxsId current_id;
|
RsGxsId current_id;
|
||||||
rsMsgs->getIdentityForChatLobby(lobbyId, current_id);
|
rsMsgs->getIdentityForChatLobby(lobbyId, current_id);
|
||||||
|
|
@ -207,7 +214,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
||||||
|
|
||||||
connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));
|
connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby()));
|
||||||
|
|
||||||
getChatWidget()->addTitleBarWidget(unsubscribeButton) ;
|
ChatLobbyDialog::getChatWidget()->addTitleBarWidget(unsubscribeButton) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::leaveLobby()
|
void ChatLobbyDialog::leaveLobby()
|
||||||
|
|
@ -282,9 +289,12 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
||||||
if (idList.isEmpty())
|
if (idList.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
contextMnu->setToolTipsVisible(true);
|
||||||
|
|
||||||
contextMnu->addAction(distantChatAct);
|
contextMnu->addAction(distantChatAct);
|
||||||
contextMnu->addAction(sendMessageAct);
|
contextMnu->addAction(sendMessageAct);
|
||||||
contextMnu->addSeparator();
|
contextMnu->addSeparator();
|
||||||
|
contextMnu->addAction(notifyNewArrivalAct);
|
||||||
contextMnu->addAction(muteAct);
|
contextMnu->addAction(muteAct);
|
||||||
contextMnu->addAction(votePositiveAct);
|
contextMnu->addAction(votePositiveAct);
|
||||||
contextMnu->addAction(voteNeutralAct);
|
contextMnu->addAction(voteNeutralAct);
|
||||||
|
|
@ -293,6 +303,10 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
||||||
|
|
||||||
distantChatAct->setEnabled(false);
|
distantChatAct->setEnabled(false);
|
||||||
sendMessageAct->setEnabled(false);
|
sendMessageAct->setEnabled(false);
|
||||||
|
notifyNewArrivalAct->setEnabled(false);
|
||||||
|
notifyNewArrivalAct->setCheckable(true);
|
||||||
|
notifyNewArrivalAct->setChecked(false);
|
||||||
|
notifyNewArrivalAct->setToolTip("");
|
||||||
muteAct->setEnabled(false);
|
muteAct->setEnabled(false);
|
||||||
muteAct->setCheckable(true);
|
muteAct->setCheckable(true);
|
||||||
muteAct->setChecked(false);
|
muteAct->setChecked(false);
|
||||||
|
|
@ -303,6 +317,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
||||||
|
|
||||||
distantChatAct->setData(QVariant::fromValue(idList));
|
distantChatAct->setData(QVariant::fromValue(idList));
|
||||||
sendMessageAct->setData(QVariant::fromValue(idList));
|
sendMessageAct->setData(QVariant::fromValue(idList));
|
||||||
|
notifyNewArrivalAct->setData(QVariant::fromValue(idList));
|
||||||
muteAct->setData(QVariant::fromValue(idList));
|
muteAct->setData(QVariant::fromValue(idList));
|
||||||
votePositiveAct->setData(QVariant::fromValue(idList));
|
votePositiveAct->setData(QVariant::fromValue(idList));
|
||||||
voteNeutralAct->setData(QVariant::fromValue(idList));
|
voteNeutralAct->setData(QVariant::fromValue(idList));
|
||||||
|
|
@ -315,6 +330,17 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
||||||
{
|
{
|
||||||
distantChatAct->setEnabled(true);
|
distantChatAct->setEnabled(true);
|
||||||
sendMessageAct->setEnabled(true);
|
sendMessageAct->setEnabled(true);
|
||||||
|
if (SoundManager::eventEnabled(SOUND_LOBBY_INCOMING))
|
||||||
|
{
|
||||||
|
notifyNewArrivalAct->setEnabled(true);
|
||||||
|
notifyNewArrivalAct->setToolTip(tr("Play a sound when this user come back."));
|
||||||
|
} else {
|
||||||
|
notifyNewArrivalAct->setEnabled(false);
|
||||||
|
notifyNewArrivalAct->setToolTip(tr("'Specific User incoming in Chat Room' is unchecked in Sound Preferences page."));
|
||||||
|
}
|
||||||
|
notifyNewArrivalAct->setChecked(isParticipantWaitingArrival(gxsid));
|
||||||
|
muteAct->setEnabled(true);
|
||||||
|
muteAct->setChecked(isParticipantMuted(gxsid));
|
||||||
votePositiveAct->setEnabled(
|
votePositiveAct->setEnabled(
|
||||||
rsReputations->overallReputationLevel(gxsid) !=
|
rsReputations->overallReputationLevel(gxsid) !=
|
||||||
RsReputationLevel::LOCALLY_POSITIVE );
|
RsReputationLevel::LOCALLY_POSITIVE );
|
||||||
|
|
@ -326,8 +352,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
||||||
voteNegativeAct->setEnabled(
|
voteNegativeAct->setEnabled(
|
||||||
rsReputations->overallReputationLevel(gxsid) !=
|
rsReputations->overallReputationLevel(gxsid) !=
|
||||||
RsReputationLevel::LOCALLY_NEGATIVE );
|
RsReputationLevel::LOCALLY_NEGATIVE );
|
||||||
muteAct->setEnabled(true);
|
|
||||||
muteAct->setChecked(isParticipantMuted(gxsid));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,7 +435,7 @@ void ChatLobbyDialog::init(const ChatId &/*id*/, const QString &/*title*/)
|
||||||
if(rsIdentity->getIdDetails(gxs_id,details))
|
if(rsIdentity->getIdDetails(gxs_id,details))
|
||||||
break ;
|
break ;
|
||||||
else
|
else
|
||||||
rstime::rs_usleep(1000*300) ;
|
std::this_thread::sleep_for(std::chrono::milliseconds(300)) ;
|
||||||
|
|
||||||
ui.chatWidget->setName(QString::fromUtf8(details.mNickname.c_str()));
|
ui.chatWidget->setName(QString::fromUtf8(details.mNickname.c_str()));
|
||||||
//ui.chatWidget->addToolsAction(ui.actionChangeNickname);
|
//ui.chatWidget->addToolsAction(ui.actionChangeNickname);
|
||||||
|
|
@ -532,6 +556,13 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
|
||||||
QString message = QString::fromUtf8(msg.msg.c_str());
|
QString message = QString::fromUtf8(msg.msg.c_str());
|
||||||
RsGxsId gxs_id = msg.lobby_peer_gxs_id ;
|
RsGxsId gxs_id = msg.lobby_peer_gxs_id ;
|
||||||
|
|
||||||
|
if (isParticipantWaitingArrival(gxs_id))
|
||||||
|
{
|
||||||
|
// Who ask a notification for muted? We don't know...
|
||||||
|
SoundManager::play(SOUND_LOBBY_INCOMING);
|
||||||
|
idToNotifyWhenComeBack.erase(gxs_id);
|
||||||
|
}
|
||||||
|
|
||||||
if(!isParticipantMuted(gxs_id))
|
if(!isParticipantMuted(gxs_id))
|
||||||
{
|
{
|
||||||
// We could change addChatMsg to display the peers icon, passing a ChatId
|
// We could change addChatMsg to display the peers icon, passing a ChatId
|
||||||
|
|
@ -562,7 +593,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
|
||||||
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(gxs_id.toStdString()),Qt::MatchExactly,COLUMN_ID);
|
QList<QTreeWidgetItem*> qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(gxs_id.toStdString()),Qt::MatchExactly,COLUMN_ID);
|
||||||
if (qlFoundParticipants.count()!=0) qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(now));
|
if (qlFoundParticipants.count()!=0) qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(now));
|
||||||
|
|
||||||
if (now > lastUpdateListTime) {
|
if (now > lastUpdateListTime) {
|
||||||
|
|
@ -627,30 +658,32 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||||
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
|
time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt();
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
|
||||||
widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20));
|
widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20));
|
||||||
|
|
||||||
|
|
||||||
if(isParticipantMuted(it2->first))
|
|
||||||
widgetitem->setIcon(COLUMN_ICON, bullet_red_128);
|
|
||||||
else if (tLastAct + timeToInactivity < now)
|
|
||||||
widgetitem->setIcon(COLUMN_ICON, bullet_grey_128);
|
|
||||||
else if (tLastAct + timeToInactivity2 < now)
|
|
||||||
widgetitem->setIcon(COLUMN_ICON, bullet_yellow_128);
|
|
||||||
else
|
|
||||||
widgetitem->setIcon(COLUMN_ICON, bullet_green_128);
|
|
||||||
|
|
||||||
RsGxsId gxs_id;
|
RsGxsId gxs_id;
|
||||||
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
|
rsMsgs->getIdentityForChatLobby(lobbyId, gxs_id);
|
||||||
|
bool inNotif = isParticipantWaitingArrival(it2->first);
|
||||||
|
|
||||||
if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, bullet_blue_128);
|
if (RsGxsId(participant.toStdString()) == gxs_id)
|
||||||
|
widgetitem->setIcon(COLUMN_ICON, bullet_blue_128);
|
||||||
|
else if(isParticipantMuted(it2->first))
|
||||||
|
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_red_128_star : bullet_red_128);
|
||||||
|
else if (tLastAct + timeToInactivity < now)
|
||||||
|
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_grey_128_star : bullet_grey_128);
|
||||||
|
else if (tLastAct + timeToInactivity2 < now)
|
||||||
|
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_yellow_128_star : bullet_yellow_128);
|
||||||
|
else
|
||||||
|
widgetitem->setIcon(COLUMN_ICON, inNotif ? bullet_green_128_star : bullet_green_128);
|
||||||
|
|
||||||
widgetitem->updateBannedState();
|
widgetitem->updateBannedState();
|
||||||
|
|
||||||
QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct);
|
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/>")
|
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:")
|
+tr("This participant is not active since:")
|
||||||
+qtLastAct.toString()
|
+qtLastAct.toString()
|
||||||
+tr(" seconds")
|
+tr(" seconds")
|
||||||
|
+ (inNotif ? tr("<br/>A notification (sound) is waiting for this participant come back.") :"")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -659,6 +692,31 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||||
filterIds();
|
filterIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatLobbyDialog::changeNotifyForParticipant()
|
||||||
|
{
|
||||||
|
QAction *act = dynamic_cast<QAction*>(sender()) ;
|
||||||
|
if(!act)
|
||||||
|
{
|
||||||
|
RS_ERR("No sender! Some bug in the code.");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<RsGxsId> idList = act->data().value<QList<RsGxsId>>();
|
||||||
|
|
||||||
|
for (auto& item : idList)
|
||||||
|
{
|
||||||
|
if (act->isChecked()) {
|
||||||
|
if(!isParticipantWaitingArrival(item))
|
||||||
|
idToNotifyWhenComeBack.insert(item);
|
||||||
|
} else {
|
||||||
|
if(isParticipantWaitingArrival(item))
|
||||||
|
idToNotifyWhenComeBack.erase(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateParticipantsList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a Participant get Clicked / Changed
|
* Called when a Participant get Clicked / Changed
|
||||||
*
|
*
|
||||||
|
|
@ -813,6 +871,16 @@ bool ChatLobbyDialog::isNicknameInLobby(const RsGxsId& nickname)
|
||||||
return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ;
|
return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Is Lobby waiting this participant new arrival to notify.
|
||||||
|
* @param participant: GxsID to check.
|
||||||
|
* @return True if in the list.
|
||||||
|
*/
|
||||||
|
bool ChatLobbyDialog::isParticipantWaitingArrival(const RsGxsId &participant)
|
||||||
|
{
|
||||||
|
return idToNotifyWhenComeBack.find(participant) != idToNotifyWhenComeBack.end();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should Messages from this Nickname be muted?
|
* Should Messages from this Nickname be muted?
|
||||||
*
|
*
|
||||||
|
|
@ -882,7 +950,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
|
||||||
|
|
||||||
ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(),
|
ui.chatWidget->addChatMsg(true, tr("Chat room management"), QDateTime::currentDateTime(),
|
||||||
QDateTime::currentDateTime(),
|
QDateTime::currentDateTime(),
|
||||||
tr("%1 changed his name to: %2").arg(RsHtml::plainText(name)).arg(RsHtml::plainText(newname)),
|
tr("%1 changed his name to: %2").arg(RsHtml::plainText(name), RsHtml::plainText(newname)),
|
||||||
ChatWidget::MSGTYPE_SYSTEM);
|
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
|
// 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
|
||||||
|
|
@ -897,15 +965,22 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
|
||||||
std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled chat room event type " << event_type << std::endl;
|
std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled chat room event type " << event_type << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qsParticipant.isNull())
|
if (!qsParticipant.isNull())
|
||||||
{
|
{
|
||||||
QList<QTreeWidgetItem*> qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(qsParticipant.toStdString()),Qt::MatchExactly,COLUMN_ID);
|
QList<QTreeWidgetItem*> qlFoundParticipants=ui.participantsList->findItems(QString::fromStdString(qsParticipant.toStdString()),Qt::MatchExactly,COLUMN_ID);
|
||||||
|
|
||||||
if (qlFoundParticipants.count()!=0)
|
if (qlFoundParticipants.count()!=0)
|
||||||
qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
|
qlFoundParticipants.at(0)->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
|
||||||
}
|
|
||||||
|
|
||||||
updateParticipantsList() ;
|
if( (event_type != RS_CHAT_LOBBY_EVENT_PEER_LEFT)
|
||||||
|
&& isParticipantWaitingArrival(gxs_id))
|
||||||
|
{
|
||||||
|
SoundManager::play(SOUND_LOBBY_INCOMING);
|
||||||
|
idToNotifyWhenComeBack.erase(gxs_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateParticipantsList() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatLobbyDialog::canClose()
|
bool ChatLobbyDialog::canClose()
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,9 @@ public:
|
||||||
virtual ChatWidget *getChatWidget();
|
virtual ChatWidget *getChatWidget();
|
||||||
virtual bool hasPeerStatus() { return false; }
|
virtual bool hasPeerStatus() { return false; }
|
||||||
virtual bool notifyBlink();
|
virtual bool notifyBlink();
|
||||||
void setIdentity(const RsGxsId& gxs_id);
|
void setIdentity(const RsGxsId& gxs_id);
|
||||||
bool isParticipantMuted(const RsGxsId &participant);
|
bool isParticipantWaitingArrival(const RsGxsId &participant);
|
||||||
|
bool isParticipantMuted(const RsGxsId &participant);
|
||||||
ChatLobbyId id() const { return lobbyId ;}
|
ChatLobbyId id() const { return lobbyId ;}
|
||||||
void sortParcipants();
|
void sortParcipants();
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||||
|
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
virtual ~ChatLobbyDialog();
|
virtual ~ChatLobbyDialog();
|
||||||
|
|
@ -85,6 +86,7 @@ protected:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void changeNickname();
|
void changeNickname();
|
||||||
|
void changeNotifyForParticipant();
|
||||||
void changeParticipationState();
|
void changeParticipationState();
|
||||||
void distantChatParticipant();
|
void distantChatParticipant();
|
||||||
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
void participantsTreeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
|
|
@ -119,22 +121,30 @@ private:
|
||||||
Ui::ChatLobbyDialog ui;
|
Ui::ChatLobbyDialog ui;
|
||||||
|
|
||||||
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
|
/** Ignored Users in Chatlobby by nickname until we had implemented Peer Ids in ver 0.6 */
|
||||||
std::set<RsGxsId> mutedParticipants;
|
std::set<RsGxsId> mutedParticipants;
|
||||||
|
|
||||||
QAction *muteAct;
|
/**
|
||||||
QAction *votePositiveAct;
|
* @brief List of GxsId to notify when they arrive.
|
||||||
QAction *voteNeutralAct;
|
* This don't use ChatLobbyUserNotify because no need to save it as GxsId can go away before read notification.
|
||||||
QAction *voteNegativeAct;
|
*/
|
||||||
QAction *distantChatAct;
|
std::set<RsGxsId> idToNotifyWhenComeBack;
|
||||||
QAction *actionSortByName;
|
|
||||||
QAction *actionSortByActivity;
|
|
||||||
QWidgetAction *checkableAction;
|
|
||||||
QAction *sendMessageAct;
|
|
||||||
QAction *showInPeopleAct;
|
|
||||||
|
|
||||||
GxsIdChooser *ownIdChooser ;
|
QAction *notifyNewArrivalAct;
|
||||||
//icons cache
|
QAction *muteAct;
|
||||||
QIcon bullet_red_128, bullet_grey_128, bullet_green_128, bullet_yellow_128, bullet_blue_128;
|
QAction *votePositiveAct;
|
||||||
|
QAction *voteNeutralAct;
|
||||||
|
QAction *voteNegativeAct;
|
||||||
|
QAction *distantChatAct;
|
||||||
|
QAction *actionSortByName;
|
||||||
|
QAction *actionSortByActivity;
|
||||||
|
QWidgetAction *checkableAction;
|
||||||
|
QAction *sendMessageAct;
|
||||||
|
QAction *showInPeopleAct;
|
||||||
|
|
||||||
|
GxsIdChooser *ownIdChooser ;
|
||||||
|
//icons cache
|
||||||
|
QIcon bullet_red_128, bullet_grey_128, bullet_yellow_128, bullet_green_128, bullet_blue_128;
|
||||||
|
QIcon bullet_red_128_star, bullet_grey_128_star, bullet_yellow_128_star, bullet_green_128_star;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
|
#include <QPainter>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
@ -411,10 +412,6 @@ QString misc::getExistingDirectory(QWidget *parent, const QString &caption, cons
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* Clear a Layout content
|
|
||||||
* \param layout: Layout to Clear
|
|
||||||
*/
|
|
||||||
void misc::clearLayout(QLayout * layout) {
|
void misc::clearLayout(QLayout * layout) {
|
||||||
if (! layout)
|
if (! layout)
|
||||||
return;
|
return;
|
||||||
|
|
@ -444,3 +441,15 @@ QSizeF misc::getFontSizeFactor(const QString &group, const qreal defaultFactor /
|
||||||
return QSizeF(appFontWidth*factor,appFontHeight*factor);
|
return QSizeF(appFontWidth*factor,appFontHeight*factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon misc::mergeIcon(QString iconB, QString iconF)
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(iconB);
|
||||||
|
QPixmap oli = FilesDefs::getPixmapFromQtResourcePath(iconF);
|
||||||
|
|
||||||
|
QPainter painter(&pix);
|
||||||
|
painter.drawPixmap(0, 0, oli);
|
||||||
|
|
||||||
|
icon.addPixmap(pix);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QIcon>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
@ -185,12 +186,29 @@ class misc : public QObject
|
||||||
, const QString &caption = QString()
|
, const QString &caption = QString()
|
||||||
, const QString &dir = QString());
|
, const QString &dir = QString());
|
||||||
|
|
||||||
//Clear QLayout
|
/*!
|
||||||
|
* Clear a Layout content
|
||||||
|
* \param layout: Layout to Clear
|
||||||
|
*/
|
||||||
static void clearLayout(QLayout *layout);
|
static void clearLayout(QLayout *layout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get Size depending of application Font Metrics
|
||||||
|
* @param group: Group name for factor from setting file
|
||||||
|
* @param defaultFactor: Default factor to use if none is defined
|
||||||
|
* @return Size factorized font size
|
||||||
|
*/
|
||||||
static QSizeF getFontSizeFactor(const QString &group, const qreal defaultFactor = 1.0);
|
static QSizeF getFontSizeFactor(const QString &group, const qreal defaultFactor = 1.0);
|
||||||
static QSizeF getFontSizeFactor() {return getFontSizeFactor("Main");}
|
static QSizeF getFontSizeFactor() {return getFontSizeFactor("Main");}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Merge two icons in one
|
||||||
|
* @param iconB: Background icon file
|
||||||
|
* @param iconF: Foreground icon file
|
||||||
|
* @return Merged icon
|
||||||
|
*/
|
||||||
|
static QIcon mergeIcon(QString iconB, QString iconF);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Trick to get a portable sleep() function
|
// Trick to get a portable sleep() function
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue