swift
audiodevicevolumesetupcomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_AUDIODEVICEVOLUMESETUPCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_AUDIODEVICEVOLUMESETUPCOMPONENT_H
8 
9 #include <QCheckBox>
10 #include <QFrame>
11 #include <QObject>
12 #include <QScopedPointer>
13 
14 #include "gui/swiftguiexport.h"
18 #include "misc/connectionguard.h"
19 #include "misc/digestsignal.h"
20 #include "misc/settingscache.h"
21 
22 namespace Ui
23 {
24  class CAudioDeviceVolumeSetupComponent;
25 }
26 namespace swift::core::afv::clients
27 {
28  class CAfvClient;
29 }
30 namespace swift::gui::components
31 {
34  {
35  Q_OBJECT
36 
37  public:
39  explicit CAudioDeviceVolumeSetupComponent(QWidget *parent = nullptr);
40 
43 
46  int getInValue(int from = swift::misc::audio::CSettings::InMin,
48  int getOutValue(int from = swift::misc::audio::CSettings::OutMin,
50  int getOutValueCom1(int from = swift::misc::audio::CSettings::OutMin,
52  int getOutValueCom2(int from = swift::misc::audio::CSettings::OutMin,
55 
58  void setInValue(int value, int from = swift::misc::audio::CSettings::InMin,
60  void setOutValue(int value, int from = swift::misc::audio::CSettings::InMin,
62  void setOutValueCom1(int value, int from = swift::misc::audio::CSettings::OutMin,
64  void setOutValueCom2(int value, int from = swift::misc::audio::CSettings::OutMin,
67 
70  void setInLevel(double value);
71  void setOutLevel(double value);
73 
74  private:
76  void init();
77 
79  void initWithAfvClient();
80 
82  void reloadSettings();
83 
86  void onAudioDeviceSelected(int index);
87 
89  void onAudioStarted(const swift::misc::audio::CAudioDeviceInfo &input,
91 
93  void onAudioStopped();
94 
96  bool onAudioDevicesChanged(const swift::misc::audio::CAudioDeviceInfoList &devices);
97 
99  void onLoopbackToggled(bool loopback);
100 
102  void onDisableAudioEffectsToggled(bool disabled);
103 
105  void initAudioDeviceLists();
106 
108  bool hasAudio() const;
109 
111  bool hasSimulator() const;
112 
114  void onVolumeSliderChanged(int v);
115 
117  void saveVolumes();
118 
119  void onOutputVU(double vu);
120  void onInputVU(double vu);
121 
122  void onReloadDevices();
123  void onResetVolumeIn();
124  void onResetVolumeOut();
125  void onResetVolumeOutCom1();
126  void onResetVolumeOutCom2();
127 
128  void showAudioRunsWhereDialog();
129 
130  bool isComIntegrated() const;
131 
132  void onRxTxChanged(bool checked);
133  void setRxTxCheckboxes(bool rx1, bool tx1, bool rx2, bool tx2);
134 
135  // TODO: Move TransceiverReceivingCallsignsChangedArgs to Misc
136  void onReceivingCallsignsChanged(const swift::misc::aviation::CCallsignSet &com1Callsigns,
137  const swift::misc::aviation::CCallsignSet &com2Callsigns);
138  void onUpdatedClientWithCockpitData();
139 
140  swift::misc::audio::CAudioDeviceInfo getSelectedInputDevice() const;
141  swift::misc::audio::CAudioDeviceInfo getSelectedOutputDevice() const;
142 
145  void setTransmitReceiveInUi(bool tx1, bool rec1, bool tx2, bool rec2, bool integrated);
146  void setTransmitReceiveInUiFromVoiceClient();
148 
150  void setCheckBoxesReadOnly(bool readonly);
151 
153  void setVolumeSlidersReadOnly(bool readonly);
154 
156  static swift::core::afv::clients::CAfvClient *afvClient();
157 
158  bool m_init = false;
159  swift::misc::CConnectionGuard m_afvConnections;
162  swift::misc::CDigestSignal m_volumeSliderChanged { this, &CAudioDeviceVolumeSetupComponent::saveVolumes,
163  std::chrono::milliseconds(1000), 10 };
165  this, &CAudioDeviceVolumeSetupComponent::reloadSettings
166  };
167 
168  private slots:
169  void simulatorSettingsChanged();
170  };
171 } // namespace swift::gui::components
172 
173 #endif // SWIFT_GUI_COMPONENTS_AUDIODEVICEVOLUMESETUPCOMPONENT_H
List of QMetaObject::Connection.
Receive 1..n signals, collect them over time, and resend afer n milliseconds.
Definition: digestsignal.h:18
Value object encapsulating information of a audio device.
Value object encapsulating a list of audio devices.
static constexpr int OutMin
Ranges for audio.
Definition: audiosettings.h:32
static constexpr int OutMax
Ranges for audio.
Definition: audiosettings.h:31
static constexpr int InMin
Ranges for audio.
Definition: audiosettings.h:30
static constexpr int InMax
Ranges for audio.
Definition: audiosettings.h:29
Value object for a set of callsigns.
Definition: callsignset.h:26
High level reusable GUI components.
Definition: aboutdialog.cpp:14
#define SWIFT_GUI_EXPORT
Export a class or function from the library.