10 #include <QToolButton>
13 #include "ui_audionotificationcomponent.h"
22 using namespace swift::core::context;
24 using namespace swift::misc::aviation;
25 using namespace swift::misc::audio;
26 using namespace swift::misc::physical_quantities;
30 CAudioNotificationComponent::CAudioNotificationComponent(QWidget *parent)
38 QPointer<CAudioNotificationComponent> myself(
this);
45 void CAudioNotificationComponent::init()
48 this->reloadSettings();
51 bool c = connect(ui->cb_SetupAudioPTTClickDown, &QCheckBox::toggled,
this,
52 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
54 c = connect(ui->cb_SetupAudioPTTClickUp, &QCheckBox::toggled,
this,
55 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
57 c = connect(ui->cb_SetupAudioNotificationTextMessageFrequency, &QCheckBox::toggled,
this,
58 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
60 c = connect(ui->cb_SetupAudioNotificationTextMessagePrivate, &QCheckBox::toggled,
this,
61 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
63 c = connect(ui->cb_SetupAudioNotificationTextMessageSupervisor, &QCheckBox::toggled,
this,
64 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
66 c = connect(ui->cb_SetupAudioNotificationTextMessageUnicom, &QCheckBox::toggled,
this,
67 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
69 c = connect(ui->cb_SetupAudioNotificationTextCallsignMentioned, &QCheckBox::toggled,
this,
70 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
72 c = connect(ui->cb_SetupAfvBlocked, &QCheckBox::toggled,
this,
73 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
75 c = connect(ui->cb_SetupAfvClicked, &QCheckBox::toggled,
this,
76 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
78 c = connect(ui->cb_SetupAudioNotificationLogin, &QCheckBox::toggled,
this,
79 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
81 c = connect(ui->cb_SetupAudioNotificationLogoff, &QCheckBox::toggled,
this,
82 &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
84 c = connect(ui->pb_SoundReset, &QPushButton::released,
this,
85 &CAudioNotificationComponent::resetNotificationSoundsDir, Qt::QueuedConnection);
87 c = connect(ui->pb_SoundDir, &QPushButton::released,
this,
88 &CAudioNotificationComponent::selectNotificationSoundsDir, Qt::QueuedConnection);
92 c = connect(ui->sb_NotificationValueVolume, qOverload<int>(&QSpinBox::valueChanged),
this,
93 &CAudioNotificationComponent::onNotificationVolumeChanged);
99 void CAudioNotificationComponent::reloadSettings()
103 ui->cb_SetupAudioPTTClickDown->setChecked(as.isNotificationFlagSet(CNotificationSounds::PTTClickKeyDown));
104 ui->cb_SetupAudioPTTClickUp->setChecked(as.isNotificationFlagSet(CNotificationSounds::PTTClickKeyUp));
106 ui->cb_SetupAudioNotificationTextMessageFrequency->setChecked(
107 as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessageFrequency));
108 ui->cb_SetupAudioNotificationTextMessagePrivate->setChecked(
109 as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessagePrivate));
110 ui->cb_SetupAudioNotificationTextMessageSupervisor->setChecked(
111 as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessageSupervisor));
112 ui->cb_SetupAudioNotificationTextMessageUnicom->setChecked(
113 as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessageUnicom));
114 ui->cb_SetupAudioNotificationTextCallsignMentioned->setChecked(
115 as.isNotificationFlagSet(CNotificationSounds::NotificationTextCallsignMentioned));
117 ui->cb_SetupAfvBlocked->setChecked(as.isNotificationFlagSet(CNotificationSounds::AFVBlocked));
118 ui->cb_SetupAfvClicked->setChecked(as.isNotificationFlagSet(CNotificationSounds::AFVClicked));
120 ui->cb_SetupAudioNotificationLogin->setChecked(
121 as.isNotificationFlagSet(CNotificationSounds::NotificationLogin));
122 ui->cb_SetupAudioNotificationLogoff->setChecked(
123 as.isNotificationFlagSet(CNotificationSounds::NotificationLogoff));
125 ui->le_SoundDir->setText(as.getNotificationSoundDirectory());
126 ui->sb_NotificationValueVolume->setValue(as.getNotificationVolume());
129 void CAudioNotificationComponent::onNotificationVolumeChanged(
int volume)
131 volume = qMax(25, qMin(100, volume));
133 if (as.getNotificationVolume() == volume) {
return; }
134 as.setNotificationVolume(volume);
135 m_audioSettings.
set(as);
140 if (!cb) {
return CNotificationSounds::NoNotifications; }
142 if (cb == ui->cb_SetupAudioPTTClickDown) {
return CNotificationSounds::PTTClickKeyDown; }
143 if (cb == ui->cb_SetupAudioPTTClickUp) {
return CNotificationSounds::PTTClickKeyUp; }
145 if (cb == ui->cb_SetupAudioNotificationTextCallsignMentioned)
147 return CNotificationSounds::NotificationTextCallsignMentioned;
149 if (cb == ui->cb_SetupAudioNotificationTextMessageFrequency)
151 return CNotificationSounds::NotificationTextMessageFrequency;
153 if (cb == ui->cb_SetupAudioNotificationTextMessagePrivate)
155 return CNotificationSounds::NotificationTextMessagePrivate;
157 if (cb == ui->cb_SetupAudioNotificationTextMessageSupervisor)
159 return CNotificationSounds::NotificationTextMessageSupervisor;
161 if (cb == ui->cb_SetupAudioNotificationTextMessageUnicom)
163 return CNotificationSounds::NotificationTextMessageUnicom;
166 if (cb == ui->cb_SetupAfvBlocked) {
return CNotificationSounds::AFVBlocked; }
167 if (cb == ui->cb_SetupAfvClicked) {
return CNotificationSounds::AFVClicked; }
169 if (cb == ui->cb_SetupAudioNotificationLogin) {
return CNotificationSounds::NotificationLogin; }
170 if (cb == ui->cb_SetupAudioNotificationLogoff) {
return CNotificationSounds::NotificationLogoff; }
172 return CNotificationSounds::NoNotifications;
175 void CAudioNotificationComponent::onNotificationsToggled(
bool checked)
180 as.setNotificationFlag(CNotificationSounds::PTTClickKeyDown, ui->cb_SetupAudioPTTClickDown->isChecked());
181 as.setNotificationFlag(CNotificationSounds::PTTClickKeyUp, ui->cb_SetupAudioPTTClickUp->isChecked());
183 as.setNotificationFlag(CNotificationSounds::NotificationTextMessageFrequency,
184 ui->cb_SetupAudioNotificationTextMessageFrequency->isChecked());
185 as.setNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate,
186 ui->cb_SetupAudioNotificationTextMessagePrivate->isChecked());
187 as.setNotificationFlag(CNotificationSounds::NotificationTextMessageSupervisor,
188 ui->cb_SetupAudioNotificationTextMessageSupervisor->isChecked());
189 as.setNotificationFlag(CNotificationSounds::NotificationTextMessageUnicom,
190 ui->cb_SetupAudioNotificationTextMessageUnicom->isChecked());
191 as.setNotificationFlag(CNotificationSounds::NotificationTextCallsignMentioned,
192 ui->cb_SetupAudioNotificationTextCallsignMentioned->isChecked());
194 as.setNotificationFlag(CNotificationSounds::AFVBlocked, ui->cb_SetupAfvBlocked->isChecked());
195 as.setNotificationFlag(CNotificationSounds::AFVClicked, ui->cb_SetupAfvClicked->isChecked());
197 as.setNotificationFlag(CNotificationSounds::NotificationLogin, ui->cb_SetupAudioNotificationLogin->isChecked());
198 as.setNotificationFlag(CNotificationSounds::NotificationLogoff,
199 ui->cb_SetupAudioNotificationLogoff->isChecked());
204 const QCheckBox *sender = qobject_cast<const QCheckBox *>(QObject::sender());
212 void CAudioNotificationComponent::selectNotificationSoundsDir()
217 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
224 CLogMessage::preformatted(m);
228 void CAudioNotificationComponent::resetNotificationSoundsDir()
233 CLogMessage::preformatted(m);
234 ui->le_SoundDir->clear();
const context::IContextAudio * getIContextAudio() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
const context::CContextAudioBase * getCContextAudioBase() const
Direct access to contexts if a CCoreFacade has been initialized.
void playNotification(swift::misc::audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume=-1)
Notification sounds.
Audio component, volume, ...
~CAudioNotificationComponent()
Destructor.
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
CStatusMessage set(const T &value, qint64 timestamp=0)
Write a new value. Must be called from the thread in which the owner lives.
const T & getThreadLocal() const
Read the current value.
T get() const
Get a copy of the current value.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
Streamable status message, e.g.
Value object encapsulating information of audio related settings.
void setNotificationSoundDirectory(const QString &dir)
Directory.
const QString & getNotificationSoundDirectory() const
Notification directory.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
NotificationFlag
Play notification.