JS8Call-Improved master
Loading...
Searching...
No Matches
Configuration.h
1#ifndef CONFIGURATION_HPP_
2#define CONFIGURATION_HPP_
3
4#include "JS8_Audio/AudioDevice.h"
5#include "JS8_Include/pimpl_h.h"
6#include "JS8_Main/IARURegions.h"
7#include "JS8_Main/Radio.h"
8#include "JS8_Main/StationList.h"
9#include "JS8_Transceiver/Transceiver.h"
10
11#include <QAction>
12#include <QFont>
13#include <QLineEdit>
14#include <QObject>
15
16#include <utility>
17
18class QSettings;
19class QWidget;
20class QAudioDevice;
21class QString;
22class QDir;
23class Bands;
25class StationList;
26class QStringListModel;
27class QHostAddress;
28
29//
30// Class Configuration
31//
32// Encapsulates the control, access and, persistence of user defined
33// settings for the GUI. Setting values are accessed through a
34// QDialog window containing concept orientated tab windows.
35//
36// Responsibilities
37//
38// Provides management of the CAT and PTT rig interfaces, providing
39// control access via a minimal generic set of Qt slots and status
40// updates via Qt signals. Internally the rig control capability is
41// farmed out to a separate thread since many of the rig control
42// functions are blocking.
43//
44// All user settings required by the GUI are exposed through
45// query methods. Settings only become visible once they have been
46// accepted by the user which is done by clicking the "OK" button on
47// the settings dialog.
48//
49// The QSettings instance passed to the constructor is used to read
50// and write user settings.
51//
52// Pointers to three QAbstractItemModel objects are provided to give
53// access to amateur band information, user working frequencies and,
54// user operating band information. These porovide consistent data
55// models that can be used in GUI lists or tables or simply queried
56// for user defined bands, default operating frequencies and, station
57// descriptions.
58//
59class Configuration final : public QObject {
60 Q_OBJECT
61 Q_ENUMS(DataMode)
62
63 public:
64 using MODE = Transceiver::MODE;
65 using TransceiverState = Transceiver::TransceiverState;
66 using Frequency = Radio::Frequency;
67 using port_type = quint16;
68
69 enum DataMode { data_mode_none, data_mode_USB, data_mode_data };
70 Q_ENUM(DataMode)
71
72 explicit Configuration(QDir const &temp_directory, QSettings *settings,
73 QWidget *parent = nullptr);
74 ~Configuration();
75
76 void select_tab(int);
77 int exec();
78 bool is_active() const;
79
80 QDir temp_dir() const;
81 QDir writeable_data_dir() const;
82
83 QAudioDevice const &audio_input_device() const;
84 AudioDevice::Channel audio_input_channel() const;
85 QAudioDevice const &audio_output_device() const;
86 AudioDevice::Channel audio_output_channel() const;
87 QAudioDevice const &notification_audio_output_device() const;
88
89 bool notifications_enabled() const;
90 QString notification_path(const QString &key) const;
91 QString test_notification_path(const QString &key) const;
92 Q_SIGNAL void test_notify(const QString &key);
93
94 // These query methods should be used after a call to exec() to
95 // determine if either the audio input or audio output stream
96 // parameters have changed. The respective streams should be
97 // re-opened if they return true.
98 bool restart_audio_input() const;
99 bool restart_audio_output() const;
100 bool restart_notification_audio_output() const;
101
102 bool use_dynamic_grid() const;
103 QString my_callsign() const;
104 QString my_grid() const;
105 QSet<QString> my_groups() const;
106 void addGroup(QString const &group);
107 void removeGroup(QString const &group);
108 void setMyGroups(QStringList const &groups);
109 void addToHbBlacklist(const QString &callsign);
110 QSet<QString> auto_whitelist() const;
111 QSet<QString> auto_blacklist() const;
112 QSet<QString> hb_blacklist() const;
113 QSet<QString> spot_blacklist() const;
114 QSet<QString> rx_callsign_blocklist() const;
115 QSet<QString> primary_highlight_words() const;
116 QSet<QString> secondary_highlight_words() const;
117 int activity_aging() const;
118 int callsign_aging() const;
119 QString eot() const;
120 QString mfi() const;
121 QString my_info() const;
122 QString my_status() const;
123 QString hb_message() const;
124 QString cq_message() const;
125 QString reply_message() const;
126 QFont table_font() const;
127 QFont text_font() const;
128 QFont rx_text_font() const;
129 QFont tx_text_font() const;
130 QFont compose_text_font() const;
131 double txDelay() const;
132 bool write_logs() const;
133 bool reset_activity() const;
134 bool check_for_updates() const;
135 bool tx_qsy_allowed() const;
136 bool spot_to_reporting_networks() const;
137 void set_spot_to_reporting_networks(bool);
138 bool spot_to_aprs() const;
139 bool spot_to_aprs_relay() const;
140 bool transmit_directed() const;
141 bool autoreply_on_at_startup() const;
142 bool autoreply_confirmation() const;
143 void set_autoreply_confirmation(bool);
144 bool heartbeat_anywhere() const;
145 bool heartbeat_qso_pause() const;
146 bool heartbeat_ack_snr() const;
147 bool hb_rate_limit() const;
148 bool relay_off() const;
149 bool monitor_off_at_startup() const;
150 bool transmit_off_at_startup() const;
151 bool monitor_last_used() const;
152 bool insert_blank() const;
153 bool DXCC() const;
154 bool ppfx() const;
155 bool miles() const;
156 bool hold_ptt() const;
157 bool avoid_forced_identify() const;
158 bool avoid_allcall() const;
159 void set_avoid_allcall(bool avoid);
160 bool spellcheck() const;
161 int heartbeat() const;
162 int watchdog() const;
163 bool TX_messages() const;
164 bool split_mode() const;
165 QString opCall() const;
166 QString ptt_command() const;
167 QString aprs_server_name() const;
168 port_type aprs_server_port() const;
169 QString udp_server_name() const;
170 port_type udp_server_port() const;
171 QString tcp_server_name() const;
172 port_type tcp_server_port() const;
173 QString n1mm_server_name() const;
174 port_type n1mm_server_port() const;
175 bool valid_n1mm_info() const;
176 bool broadcast_to_n1mm() const;
177 QString n3fjp_server_name() const;
178 port_type n3fjp_server_port() const;
179 bool valid_n3fjp_info() const;
180 bool broadcast_to_n3fjp() const;
181 bool accept_udp_requests() const;
182 bool accept_tcp_requests() const;
183 bool udpEnabled() const;
184 bool tcpEnabled() const;
185 // WSJT-X Protocol settings
190 bool wsjtx_protocol_enabled() const;
191
196 QString wsjtx_server_name() const;
197
202 port_type wsjtx_server_port() const;
203
208 int wsjtx_TTL() const;
209
214 bool wsjtx_accept_requests() const;
215
220 QStringList wsjtx_interface_names() const;
221 int tcp_max_connections() const;
222 Bands *bands();
223 Bands const *bands() const;
224 IARURegions::Region region() const;
225 FrequencyList_v3 *frequencies();
226 FrequencyList_v3 const *frequencies() const;
227 StationList *stations();
228 StationList const *stations() const;
229 bool auto_switch_bands() const;
230 QStringListModel *macros();
231 QStringListModel const *macros() const;
232 QDir save_directory() const;
233 QString rig_name() const;
234 QColor color_table_background() const;
235 QColor color_table_highlight() const;
236 QColor color_table_foreground() const;
237 QColor color_primary_highlight() const;
238 QColor color_secondary_highlight() const;
239 QColor color_CQ() const;
240 QColor color_MyCall() const;
241 QColor color_rx_background() const;
242 QColor color_rx_foreground() const;
243 QColor color_tx_foreground() const;
244 QColor color_compose_background() const;
245 QColor color_compose_foreground() const;
246 QColor color_DXCC() const;
247 QColor color_NewCall() const;
248 bool pills_enabled() const;
249 QColor color_pill_recipient_bg() const;
250 QColor color_pill_recipient_fg() const;
251 QColor color_pill_command_bg() const;
252 QColor color_pill_command_fg() const;
253 QColor color_pill_group_bg() const;
254 QColor color_pill_group_fg() const;
255 QColor color_pill_sender_bg() const;
256 QColor color_pill_sender_fg() const;
257 bool pwrBandTxMemory() const;
258 bool pwrBandTuneMemory() const;
259
260 struct CalibrationParams {
261 CalibrationParams() : intercept{0.}, slope_ppm{0.} {}
262
263 CalibrationParams(double the_intercept, double the_slope_ppm)
264 : intercept{the_intercept}, slope_ppm{the_slope_ppm} {}
265
266 double intercept; // Hertz
267 double slope_ppm; // Hertz
268 };
269
270 // Temporarily enable or disable calibration adjustments.
271 void enable_calibration(bool = true);
272
273 // Set the calibration parameters and enable calibration corrections.
274 void set_calibration(CalibrationParams);
275
276 // Set the dynamic grid which is only used if configuration setting is
277 // enabled.
278 void set_dynamic_location(QString const &);
279
280 // Set the dynamic station info message which is only used if configuration
281 // setting is enabled.
282 void set_dynamic_station_info(QString const &info);
283
284 // Set the dynamic station status message which is only used if
285 // configuration setting is enabled.
286 void set_dynamic_station_status(QString const &status);
287
288 // context menu item to block a callsign
289 void add_to_rx_callsign_blocklist(const QString &callsign);
290
291 // This method queries if a CAT and PTT connection is operational.
292 bool is_transceiver_online() const;
293
294 // Start the rig connection, safe and normal to call when rig is
295 // already open.
296 bool transceiver_online();
297
298 // check if a real rig is configured
299 bool is_dummy_rig() const;
300
301 // Frequency resolution of the rig
302 //
303 // 0 - 1Hz
304 // 1 - 10Hz rounded
305 // -1 - 10Hz truncated
306 // 2 - 100Hz rounded
307 // -2 - 100Hz truncated
308 int transceiver_resolution() const;
309
310 // Close down connection to rig.
311 void transceiver_offline();
312
313 // Set transceiver frequency in Hertz.
314 Q_SLOT void transceiver_frequency(Frequency);
315
316 // Setting a non zero TX frequency means split operation
317 // rationalise_mode means ensure TX uses same mode as RX.
318 Q_SLOT void transceiver_tx_frequency(Frequency = 0u);
319
320 // Set transceiver mode.
321 //
322 // Rationalise means ensure TX uses same mode as RX.
323 Q_SLOT void transceiver_mode(MODE);
324
325 // Set/unset PTT.
326 //
327 // Note that this must be called even if VOX PTT is selected since
328 // the "Emulate Split" mode requires PTT information to coordinate
329 // frequency changes.
330 Q_SLOT void transceiver_ptt(bool = true);
331
332 // Attempt to (re-)synchronise transceiver state.
333 //
334 // Force signal guarantees either a transceiver_update or a
335 // transceiver_failure signal.
336 //
337 // The enforce_mode_and_split parameter ensures that future
338 // transceiver updates have the correct mode and split setting
339 // i.e. the transceiver is ready for use.
340 Q_SLOT void sync_transceiver(bool force_signal = false,
341 bool enforce_mode_and_split = false);
342
343 Q_SLOT void invalidate_audio_input_device(QString error);
344 Q_SLOT void invalidate_audio_output_device(QString error);
345 Q_SLOT void invalidate_notification_audio_output_device(QString error);
346
347 //
348 // These signals indicate a font has been selected and accepted for
349 // the application text and decoded text respectively.
350 //
351 Q_SIGNAL void gui_text_font_changed(QFont);
352 Q_SIGNAL void tx_text_font_changed(QFont);
353 Q_SIGNAL void rx_text_font_changed(QFont);
354 Q_SIGNAL void compose_text_font_changed(QFont);
355 Q_SIGNAL void table_font_changed(QFont);
356 Q_SIGNAL void colors_changed();
357
358 //
359 // This signal is emitted when the UDP & TCP server changes
360 //
361 Q_SIGNAL void udp_server_name_changed(QString const &name);
362 Q_SIGNAL void udp_server_port_changed(port_type port);
363 Q_SIGNAL void tcp_server_changed(QString const &host);
364 Q_SIGNAL void tcp_server_port_changed(port_type port);
365 Q_SIGNAL void tcp_max_connections_changed(int n);
366
367 Q_SIGNAL void spot_to_aprs_relay_changed(bool enabled);
368
369 // WSJT-X Protocol signals
374 Q_SIGNAL void wsjtx_protocol_enabled_changed(bool) const;
375
380 Q_SIGNAL void wsjtx_server_changed(QString const &) const;
381
386 Q_SIGNAL void wsjtx_server_port_changed(port_type) const;
387
392 Q_SIGNAL void wsjtx_TTL_changed(int) const;
393
398 Q_SIGNAL void wsjtx_interfaces_changed(QStringList const &) const;
399
400 // This signal is emitted when the band schedule changes
401 Q_SIGNAL void band_schedule_changed(StationList &stations);
402
403 // This signal is emitted when the auto switch bands choice changes
404 Q_SIGNAL void auto_switch_bands_changed(bool auto_switch_bands);
405
406 // This signal is emitted when the user requests a manual station hop
407 Q_SIGNAL void manual_band_hop_requested(StationList::Station const station);
408
409 //
410 // These signals are emitted and reflect transceiver state changes
411 //
412
413 // signals a change in one of the TransceiverState members
414 Q_SIGNAL void
415 transceiver_update(Transceiver::TransceiverState const &) const;
416
417 // Signals a failure of a control rig CAT or PTT connection.
418 //
419 // A failed rig CAT or PTT connection is fatal and the underlying
420 // connections are closed automatically. The connections can be
421 // re-established with a call to transceiver_online(true) assuming
422 // the fault condition has been rectified or is transient.
423 Q_SIGNAL void transceiver_failure(QString const &reason) const;
424
425 // signal announces audio devices are being enumerated
426 //
427 // As this can take some time, particularly on Linux, consumers
428 // might like to notify the user.
429 Q_SIGNAL void enumerating_audio_devices();
430
431 private:
432 class impl;
433 pimpl<impl> m_;
434};
435
436#if !defined(QT_NO_DEBUG_STREAM)
437ENUM_QDEBUG_OPS_DECL(Configuration, DataMode);
438#endif
439
440ENUM_QDATASTREAM_OPS_DECL(Configuration, DataMode);
441
442ENUM_CONVERSION_OPS_DECL(Configuration, DataMode);
443
444#endif
Definition Bands.h:30
Definition Configuration.cpp:375
Definition Configuration.h:59
Q_SIGNAL void wsjtx_TTL_changed(int) const
Emitted when WSJT-X TTL changes.
bool wsjtx_accept_requests() const
Check if WSJT-X accepts incoming requests.
Definition Configuration.cpp:1016
QStringList wsjtx_interface_names() const
Get selected network interface names for multicast.
Definition Configuration.cpp:1019
port_type wsjtx_server_port() const
Get WSJT-X server UDP port.
Definition Configuration.cpp:1012
bool wsjtx_protocol_enabled() const
Check if WSJT-X protocol is enabled.
Definition Configuration.cpp:1006
Q_SIGNAL void wsjtx_interfaces_changed(QStringList const &) const
Emitted when WSJT-X network interfaces selection changes.
int wsjtx_TTL() const
Get WSJT-X multicast TTL.
Definition Configuration.cpp:1015
QString wsjtx_server_name() const
Get WSJT-X server hostname or IP address.
Definition Configuration.cpp:1009
Q_SIGNAL void wsjtx_protocol_enabled_changed(bool) const
Emitted when WSJT-X protocol enabled state changes.
Q_SIGNAL void wsjtx_server_port_changed(port_type) const
Emitted when WSJT-X server port changes.
Q_SIGNAL void wsjtx_server_changed(QString const &) const
Emitted when WSJT-X server address changes.
Definition FrequencyList.h:40
Definition StationList.h:40
Definition Transceiver.h:83
Definition pimpl_h.h:16
Definition Configuration.h:260
Definition StationList.h:50