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 QString test_notification_path(const QString &key) const;
90 Q_SIGNAL void test_notify(const QString &key);
91
92 // These query methods should be used after a call to exec() to
93 // determine if either the audio input or audio output stream
94 // parameters have changed. The respective streams should be
95 // re-opened if they return true.
96 bool restart_audio_input() const;
97 bool restart_audio_output() const;
98 bool restart_notification_audio_output() const;
99
100 bool use_dynamic_grid() const;
101 QString my_callsign() const;
102 QString my_grid() const;
103 QSet<QString> my_groups() const;
104 void addGroup(QString const &group);
105 void removeGroup(QString const &group);
106 void setMyGroups(QStringList const &groups);
107 void addToHbBlacklist(const QString &callsign);
108 QSet<QString> auto_whitelist() const;
109 QSet<QString> auto_blacklist() const;
110 QSet<QString> hb_blacklist() const;
111 QSet<QString> spot_blacklist() const;
112 QSet<QString> rx_callsign_blocklist() const;
113 QSet<QString> primary_highlight_words() const;
114 QSet<QString> secondary_highlight_words() const;
115 int activity_aging() const;
116 int callsign_aging() const;
117 QString eot() const;
118 QString mfi() const;
119 QString my_info() const;
120 QString my_status() const;
121 QString hb_message() const;
122 QString cq_message() const;
123 QString reply_message() const;
124 QFont table_font() const;
125 QFont text_font() const;
126 QFont rx_text_font() const;
127 QFont tx_text_font() const;
128 QFont compose_text_font() const;
129 double txDelay() const;
130 bool write_logs() const;
131 bool reset_activity() const;
132 bool check_for_updates() const;
133 bool tx_qsy_allowed() const;
134 bool spot_to_reporting_networks() const;
135 void set_spot_to_reporting_networks(bool);
136 bool spot_to_aprs() const;
137 bool spot_to_aprs_relay() const;
138 bool transmit_directed() const;
139 bool autoreply_on_at_startup() const;
140 bool autoreply_confirmation() const;
141 void set_autoreply_confirmation(bool);
142 bool heartbeat_anywhere() const;
143 bool heartbeat_qso_pause() const;
144 bool heartbeat_ack_snr() const;
145 bool hb_rate_limit() const;
146 bool relay_off() const;
147 bool monitor_off_at_startup() const;
148 bool transmit_off_at_startup() const;
149 bool monitor_last_used() const;
150 bool insert_blank() const;
151 bool DXCC() const;
152 bool ppfx() const;
153 bool miles() const;
154 bool hold_ptt() const;
155 bool avoid_forced_identify() const;
156 bool avoid_allcall() const;
157 void set_avoid_allcall(bool avoid);
158 bool spellcheck() const;
159 int heartbeat() const;
160 int watchdog() const;
161 bool TX_messages() const;
162 bool split_mode() const;
163 QString opCall() const;
164 QString ptt_command() const;
165 QString aprs_server_name() const;
166 port_type aprs_server_port() const;
167 QString udp_server_name() const;
168 port_type udp_server_port() const;
169 QString tcp_server_name() const;
170 port_type tcp_server_port() const;
171 QString n1mm_server_name() const;
172 port_type n1mm_server_port() const;
173 bool valid_n1mm_info() const;
174 bool broadcast_to_n1mm() const;
175 QString n3fjp_server_name() const;
176 port_type n3fjp_server_port() const;
177 bool valid_n3fjp_info() const;
178 bool broadcast_to_n3fjp() const;
179 bool accept_udp_requests() const;
180 bool accept_tcp_requests() const;
181 bool udpEnabled() const;
182 bool tcpEnabled() const;
183 // WSJT-X Protocol settings
188 bool wsjtx_protocol_enabled() const;
189
194 QString wsjtx_server_name() const;
195
200 port_type wsjtx_server_port() const;
201
206 int wsjtx_TTL() const;
207
212 bool wsjtx_accept_requests() const;
213
218 QStringList wsjtx_interface_names() const;
219 int tcp_max_connections() const;
220 Bands *bands();
221 Bands const *bands() const;
222 IARURegions::Region region() const;
223 FrequencyList_v3 *frequencies();
224 FrequencyList_v3 const *frequencies() const;
225 StationList *stations();
226 StationList const *stations() const;
227 bool auto_switch_bands() const;
228 QStringListModel *macros();
229 QStringListModel const *macros() const;
230 QDir save_directory() const;
231 QString rig_name() const;
232 QColor color_table_background() const;
233 QColor color_table_highlight() const;
234 QColor color_table_foreground() const;
235 QColor color_primary_highlight() const;
236 QColor color_secondary_highlight() const;
237 QColor color_CQ() const;
238 QColor color_MyCall() const;
239 QColor color_rx_background() const;
240 QColor color_rx_foreground() const;
241 QColor color_tx_foreground() const;
242 QColor color_compose_background() const;
243 QColor color_compose_foreground() const;
244 QColor color_DXCC() const;
245 QColor color_NewCall() const;
246 bool pills_enabled() const;
247 QColor color_pill_recipient_bg() const;
248 QColor color_pill_recipient_fg() const;
249 QColor color_pill_command_bg() const;
250 QColor color_pill_command_fg() const;
251 QColor color_pill_group_bg() const;
252 QColor color_pill_group_fg() const;
253 QColor color_pill_sender_bg() const;
254 QColor color_pill_sender_fg() const;
255 bool pwrBandTxMemory() const;
256 bool pwrBandTuneMemory() const;
257
258 struct CalibrationParams {
259 CalibrationParams() : intercept{0.}, slope_ppm{0.} {}
260
261 CalibrationParams(double the_intercept, double the_slope_ppm)
262 : intercept{the_intercept}, slope_ppm{the_slope_ppm} {}
263
264 double intercept; // Hertz
265 double slope_ppm; // Hertz
266 };
267
268 // Temporarily enable or disable calibration adjustments.
269 void enable_calibration(bool = true);
270
271 // Set the calibration parameters and enable calibration corrections.
272 void set_calibration(CalibrationParams);
273
274 // Set the dynamic grid which is only used if configuration setting is
275 // enabled.
276 void set_dynamic_location(QString const &);
277
278 // Set the dynamic station info message which is only used if configuration
279 // setting is enabled.
280 void set_dynamic_station_info(QString const &info);
281
282 // Set the dynamic station status message which is only used if
283 // configuration setting is enabled.
284 void set_dynamic_station_status(QString const &status);
285
286 // context menu item to block a callsign
287 void add_to_rx_callsign_blocklist(const QString &callsign);
288
289 // This method queries if a CAT and PTT connection is operational.
290 bool is_transceiver_online() const;
291
292 // Start the rig connection, safe and normal to call when rig is
293 // already open.
294 bool transceiver_online();
295
296 // check if a real rig is configured
297 bool is_dummy_rig() const;
298
299 // Frequency resolution of the rig
300 //
301 // 0 - 1Hz
302 // 1 - 10Hz rounded
303 // -1 - 10Hz truncated
304 // 2 - 100Hz rounded
305 // -2 - 100Hz truncated
306 int transceiver_resolution() const;
307
308 // Close down connection to rig.
309 void transceiver_offline();
310
311 // Set transceiver frequency in Hertz.
312 Q_SLOT void transceiver_frequency(Frequency);
313
314 // Setting a non zero TX frequency means split operation
315 // rationalise_mode means ensure TX uses same mode as RX.
316 Q_SLOT void transceiver_tx_frequency(Frequency = 0u);
317
318 // Set transceiver mode.
319 //
320 // Rationalise means ensure TX uses same mode as RX.
321 Q_SLOT void transceiver_mode(MODE);
322
323 // Set/unset PTT.
324 //
325 // Note that this must be called even if VOX PTT is selected since
326 // the "Emulate Split" mode requires PTT information to coordinate
327 // frequency changes.
328 Q_SLOT void transceiver_ptt(bool = true);
329
330 // Attempt to (re-)synchronise transceiver state.
331 //
332 // Force signal guarantees either a transceiver_update or a
333 // transceiver_failure signal.
334 //
335 // The enforce_mode_and_split parameter ensures that future
336 // transceiver updates have the correct mode and split setting
337 // i.e. the transceiver is ready for use.
338 Q_SLOT void sync_transceiver(bool force_signal = false,
339 bool enforce_mode_and_split = false);
340
341 Q_SLOT void invalidate_audio_input_device(QString error);
342 Q_SLOT void invalidate_audio_output_device(QString error);
343 Q_SLOT void invalidate_notification_audio_output_device(QString error);
344
345 //
346 // These signals indicate a font has been selected and accepted for
347 // the application text and decoded text respectively.
348 //
349 Q_SIGNAL void gui_text_font_changed(QFont);
350 Q_SIGNAL void tx_text_font_changed(QFont);
351 Q_SIGNAL void rx_text_font_changed(QFont);
352 Q_SIGNAL void compose_text_font_changed(QFont);
353 Q_SIGNAL void table_font_changed(QFont);
354 Q_SIGNAL void colors_changed();
355
356 //
357 // This signal is emitted when the UDP & TCP server changes
358 //
359 Q_SIGNAL void udp_server_name_changed(QString const &name);
360 Q_SIGNAL void udp_server_port_changed(port_type port);
361 Q_SIGNAL void tcp_server_changed(QString const &host);
362 Q_SIGNAL void tcp_server_port_changed(port_type port);
363 Q_SIGNAL void tcp_max_connections_changed(int n);
364
365 Q_SIGNAL void spot_to_aprs_relay_changed(bool enabled);
366
367 // WSJT-X Protocol signals
372 Q_SIGNAL void wsjtx_protocol_enabled_changed(bool) const;
373
378 Q_SIGNAL void wsjtx_server_changed(QString const &) const;
379
384 Q_SIGNAL void wsjtx_server_port_changed(port_type) const;
385
390 Q_SIGNAL void wsjtx_TTL_changed(int) const;
391
396 Q_SIGNAL void wsjtx_interfaces_changed(QStringList const &) const;
397
398 // This signal is emitted when the band schedule changes
399 Q_SIGNAL void band_schedule_changed(StationList &stations);
400
401 // This signal is emitted when the auto switch bands choice changes
402 Q_SIGNAL void auto_switch_bands_changed(bool auto_switch_bands);
403
404 // This signal is emitted when the user requests a manual station hop
405 Q_SIGNAL void manual_band_hop_requested(StationList::Station const station);
406
407 //
408 // These signals are emitted and reflect transceiver state changes
409 //
410
411 // signals a change in one of the TransceiverState members
412 Q_SIGNAL void
413 transceiver_update(Transceiver::TransceiverState const &) const;
414
415 // Signals a failure of a control rig CAT or PTT connection.
416 //
417 // A failed rig CAT or PTT connection is fatal and the underlying
418 // connections are closed automatically. The connections can be
419 // re-established with a call to transceiver_online(true) assuming
420 // the fault condition has been rectified or is transient.
421 Q_SIGNAL void transceiver_failure(QString const &reason) const;
422
423 // signal announces audio devices are being enumerated
424 //
425 // As this can take some time, particularly on Linux, consumers
426 // might like to notify the user.
427 Q_SIGNAL void enumerating_audio_devices();
428
429 private:
430 class impl;
431 pimpl<impl> m_;
432};
433
434#if QT_VERSION < 0x050500
435Q_DECLARE_METATYPE(Configuration::DataMode);
436#endif
437
438#if !defined(QT_NO_DEBUG_STREAM)
439ENUM_QDEBUG_OPS_DECL(Configuration, DataMode);
440#endif
441
442ENUM_QDATASTREAM_OPS_DECL(Configuration, DataMode);
443
444ENUM_CONVERSION_OPS_DECL(Configuration, DataMode);
445
446#endif
Definition Bands.h:30
Definition Configuration.cpp:375
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: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:258
Definition StationList.h:50