Set the color highlighting scheme at startup, or after a call to Settings.

This commit is contained in:
Joe Taylor 2018-08-24 13:18:49 -04:00
parent c7b9892517
commit 0fbc9f3514
4 changed files with 70 additions and 47 deletions

View File

@ -152,8 +152,7 @@ void DisplayText::appendText(QString const& text, QColor bg, QString const& call
} }
QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg,
LogBook const& logBook, QColor color_CQ, QColor color_DXCC, QColor color_NewCall, LogBook const& logBook, QString currentBand)
QColor color_NewCallBand, QString currentBand)
{ {
// allow for seconds // allow for seconds
int padding {message.indexOf (" ") > 4 ? 2 : 0}; int padding {message.indexOf (" ") > 4 ? 2 : 0};
@ -183,19 +182,19 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
if (!countryWorkedBefore) { if (!countryWorkedBefore) {
// therefore not worked call either // therefore not worked call either
appendage += "!"; appendage += "!";
*bg = color_DXCC; *bg = m_color_DXCC;
} else { } else {
if (!callWorkedBefore) { if (!callWorkedBefore) {
// but have worked the country // but have worked the country
appendage += "~"; appendage += "~";
*bg = color_NewCall; *bg = m_color_NewCall;
} else { } else {
if(!callB4onBand) { if(!callB4onBand) {
appendage += "~"; appendage += "~";
*bg = color_NewCallBand; *bg = m_color_NewCallBand;
} else { } else {
appendage += " "; // have worked this call before appendage += " "; // have worked this call before
*bg = color_CQ; *bg = m_color_CQ;
} }
} }
} }
@ -244,9 +243,6 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign
void DisplayText::displayDecodedText(DecodedText const& decodedText, QString const& myCall, void DisplayText::displayDecodedText(DecodedText const& decodedText, QString const& myCall,
bool displayDXCCEntity, LogBook const& logBook, bool displayDXCCEntity, LogBook const& logBook,
QColor color_CQ, QColor color_MyCall,
QColor color_DXCC, QColor color_NewCall,
QColor color_NewCallBand,
QString currentBand, bool ppfx, bool bCQonly) QString currentBand, bool ppfx, bool bCQonly)
{ {
m_bPrincipalPrefix=ppfx; m_bPrincipalPrefix=ppfx;
@ -257,7 +253,7 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|| decodedText.string ().contains (" QRZ ")) || decodedText.string ().contains (" QRZ "))
{ {
CQcall = true; CQcall = true;
bg = color_CQ; bg = m_color_CQ;
} }
if(bCQonly and !CQcall) return; if(bCQonly and !CQcall) return;
if (myCall != "" and ( if (myCall != "" and (
@ -266,7 +262,7 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
or decodedText.indexOf ("/" + myCall + " ") >= 0 or decodedText.indexOf ("/" + myCall + " ") >= 0
or decodedText.indexOf ("<" + myCall + " ") >= 0 or decodedText.indexOf ("<" + myCall + " ") >= 0
or decodedText.indexOf (" " + myCall + ">") >= 0)) { or decodedText.indexOf (" " + myCall + ">") >= 0)) {
bg = color_MyCall; bg = m_color_MyCall;
} }
auto message = decodedText.string(); auto message = decodedText.string();
QString dxCall; QString dxCall;
@ -276,14 +272,12 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
if (displayDXCCEntity && CQcall) if (displayDXCCEntity && CQcall)
// if enabled add the DXCC entity and B4 status to the end of the // if enabled add the DXCC entity and B4 status to the end of the
// preformated text line t1 // preformated text line t1
message = appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, color_CQ, message = appendDXCCWorkedB4 (message, decodedText.CQersCall (), &bg, logBook, currentBand);
color_DXCC, color_NewCall, color_NewCallBand, currentBand);
appendText (message.trimmed (), bg, decodedText.call (), dxCall); appendText (message.trimmed (), bg, decodedText.call (), dxCall);
} }
void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq, void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 txFreq,bool bFastMode)
QColor color_TxMsg, bool bFastMode)
{ {
QString t1=" @ "; QString t1=" @ ";
if(modeTx=="FT8") t1=" ~ "; if(modeTx=="FT8") t1=" ~ ";
@ -303,7 +297,7 @@ void DisplayText::displayTransmittedText(QString text, QString modeTx, qint32 tx
t = QDateTime::currentDateTimeUtc().toString("hhmm") + \ t = QDateTime::currentDateTimeUtc().toString("hhmm") + \
" Tx " + t2 + t1 + text; " Tx " + t2 + t1 + text;
} }
appendText (t, color_TxMsg); appendText (t, m_color_TxMsg);
} }
void DisplayText::displayQSY(QString text) void DisplayText::displayQSY(QString text)
@ -409,3 +403,19 @@ void DisplayText::highlight_callsign (QString const& callsign, QColor const& bg,
} }
setCurrentCharFormat (old_format); setCurrentCharFormat (old_format);
} }
void DisplayText::setDecodedTextColors(QColor color_CQ, QColor color_MyCall,
QColor color_DXCC, QColor color_DXCCband,QColor color_NewCall,QColor color_NewCallBand,
QColor color_NewGrid, QColor color_NewGridBand,QColor color_TxMsg)
{
// Save the color highlighting scheme selected by the user.
m_color_CQ=color_CQ;
m_color_DXCC=color_DXCC;
m_color_DXCCband=color_DXCCband;
m_color_MyCall=color_MyCall;
m_color_NewCall=color_NewCall;
m_color_NewCallBand=color_NewCallBand;
m_color_NewGrid=color_NewGrid;
m_color_NewGridBand=color_NewGridBand;
m_color_TxMsg=color_TxMsg;
}

