mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Improved decode highlighting
Add "Settings->Colors->Decode Highlighting" context menu buttons to unset b/g and f/g colours. Add colour value as #rrggbb or unset in text to list items. Improved colour assignment to decodes giving better and more intuitive behaviour.
This commit is contained in:
parent
4b4f65eb9f
commit
e5b17e270c
@ -2197,7 +2197,7 @@ Right click for insert and delete options.</string>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Enable or disable using the check boxes and right-click an item to change the foreground color, background color, or reset the item to default values. Drag and drop the items to change their priority, higher in the list is higher in priority.</p></body></html></string>
|
||||
<string><html><head/><body><p>Enable or disable using the check boxes and right-click an item to change or unset the foreground color, background color, or reset the item to default values. Drag and drop the items to change their priority, higher in the list is higher in priority.</p><p>Note that each foreground or background color may be either set or unset, unset means that it is not allocated for that item's type and lower priority items may apply.</p></body></html></string>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
@ -3013,12 +3013,12 @@ Right click for insert and delete options.</string>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="CAT_stop_bits_button_group"/>
|
||||
<buttongroup name="TX_audio_source_button_group"/>
|
||||
<buttongroup name="TX_mode_button_group"/>
|
||||
<buttongroup name="split_mode_button_group"/>
|
||||
<buttongroup name="CAT_handshake_button_group"/>
|
||||
<buttongroup name="special_op_activity_button_group"/>
|
||||
<buttongroup name="PTT_method_button_group"/>
|
||||
<buttongroup name="TX_audio_source_button_group"/>
|
||||
<buttongroup name="split_mode_button_group"/>
|
||||
<buttongroup name="CAT_data_bits_button_group"/>
|
||||
<buttongroup name="PTT_method_button_group"/>
|
||||
<buttongroup name="CAT_handshake_button_group"/>
|
||||
<buttongroup name="TX_mode_button_group"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
@ -160,7 +161,10 @@ QVariant DecodeHighlightingModel::data (const QModelIndex& index, int role) cons
|
||||
result = item.enabled_ ? Qt::Checked : Qt::Unchecked;
|
||||
break;
|
||||
case Qt::DisplayRole:
|
||||
result = highlight_name (item.type_);
|
||||
return QString {"%1 [f/g:%2, b/g:%3]"}
|
||||
.arg (highlight_name (item.type_))
|
||||
.arg (item.foreground_.style () != Qt::NoBrush ? QString {"#%1"}.arg (item.foreground_.color ().rgb () & 0xffffff, 6, 16, QChar {'0'}) : QString {"unset"})
|
||||
.arg (item.background_.style () != Qt::NoBrush ? QString {"#%1"}.arg (item.background_.color ().rgb () & 0xffffff, 6, 16, QChar {'0'}) : QString {"unset"});
|
||||
break;
|
||||
case Qt::ForegroundRole:
|
||||
if (Qt::NoBrush != item.foreground_.style ())
|
||||
|
@ -6,31 +6,12 @@
|
||||
#include "models/DecodeHighlightingModel.hpp"
|
||||
#include "MessageBox.hpp"
|
||||
|
||||
#include "pimpl_impl.hpp"
|
||||
|
||||
class DecodeHighlightingListView::impl final
|
||||
{
|
||||
public:
|
||||
impl ()
|
||||
: fg_colour_action_ {tr ("&Foreground color ..."), nullptr}
|
||||
, bg_colour_action_ {tr ("&Background color ..."), nullptr}
|
||||
, defaults_action_ {tr ("&Reset this item to defaults"), nullptr}
|
||||
{
|
||||
}
|
||||
|
||||
DecodeHighlightingListView * self_;
|
||||
QAction fg_colour_action_;
|
||||
QAction bg_colour_action_;
|
||||
QAction defaults_action_;
|
||||
};
|
||||
|
||||
DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
|
||||
: QListView {parent}
|
||||
{
|
||||
addAction (&m_->fg_colour_action_);
|
||||
addAction (&m_->bg_colour_action_);
|
||||
addAction (&m_->defaults_action_);
|
||||
connect (&m_->fg_colour_action_, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
auto * fg_colour_action = new QAction {tr ("&Foreground color ..."), this};
|
||||
addAction (fg_colour_action);
|
||||
connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
auto const& index = currentIndex ();
|
||||
auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color ()
|
||||
, this
|
||||
@ -38,10 +19,19 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
|
||||
.arg (model ()->data (index).toString ()));
|
||||
if (colour.isValid ())
|
||||
{
|
||||
model ()->setData (index, colour, Qt::ForegroundRole);
|
||||
model ()->setData (index, QBrush {colour}, Qt::ForegroundRole);
|
||||
}
|
||||
});
|
||||
connect (&m_->bg_colour_action_, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
|
||||
auto * unset_fg_colour_action = new QAction {tr ("&Unset foreground color"), this};
|
||||
addAction (unset_fg_colour_action);
|
||||
connect (unset_fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
model ()->setData (currentIndex (), QBrush {}, Qt::ForegroundRole);
|
||||
});
|
||||
|
||||
auto * bg_colour_action = new QAction {tr ("&Background color ..."), this};
|
||||
addAction (bg_colour_action);
|
||||
connect (bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
auto const& index = currentIndex ();
|
||||
auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value<QBrush> ().color ()
|
||||
, this
|
||||
@ -49,10 +39,19 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
|
||||
.arg (model ()->data (index).toString ()));
|
||||
if (colour.isValid ())
|
||||
{
|
||||
model ()->setData (index, colour, Qt::BackgroundRole);
|
||||
model ()->setData (index, QBrush {colour}, Qt::BackgroundRole);
|
||||
}
|
||||
});
|
||||
connect (&m_->defaults_action_, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
|
||||
auto * unset_bg_colour_action = new QAction {tr ("U&nset background color"), this};
|
||||
addAction (unset_bg_colour_action);
|
||||
connect (unset_bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
model ()->setData (currentIndex (), QBrush {}, Qt::BackgroundRole);
|
||||
});
|
||||
|
||||
auto * defaults_action = new QAction {tr ("&Reset this item to defaults"), this};
|
||||
addAction (defaults_action);
|
||||
connect (defaults_action, &QAction::triggered, [this] (bool /*checked*/) {
|
||||
auto const& index = currentIndex ();
|
||||
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::EnabledDefaultRole).toBool () ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole);
|
||||
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::ForegroundDefaultRole), Qt::ForegroundRole);
|
||||
@ -60,10 +59,6 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent)
|
||||
});
|
||||
}
|
||||
|
||||
DecodeHighlightingListView::~DecodeHighlightingListView ()
|
||||
{
|
||||
}
|
||||
|
||||
QSize DecodeHighlightingListView::sizeHint () const
|
||||
{
|
||||
auto item_height = sizeHintForRow (0);
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <QListView>
|
||||
|
||||
#include "pimpl_h.hpp"
|
||||
|
||||
class QWidget;
|
||||
|
||||
// Class Decode Highlighting List View
|
||||
@ -20,13 +18,9 @@ class DecodeHighlightingListView final
|
||||
{
|
||||
public:
|
||||
explicit DecodeHighlightingListView (QWidget * parent = nullptr);
|
||||
~DecodeHighlightingListView ();
|
||||
|
||||
private:
|
||||
QSize sizeHint () const override;
|
||||
|
||||
class impl;
|
||||
pimpl<impl> m_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -121,6 +121,7 @@ void DisplayText::appendText(QString const& text, QColor bg, QColor fg
|
||||
, QString const& call1, QString const& call2)
|
||||
{
|
||||
// qDebug () << "DisplayText::appendText: text:" << text << "Nbsp pos:" << text.indexOf (QChar::Nbsp);
|
||||
|
||||
auto cursor = textCursor ();
|
||||
cursor.movePosition (QTextCursor::End);
|
||||
auto block_format = cursor.blockFormat ();
|
||||
@ -136,16 +137,6 @@ void DisplayText::appendText(QString const& text, QColor bg, QColor fg
|
||||
{
|
||||
format.setForeground (fg);
|
||||
}
|
||||
if (call2.size () && m_config && m_config->lotw_users ().user (call2))
|
||||
{
|
||||
QColor bg;
|
||||
QColor fg;
|
||||
highlight_types types {Highlight::LotW};
|
||||
set_colours (m_config, &bg, &fg, types);
|
||||
if (bg.isValid ()) block_format.setBackground (bg);
|
||||
if (fg.isValid ()) format.setForeground (fg);
|
||||
}
|
||||
|
||||
if (cursor.position ())
|
||||
{
|
||||
cursor.insertBlock (block_format, format);
|
||||
@ -212,13 +203,12 @@ void DisplayText::appendText(QString const& text, QColor bg, QColor fg
|
||||
document ()->setMaximumBlockCount (document ()->maximumBlockCount ());
|
||||
}
|
||||
|
||||
QString DisplayText::appendWorkedB4 (QString message, QString const& callsign, QString const& grid,
|
||||
QString DisplayText::appendWorkedB4 (QString message, QString call, QString const& grid,
|
||||
QColor * bg, QColor * fg, LogBook const& logBook,
|
||||
QString const& currentBand, QString const& currentMode)
|
||||
{
|
||||
// allow for seconds
|
||||
int padding {message.indexOf (" ") > 4 ? 2 : 0};
|
||||
QString call = callsign;
|
||||
QString countryName;
|
||||
bool callB4;
|
||||
bool callB4onBand;
|
||||
@ -292,6 +282,10 @@ QString DisplayText::appendWorkedB4 (QString message, QString const& callsign, Q
|
||||
if(!ITUZoneB4onBand) {
|
||||
types.push_back (Highlight::ITUZoneBand);
|
||||
}
|
||||
if (m_config && m_config->lotw_users ().user (call))
|
||||
{
|
||||
types.push_back (Highlight::LotW);
|
||||
}
|
||||
types.push_back (Highlight::CQ);
|
||||
auto top_highlight = set_colours (m_config, bg, fg, types);
|
||||
|
||||
@ -367,11 +361,11 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|
||||
|| decodedText.string ().contains (" QRZ "))
|
||||
{
|
||||
CQcall = true;
|
||||
highlight_types types {Highlight::CQ};
|
||||
set_colours (m_config, &bg, &fg, types);
|
||||
}
|
||||
if(bCQonly and !CQcall) return;
|
||||
if (myCall != "" and (decodedText.indexOf (" " + myCall + " ") >= 0
|
||||
else
|
||||
{
|
||||
if (bCQonly) return;
|
||||
if (myCall != "" && (decodedText.indexOf (" " + myCall + " ") >= 0
|
||||
or decodedText.indexOf (" " + myCall + "/") >= 0
|
||||
or decodedText.indexOf ("<" + myCall + "/") >= 0
|
||||
or decodedText.indexOf ("/" + myCall + " ") >= 0
|
||||
@ -382,6 +376,7 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|
||||
highlight_types types {Highlight::MyCall};
|
||||
set_colours (m_config, &bg, &fg, types);
|
||||
}
|
||||
}
|
||||
auto message = decodedText.string();
|
||||
QString dxCall;
|
||||
QString dxGrid;
|
||||
@ -389,7 +384,9 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|
||||
QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"};
|
||||
if(!dxGrid.contains(grid_regexp)) dxGrid="";
|
||||
message = message.left (message.indexOf (QChar::Nbsp)); // strip appended info
|
||||
if (displayDXCCEntity && CQcall)
|
||||
if (CQcall)
|
||||
{
|
||||
if (displayDXCCEntity)
|
||||
{
|
||||
// if enabled add the DXCC entity and B4 status to the end of the
|
||||
// preformated text line t1
|
||||
@ -401,6 +398,12 @@ void DisplayText::displayDecodedText(DecodedText const& decodedText, QString con
|
||||
message = appendWorkedB4 (message, decodedText.CQersCall(), dxGrid, &bg, &fg
|
||||
, logBook, currentBand, currentMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
highlight_types types {Highlight::CQ, Highlight::LotW};
|
||||
set_colours (m_config, &bg, &fg, types);
|
||||
}
|
||||
}
|
||||
appendText (message.trimmed (), bg, fg, decodedText.call (), dxCall);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
private:
|
||||
Configuration const * m_config;
|
||||
bool m_bPrincipalPrefix;
|
||||
QString appendWorkedB4(QString message, QString const& callsign
|
||||
QString appendWorkedB4(QString message, QString callsign
|
||||
, QString const& grid, QColor * bg, QColor * fg
|
||||
, LogBook const& logBook, QString const& currentBand
|
||||
, QString const& currentMode);
|
||||
|
Loading…
Reference in New Issue
Block a user