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 
42  virtual ~CAudioDeviceVolumeSetupComponent() override;
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 
75  void setInfo(const QString &info);
76 
77  private:
79  void init();
80 
82  void initWithAfvClient();
83 
85  void reloadSettings();
86 
89  void onAudioDeviceSelected(int index);
90 
92  void onAudioStarted(const swift::misc::audio::CAudioDeviceInfo &input,
94 
96  void onAudioStopped();
97 
99  bool onAudioDevicesChanged(const swift::misc::audio::CAudioDeviceInfoList &devices);
100 
102  void onLoopbackToggled(bool loopback);
103 
105  void onDisableAudioEffectsToggled(bool disabled);
106 
108  void initAudioDeviceLists();
109 
111  bool hasAudio() const;
112 
114  bool hasSimulator() const;
115 
117  void onVolumeSliderChanged(int v);
118 
120  void saveVolumes();
121 
122  void onOutputVU(double vu);
123  void onInputVU(double vu);
124 
125  void onReloadDevices();
126  void onResetVolumeIn();
127  void onResetVolumeOut();
128  void onResetVolumeOutCom1();
129  void onResetVolumeOutCom2();
130 
131  void setAudioRunsWhere();
132 
133  bool isComIntegrated() const;
134 
135  void onRxTxChanged(bool checked);
136  void setRxTxCheckboxes(bool rx1, bool tx1, bool rx2, bool tx2);
137 
138  // TODO: Move TransceiverReceivingCallsignsChangedArgs to Misc
139  void onReceivingCallsignsChanged(const swift::misc::aviation::CCallsignSet &com1Callsigns,
140  const swift::misc::aviation::CCallsignSet &com2Callsigns);
141  void onUpdatedClientWithCockpitData();
142 
143  swift::misc::audio::CAudioDeviceInfo getSelectedInputDevice() const;
144  swift::misc::audio::CAudioDeviceInfo getSelectedOutputDevice() const;
145 
148  void setTransmitReceiveInUi(bool tx1, bool rec1, bool tx2, bool rec2, bool integrated);
149  void setTransmitReceiveInUiFromVoiceClient();
151 
153  void setCheckBoxesReadOnly(bool readonly);
154 
156  void setVolumeSlidersReadOnly(bool readonly);
157 
159  static swift::core::afv::clients::CAfvClient *afvClient();
160 
161  bool m_init = false;
162  swift::misc::CConnectionGuard m_afvConnections;
163  QScopedPointer<Ui::CAudioDeviceVolumeSetupComponent> ui;
165  swift::misc::CDigestSignal m_volumeSliderChanged { this, &CAudioDeviceVolumeSetupComponent::saveVolumes,
166  std::chrono::milliseconds(1000), 10 };
168  this, &CAudioDeviceVolumeSetupComponent::reloadSettings
169  };
170 
171  private slots:
172  void simulatorSettingsChanged();
173  };
174 } // namespace swift::gui::components
175 
176 #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:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.