mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-15 16:42:12 -05:00
873b1d1c43
Includes a new settings facility with the highlighting being contrled by a new model class and a modified QListView to display the data for editing. Edits include enable and disable check boxes, a contextual pop-up menu to adjust backkground and foreground colours. Still to be implemented are priorities for highlighting categories. This will be adjustable by drag and drop in the Colors settings panel, it is already implemented by the priority order has no effect on highlighting of decodes yet. The LotW users data file fetch and time since user's last upload is now controled from the settings dialog. This change also drops support for Qt versions before 5.5 so that many workarounds for earlier versions can be removed. Debug trace is slightly modified to make better use of the Qt built in facilities to format and synchronize cross thread messaging.
78 lines
2.9 KiB
C++
78 lines
2.9 KiB
C++
#include "DecodeHighlightingListView.hpp"
|
|
|
|
#include <QAction>
|
|
#include <QColorDialog>
|
|
|
|
#include "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 const& index = currentIndex ();
|
|
auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value<QBrush> ().color ()
|
|
, this
|
|
, tr ("Choose %1 Foreground Color")
|
|
.arg (model ()->data (index).toString ()));
|
|
if (colour.isValid ())
|
|
{
|
|
model ()->setData (index, colour, Qt::ForegroundRole);
|
|
}
|
|
});
|
|
connect (&m_->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
|
|
, tr ("Choose %1 Background Color")
|
|
.arg (model ()->data (index).toString ()));
|
|
if (colour.isValid ())
|
|
{
|
|
model ()->setData (index, colour, Qt::BackgroundRole);
|
|
}
|
|
});
|
|
connect (&m_->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);
|
|
model ()->setData (index, model ()->data (index, DecodeHighlightingModel::BackgroundDefaultRole), Qt::BackgroundRole);
|
|
});
|
|
}
|
|
|
|
DecodeHighlightingListView::~DecodeHighlightingListView ()
|
|
{
|
|
}
|
|
|
|
QSize DecodeHighlightingListView::sizeHint () const
|
|
{
|
|
auto item_height = sizeHintForRow (0);
|
|
if (item_height >= 0)
|
|
{
|
|
// set the height hint to exactly the space required for all the
|
|
// items
|
|
return {width (), (model ()->rowCount () * (item_height + 2 * spacing ())) + 2 * frameWidth ()};
|
|
}
|
|
return QListView::sizeHint ();
|
|
}
|