mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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;
|
||||
this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode"));
|
||||
}
|
||||
|
||||
msgs = this->m_contextNetwork->connectToNetwork(static_cast<uint>(mode));
|
||||
}
|
||||
else
|
||||
@@ -296,6 +295,22 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to)
|
||||
this->startUpdateTimers();
|
||||
else if (newStatus == INetwork::Disconnecting || newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
|
||||
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();
|
||||
|
||||
/*!
|
||||
* \brief Play notifcation sound
|
||||
*/
|
||||
void playNotifcationSound(BlackSound::CSoundGenerator::Notification notification) const;
|
||||
|
||||
private slots:
|
||||
|
||||
//
|
||||
|
||||
@@ -454,7 +454,7 @@ QStatusBar QLabel {
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_StatusPage">
|
||||
<property name="sizePolicy">
|
||||
@@ -540,7 +540,7 @@ QStatusBar QLabel {
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_VoiceStatus">
|
||||
<widget class="QLabel" name="lbl_StatusVoiceStatus">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -564,8 +564,8 @@ QStatusBar QLabel {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>326</width>
|
||||
<height>267</height>
|
||||
<width>86</width>
|
||||
<height>59</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -607,8 +607,8 @@ QStatusBar QLabel {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>326</width>
|
||||
<height>267</height>
|
||||
<width>90</width>
|
||||
<height>55</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -1387,22 +1387,6 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QComboBox" name="cb_CockpitTransponderMode">
|
||||
<property name="sizePolicy">
|
||||
@@ -1459,8 +1443,24 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<spacer name="vs_CockpitSelcal">
|
||||
<item row="2" column="4" alignment="Qt::AlignRight">
|
||||
<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">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@@ -2224,21 +2224,14 @@ QStatusBar QLabel {
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsAudioTestActionAndResult">
|
||||
<property name="text">
|
||||
<string>Result</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QProgressBar" name="prb_SettingsAudioTestProgress">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPlainTextEdit" name="pte_SettingsAudioTestActionAndResult">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@@ -2251,6 +2244,47 @@ QStatusBar QLabel {
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -34,7 +34,7 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
||||
QPushButton *closeIcon = new QPushButton(this);
|
||||
closeIcon->setStyleSheet("margin: 0; padding: 0; background: transparent;");
|
||||
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(closeIcon, 0, Qt::AlignTop | Qt::AlignRight);
|
||||
this->ui->vl_CentralWidgetOutside->insertLayout(0, menuBarLayout, 0);
|
||||
|
||||
@@ -53,8 +53,10 @@ void MainWindow::menuClicked()
|
||||
*/
|
||||
void MainWindow::initContextMenus()
|
||||
{
|
||||
this->ui->lbl_VoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this->ui->lbl_VoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
|
||||
this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
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);
|
||||
connect(this->ui->tv_StatusMessages, &QTableView::customContextMenuRequested, this, &MainWindow::messageListContextMenu);
|
||||
}
|
||||
@@ -65,7 +67,9 @@ void MainWindow::initContextMenus()
|
||||
void MainWindow::audioIconContextMenu(const QPoint &position)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,10 @@ void MainWindow::reloadSettings()
|
||||
this->m_trafficServerList->update(nws.getTrafficNetworkServers());
|
||||
this->ui->tv_SettingsTnServers->resizeColumnsToContents();
|
||||
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);
|
||||
if (textEdit == nullptr) return; // do not crash, though this situation could not happen
|
||||
textEdit->append(textMessage.asString(true, false, "\t"));
|
||||
|
||||
// sound
|
||||
this->playNotifcationSound(BlackSound::CSoundGenerator::NotificationTextMessage);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_voice.h"
|
||||
#include "blacksound/soundgenerator.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackSound;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Voice;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -136,7 +138,8 @@ void MainWindow::audioVolumes()
|
||||
com1.setEnabled(!muted);
|
||||
com2.setEnabled(!muted);
|
||||
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;" : "");
|
||||
if (muted) this->displayOverlayInfo("Sound is muted!");
|
||||
|
||||
@@ -227,3 +230,14 @@ void MainWindow::audioTestUpdate()
|
||||
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