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:
Bill Somerville 2015-04-05 12:22:01 +00:00
parent 4b0d7f2d18
commit 868ce60f7e
3 changed files with 21 additions and 2 deletions

View File

@ -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 ();
}

View File

@ -13,6 +13,7 @@ class DisplayText : public QTextEdit
public:
explicit DisplayText(QWidget *parent = 0);
void setContentFont (QFont const&);
void insertLineSpacer();
void displayDecodedText(DecodedText decodedText, QString myCall, bool displayDXCCEntity,
LogBook logBook, QColor color_CQ, QColor color_MyCall,

View File

@ -596,9 +596,9 @@ void MainWindow::readSettings()
void MainWindow::setDecodedTextFont (QFont const& font)
{
ui->decodedTextBrowser->setContentFont (font);
ui->decodedTextBrowser2->setContentFont (font);
auto style_sheet = font_as_stylesheet (font);
ui->decodedTextBrowser->setStyleSheet (ui->decodedTextBrowser->styleSheet () + style_sheet);
ui->decodedTextBrowser2->setStyleSheet (ui->decodedTextBrowser2->styleSheet () + style_sheet);
ui->decodedTextLabel->setStyleSheet (ui->decodedTextLabel->styleSheet () + style_sheet);
ui->decodedTextLabel2->setStyleSheet (ui->decodedTextLabel2->styleSheet () + style_sheet);
}