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)
45 void CAudioNotificationComponent::init()
48 this->reloadSettings();
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());
202 CLogMessage::preformatted(msg);
212 void CAudioNotificationComponent::selectNotificationSoundsDir()
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.
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.
QString getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const
NotificationFlag
Play notification.