Ref T731, UI components for notifications and volume/device

* changed version without voice rooms
* notifications only
* volume and devices
This commit is contained in:
Klaus Basan
2019-09-20 01:54:24 +02:00
committed by Mat Sutcliffe
parent b3cceaa76b
commit 74bea4959e
7 changed files with 870 additions and 38 deletions

View File

@@ -0,0 +1,174 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "blackcore/context/contextaudio.h"
#include "blackgui/components/audiodevicevolumesetupcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/audio/audiodeviceinfo.h"
#include "blackmisc/audio/notificationsounds.h"
#include "blackmisc/audio/audiosettings.h"
#include "blackmisc/sequence.h"
#include "ui_audiodevicevolumesetupcomponent.h"
#include <QCheckBox>
#include <QComboBox>
#include <QToolButton>
#include <QtGlobal>
#include <QPointer>
#include <QFileDialog>
using namespace BlackCore;
using namespace BlackCore::Context;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Audio;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackGui
{
namespace Components
{
CAudioDeviceVolumeSetupComponent::CAudioDeviceVolumeSetupComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CAudioDeviceVolumeSetupComponent)
{
ui->setupUi(this);
// deferred init, because in a distributed swift system
// it takes a moment until the settings are sychronized
// this is leading to undesired "save settings" messages and played sounds
QPointer<CAudioDeviceVolumeSetupComponent> myself(this);
QTimer::singleShot(2500, this, [ = ]
{
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
this->init();
});
}
void CAudioDeviceVolumeSetupComponent::init()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
// audio is optional
const bool audio = this->hasAudio();
this->setEnabled(audio);
this->reloadSettings();
bool c = connect(ui->cb_SetupAudioLoopback, &QCheckBox::toggled, this, &CAudioDeviceVolumeSetupComponent::onLoopbackToggled);
Q_ASSERT(c);
if (audio)
{
ui->le_ExtraInfo->setText(audio ? sGui->getIContextAudio()->audioRunsWhereInfo() : "No audio, cannot change.");
this->initAudioDeviceLists();
// default
ui->cb_SetupAudioLoopback->setChecked(sGui->getIContextAudio()->isAudioLoopbackEnabled());
// the connects depend on initAudioDeviceLists
c = connect(ui->cb_SetupAudioInputDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioOutputDevice, qOverload<int>(&QComboBox::currentIndexChanged), this, &CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected);
Q_ASSERT(c);
// context
c = connect(sGui->getIContextAudio(), &IContextAudio::changedAudioDevices, this, &CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(sGui->getIContextAudio(), &IContextAudio::changedSelectedAudioDevices, this, &CAudioDeviceVolumeSetupComponent::onCurrentAudioDevicesChanged, Qt::QueuedConnection);
Q_ASSERT(c);
}
Q_UNUSED(c);
}
CAudioDeviceVolumeSetupComponent::~CAudioDeviceVolumeSetupComponent()
{ }
void CAudioDeviceVolumeSetupComponent::reloadSettings()
{
const CSettings as(m_audioSettings.getThreadLocal());
}
void CAudioDeviceVolumeSetupComponent::initAudioDeviceLists()
{
if (!this->hasAudio()) { return; }
this->onAudioDevicesChanged(sGui->getIContextAudio()->getAudioDevices());
this->onCurrentAudioDevicesChanged(sGui->getIContextAudio()->getCurrentAudioDevices());
}
bool CAudioDeviceVolumeSetupComponent::hasAudio() const
{
return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
}
void CAudioDeviceVolumeSetupComponent::onAudioDeviceSelected(int index)
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
if (index < 0) { return; }
CAudioDeviceInfoList devices = sGui->getIContextAudio()->getAudioDevices();
if (devices.isEmpty()) { return; }
CAudioDeviceInfo selectedDevice;
const QObject *sender = QObject::sender();
if (sender == ui->cb_SetupAudioInputDevice)
{
const CAudioDeviceInfoList inputDevices = devices.getInputDevices();
if (index >= inputDevices.size()) { return; }
selectedDevice = inputDevices[index];
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
}
else if (sender == ui->cb_SetupAudioOutputDevice)
{
const CAudioDeviceInfoList outputDevices = devices.getOutputDevices();
if (index >= outputDevices.size()) { return; }
selectedDevice = outputDevices[index];
sGui->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
}
}
void CAudioDeviceVolumeSetupComponent::onCurrentAudioDevicesChanged(const CAudioDeviceInfoList &devices)
{
for (auto &device : devices)
{
if (device.getType() == CAudioDeviceInfo::InputDevice)
{
ui->cb_SetupAudioInputDevice->setCurrentText(device.toQString(true));
}
else if (device.getType() == CAudioDeviceInfo::OutputDevice)
{
ui->cb_SetupAudioOutputDevice->setCurrentText(device.toQString(true));
}
}
}
void CAudioDeviceVolumeSetupComponent::onAudioDevicesChanged(const CAudioDeviceInfoList &devices)
{
ui->cb_SetupAudioOutputDevice->clear();
ui->cb_SetupAudioInputDevice->clear();
for (const CAudioDeviceInfo &device : devices)
{
if (device.getType() == CAudioDeviceInfo::InputDevice)
{
ui->cb_SetupAudioInputDevice->addItem(device.toQString(true));
}
else if (device.getType() == CAudioDeviceInfo::OutputDevice)
{
ui->cb_SetupAudioOutputDevice->addItem(device.toQString(true));
}
}
}
void CAudioDeviceVolumeSetupComponent::onLoopbackToggled(bool loopback)
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
if (sGui->getIContextAudio()->isAudioLoopbackEnabled() == loopback) { return; }
sGui->getIContextAudio()->enableAudioLoopback(loopback);
}
} // namespace
} // namespace

