From 378bbcd6e398484e88e5b7b200851770e46d71ae Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Tue, 9 Jul 2019 13:58:28 -0400 Subject: [PATCH] Added secondary highlight coloring to settings --- Configuration.cpp | 74 +++++--- Configuration.hpp | 6 +- Configuration.ui | 453 ++++++++++++++++++++++++++++------------------ mainwindow.cpp | 35 +++- 4 files changed, 361 insertions(+), 207 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index e88e516..1d2e816 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -467,7 +467,8 @@ private: Q_SLOT void on_calibration_slope_ppm_spin_box_valueChanged (double); Q_SLOT void handle_transceiver_update (TransceiverState const&, unsigned sequence_number); Q_SLOT void handle_transceiver_failure (QString const& reason); - Q_SLOT void on_pbCQmsg_clicked(); + Q_SLOT void on_primaryHighlightButton_clicked(); + Q_SLOT void on_secondaryHighlightButton_clicked(); Q_SLOT void on_pbMyCall_clicked(); Q_SLOT void on_tableBackgroundButton_clicked(); Q_SLOT void on_tableSelectedRowBackgroundButton_clicked(); @@ -578,15 +579,18 @@ private: QStringList my_groups_; QStringList auto_whitelist_; QStringList auto_blacklist_; - QStringList highlight_words_; + QStringList primary_highlight_words_; + QStringList secondary_highlight_words_; QString eot_; QString my_info_; QString cq_; QString reply_; int callsign_aging_; int activity_aging_; - QColor color_cq_; - QColor next_color_cq_; + QColor color_primary_highlight_; + QColor next_color_primary_highlight_; + QColor color_secondary_highlight_; + QColor next_color_secondary_highlight_; QColor color_mycall_; QColor next_color_mycall_; @@ -722,7 +726,8 @@ QString Configuration::my_callsign () const {return m_->my_callsign_;} QColor Configuration::color_table_background() const { return m_->color_table_background_; } QColor Configuration::color_table_highlight() const { return m_->color_table_highlight_; } QColor Configuration::color_table_foreground() const { return m_->color_table_foreground_; } -QColor Configuration::color_CQ () const {return m_->color_cq_;} +QColor Configuration::color_primary_highlight () const {return m_->color_primary_highlight_;} +QColor Configuration::color_secondary_highlight () const {return m_->color_secondary_highlight_;} QColor Configuration::color_MyCall () const {return m_->color_mycall_;} QColor Configuration::color_rx_background () const {return m_->color_rx_background_;} QColor Configuration::color_rx_foreground () const {return m_->color_rx_foreground_;} @@ -995,8 +1000,12 @@ QSet Configuration::auto_blacklist() const { return QSet::fromList(m_->auto_blacklist_); } -QSet Configuration::highlight_words() const { - return QSet::fromList(m_->highlight_words_); +QSet Configuration::primary_highlight_words() const { + return QSet::fromList(m_->primary_highlight_words_); +} + +QSet Configuration::secondary_highlight_words() const { + return QSet::fromList(m_->secondary_highlight_words_); } QString Configuration::eot() const { @@ -1395,16 +1404,19 @@ void Configuration::impl::initialize_models () ui_->groups_line_edit->setText(my_groups_.join(", ")); ui_->auto_whitelist_line_edit->setText(auto_whitelist_.join(", ")); ui_->auto_blacklist_line_edit->setText(auto_blacklist_.join(", ")); - ui_->highlightTextEdit->setText(highlight_words_.join(", ")); + ui_->primaryHighlightLineEdit->setText(primary_highlight_words_.join(", ")); + ui_->secondaryHighlightLineEdit->setText(secondary_highlight_words_.join(", ")); ui_->eot_line_edit->setText(eot_.trimmed().left(2)); ui_->info_message_line_edit->setText (my_info_.toUpper()); ui_->cq_message_line_edit->setText(cq_.toUpper().replace("CQCQCQ", "CQ CQ CQ")); ui_->reply_message_line_edit->setText (reply_.toUpper()); ui_->use_dynamic_grid->setChecked(use_dynamic_info_); + ui_->tableForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); ui_->tableBackgroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); ui_->tableSelectionBackgroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_highlight_.name()).arg(next_color_table_foreground_.name())); - ui_->labCQ->setStyleSheet(QString("background: %1; color: %2").arg(next_color_cq_.name()).arg(next_color_table_foreground_.name())); + ui_->primaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_primary_highlight_.name()).arg(next_color_table_foreground_.name())); + ui_->secondaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_secondary_highlight_.name()).arg(next_color_table_foreground_.name())); ui_->labMyCall->setStyleSheet(QString("background: %1; color: %2").arg(next_color_mycall_.name()).arg(next_color_table_foreground_.name())); ui_->rxLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_rx_background_.name()).arg(color_rx_foreground_.name())); @@ -1547,14 +1559,16 @@ void Configuration::impl::read_settings () my_groups_ = settings_->value("MyGroups", QStringList{}).toStringList(); auto_whitelist_ = settings_->value("AutoWhitelist", QStringList{}).toStringList(); auto_blacklist_ = settings_->value("AutoBlacklist", QStringList{}).toStringList(); - highlight_words_ = settings_->value("HighlightWords", QStringList{"CQ"}).toStringList(); + primary_highlight_words_ = settings_->value("PrimaryHighlightWords", QStringList{"CQ"}).toStringList(); + secondary_highlight_words_ = settings_->value("SecondaryHighlightWords", QStringList{}).toStringList(); callsign_aging_ = settings_->value ("CallsignAging", 0).toInt (); activity_aging_ = settings_->value ("ActivityAging", 2).toInt (); eot_ = settings_->value("EOTCharacter", QString{"\u2662"}).toString().trimmed().left(2); my_info_ = settings_->value("MyInfo", QString {}).toString(); cq_ = settings_->value("CQMessage", QString {"CQ CQ CQ "}).toString(); reply_ = settings_->value("Reply", QString {"HW CPY?"}).toString(); - next_color_cq_ = color_cq_ = settings_->value("colorCQ","#66ff66").toString(); + next_color_primary_highlight_ = color_primary_highlight_ = settings_->value("colorPrimary", settings_->value("colorCQ","#66ff66").toString()).toString(); + next_color_secondary_highlight_ = color_secondary_highlight_ = settings_->value("colorSecondary","#ffff66").toString(); next_color_mycall_ = color_mycall_ = settings_->value("colorMyCall","#ff6666").toString(); next_color_rx_background_ = color_rx_background_ = settings_->value("color_rx_background","#ffeaa7").toString(); next_color_rx_foreground_ = color_rx_foreground_ = settings_->value("color_rx_foreground","#000000").toString(); @@ -1815,14 +1829,16 @@ void Configuration::impl::write_settings () settings_->setValue ("MyGroups", my_groups_); settings_->setValue ("AutoWhitelist", auto_whitelist_); settings_->setValue ("AutoBlacklist", auto_blacklist_); - settings_->setValue ("HighlightWords", highlight_words_); + settings_->setValue ("PrimaryHighlightWords", primary_highlight_words_); + settings_->setValue ("SecondaryHighlightWords", secondary_highlight_words_); settings_->setValue ("EOTCharacter", eot_); settings_->setValue ("MyInfo", my_info_); settings_->setValue ("CQMessage", cq_); settings_->setValue ("Reply", reply_); settings_->setValue ("CallsignAging", callsign_aging_); settings_->setValue ("ActivityAging", activity_aging_); - settings_->setValue("colorCQ",color_cq_); + settings_->setValue("colorCQ",color_primary_highlight_); + settings_->setValue("colorSecondary",color_secondary_highlight_); settings_->setValue("colorMyCall",color_mycall_); settings_->setValue("color_rx_background",color_rx_background_); settings_->setValue("color_rx_foreground",color_rx_foreground_); @@ -2315,7 +2331,8 @@ void Configuration::impl::accept () Q_EMIT self_->table_font_changed (table_font_); } - color_cq_ = next_color_cq_; + color_primary_highlight_ = next_color_primary_highlight_; + color_secondary_highlight_ = next_color_secondary_highlight_; color_mycall_ = next_color_mycall_; color_rx_background_ = next_color_rx_background_; color_rx_foreground_ = next_color_rx_foreground_; @@ -2414,7 +2431,8 @@ void Configuration::impl::accept () my_groups_ = splitGroups(ui_->groups_line_edit->text().toUpper().trimmed(), true); auto_whitelist_ = splitWords(ui_->auto_whitelist_line_edit->text().toUpper().trimmed()); auto_blacklist_ = splitWords(ui_->auto_blacklist_line_edit->text().toUpper().trimmed()); - highlight_words_ = splitWords(ui_->highlightTextEdit->toPlainText().toUpper().trimmed()); + primary_highlight_words_ = splitWords(ui_->primaryHighlightLineEdit->text().toUpper().trimmed()); + secondary_highlight_words_ = splitWords(ui_->secondaryHighlightLineEdit->text().toUpper().trimmed()); cq_ = ui_->cq_message_line_edit->text().toUpper(); reply_ = ui_->reply_message_line_edit->text().toUpper(); eot_ = ui_->eot_line_edit->text().trimmed().left(2); @@ -2581,7 +2599,8 @@ void Configuration::impl::on_tableFontButton_clicked () , QFontDialog::DontUseNativeDialog #endif ); - ui_->tableFontButton->setText(QString("Table Font (%1 %2)").arg(next_table_font_.family()).arg(next_table_font_.pointSize())); + + ui_->tableFontButton->setText(QString("Font (%1 %2)").arg(next_table_font_.family()).arg(next_table_font_.pointSize())); } @@ -2606,13 +2625,23 @@ QColor getColor(QColor initial, QWidget *parent, QString title){ } } -void Configuration::impl::on_pbCQmsg_clicked() +void Configuration::impl::on_primaryHighlightButton_clicked() { - auto new_color = getColor(next_color_cq_, this, "CQ Messages Color"); + auto new_color = getColor(next_color_primary_highlight_, this, "Primary Highlight Color"); if (new_color.isValid ()) { - next_color_cq_ = new_color; - ui_->labCQ->setStyleSheet(QString("background: %1; color: %2").arg(next_color_cq_.name()).arg(next_color_table_foreground_.name())); + next_color_primary_highlight_ = new_color; + ui_->primaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_primary_highlight_.name()).arg(next_color_table_foreground_.name())); + } +} + +void Configuration::impl::on_secondaryHighlightButton_clicked() +{ + auto new_color = getColor(next_color_secondary_highlight_, this, "Secondary Highlight Color"); + if (new_color.isValid ()) + { + next_color_secondary_highlight_ = new_color; + ui_->secondaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_secondary_highlight_.name()).arg(next_color_table_foreground_.name())); } } @@ -2632,6 +2661,7 @@ void Configuration::impl::on_tableBackgroundButton_clicked() if (new_color.isValid ()) { next_color_table_background_ = new_color; + ui_->tableForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); ui_->tableBackgroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); } } @@ -2652,9 +2682,11 @@ void Configuration::impl::on_tableForegroundButton_clicked() if (new_color.isValid ()) { next_color_table_foreground_ = new_color; + ui_->tableForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); ui_->tableBackgroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_background_.name()).arg(next_color_table_foreground_.name())); ui_->tableSelectionBackgroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_table_highlight_.name()).arg(next_color_table_foreground_.name())); - ui_->labCQ->setStyleSheet(QString("background: %1; color: %2").arg(next_color_cq_.name()).arg(next_color_table_foreground_.name())); + ui_->primaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_primary_highlight_.name()).arg(next_color_table_foreground_.name())); + ui_->secondaryHighlightLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_secondary_highlight_.name()).arg(next_color_table_foreground_.name())); ui_->labMyCall->setStyleSheet(QString("background: %1; color: %2").arg(next_color_mycall_.name()).arg(next_color_table_foreground_.name())); } } diff --git a/Configuration.hpp b/Configuration.hpp index ae528f9..8368786 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -102,7 +102,8 @@ public: void removeGroup(QString const &group); QSet auto_whitelist() const; QSet auto_blacklist() const; - QSet highlight_words() const; + QSet primary_highlight_words() const; + QSet secondary_highlight_words() const; int activity_aging() const; int callsign_aging() const; QString eot() const; @@ -203,7 +204,8 @@ public: QColor color_table_background() const; QColor color_table_highlight() const; QColor color_table_foreground() const; - QColor color_CQ () const; + QColor color_primary_highlight () const; + QColor color_secondary_highlight () const; QColor color_MyCall () const; QColor color_rx_background () const; QColor color_rx_foreground () const; diff --git a/Configuration.ui b/Configuration.ui index cbbdd54..e9c1093 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -23,7 +23,7 @@ Select tab to change configuration parameters. - 0 + 6 @@ -3037,8 +3037,8 @@ QListView::item:hover { 0 0 - 738 - 378 + 724 + 387 @@ -3065,149 +3065,17 @@ QListView::item:hover { 0 - + + + + Font - - - - - 80 - 20 - - - - QLabel{background-color: #66ff66} - - - K1ABC - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Foreground Color - - - - - - - Selected Row Background - - - - - - - - 80 - 20 - - - - QLabel{background-color: #3498db}<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> -<widget name="__qt_fake_top_level"> -<widget class="QLabel" name="labCQ"> -<property name="geometry"> -<rect> -<x>12</x> -<y>32</y> -<width>302</width> -<height>25</height> -</rect> -</property> -<property name="minimumSize"> -<size> -<width>80</width> -<height>20</height> -</size> -</property> -<property name="styleSheet"> -<string notr="true">QLabel{background-color: #66ff66}</string> -</property> -<property name="text"> -<string>K1ABC</string> -</property> -<property name="alignment"> -<set>Qt::AlignCenter</set> -</property> -</widget> -</widget> -<resources/> -</ui> - - - - K1ABC - - - Qt::AlignCenter - - - - - - - - 140 - 0 - - - - Directed Messages Background - - - - - - - Table Background - - - - - - - 80 - 20 - - - - QLabel{background-color: #ff6666} - - - K1ABC - - - Qt::AlignCenter - - - - @@ -3257,8 +3125,8 @@ QListView::item:hover { - - + + 140 @@ -3266,19 +3134,285 @@ QListView::item:hover { - Highlight Background + Directed Messages Background + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + 80 + 20 + + + + QLabel{background-color: #66ff66} + + + K1ABC + + + Qt::AlignCenter + + + + + + + Highlight these words or callsigns with the primary background color (comma separated): + + + true + + + + + + + Foreground Color + + + + + + + + 140 + 0 + + + + Primary Highlight Background + + + + + + + Table Background + + + + + + + + 80 + 20 + + + + QLabel{background-color: white}<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> +<widget name="__qt_fake_top_level"> +<widget class="QLabel" name="labCQ"> +<property name="geometry"> +<rect> +<x>12</x> +<y>32</y> +<width>302</width> +<height>25</height> +</rect> +</property> +<property name="minimumSize"> +<size> +<width>80</width> +<height>20</height> +</size> +</property> +<property name="styleSheet"> +<string notr="true">QLabel{background-color: #66ff66}</string> +</property> +<property name="text"> +<string>K1ABC</string> +</property> +<property name="alignment"> +<set>Qt::AlignCenter</set> +</property> +</widget> +</widget> +<resources/> +</ui> + + + + K1ABC + + + Qt::AlignCenter + + + + + + + Selected Row Background + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + 140 + 0 + + + + Secondary Highlight Background + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + 80 + 20 + + + + QLabel{background-color: #ffff66} + + + K1ABC + + + Qt::AlignCenter + + + + + + + + 80 + 20 + + + + QLabel{background-color: #ff6666} + + + K1ABC + + + Qt::AlignCenter + + + + + + + + + + Highlight these words or callsigns with the secondary background color (comma separated): + + + true + + + + + + + + 80 + 20 + + + + QLabel{background-color: #3498db}<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> +<widget name="__qt_fake_top_level"> +<widget class="QLabel" name="labCQ"> +<property name="geometry"> +<rect> +<x>12</x> +<y>32</y> +<width>302</width> +<height>25</height> +</rect> +</property> +<property name="minimumSize"> +<size> +<width>80</width> +<height>20</height> +</size> +</property> +<property name="styleSheet"> +<string notr="true">QLabel{background-color: #66ff66}</string> +</property> +<property name="text"> +<string>K1ABC</string> +</property> +<property name="alignment"> +<set>Qt::AlignCenter</set> +</property> +</widget> +</widget> +<resources/> +</ui> + + + + K1ABC + + + Qt::AlignCenter - + Qt::Vertical - QSizePolicy::Fixed + QSizePolicy::Expanding @@ -3288,37 +3422,6 @@ QListView::item:hover { - - - - Highlight Activity Containing These Words or Callsigns (comma separated): - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">CQ</p></body></html> - - - - - - - Qt::Vertical - - - - 20 - 348 - - - - diff --git a/mainwindow.cpp b/mainwindow.cpp index 327ffbb..6131b4a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2444,7 +2444,7 @@ void MainWindow::dataSink(qint64 frames) QString t=QString::fromLatin1(line); DecodedText decodedtext {t, false, m_config.my_grid ()}; 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_config.color_primary_highlight(),m_config.color_MyCall(),m_config.color_DXCC(), m_config.color_NewCall(),m_config.ppfx()); if (ui->measure_check_box->isChecked ()) { // Append results text to file "fmt.all". @@ -2643,7 +2643,7 @@ void MainWindow::fastSink(qint64 frames) QString message {QString::fromLatin1 (line)}; DecodedText decodedtext {message.replace (QChar::LineFeed, ""), bcontest, m_config.my_grid ()}; 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_config.color_primary_highlight(),m_config.color_MyCall(),m_config.color_DXCC(), m_config.color_NewCall(),m_config.ppfx()); m_bDecoded=true; if (m_mode != "ISCAT") postDecode (true, decodedtext.string ()); @@ -4093,7 +4093,7 @@ void::MainWindow::fast_decode_done() ui->cbVHFcontest->isChecked(), m_config.my_grid ()}; if(!m_bFastDone) { 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_config.color_primary_highlight(),m_config.color_MyCall(),m_config.color_DXCC(), m_config.color_NewCall(),m_config.ppfx()); } @@ -11551,10 +11551,21 @@ void MainWindow::displayBandActivity() { } } - auto matchingWords = m_config.highlight_words() & QSet::fromList(joined.replace(":", " ").replace(">"," ").split(" ")); - if (!text.isEmpty() && !matchingWords.isEmpty()){ - for(int i = 0; i < ui->tableWidgetRXAll->columnCount(); i++){ - ui->tableWidgetRXAll->item(row, i)->setBackground(QBrush(m_config.color_CQ())); + if(!text.isEmpty()){ + auto words = QSet::fromList(joined.replace(":", " ").replace(">"," ").split(" ")); + + auto matchingSecondaryWords = m_config.secondary_highlight_words() & words; + if (!matchingSecondaryWords.isEmpty()){ + for(int i = 0; i < ui->tableWidgetRXAll->columnCount(); i++){ + ui->tableWidgetRXAll->item(row, i)->setBackground(QBrush(m_config.color_secondary_highlight())); + } + } + + auto matchingPrimaryWords = m_config.primary_highlight_words() & words; + if (!matchingPrimaryWords.isEmpty()){ + for(int i = 0; i < ui->tableWidgetRXAll->columnCount(); i++){ + ui->tableWidgetRXAll->item(row, i)->setBackground(QBrush(m_config.color_primary_highlight())); + } } } } @@ -11854,9 +11865,15 @@ void MainWindow::displayCallActivity() { } } - if (m_config.highlight_words().contains(call)){ + if (m_config.secondary_highlight_words().contains(call)){ for(int i = 0; i < ui->tableWidgetCalls->columnCount(); i++){ - ui->tableWidgetCalls->item(row, i)->setBackground(QBrush(m_config.color_CQ())); + ui->tableWidgetCalls->item(row, i)->setBackground(QBrush(m_config.color_secondary_highlight())); + } + } + + if (m_config.primary_highlight_words().contains(call)){ + for(int i = 0; i < ui->tableWidgetCalls->columnCount(); i++){ + ui->tableWidgetCalls->item(row, i)->setBackground(QBrush(m_config.color_primary_highlight())); } } }