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