diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index f5659756b..d0b4d5fc7 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1120,8 +1120,7 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr eve break; SoundManager::play(SOUND_DOWNLOAD_COMPLETE); - if (Settings->getNotifyFlags() & RS_POPUP_DOWNLOAD) - NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); + NotifyQt::getInstance()->addToaster(RS_POPUP_DOWNLOAD, fe->mHash.toStdString(), nfo.fname.c_str(),""); } [[fallthrough]]; diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 36f547738..c73f834fb 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -441,8 +441,7 @@ void NewsFeed::handleConnectionEvent(std::shared_ptr 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(), "", ""); + NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT, e.mSslId.toStdString().c_str(), "", ""); break; case RsConnectionEventCode::PEER_DISCONNECTED: // not handled yet break; @@ -508,8 +507,7 @@ void NewsFeed::handleSecurityEvent(std::shared_ptr 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()); + NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str()); } void NewsFeed::testFeeds(uint /*notifyFlags*/) diff --git a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp index 60e6ec197..5414802e0 100644 --- a/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp +++ b/retroshare-gui/src/gui/msgs/MessageUserNotify.cpp @@ -96,13 +96,12 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr e 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() ); - } + 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: diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 59d102170..9012e77bd 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -1173,37 +1173,73 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st ToasterItem *toaster = NULL; + uint popupflags = Settings->getNotifyFlags(); + 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")))); + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + { + 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()))); + if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) + { + 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))); + if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) + { + 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()))); + if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) + { + 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; + if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) + { + // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT + ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); + ChatWidget *chatWidget; + if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { + // do not show when active + break; + } + toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + } case RS_POPUP_GROUPCHAT: #ifdef RS_DIRECT_CHAT - toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) + { + MainWindow *mainWindow = MainWindow::getInstance(); + if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { + if (MainWindow::getActivatePage() == MainWindow::Friends) { + if (FriendsDialog::isGroupChatActive()) { + // do not show when active + break; + } + } + } + toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); + } #endif // RS_DIRECT_CHAT break; case RS_POPUP_CHATLOBBY: + if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) { ChatId chat_id(id); @@ -1221,13 +1257,16 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st break; // participant is muted toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); - } + } break; case RS_POPUP_CONNECT_ATTEMPT: + if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) + { // id = gpgid // title = ssl name // msg = peer id toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); + } break; } @@ -1240,4 +1279,6 @@ void NotifyQt::addToaster(uint notifyFlags, const std::string& id, const std::st waitingToasterList.push_back(toaster); } } + /* Now start the waiting toasters */ + startWaitingToasters(); }