View File

@@ -0,0 +1,76 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_AUDIODEVICEVOLUMESETUPCOMPONENT_H
#define BLACKGUI_COMPONENTS_AUDIODEVICEVOLUMESETUPCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/audio/audiosettings.h"
#include "blackmisc/audio/audiodeviceinfolist.h"
#include "blackmisc/settingscache.h"
#include <QFrame>
#include <QCheckBox>
#include <QObject>
#include <QScopedPointer>
namespace Ui { class CAudioDeviceVolumeSetupComponent; }
namespace BlackGui
{
namespace Components
{
//! Audio setup such as input / output devices
class BLACKGUI_EXPORT CAudioDeviceVolumeSetupComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CAudioDeviceVolumeSetupComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CAudioDeviceVolumeSetupComponent() override;
private:
//! Init
void init();
//! Reload settings
void reloadSettings();
//! Audio device selected
//! \param index audio device index (COM1, COM2)
void onAudioDeviceSelected(int index);
//! Current audio devices changed
void onCurrentAudioDevicesChanged(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
//! Audio devices changed
void onAudioDevicesChanged(const BlackMisc::Audio::CAudioDeviceInfoList &devices);
//! Loopback toggled
void onLoopbackToggled(bool loopback);
//! Notification flags toggled
void onNotificationsToggled(bool checked);
//! Audio device lists from settings
void initAudioDeviceLists();
//! Audio is optional, check if available
bool hasAudio() const;
QScopedPointer<Ui::CAudioDeviceVolumeSetupComponent> ui;
BlackMisc::CSetting<BlackMisc::Audio::TSettings> m_audioSettings { this, &CAudioDeviceVolumeSetupComponent::reloadSettings };
};
} // namespace
} // namespace
#endif // guard

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAudioDeviceVolumeSetupComponent</class>
<widget class="QFrame" name="CAudioDeviceVolumeSetupComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>216</height>
</rect>
</property>
<property name="windowTitle">
<string>Audio setup</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="le_ExtraInfo">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>extra info goes here</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QProgressBar" name="pb_LevelOut">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cb_SetupAudioOutputDevice">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="lbl_VolumeOut">
<property name="text">
<string>Out</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_SetupAudioInputDevice">
<property name="text">
<string>In</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_SetupAudioOutputDevice">
<property name="text">
<string>Out</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSlider" name="hs_VolumeOut">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="cb_SetupAudioLoopback">
<property name="text">
<string>Loopback, test sound in- to output</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cb_SetupAudioInputDevice">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="pb_LevelIn">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_VolumeIn">
<property name="text">
<string>In</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSlider" name="hs_VolumeIn">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Info">
<property name="text">
<string>Info</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_SetupAudioLoopback">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Disable realistic audio simulation</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>le_ExtraInfo</tabstop>
<tabstop>cb_SetupAudioInputDevice</tabstop>
<tabstop>cb_SetupAudioOutputDevice</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>cb_SetupAudioLoopback</tabstop>
<tabstop>hs_VolumeIn</tabstop>
<tabstop>hs_VolumeOut</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,189 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "blackgui/components/audionotificationcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackcore/context/contextaudio.h"
#include "blackmisc/audio/audiodeviceinfo.h"
#include "blackmisc/audio/notificationsounds.h"
#include "blackmisc/audio/audiosettings.h"
#include "blackmisc/sequence.h"
#include "ui_audionotificationcomponent.h"
#include <QCheckBox>
#include <QComboBox>
#include <QToolButton>
#include <QtGlobal>
#include <QPointer>
#include <QFileDialog>
using namespace BlackCore;
using namespace BlackCore::Context;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Audio;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackGui
{
namespace Components
{
CAudioNotificationComponent::CAudioNotificationComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CAudioNotificationComponent)
{
ui->setupUi(this);
// deferred init, because in a distributed swift system
// it takes a moment until the settings are sychronized
// this is leading to undesired "save settings" messages and played sounds
QPointer<CAudioNotificationComponent> myself(this);
QTimer::singleShot(2500, this, [ = ]
{
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
this->init();
});
}
void CAudioNotificationComponent::init()
{
if (!sGui || sGui->isShuttingDown()) { return; }
this->reloadSettings();
// checkboxes for notifications
bool c = connect(ui->cb_SetupAudioPTTClickDown, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioPTTClickUp, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNotificationVoiceRoomLeft, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNotificationVoiceRoomJoined, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNotificationTextMessagePrivate, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNotificationTextMessageSupervisor, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNotificationTextCallsignMentioned, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->cb_SetupAudioNoTransmission, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->pb_SoundReset, &QPushButton::released, this, &CAudioNotificationComponent::resetNotificationSoundsDir, Qt::QueuedConnection);
Q_ASSERT(c);
c = connect(ui->pb_SoundDir, &QPushButton::released, this, &CAudioNotificationComponent::selectNotificationSoundsDir, Qt::QueuedConnection);
Q_ASSERT(c);
// volumes
c = connect(ui->sb_NotificationValueVolume, qOverload<int>(&QSpinBox::valueChanged), this, &CAudioNotificationComponent::onNotificationVolumeChanged);
Q_ASSERT(c);
}
CAudioNotificationComponent::~CAudioNotificationComponent()
{ }
bool CAudioNotificationComponent::playNotificationSounds() const
{
return ui->cb_SetupAudioPTTClickDown->isChecked() || ui->cb_SetupAudioPTTClickUp->isChecked() ||
ui->cb_SetupAudioNotificationTextMessagePrivate->isChecked() || ui->cb_SetupAudioNotificationTextMessageSupervisor->isChecked() ||
ui->cb_SetupAudioNotificationVoiceRoomLeft->isChecked() || ui->cb_SetupAudioNotificationVoiceRoomJoined->isChecked() ||
ui->cb_SetupAudioNotificationTextCallsignMentioned->isChecked() || ui->cb_SetupAudioNoTransmission->isChecked();
}
void CAudioNotificationComponent::reloadSettings()
{
const CSettings as(m_audioSettings.getThreadLocal());
ui->cb_SetupAudioPTTClickDown->setChecked(as.isNotificationFlagSet(CNotificationSounds::PTTClickKeyDown));
ui->cb_SetupAudioPTTClickUp->setChecked(as.isNotificationFlagSet(CNotificationSounds::PTTClickKeyUp));
ui->cb_SetupAudioNotificationVoiceRoomLeft->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationVoiceRoomLeft));
ui->cb_SetupAudioNotificationVoiceRoomJoined->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationVoiceRoomJoined));
ui->cb_SetupAudioNotificationTextMessagePrivate->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessagePrivate));
ui->cb_SetupAudioNotificationTextMessageSupervisor->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationTextMessageSupervisor));
ui->cb_SetupAudioNotificationTextCallsignMentioned->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationTextCallsignMentioned));
ui->cb_SetupAudioNoTransmission->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationNoAudioTransmission));
ui->le_SoundDir->setText(as.getNotificationSoundDirectory());
ui->sb_NotificationValueVolume->setValue(as.getNotificationVolume());
}
void CAudioNotificationComponent::onNotificationVolumeChanged(int volume)
{
volume = qMax(25, qMin(100, volume));
CSettings as(m_audioSettings.getThreadLocal());
if (as.getNotificationVolume() == volume) { return; }
as.setNotificationVolume(volume);
m_audioSettings.set(as);
}
CNotificationSounds::NotificationFlag CAudioNotificationComponent::checkBoxToFlag(const QCheckBox *cb) const
{
if (!cb) { return CNotificationSounds::NoNotifications; }
if (cb == ui->cb_SetupAudioPTTClickDown) { return CNotificationSounds::PTTClickKeyDown; }
if (cb == ui->cb_SetupAudioPTTClickUp) { return CNotificationSounds::PTTClickKeyUp; }
if (cb == ui->cb_SetupAudioNotificationVoiceRoomJoined) { return CNotificationSounds::NotificationVoiceRoomJoined; }
if (cb == ui->cb_SetupAudioNotificationVoiceRoomLeft) { return CNotificationSounds::NotificationVoiceRoomLeft; }
if (cb == ui->cb_SetupAudioNotificationTextCallsignMentioned) { return CNotificationSounds::NotificationTextCallsignMentioned; }
if (cb == ui->cb_SetupAudioNotificationTextMessagePrivate) { return CNotificationSounds::NotificationTextMessagePrivate; }
if (cb == ui->cb_SetupAudioNotificationTextMessageSupervisor) { return CNotificationSounds::NotificationTextMessageSupervisor; }
if (cb == ui->cb_SetupAudioNoTransmission) { return CNotificationSounds::NotificationNoAudioTransmission; }
return CNotificationSounds::NoNotifications;
}
void CAudioNotificationComponent::onNotificationsToggled(bool checked)
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextAudio()) { return; }
CSettings as(m_audioSettings.getThreadLocal());
as.setNotificationFlag(CNotificationSounds::PTTClickKeyDown, ui->cb_SetupAudioPTTClickDown->isChecked());
as.setNotificationFlag(CNotificationSounds::PTTClickKeyUp, ui->cb_SetupAudioPTTClickUp->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationVoiceRoomLeft, ui->cb_SetupAudioNotificationVoiceRoomLeft->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationVoiceRoomJoined, ui->cb_SetupAudioNotificationVoiceRoomJoined->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate, ui->cb_SetupAudioNotificationTextMessagePrivate->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationTextMessageSupervisor, ui->cb_SetupAudioNotificationTextMessageSupervisor->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationTextCallsignMentioned, ui->cb_SetupAudioNotificationTextCallsignMentioned->isChecked());
as.setNotificationFlag(CNotificationSounds::NotificationNoAudioTransmission, ui->cb_SetupAudioNoTransmission->isChecked());
const CStatusMessage msg = m_audioSettings.set(as);
CLogMessage(this).preformatted(msg);
const QCheckBox *sender = qobject_cast<const QCheckBox *>(QObject::sender());
if (checked && sGui && sGui->getIContextAudio() && sender)
{
const CNotificationSounds::NotificationFlag f = this->checkBoxToFlag(sender);
sGui->getIContextAudio()->playNotification(f, false, as.getNotificationVolume());
}
}
void CAudioNotificationComponent::selectNotificationSoundsDir()
{
CSettings s = m_audioSettings.get();
const QString dir = QFileDialog::getExistingDirectory(this, QStringLiteral("Open directory"), s.getNotificationSoundDirectory(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
const QDir d(dir);
if (d.exists())
{
s.setNotificationSoundDirectory(dir);
ui->le_SoundDir->setText(s.getNotificationSoundDirectory());
const CStatusMessage m = m_audioSettings.setAndSave(s);
CLogMessage::preformatted(m);
}
}
void CAudioNotificationComponent::resetNotificationSoundsDir()
{
CSettings s = m_audioSettings.get();
s.setNotificationSoundDirectory("");
const CStatusMessage m = m_audioSettings.setAndSave(s);
CLogMessage::preformatted(m);
ui->le_SoundDir->clear();
}
} // namespace
} // namespace

