1
0
mirror of https://github.com/JvanKatwijk/qt-dab.git synced 2025-10-06 08:12:40 +02:00
Files
SDR-DAB_Qt-DAB/qt-dab-6.9/support/config-handler.cpp

1009 lines
33 KiB
C++
Raw Normal View History

2024-02-16 15:46:54 +01:00
#
/*
* Copyright (C) 2015, 2023
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the Qt-DAB
*
* Qt-DAB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Qt-DAB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Qt-DAB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <QSettings>
#include <QDebug>
#include <QStringList>
#include <QStringListModel>
#include <QColorDialog>
#include "dab-constants.h"
#include "config-handler.h"
#include "mapport.h"
#include "skin-handler.h"
#include "radio.h"
2024-03-04 14:45:33 +01:00
#include "position-handler.h"
2024-02-25 14:18:27 +01:00
#include "settingNames.h"
#include "settings-handler.h"
2024-03-13 19:45:53 +01:00
#include "audiosystem-selector.h"
#define AUDIOSELECT_BUTTON QString ("audioSelectButton")
#define FONT_BUTTON QString ("fontButton")
#define FONTCOLOR_BUTTON QString ("fontColorButton")
#define DEVICEWIDGET_BUTTON QString ("devicewidgetButton")
#define PORT_SELECTOR QString ("portSelector")
2024-11-24 13:08:32 +01:00
#define DLTEXT_BUTTON QString ("dlTextButton")
2024-03-13 19:45:53 +01:00
#define RESET_BUTTON QString ("resetButton")
#define SCHEDULE_BUTTON QString ("scheduleButton")
#define SNR_BUTTON QString ("snrButton")
#define SET_COORDINATES_BUTTON QString ("set_coordinatesButton")
#define LOAD_TABLE_BUTTON QString ("loadTableButton")
#define SKIN_BUTTON QString ("skinButton")
#define DUMP_BUTTON QString ("dumpButton")
2024-02-25 14:18:27 +01:00
2024-10-31 10:58:24 +01:00
#define PATH_BUTTON QString ("pathButton")
2024-11-10 12:45:48 +01:00
#define WHITE "#ffffff"
#define BLACK "#000000"
#define GREEN "#8ff0a4"
#define BLUE "#00ffff"
#define RED "#ff007f"
#define YELLOW "#f9f06b"
2024-02-16 15:46:54 +01:00
static struct {
QString decoderName;
int decoderKey;
} decoders [] = {
2024-11-24 13:08:32 +01:00
{"decoder_a", DECODER_1},
{"decoder_b", DECODER_2},
{"decoder_c", DECODER_3},
2024-11-25 14:55:59 +01:00
{"decoder_d", DECODER_4},
{"decoder_e", DECODER_5},
2024-02-16 15:46:54 +01:00
{"", 0}
};
2024-11-10 12:45:48 +01:00
static
int index_for_key (int key) {
for (int i = 0; decoders [i]. decoderKey != 0; i ++)
if (decoders [i]. decoderKey == key)
return i;
return 0;
}
2024-02-16 15:46:54 +01:00
configHandler::configHandler (RadioInterface *parent,
2024-02-25 14:18:27 +01:00
QSettings *settings):
myFrame (nullptr) {
2024-02-16 15:46:54 +01:00
this -> myRadioInterface = parent;
this -> dabSettings = settings;
2024-02-25 14:18:27 +01:00
this -> setupUi (&myFrame);
2024-03-04 14:45:33 +01:00
set_position_and_size (settings, &myFrame, CONFIG_HANDLER);
2024-02-25 14:18:27 +01:00
hide ();
2024-04-14 12:47:14 +02:00
connect (&myFrame, &superFrame::frameClosed,
this, &configHandler::frameClosed);
2024-02-16 15:46:54 +01:00
// inits of checkboxes etc in the configuration widget,
// note that ONLY the GUI is set, values are not used
int x = value_i (dabSettings, CONFIG_HANDLER, MUTE_TIME_SETTING, 10);
2024-02-16 15:46:54 +01:00
this -> muteTimeSetting -> setValue (x);
int fontSize =
value_i (dabSettings, COLOR_SETTINGS, "fontSize", 10);
2024-02-16 15:46:54 +01:00
this -> fontSizeSelector -> setValue (fontSize);
x = value_i (dabSettings, CONFIG_HANDLER, SWITCH_VALUE_SETTING,
DEFAULT_SWITCHVALUE);
2024-02-16 15:46:54 +01:00
this -> switchDelaySetting -> setValue (x);
x = value_i ( dabSettings, CONFIG_HANDLER, SERVICE_ORDER_SETTING,
ALPHA_BASED);
2024-02-16 15:46:54 +01:00
if (x == ALPHA_BASED)
this -> orderAlfabetical -> setChecked (true);
else
if (x == ID_BASED)
this -> orderServiceIds -> setChecked (true);
else
this -> ordersubChannelIds -> setChecked (true);
serviceOrder = x;
// first row of checkboxes
2024-02-25 14:18:27 +01:00
// unused element
x = value_i (dabSettings, CONFIG_HANDLER, LOG_MODE, 1);
2024-10-14 13:12:03 +02:00
if (x != 0)
this -> logger_selector -> setChecked (true);
x = value_i (dabSettings, CONFIG_HANDLER, EPG2XML_SETTING, 0);
2024-02-16 15:46:54 +01:00
if (x != 0)
this -> epg2xmlSelector -> setChecked (true);
//
bool b = value_i (dabSettings, CONFIG_HANDLER,
UTC_SELECTOR_SETTING, 0) == 1;
2024-02-16 15:46:54 +01:00
this -> utc_selector -> setChecked (b);
b = value_i (dabSettings, CONFIG_HANDLER,
ON_TOP_SETTING, 0) == 1;
2024-02-16 15:46:54 +01:00
this -> onTop -> setChecked (b);
//
// third row of checkboxes
b = value_i (dabSettings, CONFIG_HANDLER,
CLOSE_DIRECT_SETTING, 0) != 0;
2024-02-16 15:46:54 +01:00
this -> closeDirect_selector -> setChecked (b);
b = value_i (dabSettings, CONFIG_HANDLER,
EPG_FLAG_SETTING, 0) != 0;
2024-02-16 15:46:54 +01:00
this -> epg_selector -> setChecked (b);
b = value_i (dabSettings, CONFIG_HANDLER,
LOCAL_BROWSER_SETTING, 1) != 0;
2024-02-16 15:46:54 +01:00
this -> localBrowserSelector -> setChecked (b);
//
2024-02-16 15:46:54 +01:00
// fifth row of checkboxes
b = value_i (dabSettings, CONFIG_HANDLER,
CLEAR_SCAN_RESULT_SETTING, 1) == 1;
2024-02-16 15:46:54 +01:00
this -> clearScan_selector -> setChecked (b);
b = value_i (dabSettings, CONFIG_HANDLER,
SAVE_SLIDES_SETTING, 0) == 1;
2024-02-16 15:46:54 +01:00
this -> saveSlides -> setChecked (b);
b = value_i (dabSettings, CONFIG_HANDLER,
TRANSMITTER_NAMES_SETTING, 0) == 1;
b = value_i (dabSettings, CONFIG_HANDLER,
S_CORRELATION_ORDER, 0) != 0;
2024-04-03 18:44:52 +02:00
this -> correlationSelector -> setChecked (b);
2024-11-24 13:08:32 +01:00
b = value_i (dabSettings, CONFIG_HANDLER, "audioServices_only", 1);
this -> audioServices_only -> setChecked (b);
2024-12-21 13:46:43 +01:00
b = value_i (dabSettings, CONFIG_HANDLER, "auto_http", 9) != 0;
this -> auto_http -> setChecked (b);
2025-01-02 09:41:23 +01:00
int c = value_i (dabSettings, CONFIG_HANDLER, "tiiCollisions", 0);
this -> tiiCollisions -> setValue (c);
b = value_i (dabSettings, CONFIG_HANDLER, "tiiFilter", 1) != 0;
this -> tiiFilter -> setChecked (b);
2024-12-21 13:46:43 +01:00
2024-02-16 15:46:54 +01:00
#ifndef __MSC_THREAD__
for (int i = 0; decoders [i]. decoderName != ""; i ++)
this -> decoderSelector -> addItem (decoders [i]. decoderName);
2024-11-29 20:31:44 +01:00
this -> decoderSelector -> setToolTip (" There are several ideas on how to derive the softbits from the phase difference in the subsequent bins of the FFT output. 5 different approaches are implemented, decoder C is said to be the best when there is white noise and a difference in the amplitude of the carriers. while decoder D is said to be the best when there is frequency selective interference and finally, decider E is said the best when there is strong frequency selective interference. The decoders C, D and E are derived from the work of old-dab");
2024-02-16 15:46:54 +01:00
#else
this -> decoderSelector -> setEnabled (false);
#endif
2024-11-10 12:45:48 +01:00
int k = value_i (dabSettings, CONFIG_HANDLER,
2024-11-24 13:08:32 +01:00
"decoders", DECODER_1);
2024-11-10 12:45:48 +01:00
decoderSelector -> setCurrentIndex (index_for_key (k));
2025-01-06 20:47:14 +01:00
2025-01-10 14:24:41 +01:00
int v = value_i (dabSettings, CONFIG_HANDLER, "tii-detector", 1);
2025-01-06 20:47:14 +01:00
this -> tiiSelector -> setChecked (v != 0);
2025-01-10 14:24:41 +01:00
if (v == 0) {
2025-01-06 20:47:14 +01:00
tiiCollisions -> setEnabled (false);
2025-01-10 14:24:41 +01:00
tiiThreshold_setter -> setMinimum (4);
}
else
tiiThreshold_setter -> setMinimum (6);
v = value_i (dabSettings, CONFIG_HANDLER,
TII_THRESHOLD, 12);
this -> tiiThreshold_setter -> setValue (v);
connect (tiiThreshold_setter, qOverload<int>(&QSpinBox::valueChanged),
2024-12-02 14:46:38 +01:00
myRadioInterface, &RadioInterface::handle_tiiThreshold);
2024-12-30 14:51:14 +01:00
connect (this, &configHandler::process_tiiCollisions,
myRadioInterface, &RadioInterface::handle_tiiCollisions);
connect (this, &configHandler::process_tiiFilter,
myRadioInterface, &RadioInterface::handle_tiiFilter);
2024-10-31 10:58:24 +01:00
connect (pathButton, &QPushButton::clicked,
this, &configHandler::handle_pathButton);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (auto_http, &QCheckBox::checkStateChanged,
#else
2024-12-21 13:46:43 +01:00
connect (auto_http, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-12-21 13:46:43 +01:00
this, &configHandler::handle_auto_http);
2025-01-02 09:41:23 +01:00
connect (tiiCollisions, qOverload<int>(&QSpinBox::valueChanged),
this, &configHandler::handle_tiiCollisions);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (tiiFilter, &QCheckBox::checkStateChanged,
#else
connect (tiiFilter, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
this, &configHandler::handle_tiiFilter);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (tiiSelector, &QCheckBox::checkStateChanged,
#else
2025-01-06 20:47:14 +01:00
connect (tiiSelector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2025-01-06 20:47:14 +01:00
this, &configHandler::handle_tiiSelector);
connect (this, &configHandler::process_tiiSelector,
myRadioInterface, &RadioInterface::process_tiiSelector);
2024-02-16 15:46:54 +01:00
set_Colors ();
}
configHandler::~configHandler () {
2024-03-04 14:45:33 +01:00
store_widget_position (dabSettings, &myFrame, CONFIG_HANDLER);
2024-02-16 15:46:54 +01:00
}
2024-02-25 14:18:27 +01:00
void configHandler::show () {
myFrame. show ();
}
void configHandler::hide () {
myFrame. hide ();
}
bool configHandler::isHidden () {
return myFrame. isHidden ();
}
2024-02-16 15:46:54 +01:00
void configHandler::setDeviceList (const QStringList &sl) {
for (auto &sle : sl)
deviceSelector -> addItem (sle);
}
bool configHandler::findDevice (const QString &dev) {
int k = deviceSelector -> findText (dev);
if (k != -1)
deviceSelector -> setCurrentIndex (k);
return k >= 0;
}
void configHandler::connectDevices () {
2024-04-15 14:03:12 +02:00
connect (deviceSelector,
2024-10-07 19:35:30 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
&QComboBox::textActivated,
#else
2024-04-15 14:03:12 +02:00
qOverload<const QString &>(&QComboBox::activated),
2024-10-07 19:35:30 +02:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::doStart);
2024-02-16 15:46:54 +01:00
}
void configHandler::disconnectDevices () {
2024-04-15 14:03:12 +02:00
disconnect (deviceSelector,
2024-10-07 19:35:30 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
qOverload<const QString &>(&QComboBox::textActivated),
#else
2024-04-15 14:03:12 +02:00
qOverload<const QString &>(&QComboBox::activated),
2024-10-07 19:35:30 +02:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::doStart);
2024-04-15 14:03:12 +02:00
disconnect (deviceSelector,
2024-10-07 19:35:30 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
qOverload<const QString &>(&QComboBox::textActivated),
#else
2024-04-15 14:03:12 +02:00
qOverload<const QString &>(&QComboBox::activated),
2024-10-07 19:35:30 +02:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::newDevice);
2024-02-16 15:46:54 +01:00
}
void configHandler::reconnectDevices () {
2024-04-15 14:03:12 +02:00
connect (deviceSelector,
2024-10-07 19:35:30 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
qOverload<const QString &>(&QComboBox::textActivated),
#else
2024-04-15 14:03:12 +02:00
qOverload<const QString &>(&QComboBox::activated),
2024-10-07 19:35:30 +02:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::newDevice);
2024-02-16 15:46:54 +01:00
}
void configHandler::set_connections () {
2024-04-14 12:47:14 +02:00
connect (audioSelectButton, &smallPushButton::clicked,
this, &configHandler::handle_audioSelectButton);
connect (this, &configHandler::selectDecoder,
myRadioInterface, &RadioInterface::selectDecoder);
connect (this, &configHandler::set_transmitters_local,
myRadioInterface, &RadioInterface::set_transmitters_local);
connect (audioSelectButton, &smallPushButton::rightClicked,
this, &configHandler::color_audioSelectButton);
connect (fontButton, &smallPushButton::rightClicked,
this, &configHandler::color_fontButton);
connect (fontColorButton, &smallPushButton::rightClicked,
this, &configHandler::color_fontColorButton );
connect (devicewidgetButton, &smallPushButton::rightClicked,
this, &configHandler::color_devicewidgetButton);
connect (portSelector, &smallPushButton::rightClicked,
this, &configHandler::color_portSelector);
connect (dlTextButton, &smallPushButton::rightClicked,
this, &configHandler::color_dlTextButton);
connect (resetButton, &smallPushButton::rightClicked,
this, &configHandler::color_resetButton);
connect (scheduleButton, &smallPushButton::rightClicked,
2024-09-04 09:46:23 +02:00
this, &configHandler::color_scheduleButton);
2024-04-14 12:47:14 +02:00
connect (snrButton, &smallPushButton::rightClicked,
this, &configHandler::color_snrButton);
connect (set_coordinatesButton, &smallPushButton::rightClicked,
this, &configHandler::color_set_coordinatesButton);
connect (loadTableButton, &smallPushButton::rightClicked,
this, &configHandler::color_loadTableButton);
connect (dumpButton, &smallPushButton::rightClicked,
this, &configHandler::color_sourcedumpButton);
2024-10-31 10:58:24 +01:00
connect (pathButton, &smallPushButton::rightClicked,
this, &configHandler::color_pathButton);
2024-04-14 12:47:14 +02:00
connect (skinButton, &smallPushButton::rightClicked,
this, &configHandler::color_skinButton);
2024-02-16 15:46:54 +01:00
//
// real handlers
2024-04-14 12:47:14 +02:00
connect (scheduleButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_scheduleButton);
connect (muteTimeSetting, qOverload<int>(&QSpinBox::valueChanged),
this, &configHandler::handle_muteTimeSetting);
connect (switchDelaySetting, qOverload<int>(&QSpinBox::valueChanged),
this, &configHandler::handle_switchDelaySetting);
connect (orderAlfabetical, &QRadioButton::clicked,
this, &configHandler::handle_orderAlfabetical);
connect (orderServiceIds, &QRadioButton::clicked,
this, &configHandler::handle_orderServiceIds);
connect (ordersubChannelIds, &QRadioButton::clicked,
this, &configHandler::handle_ordersubChannelIds);
2024-02-16 15:46:54 +01:00
//
2024-04-14 12:47:14 +02:00
connect (fontButton, &QPushButton::clicked,
this, &configHandler::handle_fontSelect);
connect (fontColorButton, &QPushButton::clicked,
this, &configHandler::handle_fontColorSelect);
connect (fontSizeSelector, qOverload<int>(&QSpinBox::valueChanged),
this, &configHandler::handle_fontSizeSelect);
2024-02-16 15:46:54 +01:00
//
// Now the two rows with buttons
//
2024-04-14 12:47:14 +02:00
connect (devicewidgetButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_devicewidgetButton);
connect (portSelector, &QPushButton::clicked,
this, &configHandler::handle_portSelector);
connect (dlTextButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_dlTextButton);
connect (resetButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_resetButton);
2024-02-16 15:46:54 +01:00
//
// second row
2024-04-14 12:47:14 +02:00
connect (snrButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_snrButton);
connect (set_coordinatesButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_set_coordinatesButton );
connect (loadTableButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_loadTable);
2025-01-13 19:13:10 +01:00
loadTableButton -> setText ("refresh table");
2024-03-04 14:45:33 +01:00
// however, by default loadTable is disabled
2024-02-25 14:18:27 +01:00
loadTableButton -> setEnabled (false);
2024-04-14 12:47:14 +02:00
connect (dumpButton, &QPushButton::clicked,
myRadioInterface, &RadioInterface::handle_sourcedumpButton);
connect (skinButton, &QPushButton::clicked,
this, &configHandler::handle_skinSelector);
2024-02-16 15:46:54 +01:00
//
// Now the checkboxes
// top line
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (audioServices_only, &QCheckBox::checkStateChanged,
#else
2024-11-24 13:08:32 +01:00
connect (audioServices_only, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-11-24 13:08:32 +01:00
this, &configHandler::handle_audioServices_only);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (correlationSelector, &QCheckBox::checkStateChanged,
#else
2024-11-24 13:08:32 +01:00
connect (correlationSelector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-11-24 13:08:32 +01:00
myRadioInterface, &RadioInterface::handle_correlationSelector);
//
// second line
int upload = value_i (dabSettings, CONFIG_HANDLER,
"UPLOAD_ENABLED", 0);
2024-03-30 19:39:33 +01:00
if (upload != 0)
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (upload_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (upload_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_upload_selector);
2024-03-30 19:39:33 +01:00
else
upload_selector -> setEnabled (false);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (logger_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (logger_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::handle_LoggerButton);
2024-02-16 15:46:54 +01:00
// the epg2xmlSelector is just polled, no need to react on an event
2024-11-24 13:08:32 +01:00
// third line
2024-02-16 15:46:54 +01:00
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (utc_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (utc_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_utc_selector);
2024-02-25 14:18:27 +01:00
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (onTop, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (onTop, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_onTop);
2024-02-16 15:46:54 +01:00
//
2024-11-24 13:08:32 +01:00
// fourthline
2024-02-16 15:46:54 +01:00
// here we expect the close without asking
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (epg_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (epg_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_epgSelector);
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (localBrowserSelector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (localBrowserSelector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_localBrowser);
2024-02-16 15:46:54 +01:00
//
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (etiActivated_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (etiActivated_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
myRadioInterface, &RadioInterface::handle_eti_activeSelector);
2024-02-16 15:46:54 +01:00
//
// fifh line
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (clearScan_selector, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (clearScan_selector, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_clearScan_Selector);
2024-02-16 15:46:54 +01:00
2025-01-18 19:28:38 +01:00
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 2)
connect (saveSlides, &QCheckBox::checkStateChanged,
#else
2024-04-14 12:47:14 +02:00
connect (saveSlides, &QCheckBox::stateChanged,
2025-01-18 19:28:38 +01:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_saveSlides);
2024-02-16 15:46:54 +01:00
//
// botton row
2024-04-15 14:03:12 +02:00
connect (decoderSelector,
2024-10-07 19:35:30 +02:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
&QComboBox::textActivated,
#else
2024-04-15 14:03:12 +02:00
qOverload<const QString &>(&QComboBox::activated),
2024-10-07 19:35:30 +02:00
#endif
2024-04-14 12:47:14 +02:00
this, &configHandler::handle_decoderSelector);
2024-02-16 15:46:54 +01:00
}
/////////////////////////////////////////////////////////////////////////
//
void configHandler::set_Colors () {
2024-03-13 19:45:53 +01:00
QString audioSelectButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
AUDIOSELECT_BUTTON + "_color", GREEN);
QString audioSelectButton_font =
value_s (dabSettings, COLOR_SETTINGS,
AUDIOSELECT_BUTTON + "_font", BLACK);
2024-03-13 19:45:53 +01:00
2024-02-16 15:46:54 +01:00
QString fontButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
FONT_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString fontButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
FONT_BUTTON + "_color", WHITE);
2024-02-16 15:46:54 +01:00
QString fontColorButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
FONTCOLOR_BUTTON + "_font", WHITE);
2024-02-16 15:46:54 +01:00
QString fontColorButton_color =
value_s (dabSettings, "COLOR_SETTINGD",
2024-11-10 12:45:48 +01:00
FONTCOLOR_BUTTON + "_color", BLACK);
2024-02-16 15:46:54 +01:00
QString devicewidgetButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DEVICEWIDGET_BUTTON + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString devicewidgetButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DEVICEWIDGET_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString portSelector_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
PORT_SELECTOR + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString portSelector_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
PORT_SELECTOR + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString dlTextButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DLTEXT_BUTTON + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString dlTextButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DLTEXT_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString resetButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
RESET_BUTTON + "_color", RED);
2024-02-16 15:46:54 +01:00
QString resetButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
RESET_BUTTON + "_font", WHITE);
2024-02-16 15:46:54 +01:00
QString scheduleButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SCHEDULE_BUTTON + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString scheduleButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SCHEDULE_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString snrButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SNR_BUTTON + "_color", BLUE);
2024-02-16 15:46:54 +01:00
QString snrButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SNR_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString set_coordinatesButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SET_COORDINATES_BUTTON + "_color", BLUE);
2024-02-16 15:46:54 +01:00
QString set_coordinatesButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SET_COORDINATES_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString loadTableButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
LOAD_TABLE_BUTTON + "_color", RED);
2024-02-16 15:46:54 +01:00
QString loadTableButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
LOAD_TABLE_BUTTON + "_font", WHITE);
2024-02-16 15:46:54 +01:00
QString dumpButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DUMP_BUTTON + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString dumpButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
DUMP_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
2024-10-31 10:58:24 +01:00
QString pathButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
PATH_BUTTON + "_color", GREEN);
2024-10-31 10:58:24 +01:00
QString pathButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
PATH_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString skinButton_font =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SKIN_BUTTON + "_font", BLACK);
2024-02-16 15:46:54 +01:00
QString skinButton_color =
value_s (dabSettings, COLOR_SETTINGS,
2024-11-10 12:45:48 +01:00
SKIN_BUTTON + "_color", YELLOW);
2024-02-16 15:46:54 +01:00
QString temp = "QPushButton {background-color: %1; color: %2}";
2024-03-13 19:45:53 +01:00
this -> audioSelectButton ->
setStyleSheet (temp. arg (audioSelectButton_color,
audioSelectButton_font));
2024-02-16 15:46:54 +01:00
this -> fontButton ->
setStyleSheet (temp. arg (fontButton_color,
fontButton_font));
this -> fontColorButton ->
setStyleSheet (temp. arg (fontColorButton_color,
fontColorButton_font));
this -> devicewidgetButton ->
setStyleSheet (temp. arg (devicewidgetButton_color,
devicewidgetButton_font));
this -> portSelector ->
setStyleSheet (temp. arg (portSelector_color,
portSelector_font));
this -> dlTextButton ->
setStyleSheet (temp. arg (dlTextButton_color,
dlTextButton_font));
this -> resetButton ->
setStyleSheet (temp. arg (resetButton_color,
resetButton_font));
this -> scheduleButton ->
setStyleSheet (temp. arg (scheduleButton_color,
scheduleButton_font));
this -> snrButton ->
setStyleSheet (temp. arg (snrButton_color,
snrButton_font));
this -> set_coordinatesButton ->
setStyleSheet (temp. arg (set_coordinatesButton_color,
set_coordinatesButton_font));
this -> loadTableButton ->
setStyleSheet (temp. arg (loadTableButton_color,
loadTableButton_font));
this -> dumpButton ->
setStyleSheet (temp. arg (dumpButton_color,
dumpButton_font));
2024-10-31 10:58:24 +01:00
this -> pathButton ->
setStyleSheet (temp. arg (pathButton_color,
pathButton_font));
2024-02-16 15:46:54 +01:00
this -> skinButton ->
setStyleSheet (temp. arg (skinButton_color,
skinButton_font));
}
2024-03-13 19:45:53 +01:00
void configHandler::color_audioSelectButton () {
set_buttonColors (this -> audioSelectButton, AUDIOSELECT_BUTTON);
}
2024-02-16 15:46:54 +01:00
void configHandler::color_fontButton () {
set_buttonColors (this -> fontButton, FONT_BUTTON);
}
void configHandler::color_fontColorButton () {
set_buttonColors (this -> fontColorButton, FONTCOLOR_BUTTON);
}
void configHandler::color_devicewidgetButton () {
set_buttonColors (this -> devicewidgetButton, DEVICEWIDGET_BUTTON);
}
void configHandler::color_portSelector () {
set_buttonColors (this -> portSelector, PORT_SELECTOR);
}
void configHandler::color_dlTextButton () {
set_buttonColors (this -> dlTextButton, DLTEXT_BUTTON);
}
void configHandler::color_resetButton () {
set_buttonColors (this -> resetButton, RESET_BUTTON);
}
void configHandler::color_scheduleButton () {
set_buttonColors (this -> scheduleButton, SCHEDULE_BUTTON);
}
void configHandler::color_snrButton () {
set_buttonColors (this -> snrButton, SNR_BUTTON);
}
void configHandler::color_set_coordinatesButton () {
set_buttonColors (this -> set_coordinatesButton,
SET_COORDINATES_BUTTON);
}
void configHandler::color_loadTableButton () {
set_buttonColors (this -> loadTableButton, LOAD_TABLE_BUTTON);
}
void configHandler::color_sourcedumpButton () {
set_buttonColors (this -> dumpButton, DUMP_BUTTON);
}
2024-10-31 10:58:24 +01:00
void configHandler::color_pathButton () {
set_buttonColors (this -> pathButton, PATH_BUTTON);
}
2024-02-16 15:46:54 +01:00
void configHandler::color_skinButton () {
set_buttonColors (this -> skinButton, SKIN_BUTTON);
}
void configHandler::set_buttonColors (QPushButton *b,
const QString &buttonName) {
QColor baseColor;
QColor textColor;
QColor color;
color = QColorDialog::getColor (baseColor, nullptr, "baseColor");
if (!color. isValid ())
return;
baseColor = color;
color = QColorDialog::getColor (textColor, nullptr, "textColor");
if (!color. isValid ())
return;
textColor = color;
QString temp = "QPushButton {background-color: %1; color: %2}";
b -> setStyleSheet (temp. arg (baseColor. name (),
textColor. name ()));
QString buttonColor = buttonName + "_color";
QString buttonFont = buttonName + "_font";
QString baseColor_name = baseColor. name ();
QString textColor_name = textColor. name ();
store (dabSettings, COLOR_SETTINGS, buttonColor, baseColor_name);
store (dabSettings, COLOR_SETTINGS, buttonFont, textColor_name);
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_muteTimeSetting (int newV) {
store (dabSettings, CONFIG_HANDLER, MUTE_TIME_SETTING, newV);
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_switchDelaySetting (int newV) {
store (dabSettings, CONFIG_HANDLER, SWITCH_VALUE_SETTING, newV);
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_orderAlfabetical () {
set_serviceOrder (ALPHA_BASED);
serviceOrder = ALPHA_BASED;
}
void configHandler::handle_orderServiceIds () {
set_serviceOrder (ID_BASED);
serviceOrder = ID_BASED;
}
void configHandler::handle_ordersubChannelIds () {
set_serviceOrder (SUBCH_BASED);
serviceOrder = SUBCH_BASED;
}
void configHandler::handle_portSelector () {
QString oldPort = value_s (dabSettings, "MAP_HANDLING",
MAP_PORT_SETTING, "8080");
2024-02-25 14:18:27 +01:00
mapPortHandler theHandler (oldPort);
int portNumber = theHandler. QDialog::exec ();
if (portNumber != 0) {
QString ss = QString::number (portNumber);
store (dabSettings, "MAP_HANDLING", MAP_PORT_SETTING, ss);
}
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_skinSelector () {
skinHandler theSkins;
int skinIndex = theSkins. QDialog::exec ();
QString skinName = theSkins. skins. at (skinIndex);
store (dabSettings, "SKIN_HANDLING", SKIN_SETTING, skinName);
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_onTop (int d) {
bool onTop = false;
(void)d;
if (this -> onTop -> isChecked ())
onTop = true;
store (dabSettings, CONFIG_HANDLER, ON_TOP_SETTING, onTop ? 1 : 0);
2024-02-16 15:46:54 +01:00
}
void configHandler::handle_epgSelector (int x) {
(void)x;
store (dabSettings, CONFIG_HANDLER, EPG_FLAG_SETTING,
2024-02-16 15:46:54 +01:00
this -> epg_selector -> isChecked () ? 1 : 0);
}
void configHandler::handle_localBrowser (int d) {
(void)d;
store (dabSettings, CONFIG_HANDLER, LOCAL_BROWSER_SETTING,
2024-02-16 15:46:54 +01:00
this -> localBrowserSelector -> isChecked () ? 1 : 0);
}
void configHandler::handle_clearScan_Selector (int c) {
(void)c;
store (dabSettings, CONFIG_HANDLER, CLEAR_SCAN_RESULT_SETTING,
2024-02-16 15:46:54 +01:00
this -> clearScan_selector -> isChecked () ? 1 : 0);
}
void configHandler::handle_saveSlides (int x) {
(void)x;
store (dabSettings, CONFIG_HANDLER, SAVE_SLIDES_SETTING,
2024-02-16 15:46:54 +01:00
this -> saveSlides -> isChecked () ? 1 : 0);
}
void configHandler::handle_decoderSelector (const QString &s) {
int decoder = 0100;
for (int i = 0; decoders [i]. decoderName != ""; i ++)
if (decoders [i]. decoderName == s) {
decoder = decoders [i]. decoderKey;
selectDecoder (decoder);
2024-11-10 12:45:48 +01:00
store (dabSettings, CONFIG_HANDLER, "decoders", decoder);
break;
2024-02-16 15:46:54 +01:00
}
}
2024-03-04 14:45:33 +01:00
void configHandler::handle_upload_selector (int d) {
(void)d;
}
2024-02-25 14:18:27 +01:00
void configHandler::handle_utc_selector (int d) {
(void)d;
store (dabSettings, CONFIG_HANDLER, UTC_SELECTOR_SETTING,
utc_selector -> isChecked () ? 1 : 0);
2024-02-16 15:46:54 +01:00
}
2024-02-25 14:18:27 +01:00
int configHandler::get_serviceOrder () {
return serviceOrder;
2024-02-16 15:46:54 +01:00
}
2024-03-04 14:45:33 +01:00
bool configHandler::upload_selector_active () {
return upload_selector -> isChecked ();
}
2024-02-16 15:46:54 +01:00
bool configHandler::closeDirect_active () {
return closeDirect_selector -> isChecked ();
}
bool configHandler::clearScan_Selector_active () {
return clearScan_selector -> isChecked ();
}
//
//column 2
bool configHandler::logger_active () {
return logger_selector -> isChecked ();
}
bool configHandler::utcSelector_active () {
return utc_selector -> isChecked ();
}
bool configHandler::epg_automatic_active () {
return epg_selector -> isChecked ();
}
bool configHandler::eti_active () {
return etiActivated_selector -> isChecked ();
}
bool configHandler::saveSliders_active () {
return saveSlides -> isChecked ();
}
//
// Column 3
bool configHandler::epg2_active () {
return epg2xmlSelector -> isChecked ();
}
bool configHandler::onTop_active () {
return onTop -> isChecked ();
}
bool configHandler::localBrowserSelector_active () {
return localBrowserSelector -> isChecked ();
}
static inline
void setButtonFont (QPushButton *b, QString text, int size) {
QFont font = b -> font ();
font. setPointSize (size);
b -> setFont (font);
b -> setText (text);
b -> update ();
}
void configHandler::mark_dumpButton (bool b) {
if (b)
setButtonFont (dumpButton, "writing", 12);
else
setButtonFont (dumpButton, "Raw dump", 10);
}
void configHandler::mark_dlTextButton (bool b) {
if (b)
setButtonFont (dlTextButton, "writing", 12);
else
setButtonFont (dlTextButton, "dlText", 10);
}
void configHandler::set_closeDirect (bool b) {
closeDirect_selector -> setChecked (b);
}
void configHandler::show_streamSelector (bool b) {
if (b)
streamoutSelector -> show ();
else
streamoutSelector -> hide ();
}
void configHandler::fill_streamTable (const QStringList &sl) {
2025-01-10 14:24:41 +01:00
for (int i = streamoutSelector -> count () - 1; i >= 0; i --)
streamoutSelector -> removeItem (i);
2024-02-16 15:46:54 +01:00
for (auto sle : sl)
streamoutSelector -> addItem (sle);
}
int configHandler::init_streamTable (const QString &s) {
int k =streamoutSelector -> findText (s);
if (k > 0)
streamoutSelector -> setCurrentIndex (k);
return k;
}
void configHandler::connect_streamTable () {
2024-04-14 12:47:14 +02:00
connect (streamoutSelector, qOverload<int>(&QComboBox::activated),
myRadioInterface, &RadioInterface::set_streamSelector);
2024-02-16 15:46:54 +01:00
}
QString configHandler::currentStream () {
if (streamoutSelector -> count () == 0)
return "";
return streamoutSelector -> currentText ();
}
int configHandler::switchDelayValue () {
return switchDelaySetting -> value () * 1000;
}
int configHandler::muteValue () {
return muteTimeSetting -> value ();
}
void configHandler::showLoad (float load) {
loadDisplay -> display (load);
}
2024-02-25 14:18:27 +01:00
void configHandler::enable_loadLib () {
loadTableButton -> setEnabled (true);
}
2024-03-13 19:45:53 +01:00
void configHandler::handle_audioSelectButton () {
audiosystemSelector the_selector (dabSettings);
(void)the_selector. QDialog::exec ();
}
2024-04-03 18:44:52 +02:00
bool configHandler::get_correlationSelector () {
return correlationSelector -> isChecked ();
}
void configHandler::handle_tiiThreshold (int t) {
store (dabSettings, CONFIG_HANDLER, TII_THRESHOLD, t);
}
2024-04-03 18:44:52 +02:00
2024-10-31 10:58:24 +01:00
void configHandler::handle_pathButton () {
QString dir =
QFileDialog::getExistingDirectory (nullptr,
tr("Open Directory"),
QDir::homePath (),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (dir != "")
store (dabSettings, CONFIG_HANDLER, "filePath", dir);
2024-10-31 10:58:24 +01:00
}
2024-11-24 13:08:32 +01:00
bool configHandler::get_audioServices_only () {
return audioServices_only -> isChecked ();
}
2024-12-21 13:46:43 +01:00
void configHandler::handle_auto_http (int state) {
uint8_t x = auto_http -> isChecked ();
(void)state;
store (dabSettings, CONFIG_HANDLER, "auto_http", x);
}
2024-12-27 12:39:00 +01:00
void configHandler::handle_audioServices_only (int state) {
uint8_t x = audioServices_only -> isChecked ();
(void)state;
store (dabSettings, CONFIG_HANDLER, "audioServices_only", x);
}
2025-01-02 09:41:23 +01:00
void configHandler::handle_tiiCollisions (int value) {
store (dabSettings, CONFIG_HANDLER, "tiiCollisions", value);
process_tiiCollisions (value);
}
2024-12-30 14:51:14 +01:00
void configHandler::handle_tiiFilter (int state) {
bool x = tiiFilter -> isChecked ();
(void)state;
store (dabSettings, CONFIG_HANDLER, "tiiFilter", x ? 1 : 0);
process_tiiFilter (x);
}
2025-01-06 20:47:14 +01:00
void configHandler::handle_tiiSelector (int state) {
bool x = tiiSelector -> isChecked ();
(void)state;
store (dabSettings, CONFIG_HANDLER, "tii-detector", x ? 1 : 0);
tiiCollisions -> setEnabled (x);
2025-01-10 14:24:41 +01:00
if (x)
tiiThreshold_setter -> setMinimum (6);
else
tiiThreshold_setter -> setMinimum (4);
2025-01-06 20:47:14 +01:00
process_tiiSelector (x);
}