Added ability to customize the text which is highlighted in the call activity and band activity

This commit is contained in:
Jordan Sherer 2019-07-04 01:32:01 -04:00
parent 6aad422cd8
commit 925aade1a2
4 changed files with 279 additions and 215 deletions

View File

@ -591,6 +591,7 @@ private:
QStringList my_groups_;
QStringList auto_whitelist_;
QStringList auto_blacklist_;
QStringList highlight_words_;
QString eot_;
QString my_info_;
QString cq_;
@ -1010,6 +1011,10 @@ QSet<QString> Configuration::auto_blacklist() const {
return QSet<QString>::fromList(m_->auto_blacklist_);
}
QSet<QString> Configuration::highlight_words() const {
return QSet<QString>::fromList(m_->highlight_words_);
}
QString Configuration::eot() const {
return m_->eot_;
}
@ -1406,6 +1411,7 @@ 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_->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"));
@ -1560,6 +1566,7 @@ 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();
callsign_aging_ = settings_->value ("CallsignAging", 0).toInt ();
activity_aging_ = settings_->value ("ActivityAging", 2).toInt ();
eot_ = settings_->value("EOTCharacter", QString{"\u2662"}).toString().trimmed().left(2);
@ -1830,6 +1837,7 @@ 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 ("EOTCharacter", eot_);
settings_->setValue ("MyInfo", my_info_);
settings_->setValue ("CQMessage", cq_);
@ -2125,7 +2133,7 @@ QStringList splitGroups(QString groupsString, bool filter){
return groups;
}
QStringList splitCalls(QString callsString){
QStringList splitWords(QString callsString){
QStringList calls;
if(callsString.isEmpty()){
return calls;
@ -2159,7 +2167,7 @@ bool Configuration::impl::validate ()
}
}
foreach(auto call, splitCalls(ui_->auto_whitelist_line_edit->text().toUpper().trimmed())){
foreach(auto call, splitWords(ui_->auto_whitelist_line_edit->text().toUpper().trimmed())){
if(!Varicode::isValidCallsign(call, nullptr)){
MessageBox::critical_message (this, QString("%1 is not a valid callsign to whitelist").arg(call));
return false;
@ -2429,8 +2437,9 @@ void Configuration::impl::accept ()
my_callsign_ = ui_->callsign_line_edit->text ().toUpper().trimmed();
my_grid_ = ui_->grid_line_edit->text ().toUpper().trimmed();
my_groups_ = splitGroups(ui_->groups_line_edit->text().toUpper().trimmed(), true);
auto_whitelist_ = splitCalls(ui_->auto_whitelist_line_edit->text().toUpper().trimmed());
auto_blacklist_ = splitCalls(ui_->auto_blacklist_line_edit->text().toUpper().trimmed());
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());
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);

View File

@ -102,6 +102,7 @@ public:
void removeGroup(QString const &group);
QSet<QString> auto_whitelist() const;
QSet<QString> auto_blacklist() const;
QSet<QString> highlight_words() const;
int activity_aging() const;
int callsign_aging() const;
QString eot() const;

View File

@ -23,7 +23,7 @@
<string>Select tab to change configuration parameters.</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>7</number>
</property>
<widget class="QWidget" name="general_tab">
<attribute name="title">
@ -36,7 +36,7 @@
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="stationTab">
<attribute name="title">
@ -278,7 +278,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<width>615</width>
<height>808</height>
</rect>
</property>
@ -3229,7 +3229,7 @@ QListView::item:hover {
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_8">
<widget class="QWidget" name="scrollAreaContentsWidget_8">
<property name="geometry">
<rect>
<x>0</x>
@ -3238,209 +3238,272 @@ QListView::item:hover {
<height>378</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
<layout class="QVBoxLayout" name="verticalLayout_14">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="4" column="1">
<widget class="QPushButton" name="tableForegroundButton">
<property name="text">
<string>Foreground Color</string>
<item>
<layout class="QGridLayout" name="gridLayout_15">
<property name="leftMargin">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labCQ">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
<property name="rightMargin">
<number>0</number>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: #66ff66}</string>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pbCQmsg">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>CQ Background</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="tableFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="tableSelectionBackgroundLabel">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: #3498db}&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
<item row="6" column="1">
<widget class="QPushButton" name="tableFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labCQ">
<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>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="tableForegroundButton">
<property name="text">
<string>Foreground Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="tableSelectedRowBackgroundButton">
<property name="text">
<string>Selected Row Background</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="tableSelectionBackgroundLabel">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: #3498db}&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;ui version=&quot;4.0&quot;&gt;
&lt;widget name=&quot;__qt_fake_top_level&quot;&gt;
&lt;widget class=&quot;QLabel&quot; name=&quot;labCQ&quot;&gt;
&lt;property name=&quot;geometry&quot;&gt;
&lt;rect&gt;
&lt;x&gt;12&lt;/x&gt;
&lt;y&gt;32&lt;/y&gt;
&lt;width&gt;302&lt;/width&gt;
&lt;height&gt;25&lt;/height&gt;
&lt;/rect&gt;
&lt;/property&gt;
&lt;property name=&quot;minimumSize&quot;&gt;
&lt;size&gt;
&lt;width&gt;80&lt;/width&gt;
&lt;height&gt;20&lt;/height&gt;
&lt;/size&gt;
&lt;/property&gt;
&lt;property name=&quot;styleSheet&quot;&gt;
&lt;string notr=&quot;true&quot;&gt;QLabel{background-color: #66ff66}&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;text&quot;&gt;
&lt;string&gt;K1ABC&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;alignment&quot;&gt;
&lt;set&gt;Qt::AlignCenter&lt;/set&gt;
&lt;/property&gt;
&lt;/widget&gt;
&lt;/widget&gt;
&lt;resources/&gt;
&lt;widget name=&quot;__qt_fake_top_level&quot;&gt;
&lt;widget class=&quot;QLabel&quot; name=&quot;labCQ&quot;&gt;
&lt;property name=&quot;geometry&quot;&gt;
&lt;rect&gt;
&lt;x&gt;12&lt;/x&gt;
&lt;y&gt;32&lt;/y&gt;
&lt;width&gt;302&lt;/width&gt;
&lt;height&gt;25&lt;/height&gt;
&lt;/rect&gt;
&lt;/property&gt;
&lt;property name=&quot;minimumSize&quot;&gt;
&lt;size&gt;
&lt;width&gt;80&lt;/width&gt;
&lt;height&gt;20&lt;/height&gt;
&lt;/size&gt;
&lt;/property&gt;
&lt;property name=&quot;styleSheet&quot;&gt;
&lt;string notr=&quot;true&quot;&gt;QLabel{background-color: #66ff66}&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;text&quot;&gt;
&lt;string&gt;K1ABC&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;alignment&quot;&gt;
&lt;set&gt;Qt::AlignCenter&lt;/set&gt;
&lt;/property&gt;
&lt;/widget&gt;
&lt;/widget&gt;
&lt;resources/&gt;
&lt;/ui&gt;
</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labMyCall">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: #ff6666}</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="tableBackgroundLabel">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: white}&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pbMyCall">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Directed Messages Background</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="tableBackgroundButton">
<property name="text">
<string>Table Background</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labMyCall">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: #ff6666}</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="tableBackgroundLabel">
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QLabel{background-color: white}&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;ui version=&quot;4.0&quot;&gt;
&lt;widget name=&quot;__qt_fake_top_level&quot;&gt;
&lt;widget class=&quot;QLabel&quot; name=&quot;labCQ&quot;&gt;
&lt;property name=&quot;geometry&quot;&gt;
&lt;rect&gt;
&lt;x&gt;12&lt;/x&gt;
&lt;y&gt;32&lt;/y&gt;
&lt;width&gt;302&lt;/width&gt;
&lt;height&gt;25&lt;/height&gt;
&lt;/rect&gt;
&lt;/property&gt;
&lt;property name=&quot;minimumSize&quot;&gt;
&lt;size&gt;
&lt;width&gt;80&lt;/width&gt;
&lt;height&gt;20&lt;/height&gt;
&lt;/size&gt;
&lt;/property&gt;
&lt;property name=&quot;styleSheet&quot;&gt;
&lt;string notr=&quot;true&quot;&gt;QLabel{background-color: #66ff66}&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;text&quot;&gt;
&lt;string&gt;K1ABC&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;alignment&quot;&gt;
&lt;set&gt;Qt::AlignCenter&lt;/set&gt;
&lt;/property&gt;
&lt;/widget&gt;
&lt;/widget&gt;
&lt;resources/&gt;
&lt;widget name=&quot;__qt_fake_top_level&quot;&gt;
&lt;widget class=&quot;QLabel&quot; name=&quot;labCQ&quot;&gt;
&lt;property name=&quot;geometry&quot;&gt;
&lt;rect&gt;
&lt;x&gt;12&lt;/x&gt;
&lt;y&gt;32&lt;/y&gt;
&lt;width&gt;302&lt;/width&gt;
&lt;height&gt;25&lt;/height&gt;
&lt;/rect&gt;
&lt;/property&gt;
&lt;property name=&quot;minimumSize&quot;&gt;
&lt;size&gt;
&lt;width&gt;80&lt;/width&gt;
&lt;height&gt;20&lt;/height&gt;
&lt;/size&gt;
&lt;/property&gt;
&lt;property name=&quot;styleSheet&quot;&gt;
&lt;string notr=&quot;true&quot;&gt;QLabel{background-color: #66ff66}&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;text&quot;&gt;
&lt;string&gt;K1ABC&lt;/string&gt;
&lt;/property&gt;
&lt;property name=&quot;alignment&quot;&gt;
&lt;set&gt;Qt::AlignCenter&lt;/set&gt;
&lt;/property&gt;
&lt;/widget&gt;
&lt;/widget&gt;
&lt;resources/&gt;
&lt;/ui&gt;
</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pbCQmsg">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Highlight Background</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pbMyCall">
<property name="minimumSize">
<item>
<spacer name="verticalSpacer_11">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>140</width>
<height>0</height>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>Directed Messages Background</string>
<string>Highlight Activity Containing These Words (comma separated):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="tableSelectedRowBackgroundButton">
<property name="text">
<string>Selected Row Background</string>
<item>
<widget class="QTextEdit" name="highlightTextEdit">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;CQ&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="tableBackgroundButton">
<property name="text">
<string>Table Background</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -3448,7 +3511,7 @@ QListView::item:hover {
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>348</height>
</size>
</property>
</spacer>
@ -4203,12 +4266,6 @@ soundcard changes</string>
<tabstop>font_push_button</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>scrollArea_8</tabstop>
<tabstop>tableForegroundButton</tabstop>
<tabstop>pbCQmsg</tabstop>
<tabstop>tableFontButton</tabstop>
<tabstop>pbMyCall</tabstop>
<tabstop>tableSelectedRowBackgroundButton</tabstop>
<tabstop>tableBackgroundButton</tabstop>
<tabstop>scrollArea_9</tabstop>
<tabstop>txFontButton</tabstop>
<tabstop>rxFontButton</tabstop>
@ -4297,12 +4354,12 @@ soundcard changes</string>
</connection>
</connections>
<buttongroups>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_handshake_button_group"/>
<buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="TX_mode_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/>
</buttongroups>
</ui>

View File

@ -11536,30 +11536,6 @@ void MainWindow::displayBandActivity() {
}
textItem->setTextAlignment(flag);
if (
Varicode::startsWithCQ(text.last()) ||
text.last().contains(QRegularExpression {"\\b(CQCQCQ|CQ)\\b"})
){
offsetItem->setBackground(QBrush(m_config.color_CQ()));
tdriftItem->setBackground(QBrush(m_config.color_CQ()));
ageItem->setBackground(QBrush(m_config.color_CQ()));
snrItem->setBackground(QBrush(m_config.color_CQ()));
textItem->setBackground(QBrush(m_config.color_CQ()));
}
bool isDirectedAllCall = false;
// TODO: jsherer - there's a potential here for a previous allcall to poison the highlight.
if (
(isDirectedOffset(offset, &isDirectedAllCall) && !isDirectedAllCall) || isMyCallIncluded(text.last())
) {
offsetItem->setBackground(QBrush(m_config.color_MyCall()));
tdriftItem->setBackground(QBrush(m_config.color_MyCall()));
ageItem->setBackground(QBrush(m_config.color_MyCall()));
snrItem->setBackground(QBrush(m_config.color_MyCall()));
textItem->setBackground(QBrush(m_config.color_MyCall()));
}
ui->tableWidgetRXAll->setItem(row, col++, textItem);
if (isOffsetSelected) {
@ -11567,6 +11543,21 @@ void MainWindow::displayBandActivity() {
ui->tableWidgetRXAll->item(row, i)->setSelected(true);
}
}
bool isDirectedAllCall = false;
if(
(isDirectedOffset(offset, &isDirectedAllCall) && !isDirectedAllCall) || isMyCallIncluded(text.last())
){
for(int i = 0; i < ui->tableWidgetRXAll->columnCount(); i++){
ui->tableWidgetRXAll->item(row, i)->setBackground(QBrush(m_config.color_MyCall()));
}
}
if (!text.isEmpty() && m_config.highlight_words().intersects(QSet<QString>::fromList(text.last().replace(":", " ").replace(">"," ").split(" ")))){
for(int i = 0; i < ui->tableWidgetRXAll->columnCount(); i++){
ui->tableWidgetRXAll->item(row, i)->setBackground(QBrush(m_config.color_CQ()));
}
}
}
}
@ -11863,6 +11854,12 @@ void MainWindow::displayCallActivity() {
ui->tableWidgetCalls->item(row, i)->setSelected(true);
}
}
if (m_config.highlight_words().contains(call)){
for(int i = 0; i < ui->tableWidgetCalls->columnCount(); i++){
ui->tableWidgetCalls->item(row, i)->setBackground(QBrush(m_config.color_CQ()));
}
}
}
// Set table color