mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 20:55:42 +08:00
refs #129 , updated GUI to play notification sounds:
* prepared for login/off sounds * prepared for text message sounds * helper method to play sounds * enabled mute / mixer also in cockpit, including context menus * settings for notification sounds * some minor tweaks, e.g. changed signal/slot to C++ style where missing
This commit is contained in:
@@ -215,7 +215,6 @@ void MainWindow::toggleNetworkConnection()
|
|||||||
mode = INetwork::LoginAsObserver;
|
mode = INetwork::LoginAsObserver;
|
||||||
this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode"));
|
this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode"));
|
||||||
}
|
}
|
||||||
|
|
||||||
msgs = this->m_contextNetwork->connectToNetwork(static_cast<uint>(mode));
|
msgs = this->m_contextNetwork->connectToNetwork(static_cast<uint>(mode));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -296,6 +295,22 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to)
|
|||||||
this->startUpdateTimers();
|
this->startUpdateTimers();
|
||||||
else if (newStatus == INetwork::Disconnecting || newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
|
else if (newStatus == INetwork::Disconnecting || newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
|
||||||
this->stopUpdateTimers();
|
this->stopUpdateTimers();
|
||||||
|
|
||||||
|
// sounds
|
||||||
|
switch (newStatus)
|
||||||
|
{
|
||||||
|
case INetwork::Connected:
|
||||||
|
this->playNotifcationSound(BlackSound::CSoundGenerator::NotificationLogin);
|
||||||
|
break;
|
||||||
|
case INetwork::Disconnected:
|
||||||
|
this->playNotifcationSound(BlackSound::CSoundGenerator::NotificationLogoff);
|
||||||
|
break;
|
||||||
|
case INetwork::DisconnectedError:
|
||||||
|
this->playNotifcationSound(BlackSound::CSoundGenerator::NotificationError);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -307,6 +307,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
void audioTestUpdate();
|
void audioTestUpdate();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Play notifcation sound
|
||||||
|
*/
|
||||||
|
void playNotifcationSound(BlackSound::CSoundGenerator::Notification notification) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ QStatusBar QLabel {
|
|||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>7</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="pg_StatusPage">
|
<widget class="QWidget" name="pg_StatusPage">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -540,7 +540,7 @@ QStatusBar QLabel {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="lbl_VoiceStatus">
|
<widget class="QLabel" name="lbl_StatusVoiceStatus">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
@@ -564,8 +564,8 @@ QStatusBar QLabel {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>326</width>
|
<width>86</width>
|
||||||
<height>267</height>
|
<height>59</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -607,8 +607,8 @@ QStatusBar QLabel {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>326</width>
|
<width>90</width>
|
||||||
<height>267</height>
|
<height>55</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -1387,22 +1387,6 @@ QStatusBar QLabel {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4">
|
|
||||||
<spacer name="vs_CockpitTransponder">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>28</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
<widget class="QComboBox" name="cb_CockpitTransponderMode">
|
<widget class="QComboBox" name="cb_CockpitTransponderMode">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -1459,8 +1443,24 @@ QStatusBar QLabel {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4">
|
<item row="2" column="4" alignment="Qt::AlignRight">
|
||||||
<spacer name="vs_CockpitSelcal">
|
<widget class="QLabel" name="lbl_CockpitVoiceStatus">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../../src/blackgui/blackgui.qrc">:/blackgui/icons/audiovolumelow.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="4">
|
||||||
|
<spacer name="vs_CockpitTransponder">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -2224,21 +2224,14 @@ QStatusBar QLabel {
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="lbl_SettingsAudioTestActionAndResult">
|
<widget class="QLabel" name="lbl_SettingsAudioTestActionAndResult">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Result</string>
|
<string>Result</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QProgressBar" name="prb_SettingsAudioTestProgress">
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QPlainTextEdit" name="pte_SettingsAudioTestActionAndResult">
|
<widget class="QPlainTextEdit" name="pte_SettingsAudioTestActionAndResult">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -2251,6 +2244,47 @@ QStatusBar QLabel {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QProgressBar" name="prb_SettingsAudioTestProgress">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<spacer name="vs_SettingsAudioMisc">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<widget class="QCheckBox" name="cb_SettingsAudioPlayNotificationSounds">
|
||||||
|
<property name="text">
|
||||||
|
<string>play notification sounds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QCheckBox" name="cb_SettingsAudioNotificationTextMessage">
|
||||||
|
<property name="text">
|
||||||
|
<string>notification for text messages</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="lbl_SettingsAudioNotificationSounds">
|
||||||
|
<property name="text">
|
||||||
|
<string>Notification sounds</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
|||||||
QPushButton *closeIcon = new QPushButton(this);
|
QPushButton *closeIcon = new QPushButton(this);
|
||||||
closeIcon->setStyleSheet("margin: 0; padding: 0; background: transparent;");
|
closeIcon->setStyleSheet("margin: 0; padding: 0; background: transparent;");
|
||||||
closeIcon->setIcon(QIcon(":/blackgui/icons/close.png"));
|
closeIcon->setIcon(QIcon(":/blackgui/icons/close.png"));
|
||||||
QObject::connect(closeIcon, SIGNAL(clicked()), this, SLOT(close()));
|
QObject::connect(closeIcon, &QPushButton::clicked, this, &QMainWindow::close);
|
||||||
menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft);
|
menuBarLayout->addWidget(this->ui->mb_MainMenuBar, 0, Qt::AlignTop | Qt::AlignLeft);
|
||||||
menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight);
|
menuBarLayout->addWidget(closeIcon, 0, Qt::AlignTop | Qt::AlignRight);
|
||||||
this->ui->vl_CentralWidgetOutside->insertLayout(0, menuBarLayout, 0);
|
this->ui->vl_CentralWidgetOutside->insertLayout(0, menuBarLayout, 0);
|
||||||
|
|||||||
@@ -53,8 +53,10 @@ void MainWindow::menuClicked()
|
|||||||
*/
|
*/
|
||||||
void MainWindow::initContextMenus()
|
void MainWindow::initContextMenus()
|
||||||
{
|
{
|
||||||
this->ui->lbl_VoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this->ui->lbl_VoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
|
this->ui->lbl_CockpitVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(this->ui->lbl_StatusVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
|
||||||
|
connect(this->ui->lbl_CockpitVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
|
||||||
this->ui->tv_StatusMessages->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->ui->tv_StatusMessages->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this->ui->tv_StatusMessages, &QTableView::customContextMenuRequested, this, &MainWindow::messageListContextMenu);
|
connect(this->ui->tv_StatusMessages, &QTableView::customContextMenuRequested, this, &MainWindow::messageListContextMenu);
|
||||||
}
|
}
|
||||||
@@ -65,7 +67,9 @@ void MainWindow::initContextMenus()
|
|||||||
void MainWindow::audioIconContextMenu(const QPoint &position)
|
void MainWindow::audioIconContextMenu(const QPoint &position)
|
||||||
{
|
{
|
||||||
// position for most widgets
|
// position for most widgets
|
||||||
QPoint globalPosition = this->ui->lbl_VoiceStatus->mapToGlobal(position);
|
QWidget *sender = qobject_cast<QWidget *>(QWidget::sender());
|
||||||
|
Q_ASSERT(sender);
|
||||||
|
QPoint globalPosition = sender->mapToGlobal(position);
|
||||||
|
|
||||||
if (!this->m_contextMenuAudio)
|
if (!this->m_contextMenuAudio)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ void MainWindow::reloadSettings()
|
|||||||
this->m_trafficServerList->update(nws.getTrafficNetworkServers());
|
this->m_trafficServerList->update(nws.getTrafficNetworkServers());
|
||||||
this->ui->tv_SettingsTnServers->resizeColumnsToContents();
|
this->ui->tv_SettingsTnServers->resizeColumnsToContents();
|
||||||
this->ui->tv_SettingsTnServers->resizeRowsToContents();
|
this->ui->tv_SettingsTnServers->resizeRowsToContents();
|
||||||
|
|
||||||
|
// fake setting for sound notifications
|
||||||
|
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
|
||||||
|
this->ui->cb_SettingsAudioNotificationTextMessage->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -153,6 +153,9 @@ void MainWindow::addPrivateChannelTextMessage(const CTextMessage &textMessage, b
|
|||||||
Q_ASSERT(textEdit != nullptr);
|
Q_ASSERT(textEdit != nullptr);
|
||||||
if (textEdit == nullptr) return; // do not crash, though this situation could not happen
|
if (textEdit == nullptr) return; // do not crash, though this situation could not happen
|
||||||
textEdit->append(textMessage.asString(true, false, "\t"));
|
textEdit->append(textMessage.asString(true, false, "\t"));
|
||||||
|
|
||||||
|
// sound
|
||||||
|
this->playNotifcationSound(BlackSound::CSoundGenerator::NotificationTextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
#include "blackcore/dbus_server.h"
|
#include "blackcore/dbus_server.h"
|
||||||
#include "blackcore/context_network.h"
|
#include "blackcore/context_network.h"
|
||||||
#include "blackcore/context_voice.h"
|
#include "blackcore/context_voice.h"
|
||||||
|
#include "blacksound/soundgenerator.h"
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
|
using namespace BlackSound;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
using namespace BlackMisc::Voice;
|
using namespace BlackMisc::Voice;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
@@ -136,7 +138,8 @@ void MainWindow::audioVolumes()
|
|||||||
com1.setEnabled(!muted);
|
com1.setEnabled(!muted);
|
||||||
com2.setEnabled(!muted);
|
com2.setEnabled(!muted);
|
||||||
this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute");
|
this->ui->pb_SoundMute->setText(muted ? "Unmute" : "Mute");
|
||||||
this->ui->lbl_VoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh);
|
this->ui->lbl_StatusVoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh);
|
||||||
|
this->ui->lbl_CockpitVoiceStatus->setPixmap(muted ? this->m_resPixmapVoiceMuted : this->m_resPixmapVoiceHigh);
|
||||||
this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : "");
|
this->ui->pb_SoundMute->setStyleSheet(muted ? "background-color: red;" : "");
|
||||||
if (muted) this->displayOverlayInfo("Sound is muted!");
|
if (muted) this->displayOverlayInfo("Sound is muted!");
|
||||||
|
|
||||||
@@ -227,3 +230,14 @@ void MainWindow::audioTestUpdate()
|
|||||||
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
|
this->ui->prb_SettingsAudioTestProgress->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Notification
|
||||||
|
*/
|
||||||
|
void MainWindow::playNotifcationSound(CSoundGenerator::Notification notification) const
|
||||||
|
{
|
||||||
|
if (!this->m_contextVoiceAvailable) return;
|
||||||
|
if (!this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked()) return;
|
||||||
|
if (notification == CSoundGenerator::NotificationTextMessage && !this->ui->cb_SettingsAudioNotificationTextMessage->isChecked()) return;
|
||||||
|
this->m_contextVoice->playNotification(static_cast<uint>(notification));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user