mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-24 11:40:31 -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.
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
#include "colorhighlighting.h"
|
|
|
|
#include <QApplication>
|
|
#include <QDebug>
|
|
|
|
#include "SettingsGroup.hpp"
|
|
#include "DecodeHighlightingModel.hpp"
|
|
|
|
#include "ui_colorhighlighting.h"
|
|
#include "moc_colorhighlighting.cpp"
|
|
|
|
ColorHighlighting::ColorHighlighting (QSettings * settings, DecodeHighlightingModel const& highlight_model, QWidget * parent)
|
|
: QDialog {parent}
|
|
, ui {new Ui::ColorHighlighting}
|
|
, settings_ {settings}
|
|
{
|
|
ui->setupUi(this);
|
|
setWindowTitle (QApplication::applicationName () + " - Colors");
|
|
read_settings ();
|
|
set_items (highlight_model);
|
|
}
|
|
|
|
ColorHighlighting::~ColorHighlighting()
|
|
{
|
|
if (isVisible ()) write_settings ();
|
|
}
|
|
|
|
void ColorHighlighting::read_settings ()
|
|
{
|
|
SettingsGroup group {settings_, "ColorScheme"};
|
|
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
|
|
}
|
|
|
|
void ColorHighlighting::write_settings ()
|
|
{
|
|
SettingsGroup group {settings_, "ColorScheme"};
|
|
settings_->setValue ("window/geometry", saveGeometry ());
|
|
}
|
|
|
|
void ColorHighlighting::set_items (DecodeHighlightingModel const& highlighting_model)
|
|
{
|
|
int index {0};
|
|
for (auto const& item : highlighting_model.items ())
|
|
{
|
|
QLabel * example;
|
|
QLabel * label;
|
|
switch (index++)
|
|
{
|
|
case 0:
|
|
example = ui->example1_label;
|
|
label = ui->p1_label;
|
|
break;
|
|
case 1:
|
|
example = ui->example2_label;
|
|
label = ui->p2_label;
|
|
break;
|
|
case 2:
|
|
example = ui->example3_label;
|
|
label = ui->p3_label;
|
|
break;
|
|
case 3:
|
|
example = ui->example4_label;
|
|
label = ui->p4_label;
|
|
break;
|
|
case 4:
|
|
example = ui->example5_label;
|
|
label = ui->p5_label;
|
|
break;
|
|
case 5:
|
|
example = ui->example6_label;
|
|
label = ui->p6_label;
|
|
break;
|
|
case 6:
|
|
example = ui->example7_label;
|
|
label = ui->p7_label;
|
|
break;
|
|
case 7:
|
|
example = ui->example8_label;
|
|
label = ui->p8_label;
|
|
break;
|
|
case 8:
|
|
example = ui->example9_label;
|
|
label = ui->p9_label;
|
|
break;
|
|
case 9:
|
|
example = ui->example10_label;
|
|
label = ui->p10_label;
|
|
break;
|
|
}
|
|
auto palette = example->parentWidget ()->palette ();
|
|
if (Qt::NoBrush != item.background_.style ())
|
|
{
|
|
palette.setColor (QPalette::Window, item.background_.color ());
|
|
}
|
|
if (Qt::NoBrush != item.foreground_.style ())
|
|
{
|
|
palette.setColor (QPalette::WindowText, item.foreground_.color ());
|
|
}
|
|
example->setPalette (palette);
|
|
example->setEnabled (item.enabled_);
|
|
label->setText (DecodeHighlightingModel::highlight_name (item.type_));
|
|
label->setEnabled (item.enabled_);
|
|
}
|
|
}
|