@@ -679,7 +679,9 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) {
679679 }
680680
681681 if (tc) {
682- tc->insertHtml (qtd.toHtml ());
682+ QTextCursor tcNew (&qtd);
683+ tcNew.movePosition (QTextCursor::End, QTextCursor::KeepAnchor);
684+ tc->insertFragment (tcNew.selection ());
683685 return QString ();
684686 } else {
685687 return qtd.toHtml ();
@@ -710,6 +712,11 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
710712 // the setting might change in that time).
711713 const int msgMargin = Global::get ().s .iChatMessageMargins ;
712714
715+ QTextFrameFormat qttf;
716+ qttf.setTopMargin (msgMargin);
717+ qttf.setBottomMargin (0 );
718+ qttf.setPosition (QTextFrameFormat::FloatLeft);
719+
713720 LogTextBrowser *tlog = Global::get ().mw ->qteLog ;
714721 const int oldscrollvalue = tlog->getLogScroll ();
715722 const bool scroll = (oldscrollvalue == tlog->getLogScrollMaximum ());
@@ -728,13 +735,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
728735 QString fixedNLPlain =
729736 plain.replace (QLatin1String (" \r\n " ), QLatin1String (" \n " )).replace (QLatin1String (" \r " ), QLatin1String (" \n " ));
730737
731- QTextFrameFormat qttf;
732- // `insertFrame` causes a blank line to precede the inserted frame.
733- // This is remedied by setting a negative top margin of equal height.
734- static int lineSpacing = QFontMetrics (tc.currentFrame ()->format ().toCharFormat ().font ()).lineSpacing ();
735- qttf.setTopMargin (-lineSpacing);
736- qttf.setBottomMargin (msgMargin);
737-
738738 if (fixedNLPlain.contains (QRegExp (QLatin1String (" \\ n[ \\ t]*$" )))) {
739739 // If the message ends with one or more blank lines (or lines only containing whitespace)
740740 // paint a border around the message to make clear that it contains invisible parts.
@@ -743,10 +743,11 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
743743 qttf.setBorder (1 );
744744 qttf.setPadding (2 );
745745 qttf.setBorderStyle (QTextFrameFormat::BorderStyle_Dashed);
746+ tc.insertFrame (qttf);
747+ } else if (!tc.atStart ()) {
748+ tc.insertFrame (qttf);
746749 }
747750
748- tc.insertFrame (qttf);
749-
750751 const QString timeString =
751752 dt.time ().toString (QLatin1String (Global::get ().s .bLog24HourClock ? " HH:mm:ss" : " hh:mm:ss AP" ));
752753 tc.insertHtml (Log::msgColor (QString::fromLatin1 (" [%1] " ).arg (timeString.toHtmlEscaped ()), Log::Time));
0 commit comments