diff options
-rw-r--r-- | src/mumble/Log.cpp | 47 | ||||
-rw-r--r-- | src/mumble/MainWindow.cpp | 8 | ||||
-rw-r--r-- | src/mumble/MainWindow.h | 1 | ||||
-rw-r--r-- | src/mumble/Messages.cpp | 4 | ||||
-rw-r--r-- | src/mumble/TextToSpeech.h | 2 | ||||
-rw-r--r-- | src/mumble/TextToSpeech_macx.cpp | 6 | ||||
-rw-r--r-- | src/mumble/TextToSpeech_unix.cpp | 10 | ||||
-rw-r--r-- | src/mumble/TextToSpeech_win.cpp | 10 |
8 files changed, 54 insertions, 34 deletions
diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 3f9d93245..bc6a1add7 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -219,9 +219,19 @@ void Log::saveSettings() const { } } -void Log::log(MsgType t, const QString &console, const QString &terse) { +/* +void MainWindow::appendLog(QString entry) { + qteLog->append(entry); + QTextCursor p=qteLog->textCursor(); + p.movePosition(QTextCursor::End); + qteLog->setTextCursor(p); + qteLog->ensureCursorVisible(); +} +*/ + +void Log::log(MsgType mt, const QString &console, const QString &terse) { QTime now = QTime::currentTime(); - MsgSettings *ms=qhSettings.value(t); + MsgSettings *ms=qhSettings.value(mt); Q_ASSERT(ms); if (ms->iIgnore) { @@ -229,14 +239,39 @@ void Log::log(MsgType t, const QString &console, const QString &terse) { return; } - if (ms->bConsole) - g.mw->appendLog(tr("[%2] %1").arg(console).arg(now.toString(Qt::LocalDate))); + QTextDocument t; + t.setUndoRedoEnabled(false); + t.setHtml(console); + QString plain = t.toPlainText(); + + if (ms->bConsole) { + QTextCursor tc=g.mw->qteLog->textCursor(); + tc.movePosition(QTextCursor::End); + if (plain.contains(QRegExp(QLatin1String("[\\r\\n]")))) { + QTextFrameFormat qttf; + qttf.setBorder(1); + qttf.setPadding(2); + qttf.setBorderStyle(QTextFrameFormat::BorderStyle_Solid); + tc.insertFrame(qttf); + tc.insertHtml(QString::fromLatin1("[%2] %1\n").arg(console).arg(now.toString(Qt::LocalDate))); + } else { + tc.insertBlock(); + tc.insertHtml(QString::fromLatin1("[%2] %1\n").arg(console).arg(now.toString(Qt::LocalDate))); + } + tc.movePosition(QTextCursor::End); + g.mw->qteLog->setTextCursor(tc); + g.mw->qteLog->ensureCursorVisible(); + +// g.mw->appendLog(tr("[%2] %1").arg(console).arg(now.toString(Qt::LocalDate))); + } + if (! g.s.bTTS || ! ms->bTTS) return; + /* TTS threshold limiter. */ - if (console.length() <= g.s.iTTSThreshold) - tts->say(console); + if (plain.length() <= g.s.iTTSThreshold) + tts->say(plain); else if ((! terse.isEmpty()) && (terse.length() <= g.s.iTTSThreshold)) tts->say(terse); } diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 1880bae43..d6f4df750 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -424,14 +424,6 @@ void MainWindow::hideEvent(QHideEvent *e) { QMainWindow::hideEvent(e); } -void MainWindow::appendLog(QString entry) { - qteLog->append(entry); - QTextCursor p=qteLog->textCursor(); - p.movePosition(QTextCursor::End); - qteLog->setTextCursor(p); - qteLog->ensureCursorVisible(); -} - void MainWindow::on_Players_customContextMenuRequested(const QPoint &mpos) { QModelIndex idx = qtvPlayers->indexAt(mpos); if (! idx.isValid()) diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 78996d03b..1985956b0 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -79,7 +79,6 @@ class MainWindow : public QMainWindow, public MessageHandler { QString qsDesiredChannel; void recheckTTS(); - void appendLog(QString entry); void msgBox(QString msg); protected: diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index e289b89c8..6a27faac9 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -319,9 +319,7 @@ void MainWindow::msgTextMessage(Connection *, MessageTextMessage *msg) { MSG_INIT; if (! pSrc) return; - QTextDocument td; - td.setHtml(msg->qsMessage); - g.l->log(Log::TextMessage, MainWindow::tr("From %1: %2").arg(pSrc->qsName).arg(td.toPlainText()), + g.l->log(Log::TextMessage, MainWindow::tr("From %1: %2").arg(pSrc->qsName).arg(msg->qsMessage), MainWindow::tr("Message from %1").arg(pSrc->qsName)); } diff --git a/src/mumble/TextToSpeech.h b/src/mumble/TextToSpeech.h index 00b8ad4eb..964f53f5b 100644 --- a/src/mumble/TextToSpeech.h +++ b/src/mumble/TextToSpeech.h @@ -44,7 +44,7 @@ class TextToSpeech : public QObject { ~TextToSpeech(); bool isEnabled() const; public slots: - void say(QString text); + void say(const QString &text); void setEnabled(bool ena); void setVolume(int volume); private: diff --git a/src/mumble/TextToSpeech_macx.cpp b/src/mumble/TextToSpeech_macx.cpp index 797d33b23..0a4c623a3 100644 --- a/src/mumble/TextToSpeech_macx.cpp +++ b/src/mumble/TextToSpeech_macx.cpp @@ -42,7 +42,7 @@ class TextToSpeechPrivate { public: TextToSpeechPrivate(); ~TextToSpeechPrivate(); - void say(QString text); + void say(const QString &text); void setVolume(int v); }; @@ -54,7 +54,7 @@ TextToSpeechPrivate::~TextToSpeechPrivate() { DisposeSpeechChannel(speechchan); } -void TextToSpeechPrivate::say(QString text) { +void TextToSpeechPrivate::say(const QString &text) { QByteArray ba = text.toUtf8(); const char* val = ba.data(); SpeakText(speechchan, val, 11); @@ -72,7 +72,7 @@ TextToSpeech::~TextToSpeech() { delete d; } -void TextToSpeech::say(QString text) { +void TextToSpeech::say(const QString &text) { if (enabled) d->say(text); } diff --git a/src/mumble/TextToSpeech_unix.cpp b/src/mumble/TextToSpeech_unix.cpp index 98d20def2..43a0fef3d 100644 --- a/src/mumble/TextToSpeech_unix.cpp +++ b/src/mumble/TextToSpeech_unix.cpp @@ -37,7 +37,7 @@ class TextToSpeechPrivate { public: TextToSpeechPrivate(); ~TextToSpeechPrivate(); - void say(QString text); + void say(const QString &text); void setVolume(int v); }; @@ -51,10 +51,8 @@ TextToSpeechPrivate::~TextToSpeechPrivate() { qpFestival.close(); } -void TextToSpeechPrivate::say(QString text) { - QTextDocument td; - td.setHtml(text); - qpFestival.write(QString::fromLatin1("(SayText \"%1\")").arg(td.toPlainText().replace(QLatin1String("\""),QLatin1String("\\\""))).toLatin1()); +void TextToSpeechPrivate::say(const QString &text) { + qpFestival.write(QString::fromLatin1("(SayText \"%1\")").arg(text.replace(QLatin1String("\""),QLatin1String("\\\""))).toLatin1()); } void TextToSpeechPrivate::setVolume(int) { @@ -69,7 +67,7 @@ TextToSpeech::~TextToSpeech() { delete d; } -void TextToSpeech::say(QString text) { +void TextToSpeech::say(const QString &text) { if (enabled) d->say(text); } diff --git a/src/mumble/TextToSpeech_win.cpp b/src/mumble/TextToSpeech_win.cpp index 27a313e32..7ace2df9f 100644 --- a/src/mumble/TextToSpeech_win.cpp +++ b/src/mumble/TextToSpeech_win.cpp @@ -41,7 +41,7 @@ class TextToSpeechPrivate { ISpVoice * pVoice; TextToSpeechPrivate(); ~TextToSpeechPrivate(); - void say(QString text); + void say(const QString &text); void setVolume(int v); }; @@ -58,11 +58,9 @@ TextToSpeechPrivate::~TextToSpeechPrivate() { pVoice->Release(); } -void TextToSpeechPrivate::say(QString text) { +void TextToSpeechPrivate::say(const QString &text) { if (pVoice) { - QTextDocument td; - td.setHtml(text); - pVoice->Speak((const wchar_t *) td.toPlainText().utf16(), SPF_ASYNC, NULL); + pVoice->Speak((const wchar_t *) text.utf16(), SPF_ASYNC, NULL); } } @@ -80,7 +78,7 @@ TextToSpeech::~TextToSpeech() { delete d; } -void TextToSpeech::say(QString text) { +void TextToSpeech::say(const QString &text) { if (enabled) d->say(text); } |