diff --git a/src/mumble/EnumStringConversions.cpp b/src/mumble/EnumStringConversions.cpp index c4be0959b2..cc6d2f11e4 100644 --- a/src/mumble/EnumStringConversions.cpp +++ b/src/mumble/EnumStringConversions.cpp @@ -133,7 +133,9 @@ PROCESS(Log::MsgType, PrivateTextMessage, "PrivateTextMessage") \ PROCESS(Log::MsgType, ChannelListeningAdd, "ChannelListeningAdd") \ PROCESS(Log::MsgType, ChannelListeningRemove, "ChannelListeningRemove") \ - PROCESS(Log::MsgType, PluginMessage, "PluginMessage") + PROCESS(Log::MsgType, PluginMessage, "PluginMessage") \ + PROCESS(Log::MsgType, ImageMessage, "ImageMessage") \ + PROCESS(Log::MsgType, PrivateImageMessage, "PrivateImageMessage") #define OVERLAY_PRESETS_VALUES \ PROCESS(OverlaySettings::OverlayPresets, AvatarAndName, "AvatarAndName") \ diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index e02e6a5018..623af04f8a 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -461,6 +461,8 @@ const Log::MsgType Log::msgOrder[] = { DebugInfo, PermissionDenied, TextMessage, PrivateTextMessage, + ImageMessage, + PrivateImageMessage, PluginMessage }; const char *Log::msgNames[] = { QT_TRANSLATE_NOOP("Log", "Debug"), @@ -494,7 +496,9 @@ const char *Log::msgNames[] = { QT_TRANSLATE_NOOP("Log", "Debug"), QT_TRANSLATE_NOOP("Log", "Private text message"), QT_TRANSLATE_NOOP("Log", "User started listening to channel"), QT_TRANSLATE_NOOP("Log", "User stopped listening to channel"), - QT_TRANSLATE_NOOP("Log", "Plugin message") }; + QT_TRANSLATE_NOOP("Log", "Plugin message"), + QT_TRANSLATE_NOOP("Log", "Image message"), + QT_TRANSLATE_NOOP("Log", "Private image message") }; QString Log::msgName(MsgType t) const { return tr(msgNames[t]); @@ -840,6 +844,8 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own break; case TextMessage: case PrivateTextMessage: + case ImageMessage: + case PrivateImageMessage: msgIcon = QSystemTrayIcon::NoIcon; break; case Information: diff --git a/src/mumble/Log.h b/src/mumble/Log.h index 620c063cc2..3c20994161 100644 --- a/src/mumble/Log.h +++ b/src/mumble/Log.h @@ -110,12 +110,14 @@ class Log : public QObject { PrivateTextMessage, ChannelListeningAdd, ChannelListeningRemove, - PluginMessage + PluginMessage, + ImageMessage, + PrivateImageMessage }; enum LogColorType { Time, Server, Privilege, Source, Target }; static const MsgType firstMsgType = DebugInfo; - static const MsgType lastMsgType = ChannelListeningRemove; + static const MsgType lastMsgType = PrivateImageMessage; // Display order in settingsscreen, allows to insert new events without breaking config-compatibility with older // versions. diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 5f6c26e661..2f2236bdb3 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -40,6 +40,7 @@ #include "crypto/CryptStateOCB2.h" #include "Global.h" +#include #include #define ACTOR_INIT \ @@ -1038,9 +1039,31 @@ void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) { const QString prefixMessage = target.isEmpty() ? name : tr("(%1) %2").arg(target).arg(name); - Global::get().l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage, - tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName), - false, overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false); + // Determine if this message contains an image embed + const QString messageContent = u8(msg.message()); + const QRegularExpression imageTagRegex(QLatin1String("<\\s*img\\b"), + QRegularExpression::CaseInsensitiveOption); + const bool hasImage = imageTagRegex.match(messageContent).hasMatch(); + + // Select the appropriate message type based on whether the message contains images + Log::MsgType msgType; + if (hasImage) { + if (privateMessage) { + msgType = Log::PrivateImageMessage; + } else { + msgType = Log::ImageMessage; + } + } else { + if (privateMessage) { + msgType = Log::PrivateTextMessage; + } else { + msgType = Log::TextMessage; + } + } + + Global::get().l->log(msgType, tr("%1: %2").arg(prefixMessage).arg(messageContent), + tr("Message from %1").arg(plainName), false, overrideTTS, + pSrc ? pSrc->bLocalIgnoreTTS : false); } /// This message is being received when the server informs the client about the access control list (ACL) for diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index b958942686..370505b38e 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -574,6 +574,8 @@ Settings::Settings() { qmMessageSounds[Log::YouMuted] = QLatin1String(":/UserMutedYouOrByYou.ogg"); qmMessageSounds[Log::YouKicked] = QLatin1String(":/UserKickedYouOrByYou.ogg"); qmMessageSounds[Log::Recording] = QLatin1String(":/RecordingStateChanged.ogg"); + qmMessageSounds[Log::ImageMessage] = qmMessageSounds[Log::TextMessage]; + qmMessageSounds[Log::PrivateImageMessage] = qmMessageSounds[Log::TextMessage]; qmMessages[Log::DebugInfo] = Settings::LogConsole; qmMessages[Log::Warning] = Settings::LogConsole | Settings::LogBalloon;