mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-25 05:29:16 -04:00
2. The available character count is now updated by catching resizeEvents git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3545 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
35 lines
844 B
C++
35 lines
844 B
C++
#include "displaytext.h"
|
|
#include <QDebug>
|
|
#include <QMouseEvent>
|
|
|
|
|
|
DisplayText::DisplayText(QWidget *parent) :
|
|
QTextBrowser(parent)
|
|
{
|
|
_fontWidth = 8; // typical
|
|
_maxDisplayedCharacters = 48; // a nominal safe(?) value
|
|
}
|
|
|
|
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
|
{
|
|
bool ctrl = (e->modifiers() & Qt::ControlModifier);
|
|
bool shift = (e->modifiers() & Qt::ShiftModifier);
|
|
emit(selectCallsign(shift,ctrl));
|
|
QTextBrowser::mouseDoubleClickEvent(e);
|
|
}
|
|
|
|
|
|
void DisplayText::setFont(QFont font)
|
|
{
|
|
QFontMetrics qfm(font);
|
|
_fontWidth = qfm.averageCharWidth()+1; // the plus one is emperical
|
|
QTextBrowser::setFont(font);
|
|
}
|
|
|
|
void DisplayText::resizeEvent(QResizeEvent * event)
|
|
{
|
|
if (_fontWidth > 0 && _fontWidth < 999)
|
|
_maxDisplayedCharacters = width()/_fontWidth;
|
|
QTextBrowser::resizeEvent(event);
|
|
}
|