mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-08 00:44:39 -04:00
Fix font setting
Several issues mainly related to the rather complex interaction of style sheets and widget properties with respect to fonts. Font setting on the astro window should now be consistent and not overridden by application style sheet driven font settings. Decoded text font setting should now be consistent and not revert back to Courier 10 on the next decode after a font change. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5179 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
+16
-9
@@ -1,5 +1,5 @@
|
||||
#include "displaytext.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QDateTime>
|
||||
#include <QTextCharFormat>
|
||||
@@ -15,16 +15,17 @@ DisplayText::DisplayText(QWidget *parent) :
|
||||
{
|
||||
setReadOnly (true);
|
||||
viewport ()->setCursor (Qt::ArrowCursor);
|
||||
setWordWrapMode (QTextOption::NoWrap);
|
||||
setStyleSheet ("");
|
||||
}
|
||||
|
||||
void DisplayText::setContentFont(QFont const& font)
|
||||
{
|
||||
document ()->setDefaultFont (font);
|
||||
QTextCharFormat format;
|
||||
format.setFont (font);
|
||||
setFont (font);
|
||||
m_charFormat.setFont (font);
|
||||
selectAll ();
|
||||
auto cursor = textCursor ();
|
||||
cursor.mergeCharFormat (format);
|
||||
cursor.mergeCharFormat (m_charFormat);
|
||||
cursor.clearSelection ();
|
||||
cursor.movePosition (QTextCursor::End);
|
||||
setTextCursor (cursor);
|
||||
@@ -49,10 +50,16 @@ void DisplayText::insertLineSpacer()
|
||||
void DisplayText::_insertText(const QString text, const QString bg)
|
||||
{
|
||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + text.trimmed () + "</pre></td></tr></table>";
|
||||
moveCursor (QTextCursor::End);
|
||||
append (s);
|
||||
moveCursor (QTextCursor::End);
|
||||
bg + "\">" + text.trimmed ().replace (' ', " ") + "</td></tr></table>";
|
||||
auto cursor = textCursor ();
|
||||
cursor.movePosition (QTextCursor::End);
|
||||
auto pos = cursor.position ();
|
||||
insertHtml (s);
|
||||
cursor.setPosition (pos, QTextCursor::MoveAnchor);
|
||||
cursor.movePosition (QTextCursor::End, QTextCursor::KeepAnchor);
|
||||
cursor.mergeCharFormat (m_charFormat);
|
||||
cursor.clearSelection ();
|
||||
setTextCursor (cursor);
|
||||
ensureCursorVisible ();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user