From a517f10835556b39f6c432a2531263eb4186ec6a Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Tue, 23 Jun 2020 22:38:06 +0200 Subject: [PATCH 1/2] FIX(tts): OmitScope/OmitAuthor no longer reads HTML-formatted message The new features "Omit Message Scope" and "Omit Message Author" where somewhat broken. The problems are adressed by transforming the message from HTML to plaintext and creating a new TTS string that either contains no prefix or just the scope or the author. Fixes #4309 --- src/mumble/Messages.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 70c6e3e87..9cdebc0f5 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -35,6 +35,7 @@ #include "Utils.h" #include "ChannelListener.h" #include "TalkingUI.h" +#include // We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name (like protobuf 3.7 does). As such, for now, we have to make this our last include. #include "Global.h" @@ -877,7 +878,6 @@ void MainWindow::msgChannelRemove(const MumbleProto::ChannelRemove &msg) { void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) { ACTOR_INIT; QString target; - QString overrideTTS = QString(); // Silently drop the message if this user is set to "ignore" if (pSrc && pSrc->bLocalIgnore) @@ -888,30 +888,34 @@ void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) { bool privateMessage = false; if (msg.tree_id_size() > 0) { - target += tr("(Tree) "); + target += tr("Tree"); } else if (msg.channel_id_size() > 0) { - target += tr("(Channel) "); + target += tr("Channel"); } else if (msg.session_size() > 0) { - target += tr("(Private) "); + target += tr("Private"); privateMessage = true; } // If NoScope or NoAuthor is selected generate a new string to pass to TTS - if (g.s.bTTSNoScope || g.s.bTTSNoAuthor) { - if (g.s.bTTSNoScope && g.s.bTTSNoAuthor) { - overrideTTS += tr("%2%1: %3").arg(QString()).arg(QString()).arg(u8(msg.message())); - } else if (g.s.bTTSNoAuthor) { - overrideTTS += tr("%2%1: %3").arg(QString()).arg(target).arg(u8(msg.message())); - } else if (g.s.bTTSNoScope) { - overrideTTS += tr("%2%1: %3").arg(name).arg(QString()).arg(u8(msg.message())); + const QString overrideTTS = [&]() { + if (!g.s.bTTSNoScope && !g.s.bTTSNoAuthor) { + return QString(); } - } + const QString plainMessage = QTextDocumentFragment::fromHtml(u8(msg.message())).toPlainText(); + if (g.s.bTTSNoScope && g.s.bTTSNoAuthor) { + return plainMessage; + } + const QString prefixTTS = g.s.bTTSNoScope ? plainName : target; + return tr("%1: %2").arg(prefixTTS).arg(plainMessage); + }(); + + const QString prefixMessage = target.isEmpty() ? name : tr("(%1) %2").arg(target).arg(name); g.l->log(privateMessage ? Log::PrivateTextMessage : Log::TextMessage, - tr("%2%1: %3").arg(name).arg(target).arg(u8(msg.message())), + tr("%1: %2").arg(prefixMessage).arg(u8(msg.message())), tr("Message from %1").arg(plainName), false, - overrideTTS.isNull() ? QString() : overrideTTS, + overrideTTS, pSrc ? pSrc->bLocalIgnoreTTS : false); } From 9c5857a9fb622592f43334711584175fd4f7e200 Mon Sep 17 00:00:00 2001 From: Popkornium18 Date: Thu, 25 Jun 2020 21:09:31 +0200 Subject: [PATCH 2/2] Translation update Updating 'mumble_en.ts'... Found 1881 source text(s) (5 new and 1876 already existing) Removed 4 obsolete entries --- src/mumble/mumble_en.ts | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/mumble/mumble_en.ts b/src/mumble/mumble_en.ts index 07e624126..f5d6481b3 100644 --- a/src/mumble/mumble_en.ts +++ b/src/mumble/mumble_en.ts @@ -5454,22 +5454,6 @@ Otherwise abort and check your certificate and username. message from - - (Tree) - - - - (Channel) - - - - (Private) - - - - %2%1: %3 - - Failed to load Opus, it will not be available for audio encoding/decoding. @@ -6050,6 +6034,26 @@ Valid options are: Silently disables Text-To-Speech for all text messages from the user. + + Tree + + + + Channel + + + + Private + + + + %1: %2 + + + + (%1) %2 + + Manual