View File

@ -23,13 +23,14 @@ public:
void setContentFont (QFont const&); void setContentFont (QFont const&);
void insertLineSpacer(QString const&); void insertLineSpacer(QString const&);
void displayDecodedText(DecodedText const& decodedText, QString const& myCall, void displayDecodedText(DecodedText const& decodedText, QString const& myCall,
bool displayDXCCEntity, LogBook const& logBook, QColor color_CQ, QColor color_MyCall, bool displayDXCCEntity, LogBook const& logBook,
QColor color_DXCC, QColor color_NewCall, QColor color_NewCallBand,
QString currentBand="", bool ppfx=false, bool bCQonly=false); QString currentBand="", bool ppfx=false, bool bCQonly=false);
void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, void displayTransmittedText(QString text, QString modeTx, qint32 txFreq, bool bFastMode);
QColor color_TxMsg, bool bFastMode);
void displayQSY(QString text); void displayQSY(QString text);
void displayFoxToBeCalled(QString t, QColor bg); void displayFoxToBeCalled(QString t, QColor bg);
void setDecodedTextColors(QColor color_CQ, QColor color_MyCall, QColor color_DXCC,
QColor color_DXCCband, QColor color_NewCall, QColor color_NewCallBand,
QColor color_NewGrid, QColor color_NewGridBand, QColor color_TxMsg);
Q_SIGNAL void selectCallsign (Qt::KeyboardModifiers); Q_SIGNAL void selectCallsign (Qt::KeyboardModifiers);
Q_SIGNAL void erased (); Q_SIGNAL void erased ();
@ -45,12 +46,20 @@ protected:
private: private:
bool m_bPrincipalPrefix; bool m_bPrincipalPrefix;
QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg, QString appendDXCCWorkedB4(QString message, QString const& callsign, QColor * bg,
LogBook const& logBook, QColor color_CQ, QColor color_DXCC, LogBook const& logBook, QString currentBand);
QColor color_NewCall, QColor color_NewCallBand, QString currentBand);
QFont char_font_; QFont char_font_;
QAction * erase_action_; QAction * erase_action_;
QHash<QString, QPair<QColor, QColor>> highlighted_calls_; QHash<QString, QPair<QColor, QColor>> highlighted_calls_;
QColor m_color_CQ;
QColor m_color_MyCall;
QColor m_color_DXCC;
QColor m_color_DXCCband;
QColor m_color_NewCall;
QColor m_color_NewCallBand;
QColor m_color_NewGrid;
QColor m_color_NewGridBand;
QColor m_color_TxMsg;
}; };
#endif // DISPLAYTEXT_H #endif // DISPLAYTEXT_H

View File

