mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-08 08:54:41 -04:00
Sort out decoded text font and font changes
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5159 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QDateTime>
|
||||
#include <QTextCharFormat>
|
||||
#include <QFont>
|
||||
#include <QTextCursor>
|
||||
|
||||
#include "qt_helpers.hpp"
|
||||
|
||||
@@ -14,6 +17,20 @@ DisplayText::DisplayText(QWidget *parent) :
|
||||
viewport ()->setCursor (Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void DisplayText::setContentFont(QFont const& font)
|
||||
{
|
||||
document ()->setDefaultFont (font);
|
||||
QTextCharFormat format;
|
||||
format.setFont (font);
|
||||
selectAll ();
|
||||
auto cursor = textCursor ();
|
||||
cursor.mergeCharFormat (format);
|
||||
cursor.clearSelection ();
|
||||
cursor.movePosition (QTextCursor::End);
|
||||
setTextCursor (cursor);
|
||||
ensureCursorVisible ();
|
||||
}
|
||||
|
||||
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
bool ctrl = (e->modifiers() & Qt::ControlModifier);
|
||||
@@ -36,6 +53,7 @@ void DisplayText::_insertText(const QString text, const QString bg)
|
||||
moveCursor (QTextCursor::End);
|
||||
append (s);
|
||||
moveCursor (QTextCursor::End);
|
||||
ensureCursorVisible ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user