moved popup settings for toasters

This commit is contained in:
defnax 2023-04-07 16:23:46 +02:00
parent e7ff1b15b7
commit 22a9cf4236
4 changed files with 57 additions and 20 deletions

View File

@ -1120,8 +1120,7 @@ void TransfersDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> 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]];

View File

@ -441,8 +441,7 @@ 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(), "", "");
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<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());
NotifyQt::getInstance()->addToaster(RS_POPUP_CONNECT_ATTEMPT, e.mPgpId.toStdString().c_str(), det.location, e.mSslId.toStdString().c_str());
}
void NewsFeed::testFeeds(uint /*notifyFlags*/)

View File

@ -96,13 +96,12 @@ void MessageUserNotify::handleEvent_main_thread(std::shared_ptr<const RsEvent> 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:

View File

@ -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();
}