@ -737,7 +737,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
auto t = "UTC dB DT Freq Message"; auto t = "UTC dB DT Freq Message";
ui->decodedTextLabel->setText(t); ui->decodedTextLabel->setText(t);
ui->decodedTextLabel2->setText(t); ui->decodedTextLabel2->setText(t);
readSettings(); //Restore user's setup params readSettings(); //Restore user's setup parameters
setColorHighlighting(); //Set the color highlighting scheme for decoded text.
m_audioThread.start (m_audioThreadPriority); m_audioThread.start (m_audioThreadPriority);
#ifdef WIN32 #ifdef WIN32
@ -1293,8 +1294,7 @@ void MainWindow::dataSink(qint64 frames)
QString t=QString::fromLatin1(line); QString t=QString::fromLatin1(line);
DecodedText decodedtext {t}; DecodedText decodedtext {t};
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_currentBand, m_config.ppfx());
m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand, m_config.ppfx());
if (ui->measure_check_box->isChecked ()) { if (ui->measure_check_box->isChecked ()) {
// Append results text to file "fmt.all". // Append results text to file "fmt.all".
QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")}; QFile f {m_config.writeable_data_dir ().absoluteFilePath ("fmt.all")};
@ -1534,8 +1534,7 @@ void MainWindow::fastSink(qint64 frames)
QString message {QString::fromLatin1 (line)}; QString message {QString::fromLatin1 (line)};
DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; DecodedText decodedtext {message.replace (QChar::LineFeed, "")};
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_currentBand,m_config.ppfx());
m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx());
m_bDecoded=true; m_bDecoded=true;
auto_sequence (decodedtext, ui->sbFtol->value (), std::numeric_limits<unsigned>::max ()); auto_sequence (decodedtext, ui->sbFtol->value (), std::numeric_limits<unsigned>::max ());
if (m_mode != "ISCAT") postDecode (true, decodedtext.string ()); if (m_mode != "ISCAT") postDecode (true, decodedtext.string ());
@ -1671,10 +1670,8 @@ void MainWindow::on_actionSettings_triggered() //Setup Dialog
if(m_config.single_decode() or m_mode=="JT4") { if(m_config.single_decode() or m_mode=="JT4") {
ui->label_6->setText("Single-Period Decodes"); ui->label_6->setText("Single-Period Decodes");
ui->label_7->setText("Average Decodes"); ui->label_7->setText("Average Decodes");
} else {
// ui->label_6->setText("Band Activity");
// ui->label_7->setText("Rx Frequency");
} }
update_watchdog_label (); update_watchdog_label ();
if(!m_splitMode) ui->cbCQTx->setChecked(false); if(!m_splitMode) ui->cbCQTx->setChecked(false);
if(!m_config.enable_VHF_features()) { if(!m_config.enable_VHF_features()) {
@ -1686,8 +1683,23 @@ void MainWindow::on_actionSettings_triggered() //Setup Dialog
} }
m_opCall=m_config.opCall(); m_opCall=m_config.opCall();
} }
setColorHighlighting();
} }
void MainWindow::setColorHighlighting()
{
//Inform the decoded text windows about our color-highlighting scheme.
ui->decodedTextBrowser->setDecodedTextColors(m_config.color_CQ(),m_config.color_MyCall(),
m_config.color_DXCC(),m_config.color_DXCCband(),m_config.color_NewCall(),
m_config.color_NewCallBand(),m_config.color_NewGrid(),m_config.color_NewGridBand(),
m_config.color_TxMsg());
ui->decodedTextBrowser2->setDecodedTextColors(m_config.color_CQ(),m_config.color_MyCall(),
m_config.color_DXCC(),m_config.color_DXCCband(),m_config.color_NewCall(),
m_config.color_NewCallBand(),m_config.color_NewGrid(),m_config.color_NewGridBand(),
m_config.color_TxMsg());
}
void MainWindow::on_monitorButton_clicked (bool checked) void MainWindow::on_monitorButton_clicked (bool checked)
{ {
if (!m_transmitting) { if (!m_transmitting) {
@ -2778,8 +2790,7 @@ void::MainWindow::fast_decode_done()
DecodedText decodedtext {message.replace (QChar::LineFeed, "")}; DecodedText decodedtext {message.replace (QChar::LineFeed, "")};
if(!m_bFastDone) { if(!m_bFastDone) {
ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText (decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(),m_config.color_DXCC(), m_logBook,m_currentBand,m_config.ppfx());
m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx());
} }
t=message.mid(10,5).toFloat(); t=message.mid(10,5).toFloat();
@ -2920,16 +2931,12 @@ void MainWindow::readFromStdout() //readFromStdout
// This hack sets the font. Surely there's a better way! // This hack sets the font. Surely there's a better way!
DecodedText dt{"."}; DecodedText dt{"."};
ui->decodedTextBrowser->displayDecodedText(dt,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText(dt,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(), m_logBook,m_currentBand,m_config.ppfx());
m_config.color_DXCC(), m_config.color_NewCall(),m_config.color_NewCallBand(),
m_currentBand,m_config.ppfx());
m_bDisplayedOnce=true; m_bDisplayedOnce=true;
} }
} else { } else {
ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText(decodedtext,m_baseCall,m_config.DXCC(),
m_logBook,m_config.color_CQ(),m_config.color_MyCall(), m_logBook,m_currentBand,m_config.ppfx(),
m_config.color_DXCC(), m_config.color_NewCall(),m_config.color_NewCallBand(),
m_currentBand,m_config.ppfx(),
(ui->cbCQonly->isVisible() and ui->cbCQonly->isChecked())); (ui->cbCQonly->isVisible() and ui->cbCQonly->isChecked()));
} }
} }
@ -2964,9 +2971,7 @@ void MainWindow::readFromStdout() //readFromStdout
// This msg is within 10 hertz of our tuned frequency, or a JT4 or JT65 avg, // This msg is within 10 hertz of our tuned frequency, or a JT4 or JT65 avg,
// or contains MyCall // or contains MyCall
ui->decodedTextBrowser2->displayDecodedText(decodedtext,m_baseCall,false, ui->decodedTextBrowser2->displayDecodedText(decodedtext,m_baseCall,false,
m_logBook,m_config.color_CQ(),m_config.color_MyCall(), m_logBook,m_currentBand,m_config.ppfx());
m_config.color_DXCC(),m_config.color_NewCall(),m_config.color_NewCallBand(),
m_currentBand,m_config.ppfx());
if(m_mode!="JT4") { if(m_mode!="JT4") {
bool b65=decodedtext.isJT65(); bool b65=decodedtext.isJT65();
@ -3575,7 +3580,7 @@ void MainWindow::guiUpdate()
write_transmit_entry ("ALL.TXT"); write_transmit_entry ("ALL.TXT");
if (m_config.TX_messages ()) { if (m_config.TX_messages ()) {
ui->decodedTextBrowser2->displayTransmittedText(m_currentMessage,m_modeTx, ui->decodedTextBrowser2->displayTransmittedText(m_currentMessage,m_modeTx,
ui->TxFreqSpinBox->value(),m_config.color_TxMsg(),m_bFastMode); ui->TxFreqSpinBox->value(),m_bFastMode);
} }
} }
@ -3676,7 +3681,7 @@ void MainWindow::guiUpdate()
if (m_config.TX_messages () && !m_tune && !m_config.bFox()) { if (m_config.TX_messages () && !m_tune && !m_config.bFox()) {
ui->decodedTextBrowser2->displayTransmittedText(current_message, m_modeTx, ui->decodedTextBrowser2->displayTransmittedText(current_message, m_modeTx,
ui->TxFreqSpinBox->value(),m_config.color_TxMsg(),m_bFastMode); ui->TxFreqSpinBox->value(),m_bFastMode);
} }
switch (m_ntx) switch (m_ntx)
@ -4472,8 +4477,7 @@ void MainWindow::processMessage (DecodedText const& message, Qt::KeyboardModifie
if (s1!=s2 and !message.isTX()) { if (s1!=s2 and !message.isTX()) {
if (!s2.contains(m_baseCall) or m_mode=="MSK144") { // Taken care of elsewhere if for_us and slow mode if (!s2.contains(m_baseCall) or m_mode=="MSK144") { // Taken care of elsewhere if for_us and slow mode
ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall,false, ui->decodedTextBrowser2->displayDecodedText(message, m_baseCall,false,
m_logBook,m_config.color_CQ(), m_config.color_MyCall(), m_config.color_DXCC(), m_logBook,m_currentBand,m_config.ppfx());
m_config.color_NewCall(),m_config.color_NewCallBand(),m_currentBand,m_config.ppfx());
} }
m_QSOText = s2; m_QSOText = s2;
} }
@ -8099,7 +8103,7 @@ void MainWindow::foxGenWaveform(int i,QString fm)
QString txModeArg; QString txModeArg;
txModeArg.sprintf("FT8fox %d",i+1); txModeArg.sprintf("FT8fox %d",i+1);
ui->decodedTextBrowser2->displayTransmittedText(fm.trimmed(), txModeArg, ui->decodedTextBrowser2->displayTransmittedText(fm.trimmed(), txModeArg,
ui->TxFreqSpinBox->value()+60*i,m_config.color_TxMsg(),m_bFastMode); ui->TxFreqSpinBox->value()+60*i,m_bFastMode);
foxcom_.i3bit[i]=0; foxcom_.i3bit[i]=0;
if(fm.indexOf("<")>0) foxcom_.i3bit[i]=1; if(fm.indexOf("<")>0) foxcom_.i3bit[i]=1;
strncpy(&foxcom_.cmsg[i][0],fm.toLatin1(),40); //Copy this message into cmsg[i] strncpy(&foxcom_.cmsg[i][0],fm.toLatin1(),40); //Copy this message into cmsg[i]

View File

@ -33,7 +33,6 @@
#include "DisplayManual.hpp" #include "DisplayManual.hpp"
#include "psk_reporter.h" #include "psk_reporter.h"
#include "logbook/logbook.h" #include "logbook/logbook.h"
#include "commons.h"
#include "astro.h" #include "astro.h"
#include "MessageBox.hpp" #include "MessageBox.hpp"
#include "NetworkAccessManager.hpp" #include "NetworkAccessManager.hpp"
@ -328,6 +327,7 @@ private:
void auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance); void auto_sequence (DecodedText const& message, unsigned start_tolerance, unsigned stop_tolerance);
void hideMenus(bool b); void hideMenus(bool b);
void foxTest(); void foxTest();
void setColorHighlighting();
NetworkAccessManager m_network_manager; NetworkAccessManager m_network_manager;
bool m_valid; bool m_valid;