mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-18 18:12:12 -05:00
127c633a97
Colours behave like other configuration items and changes are only applied when the Settings UI is dismissed via the "OK" button. Simplified font settings and use style sheets consistently to set the application and decoded text fonts. This is necessary because any UI widget that has a style sheet applied does not honor a font set by QWidget::setFont() even if there is no font setting in the style sheet, this is broken behaviour IMHO but that is the way Qt currently works. Use a style sheet to style the frequency display and clock. This is necessary to allow fonts to be cascaded through parent style sheets and still be overridden on these widgets. Simplify the decoded text widgets, there is no need to use the QTextBrowser as a super class since the simpler QTextEdit set as read-only is sufficient. Also removed colour setting via a background brush as it doesn't work and the HTML 'bgcolor' attribute works correctly. Change to UI properties of the decoded text widgets to allow horizontal scrolling if required, this allows larger fonts to be used without truncating decoded messages. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4957 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
130 lines
4.2 KiB
C++
130 lines
4.2 KiB
C++
#include "displaytext.h"
|
|
#include <QDebug>
|
|
#include <QMouseEvent>
|
|
#include <QDateTime>
|
|
|
|
#include "qt_helpers.hpp"
|
|
|
|
#include "moc_displaytext.cpp"
|
|
|
|
DisplayText::DisplayText(QWidget *parent) :
|
|
QTextEdit(parent)
|
|
{
|
|
setReadOnly (true);
|
|
setCursorWidth (0);
|
|
}
|
|
|
|
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
|
|
{
|
|
bool ctrl = (e->modifiers() & Qt::ControlModifier);
|
|
bool shift = (e->modifiers() & Qt::ShiftModifier);
|
|
emit(selectCallsign(shift,ctrl));
|
|
QTextEdit::mouseDoubleClickEvent(e);
|
|
}
|
|
|
|
void DisplayText::insertLineSpacer()
|
|
{
|
|
QString tt="----------------------------------------";
|
|
QString bg="#d3d3d3";
|
|
_insertText(tt,bg);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
void DisplayText::_appendDXCCWorkedB4(DecodedText& t1, QString& bg,
|
|
LogBook logBook, QColor color_CQ,
|
|
QColor color_DXCC,
|
|
QColor color_NewCall)
|
|
{
|
|
// extract the CQer's call TODO: does this work with all call formats? What about 'CQ DX'?
|
|
int s1 = 4 + t1.indexOf(" CQ ");
|
|
int s2 = t1.indexOf(" ",s1);
|
|
QString call = t1.mid(s1,s2-s1);
|
|
|
|
QString countryName;
|
|
bool callWorkedBefore;
|
|
bool countryWorkedBefore;
|
|
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
|
|
|
|
int charsAvail = 48;
|
|
|
|
// the decoder (seems) to always generate 40 chars. For a normal CQ call, the last five are spaces
|
|
// TODO this magic 36 characters is also referenced in MainWindow::doubleClickOnCall()
|
|
int s3 = t1.indexOf(" ",35);
|
|
if (s3 < 35)
|
|
s3 = 35; // we always want at least the characters to position 35
|
|
s3 += 1; // convert the index into a character count
|
|
t1 = t1.left(s3); // reduce trailing white space
|
|
charsAvail -= s3;
|
|
if (charsAvail > 4)
|
|
{
|
|
if (!countryWorkedBefore) // therefore not worked call either
|
|
{
|
|
t1 += "!";
|
|
bg=color_DXCC.name();
|
|
}
|
|
else
|
|
if (!callWorkedBefore) // but have worked the country
|
|
{
|
|
t1 += "~";
|
|
bg=color_NewCall.name();
|
|
}
|
|
else
|
|
{
|
|
t1 += " "; // have worked this call before
|
|
bg=color_CQ.name();
|
|
}
|
|
charsAvail -= 1;
|
|
|
|
if (countryName.length()>charsAvail)
|
|
countryName = countryName.left(1)+"."+countryName.right(charsAvail-2); //abreviate the first word to the first letter, show remaining right most chars
|
|
t1 += countryName;
|
|
}
|
|
}
|
|
|
|
void DisplayText::displayDecodedText(DecodedText decodedText, QString myCall,
|
|
bool displayDXCCEntity, LogBook logBook,
|
|
QColor color_CQ, QColor color_MyCall,
|
|
QColor color_DXCC, QColor color_NewCall)
|
|
{
|
|
QString bg="white";
|
|
bool CQcall = false;
|
|
if (decodedText.indexOf(" CQ ") > 0)
|
|
{
|
|
CQcall = true;
|
|
bg=color_CQ.name();
|
|
}
|
|
if (myCall != "" and decodedText.indexOf(" " + myCall + " ") > 0)
|
|
bg=color_MyCall.name();
|
|
|
|
// if enabled add the DXCC entity and B4 status to the end of the preformated text line t1
|
|
if (displayDXCCEntity && CQcall)
|
|
_appendDXCCWorkedB4(/*mod*/decodedText,bg,logBook,color_CQ,
|
|
color_DXCC,color_NewCall);
|
|
|
|
_insertText(decodedText.string(),bg);
|
|
}
|
|
|
|
|
|
void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq,
|
|
QColor color_TxMsg)
|
|
{
|
|
QString bg=color_TxMsg.name();
|
|
QString t1=" @ ";
|
|
if(modeTx=="JT65") t1=" # ";
|
|
QString t2;
|
|
t2.sprintf("%4d",txFreq);
|
|
QString t = QDateTime::currentDateTimeUtc().toString("hhmm") + \
|
|
" Tx " + t2 + t1 + text; // The position of the 'Tx' is searched for in DecodedText and in MainWindow. Not sure if thats required anymore? VK3ACF
|
|
|
|
_insertText(t,bg);
|
|
}
|