View File

@@ -0,0 +1,72 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_AUDIONOTIFICATION_COMPONENT_H
#define BLACKGUI_AUDIONOTIFICATION_COMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackmisc/audio/audiosettings.h"
#include "blackmisc/audio/audiodeviceinfolist.h"
#include "blackmisc/settingscache.h"
#include <QFrame>
#include <QCheckBox>
#include <QObject>
#include <QScopedPointer>
namespace Ui { class CAudioNotificationComponent; }
namespace BlackGui
{
namespace Components
{
//! Audio component, volume, ...
class BLACKGUI_EXPORT CAudioNotificationComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CAudioNotificationComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CAudioNotificationComponent() override;
//! Play any sounds?
bool playNotificationSounds() const;
private:
//! Init
void init();
//! Reload settings
void reloadSettings();
//! Notification flags toggled
void onNotificationsToggled(bool checked);
//! Notification sounds dir
void selectNotificationSoundsDir();
//! Notification sounds dir
void resetNotificationSoundsDir();
//! Volume has been changed
void onNotificationVolumeChanged(int volume);
//! CheckBox to flag
BlackMisc::Audio::CNotificationSounds::NotificationFlag checkBoxToFlag(const QCheckBox *cb) const;
QScopedPointer<Ui::CAudioNotificationComponent> ui;
BlackMisc::CSetting<BlackMisc::Audio::TSettings> m_audioSettings { this, &CAudioNotificationComponent::reloadSettings };
};
} // namespace
} // namespace
#endif // guard

