mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
Fixed Toasters
Fixed Online, Download Complete, Mail & FR Toaster
This commit is contained in:
parent
16137f60ff
commit
5f54db577c
@ -1111,10 +1111,16 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
FileInfo nfo ;
|
||||
if(!rsFiles->FileDetails(fe->mHash, RS_FILE_HINTS_DOWNLOAD, nfo))
|
||||
return ;
|
||||
|
||||
switch (fe->mFileTransferEventCode)
|
||||
{
|
||||
case RsFileTransferEventCode::DOWNLOAD_COMPLETE:
|
||||
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
|
||||
if (Settings->getNotifyFlags() & RS_POPUP_DOWNLOAD)
|
||||
NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),"");
|
||||
case RsFileTransferEventCode::COMPLETED_FILES_REMOVED:
|
||||
|
||||
getUserNotify()->updateIcon();
|
||||
|
@ -441,6 +441,8 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
case RsConnectionEventCode::PEER_CONNECTED:
|
||||
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false), true);
|
||||
if (Settings->getNotifyFlags() & RS_POPUP_CONNECT)
|
||||
NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", "");
|
||||
break;
|
||||
case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet
|
||||
break;
|
||||
@ -476,6 +478,7 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
|
||||
addFeedItemIfUnique(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_HELLO, false), true );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint32_t FeedItemType=0;
|
||||
|
||||
@ -504,6 +507,9 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr<const RsEvent> event)
|
||||
|
||||
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT)
|
||||
MessageComposer::addConnectAttemptMsg(e.mPgpId, e.mSslId, QString::fromStdString(det.name + "(" + det.location + ")"));
|
||||
|
||||
if (Settings->getNotifyFlags() & RS_POPUP_CONNECT_ATTEMPT)
|
||||
NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str());
|
||||
}
|
||||
|
||||
void NewsFeed::testFeeds(uint /*notifyFlags*/)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
|
||||
@ -91,8 +92,18 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr<const RsEvent> e
|
||||
return;
|
||||
}
|
||||
|
||||
std::set<RsMailMessageId>::const_iterator it;
|
||||
|
||||
switch (fe->mMailStatusEventCode) {
|
||||
case RsMailStatusEventCode::NEW_MESSAGE:
|
||||
if (Settings->getNotifyFlags() & RS_POPUP_MSG)
|
||||
for (it = fe->mChangedMsgIds.begin(); it != fe->mChangedMsgIds.end(); ++it) {
|
||||
MessageInfo msgInfo;
|
||||
if (rsMail->getMessage(*it, msgInfo)) {
|
||||
NotifyQt::getInstance()->addToaster(RS_POPUP_MSG, msgInfo.msgId.c_str(), msgInfo.title.c_str(), msgInfo.msg.c_str() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RsMailStatusEventCode::MESSAGE_CHANGED:
|
||||
case RsMailStatusEventCode::MESSAGE_REMOVED:
|
||||
updateIcon();
|
||||
|
@ -1162,3 +1162,82 @@ void NotifyQt::runningTick()
|
||||
}
|
||||
}
|
||||
|
||||
void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg)
|
||||
{
|
||||
uint pos = 0;
|
||||
|
||||
while (notifyFlags) {
|
||||
uint type = notifyFlags & (1 << pos);
|
||||
notifyFlags &= ~(1 << pos);
|
||||
++pos;
|
||||
|
||||
ToasterItem *toaster = NULL;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case RS_POPUP_ENCRYPTED_MSG:
|
||||
SoundManager::play(SOUND_MESSAGE_ARRIVED);
|
||||
|
||||
toaster = new ToasterItem(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message"))));
|
||||
break;
|
||||
case RS_POPUP_MSG:
|
||||
SoundManager::play(SOUND_MESSAGE_ARRIVED);
|
||||
|
||||
toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())));
|
||||
break;
|
||||
case RS_POPUP_CONNECT:
|
||||
SoundManager::play(SOUND_USER_ONLINE);
|
||||
|
||||
toaster = new ToasterItem(new OnlineToaster(RsPeerId(id)));
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
|
||||
|
||||
toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
|
||||
break;
|
||||
case RS_POPUP_CHAT:
|
||||
toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
break;
|
||||
case RS_POPUP_GROUPCHAT:
|
||||
#ifdef RS_DIRECT_CHAT
|
||||
toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str())));
|
||||
#endif // RS_DIRECT_CHAT
|
||||
break;
|
||||
case RS_POPUP_CHATLOBBY:
|
||||
{
|
||||
ChatId chat_id(id);
|
||||
|
||||
ChatDialog *chatDialog = ChatDialog::getChat(chat_id);
|
||||
ChatWidget *chatWidget;
|
||||
if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) {
|
||||
// do not show when active
|
||||
break;
|
||||
}
|
||||
|
||||
ChatLobbyDialog *chatLobbyDialog = dynamic_cast<ChatLobbyDialog*>(chatDialog);
|
||||
|
||||
RsGxsId sender(title);
|
||||
if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender))
|
||||
break; // participant is muted
|
||||
|
||||
toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CONNECT_ATTEMPT:
|
||||
// id = gpgid
|
||||
// title = ssl name
|
||||
// msg = peer id
|
||||
toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg)));
|
||||
break;
|
||||
}
|
||||
|
||||
if (toaster) {
|
||||
/* init attributes */
|
||||
toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
|
||||
/* add toaster to waiting list */
|
||||
//QMutexLocker lock(&waitingToasterMutex);
|
||||
waitingToasterList.push_back(toaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ class NotifyQt: public QObject, public NotifyClient
|
||||
void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
||||
|
||||
void addToaster(uint notifyFlags, const std::string& id, const std::string& title, const std::string& msg);
|
||||
void notifySettingsChanged();
|
||||
|
||||
signals:
|
||||
|
@ -21,7 +21,11 @@
|
||||
#include "MessageToaster.h"
|
||||
#include "../MainWindow.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
#include "gui/msgs/MessageInterface.h"
|
||||
|
||||
MessageToaster::MessageToaster(const std::string &peerId, const QString &title, const QString &message) : QWidget(NULL)
|
||||
{
|
||||
@ -39,8 +43,24 @@ MessageToaster::MessageToaster(const std::string &peerId, const QString &title,
|
||||
ui.textLabel->setText(message);
|
||||
ui.textLabel->setToolTip(message);
|
||||
|
||||
std::string name = (!RsPeerId(peerId).isNull())? (rsPeers->getPeerName(RsPeerId(peerId))): (rsPeers->getGPGName(RsPgpId(peerId))) ;
|
||||
ui.toasterLabel->setText(ui.toasterLabel->text() + " " + QString::fromUtf8(name.c_str()));
|
||||
MessageInfo mi;
|
||||
|
||||
if (!rsMail->getMessage(peerId, mi))
|
||||
return;
|
||||
|
||||
QString srcName;
|
||||
|
||||
if(mi.msgflags & RS_MSG_DISTANT)
|
||||
{
|
||||
RsIdentityDetails details ;
|
||||
rsIdentity->getIdDetails(mi.from.toGxsId(), details) ;
|
||||
|
||||
srcName = QString::fromUtf8(details.mNickname.c_str());
|
||||
}
|
||||
else
|
||||
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.from.toRsPeerId()).c_str());
|
||||
|
||||
ui.toasterLabel->setText(ui.toasterLabel->text() + " " + srcName);
|
||||
}
|
||||
|
||||
void MessageToaster::openmessageClicked()
|
||||
|
Loading…
Reference in New Issue
Block a user