View File

@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAudioNotificationComponent</class>
<widget class="QFrame" name="CAudioNotificationComponent">
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="windowTitle">
<string>Notification</string>
</property>
<layout class="QVBoxLayout" name="vl_AudioComponent">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="sa_AudioComponent">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="sa_AudioComponentInner">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>241</width>
<height>238</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="11" column="1">
<widget class="QCheckBox" name="cb_SetupAudioPTTClickUp">
<property name="text">
<string>PTT click (key up)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_SoundDirectory">
<property name="text">
<string>Dir.:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNoTransmission">
<property name="text">
<string>No audio transmission warning</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationTextCallsignMentioned">
<property name="text">
<string>notfication for text msg. with my callsign</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="cb_SetupAudioPTTClickDown">
<property name="text">
<string>PTT click (key down)</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationTextMessageSupervisor">
<property name="text">
<string>supervisor messages</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="sb_NotificationValueVolume">
<property name="suffix">
<string> volume 25-100 (notifications)</string>
</property>
<property name="minimum">
<number>25</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>90</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationVoiceRoomLeft">
<property name="text">
<string>notification leaving a voice room</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_Notifications">
<property name="toolTip">
<string>Notifications</string>
</property>
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationVoiceRoomJoined">
<property name="text">
<string>notification joining a voice room</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationTextMessagePrivate">
<property name="text">
<string>notification for private text messages</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="wi_SoundDir" native="true">
<layout class="QHBoxLayout" name="hl_SoundDir" stretch="0,0,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="le_SoundDir">
<property name="placeholderText">
<string>your private sound directory</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SoundReset">
<property name="text">
<string>reset</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_SoundDir">
<property name="text">
<string>[...]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>sa_AudioComponent</tabstop>
<tabstop>le_SoundDir</tabstop>
<tabstop>pb_SoundReset</tabstop>
<tabstop>pb_SoundDir</tabstop>
<tabstop>sb_NotificationValueVolume</tabstop>
<tabstop>cb_SetupAudioNotificationTextMessagePrivate</tabstop>
<tabstop>cb_SetupAudioNotificationTextMessageSupervisor</tabstop>
<tabstop>cb_SetupAudioNotificationTextCallsignMentioned</tabstop>
<tabstop>cb_SetupAudioNotificationVoiceRoomJoined</tabstop>
<tabstop>cb_SetupAudioNotificationVoiceRoomLeft</tabstop>
<tabstop>cb_SetupAudioNoTransmission</tabstop>
<tabstop>cb_SetupAudioPTTClickDown</tabstop>
<tabstop>cb_SetupAudioPTTClickUp</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>161</width>
<width>357</width>
<height>55</height>
</rect>
</property>
@@ -42,13 +42,7 @@
</size>
</property>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_CockpitVoiceRooms">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_DeviceVolume">
<property name="floating">
<bool>false</bool>
</property>
@@ -59,12 +53,12 @@
<set>Qt::BottomDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Voice rooms</string>
<string>Devices and volumes</string>
</property>
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
<widget class="QWidget" name="qw_CockpitVoiceRoomsOuter">
<widget class="QWidget" name="qw_DeviceVolumeOuter">
<layout class="QVBoxLayout" name="vl_CockpitVoiceRoomsOuter">
<property name="spacing">
<number>0</number>
@@ -82,7 +76,7 @@
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_CockpitVoiceRoomsInner">
<widget class="QFrame" name="fr_DeviceVolumeInner">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@@ -109,14 +103,7 @@
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CVoiceRoomsComponent" name="comp_VoiceRooms">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="BlackGui::Components::CAudioDeviceVolumeSetupComponent" name="comp_DeviceVolume"/>
</item>
</layout>
</widget>
@@ -124,13 +111,7 @@
</layout>
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Audio">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_AudioNotificaton">
<property name="floating">
<bool>false</bool>
</property>
@@ -141,12 +122,12 @@
<set>Qt::BottomDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Audio</string>
<string>Notifications</string>
</property>
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
<widget class="QWidget" name="qw_AudioOuter">
<widget class="QWidget" name="qw_AudioNotificatonOuter">
<layout class="QVBoxLayout" name="vl_AudioOuter">
<property name="spacing">
<number>0</number>
@@ -164,7 +145,7 @@
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_AudioInner">
<widget class="QFrame" name="fr_AudioNotificatonInner">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
@@ -191,12 +172,9 @@
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CAudioComponent" name="comp_Audio">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<widget class="BlackGui::Components::CAudioNotificationComponent" name="comp_AudioNotificaton">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
@@ -215,15 +193,15 @@
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CVoiceRoomsComponent</class>
<class>BlackGui::Components::CAudioDeviceVolumeSetupComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/voiceroomscomponent.h</header>
<header>blackgui/components/audiodevicevolumesetupcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CAudioComponent</class>
<class>BlackGui::Components::CAudioNotificationComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/audiocomponent.h</header>
<header>blackgui/components/audionotificationcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>