post-voice changes in blackgui from the kbatclist branch

refs #81
This commit is contained in:
Klaus Basan
2014-01-08 00:09:03 +00:00
committed by Mathew Sutcliffe
parent b475d7eff1
commit d15d0db431
10 changed files with 959 additions and 311 deletions

View File

@@ -12,6 +12,7 @@ using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Settings;
using namespace BlackMisc::Voice;
/*
* Constructor
@@ -19,11 +20,16 @@ using namespace BlackMisc::Settings;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow),
m_init(false), m_withDBus(true),
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false),
m_dBusConnection("dummy"), m_coreRuntime(nullptr),
m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr),
m_contextNetwork(nullptr), m_contextSettings(nullptr),
m_ownAircraft(),
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerContextWatchdog(nullptr), m_timerCollectedCockpitUpdates(nullptr)
m_atcListOnline(nullptr), m_atcListBooked(nullptr),
m_trafficServerList(nullptr), m_aircraftsInRange(nullptr),
m_contextApplication(nullptr),
m_contextNetwork(nullptr), m_contextVoice(nullptr),
m_contextSettings(nullptr),
m_ownAircraft(), m_voiceRoomCom1(), m_voiceRoomCom2(),
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr),
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr)
{
ui->setupUi(this);
}
@@ -51,6 +57,11 @@ void MainWindow::gracefulShutdown()
this->m_contextNetwork->disconnectFromNetwork();
}
if (this->m_contextVoiceAvailable)
{
this->m_contextVoice->leaveAllVoiceRooms();
}
if (this->m_timerUpdateAircraftsInRange)
{
this->m_timerUpdateAircraftsInRange->disconnect(this);
@@ -71,7 +82,6 @@ void MainWindow::gracefulShutdown()
this->m_timerCollectedCockpitUpdates->disconnect(this);
this->m_timerCollectedCockpitUpdates->stop();
}
}
/*
@@ -102,52 +112,6 @@ void MainWindow::setMainPage(bool start)
this->ui->sw_MainMiddle->setCurrentIndex(6);
}
/*
* Read stations
*/
void MainWindow::reloadAtcStationsBooked()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_atcListBooked->update(this->m_contextNetwork->getAtcStationsBooked());
this->ui->tv_AtcStationsBooked->resizeColumnsToContents();
}
/*
* Read stations
*/
void MainWindow::reloadAtcStationsOnline()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_atcListOnline->update(this->m_contextNetwork->getAtcStationsOnline());
this->ui->tv_AtcStationsOnline->resizeColumnsToContents();
}
/*
* Read aircrafts
*/
void MainWindow::reloadAircraftsInRange()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_aircraftsInRange->update(this->m_contextNetwork->getAircraftsInRange());
this->ui->tv_AircraftsInRange->resizeColumnsToContents();
}
/*
* Read own aircraft
*/
bool MainWindow::reloadOwnAircraft()
{
if (!this->isContextNetworkAvailableCheck()) return false;
if (this->isCockpitUpdatePending()) return false;
CAircraft loadedAircraft = this->m_contextNetwork->getOwnAircraft();
if (loadedAircraft == this->m_ownAircraft) return false;
// changed aircraft
this->m_ownAircraft = loadedAircraft;
this->updateCockpitFromContext();
return true;
}
/*
* Connect to Network
*/
@@ -170,6 +134,7 @@ void MainWindow::toggleNetworkConnection()
else
{
msgs = this->m_contextNetwork->disconnectFromNetwork();
this->m_contextVoice->leaveAllVoiceRooms();
}
if (!msgs.isEmpty()) this->displayStatusMessages(msgs);
}
@@ -184,6 +149,16 @@ bool MainWindow::isContextNetworkAvailableCheck()
return false;
}
/*
* Is the voice context available?
*/
bool MainWindow::isContextVoiceAvailableCheck()
{
if (this->m_contextVoiceAvailable) return true;
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Voice context not available"));
return false;
}
/*
* Display a status message
*/
@@ -265,30 +240,8 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to)
}
/*
* Station selected
*/
void MainWindow::onlineAtcStationSelected(QModelIndex index)
{
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset
const CAtcStation stationClicked = this->m_atcListOnline->at(index);
QString infoMessage;
if (stationClicked.hasAtis())
{
infoMessage.append(stationClicked.getAtis().getMessage());
}
if (stationClicked.hasMetar())
{
if (!infoMessage.isEmpty()) infoMessage.append("\n\n");
infoMessage.append(stationClicked.getMetar().getMessage());
}
this->ui->te_AtcStationsOnlineInfo->setText(infoMessage);
}
/*
* Timer event
*/
* Timer event
*/
void MainWindow::updateTimer()
{
QObject *sender = QObject::sender();
@@ -308,8 +261,7 @@ void MainWindow::updateTimer()
}
else if (sender == this->m_timerContextWatchdog)
{
qint64 t = QDateTime::currentMSecsSinceEpoch();
m_contextNetworkAvailable = (this->m_contextNetwork->usingLocalObjects() || (this->m_contextNetwork->ping(t) == t));
this->setContextAvailability();
this->updateGuiStatusInformation();
}
@@ -321,43 +273,19 @@ void MainWindow::updateTimer()
}
/*
* Get METAR
*/
void MainWindow::getMetar(const QString &airportIcaoCode)
* Context availability
*/
void MainWindow::setContextAvailability()
{
if (!this->isContextNetworkAvailableCheck()) return;
if (!this->m_contextNetwork->isConnected()) return;
QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
this->ui->le_AtcStationsOnlineMetar->setText(icao);
if (icao.length() != 4) return;
CInformationMessage metar = this->m_contextNetwork->getMetar(icao);
if (metar.getType() != CInformationMessage::METAR) return;
if (metar.isEmpty()) return;
this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage());
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = this->m_contextApplication->ping(t) == t;
this->m_contextNetworkAvailable = this->m_coreAvailable || this->m_contextNetwork->usingLocalObjects();
this->m_contextVoiceAvailable = this->m_coreAvailable || this->m_contextVoice->usingLocalObjects();
}
/*
* ATC station tab changed are changed
*/
void MainWindow::atcStationTabChanged(int /** tabIndex **/)
{
if (this->isContextNetworkAvailableCheck())
{
if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsBooked)
{
if (this->m_atcListBooked->rowCount() < 1)
this->reloadAtcStationsBooked();
}
else if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsOnline)
{
this->reloadAtcStationsOnline();
}
}
}
/*
* Middle panel changed
*/
* Middle panel changed
*/
void MainWindow::middlePanelChanged(int /* index */)
{
if (this->isContextNetworkAvailableCheck())
@@ -373,32 +301,39 @@ void MainWindow::middlePanelChanged(int /* index */)
}
/*
* Update GUI
*/
* Update GUI
*/
void MainWindow::updateGuiStatusInformation()
{
const QString now = QDateTime::currentDateTimeUtc().toString("yyyy - MM - dd HH: mm: ss");
QString network("unavailable");
if (this->m_contextNetworkAvailable)
{
const QString now = QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd HH:mm:ss");
this->ui->le_networkContextAvailable->setText(
this->m_contextNetwork->usingLocalObjects() ? "local" :
now);
if (this->m_contextNetwork->isConnected())
{
this->ui->pb_MainConnect->setText("Disconnect");
this->ui->pb_MainConnect->setStyleSheet("background-color: green");
if (!this->ui->le_StatusNetworkConnected->text().startsWith("2"))
this->ui->le_StatusNetworkConnected->setText(now);
}
else
{
this->ui->pb_MainConnect->setText("Connect");
this->ui->pb_MainConnect->setStyleSheet("background-color:");
this->ui->le_StatusNetworkConnected->setText("Disconnected");
}
network = this->m_contextNetwork->usingLocalObjects() ? "local" : now;
}
QString voice("unavailable");
if (this->m_contextVoiceAvailable)
{
voice = this->m_contextVoice->usingLocalObjects() ? "local" : now;
}
this->ui->le_StatusNetworkContext->setText(network);
this->ui->le_StatusVoiceContext->setText(voice);
this->ui->cb_StatusWithDBus->setCheckState(this->m_withDBus ? Qt::Checked : Qt::Unchecked);
// Connected button
if (this->m_contextNetworkAvailable && this->m_contextNetwork->isConnected())
{
this->ui->pb_MainConnect->setText("Disconnect");
this->ui->pb_MainConnect->setStyleSheet("background-color: green");
if (!this->ui->le_StatusNetworkConnected->text().startsWith("2"))
this->ui->le_StatusNetworkConnected->setText(now);
}
else
{
this->ui->le_networkContextAvailable->setText("Not available");
this->ui->pb_MainConnect->setText("Connect");
this->ui->pb_MainConnect->setStyleSheet("background-color: ");
this->ui->le_StatusNetworkConnected->setText("Disconnected");
}
}

View File

@@ -10,8 +10,10 @@
#include "blackgui/aircraftlistmodel.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/nwtextmessage.h"
#include "blackcore/context_voice.h"
#include "blackcore/context_network_interface.h"
#include "blackcore/context_settings_interface.h"
#include "blackcore/context_application_interface.h"
#include "blackcore/coreruntime.h"
#include <QMainWindow>
#include <QTextEdit>
@@ -57,20 +59,26 @@ private:
Ui::MainWindow *ui;
bool m_init;
bool m_withDBus;
bool m_coreAvailable;
bool m_contextNetworkAvailable;
bool m_contextVoiceAvailable;
QDBusConnection m_dBusConnection;
BlackCore::CCoreRuntime *m_coreRuntime; /*!< runtime, if working with local core */
BlackGui::CAtcListModel *m_atcListOnline;
BlackGui::CAtcListModel *m_atcListBooked;
BlackGui::CServerListModel *m_trafficServerList;
BlackGui::CAircraftListModel *m_aircraftsInRange;
BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */
BlackCore::IContextNetwork *m_contextNetwork;
BlackCore::IContextVoice *m_contextVoice;
BlackCore::IContextSettings *m_contextSettings;
BlackMisc::Aviation::CAircraft m_ownAircraft;
QTimer *m_timerUpdateAtcStationsOnline;
QTimer *m_timerUpdateAircraftsInRange;
QTimer *m_timerCollectedCockpitUpdates;
QTimer *m_timerContextWatchdog;
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
BlackMisc::Voice::CVoiceRoom m_voiceRoomCom1;
BlackMisc::Voice::CVoiceRoom m_voiceRoomCom2;
QTimer *m_timerUpdateAtcStationsOnline; /*!< update stations */
QTimer *m_timerUpdateAircraftsInRange; /*!< update aircrafts */
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */
/*!
* \brief GUI status update
@@ -95,11 +103,17 @@ private:
void initialDataReads();
/*!
* \brief Context network available check, otherwise status message
* \brief Context network availability check, otherwise status message
* \return
*/
bool isContextNetworkAvailableCheck();
/*!
* \brief Context voice availability check, otherwise status message
* \return
*/
bool isContextVoiceAvailableCheck();
/*!
* \brief Own cockpit, update from context
*/
@@ -138,6 +152,25 @@ private:
*/
BlackMisc::Network::CTextMessage getTextMessageStubForChannel();
/*!
* \brief Audio device lists
* \return
*/
void setAudioDeviceLists();
/*!
* \brief Context availability, used by watchdog
*/
void setContextAvailability();
/*!
* \brief Position of own plane for testing
* \param wgsLatitude
* \param wgsLongitude
* \param altitude
*/
void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude);
private slots:
//
@@ -175,7 +208,7 @@ private slots:
* \brief Display status messages
* \param messages
*/
void displayStatusMessages(const BlackMisc::CStatusMessages &messages);
void displayStatusMessages(const BlackMisc::CStatusMessageList &messages);
/*!
* \brief Connection status changed
@@ -287,6 +320,27 @@ private slots:
*/
void cockpitValuesChanged();
/*!
* \brief Audio device selected
* \param index
*/
void audioDeviceSelected(int index);
/*!
* \brief Reset transponder to standby
*/
void resetTransponderModerToStandby();
/*!
* \brief Reset transponder to Charly
*/
void resetTransponderModerToCharly();
/*!
* \brief Override voice room
*/
void voiceRoomOverride();
};
#pragma pop_macro("interface")

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<width>615</width>
<height>541</height>
</rect>
</property>
@@ -160,11 +160,24 @@
<widget class="QWidget" name="pg_StatusStatusPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="fl_StatusPage">
<item row="0" column="0">
<widget class="QLabel" name="lbl_StatusNetworkConnected">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="3">
<widget class="QLineEdit" name="le_StatusVoiceContext">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="cb_StatusWithDBus">
<property name="text">
<string>Network connected</string>
<string>DBus</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
@@ -175,6 +188,27 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_StatusNetworkContext">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_StatusNetworkContext">
<property name="text">
<string>Voice context</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_StatusNetworkConnected">
<property name="text">
<string>Network connected</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_networkContextAvailable">
<property name="text">
@@ -182,13 +216,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_networkContextAvailable">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -591,144 +618,10 @@
<widget class="QWidget" name="pg_Cockpit">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gl_Cockpit">
<layout class="QGridLayout" name="gl_CockpitCom">
<property name="spacing">
<number>3</number>
</property>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitCom2Active">
<property name="accelerated">
<bool>false</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>118.000000000000000</double>
</property>
<property name="maximum">
<double>136.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
<property name="value">
<double>118.250000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitTransponder">
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>7777.000000000000000</double>
</property>
<property name="value">
<double>7000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitCom1Active">
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>118.000000000000000</double>
</property>
<property name="maximum">
<double>136.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
<property name="value">
<double>118.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_CockpitCom2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>COM 2</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_CockpitTransponder">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Transponder</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_CockpitCom1">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>COM 1</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="vs_Cockpit">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cb_CockpitTransponderMode">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>S</string>
</property>
</item>
<item>
<property name="text">
<string>C</string>
</property>
</item>
<item>
<property name="text">
<string>I</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="ds_CockpitCom1Standby">
<property name="minimumSize">
@@ -760,6 +653,31 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cb_CockpitTransponderMode">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>S</string>
</property>
</item>
<item>
<property name="text">
<string>C</string>
</property>
</item>
<item>
<property name="text">
<string>I</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="ds_CockpitCom2Standby">
<property name="decimals">
@@ -779,6 +697,174 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_CockpitTransponder">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Transponder</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_CockpitCom1">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>COM 1</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_CockpitCom2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>COM 2</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitCom2Active">
<property name="accelerated">
<bool>false</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>118.000000000000000</double>
</property>
<property name="maximum">
<double>136.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
<property name="value">
<double>118.250000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitCom1Active">
<property name="maximumSize">
<size>
<width>75</width>
<height>16777215</height>
</size>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>118.000000000000000</double>
</property>
<property name="maximum">
<double>136.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
<property name="value">
<double>118.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="ds_CockpitTransponder">
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>7777.000000000000000</double>
</property>
<property name="value">
<double>7000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="ql_CockpitVoiceRooms">
<item row="1" column="0">
<widget class="QColumnView" name="cv_CockpitVoiceRoom1"/>
</item>
<item row="1" column="1">
<widget class="QColumnView" name="cv_CockpitVoiceRoom2"/>
</item>
<item row="0" column="1">
<widget class="QWidget" name="qi_CokpitViewRoom2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom2">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_CockpitVoiceRoom2Override">
<property name="text">
<string>Ovr.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="qi_CokpitViewRoom1" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom1">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_CockpitVoiceRoom1Override">
<property name="text">
<string>Ovr.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
@@ -1002,14 +1088,14 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_SettingsTnCsRealname">
<widget class="QLabel" name="lbl_SettingsTnCsRealName">
<property name="text">
<string>Real name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="le_SettingsTnCsRealname">
<widget class="QLineEdit" name="le_SettingsTnCsRealName">
<property name="text">
<string/>
</property>
@@ -1086,22 +1172,56 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_SettingsPlane">
<widget class="QWidget" name="tb_SettingsVoice">
<attribute name="title">
<string>Whatsoever</string>
<string>Voice</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_VoiceInputDevice">
<property name="text">
<string>In</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cb_VoiceInputDevice"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_VoiceOutputDevice">
<property name="text">
<string>Out</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cb_VoiceOutputDevice"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_SettingsAircraft">
<attribute name="title">
<string>Aircraft</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QFormLayout" name="fl_SettingsPlane">
<layout class="QFormLayout" name="fl_SettingsAircraft">
<item row="0" column="0">
<widget class="QLabel" name="lbl_SettingsPlaneCallsign">
<widget class="QLabel" name="lbl_SettingsAircraftCallsign">
<property name="text">
<string>Callsign</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_SettingsPlaneCallsign">
<widget class="QLineEdit" name="le_SettingsAircraftCallsign">
<property name="text">
<string>BLACK</string>
</property>
@@ -1228,7 +1348,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<width>615</width>
<height>21</height>
</rect>
</property>
@@ -1243,6 +1363,7 @@
<addaction name="menu_TestLocationsEDRY"/>
<addaction name="menu_TestLocationsEDDF"/>
<addaction name="menu_TestLocationsEDDM"/>
<addaction name="menu_TestLocationsEDNX"/>
</widget>
<widget class="QMenu" name="menu_Reload">
<property name="title">
@@ -1266,17 +1387,17 @@
<widget class="QStatusBar" name="sb_MainStatusBar"/>
<action name="menu_TestLocationsEDDF">
<property name="text">
<string>Position EDDF</string>
<string>Position EDDF (Frankfurt, GER)</string>
</property>
</action>
<action name="menu_TestLocationsEDDM">
<property name="text">
<string>Position EDDM</string>
<string>Position EDDM (Munich, GER)</string>
</property>
</action>
<action name="menu_TestLocationsEDRY">
<property name="text">
<string>Position EDRY</string>
<string>Position EDRY (Speyer, GER)</string>
</property>
</action>
<action name="menu_ReloadSettings">
@@ -1284,6 +1405,11 @@
<string>Reload settings</string>
</property>
</action>
<action name="menu_TestLocationsEDNX">
<property name="text">
<string>Position EDNX (Schleißheim, GER)</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
@@ -1503,8 +1629,8 @@
<slot>reloadAtcStationsBooked()</slot>
<hints>
<hint type="sourcelabel">
<x>178</x>
<y>110</y>
<x>175</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
@@ -1519,8 +1645,8 @@
<slot>onlineAtcStationSelected(QModelIndex)</slot>
<hints>
<hint type="sourcelabel">
<x>253</x>
<y>116</y>
<x>174</x>
<y>50</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
@@ -1583,8 +1709,8 @@
<slot>commandEntered()</slot>
<hints>
<hint type="sourcelabel">
<x>176</x>
<y>73</y>
<x>166</x>
<y>63</y>
</hint>
<hint type="destinationlabel">
<x>4</x>
@@ -1599,8 +1725,8 @@
<slot>getMetar()</slot>
<hints>
<hint type="sourcelabel">
<x>374</x>
<y>491</y>
<x>145</x>
<y>71</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
@@ -1615,8 +1741,8 @@
<slot>getMetar()</slot>
<hints>
<hint type="sourcelabel">
<x>338</x>
<y>491</y>
<x>118</x>
<y>71</y>
</hint>
<hint type="destinationlabel">
<x>341</x>
@@ -1631,8 +1757,8 @@
<slot>cockpitValuesChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>370</x>
<y>55</y>
<x>449</x>
<y>73</y>
</hint>
<hint type="destinationlabel">
<x>337</x>
@@ -1663,8 +1789,8 @@
<slot>cockpitValuesChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>379</x>
<y>88</y>
<x>449</x>
<y>96</y>
</hint>
<hint type="destinationlabel">
<x>253</x>
@@ -1711,8 +1837,8 @@
<slot>cockpitValuesChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>385</x>
<y>103</y>
<x>449</x>
<y>119</y>
</hint>
<hint type="destinationlabel">
<x>1</x>
@@ -1720,6 +1846,166 @@
</hint>
</hints>
</connection>
<connection>
<sender>cb_VoiceOutputDevice</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>MainWindow</receiver>
<slot>audioDeviceSelected(int)</slot>
<hints>
<hint type="sourcelabel">
<x>166</x>
<y>63</y>
</hint>
<hint type="destinationlabel">
<x>2</x>
<y>316</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_VoiceOutputDevice</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>MainWindow</receiver>
<slot>audioDeviceSelected(int)</slot>
<hints>
<hint type="sourcelabel">
<x>166</x>
<y>63</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>379</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_VoiceInputDevice</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>MainWindow</receiver>
<slot>audioDeviceSelected(int)</slot>
<hints>
<hint type="sourcelabel">
<x>166</x>
<y>55</y>
</hint>
<hint type="destinationlabel">
<x>26</x>
<y>355</y>
</hint>
</hints>
</connection>
<connection>
<sender>menu_TestLocationsEDNX</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>menuClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>307</x>
<y>270</y>
</hint>
</hints>
</connection>
<connection>
<sender>menu_TestLocationsEDDF</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>menuClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>307</x>
<y>270</y>
</hint>
</hints>
</connection>
<connection>
<sender>menu_TestLocationsEDDM</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>menuClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>307</x>
<y>270</y>
</hint>
</hints>
</connection>
<connection>
<sender>le_CockpitVoiceRoomCom1</sender>
<signal>returnPressed()</signal>
<receiver>MainWindow</receiver>
<slot>voiceRoomOverride()</slot>
<hints>
<hint type="sourcelabel">
<x>232</x>
<y>64</y>
</hint>
<hint type="destinationlabel">
<x>40</x>
<y>388</y>
</hint>
</hints>
</connection>
<connection>
<sender>le_CockpitVoiceRoomCom2</sender>
<signal>returnPressed()</signal>
<receiver>MainWindow</receiver>
<slot>voiceRoomOverride()</slot>
<hints>
<hint type="sourcelabel">
<x>253</x>
<y>82</y>
</hint>
<hint type="destinationlabel">
<x>70</x>
<y>304</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_CockpitVoiceRoom2Override</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>voiceRoomOverride()</slot>
<hints>
<hint type="sourcelabel">
<x>346</x>
<y>91</y>
</hint>
<hint type="destinationlabel">
<x>559</x>
<y>412</y>
</hint>
</hints>
</connection>
<connection>
<sender>cb_CockpitVoiceRoom1Override</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>voiceRoomOverride()</slot>
<hints>
<hint type="sourcelabel">
<x>368</x>
<y>61</y>
</hint>
<hint type="destinationlabel">
<x>587</x>
<y>340</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>setMainPage()</slot>
@@ -1732,5 +2018,7 @@
<slot>commandEntered()</slot>
<slot>getMetar()</slot>
<slot>cockpitValuesChanged()</slot>
<slot>audioDeviceSelected(int)</slot>
<slot>voiceRoomOverride()</slot>
</slots>
</ui>

View File

@@ -0,0 +1,75 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
using namespace BlackCore;
using namespace BlackMisc;
using namespace BlackGui;
using namespace BlackMisc::Network;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Settings;
using namespace BlackMisc::Voice;
/*
* Read aircrafts
*/
void MainWindow::reloadAircraftsInRange()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_aircraftsInRange->update(this->m_contextNetwork->getAircraftsInRange());
this->ui->tv_AircraftsInRange->resizeColumnsToContents();
}
/*
* Read own aircraft
*/
bool MainWindow::reloadOwnAircraft()
{
if (!this->isContextNetworkAvailableCheck()) return false;
if (this->isCockpitUpdatePending()) return false;
CAircraft loadedAircraft = this->m_contextNetwork->getOwnAircraft();
// changed aircraft
if (loadedAircraft == this->m_ownAircraft) return false;
this->m_ownAircraft = loadedAircraft;
// update voice rooms
if (this->m_contextVoiceAvailable)
{
CVoiceRoomList selectedRooms = this->m_contextNetwork->getSelectedVoiceRooms();
this->m_voiceRoomCom1 = this->ui->cb_CockpitVoiceRoom1Override->isChecked() ?
this->ui->le_CockpitVoiceRoomCom1->text().trimmed() :
selectedRooms[0];
this->m_voiceRoomCom2 = this->ui->cb_CockpitVoiceRoom2Override->isChecked() ?
this->ui->le_CockpitVoiceRoomCom2->text().trimmed() :
selectedRooms[1];
}
//
this->updateCockpitFromContext();
// something has changed
return true;
}
/*
* Position
*/
void MainWindow::setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const CAltitude &altitude)
{
CCoordinateGeodetic coordinate(
CLatitude::fromWgs84(wgsLatitude),
CLongitude::fromWgs84(wgsLongitude),
CLength(0, CLengthUnit::m()));
this->m_ownAircraft.setPosition(coordinate);
this->m_ownAircraft.setAltitude(altitude);
this->m_contextNetwork->updateOwnPosition(
coordinate,
altitude
);
}

View File

@@ -0,0 +1,92 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
using namespace BlackCore;
using namespace BlackMisc;
using namespace BlackGui;
using namespace BlackMisc::Network;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Settings;
/*
* Read booked stations
*/
void MainWindow::reloadAtcStationsBooked()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_atcListBooked->update(this->m_contextNetwork->getAtcStationsBooked());
this->ui->tv_AtcStationsBooked->resizeColumnsToContents();
}
/*
* Read online stations
*/
void MainWindow::reloadAtcStationsOnline()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->m_atcListOnline->update(this->m_contextNetwork->getAtcStationsOnline());
this->ui->tv_AtcStationsOnline->resizeColumnsToContents();
}
/*
* Station selected
*/
void MainWindow::onlineAtcStationSelected(QModelIndex index)
{
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset
const CAtcStation stationClicked = this->m_atcListOnline->at(index);
QString infoMessage;
if (stationClicked.hasAtis())
{
infoMessage.append(stationClicked.getAtis().getMessage());
}
if (stationClicked.hasMetar())
{
if (!infoMessage.isEmpty()) infoMessage.append("\n\n");
infoMessage.append(stationClicked.getMetar().getMessage());
}
this->ui->te_AtcStationsOnlineInfo->setText(infoMessage);
}
/*
* Get METAR
*/
void MainWindow::getMetar(const QString &airportIcaoCode)
{
if (!this->isContextNetworkAvailableCheck()) return;
if (!this->m_contextNetwork->isConnected()) return;
QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
this->ui->le_AtcStationsOnlineMetar->setText(icao);
if (icao.length() != 4) return;
CInformationMessage metar = this->m_contextNetwork->getMetar(icao);
if (metar.getType() != CInformationMessage::METAR) return;
if (metar.isEmpty()) return;
this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage());
}
/*
* ATC station tab changed are changed
*/
void MainWindow::atcStationTabChanged(int /** tabIndex **/)
{
if (this->isContextNetworkAvailableCheck())
{
if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsBooked)
{
if (this->m_atcListBooked->rowCount() < 1)
this->reloadAtcStationsBooked();
}
else if (this->ui->tw_AtcStations->currentWidget() == this->ui->tb_AtcStationsOnline)
{
this->reloadAtcStationsOnline();
}
}
}

View File

@@ -86,6 +86,34 @@ void MainWindow::updateCockpitFromContext()
break;
}
//
// voice
//
if (!this->ui->cb_CockpitVoiceRoom1Override->isChecked())
{
if (!this->ui->cb_CockpitVoiceRoom1Override->isChecked() && this->m_voiceRoomCom1.isValid())
{
QString s(this->m_voiceRoomCom1.isConnected() ? "*" : "");
s.append(this->m_voiceRoomCom1.getVoiceRoomUrl());
this->ui->le_CockpitVoiceRoomCom1->setText(s);
}
else
this->ui->le_CockpitVoiceRoomCom1->setText("");
}
if (!this->ui->cb_CockpitVoiceRoom2Override->isChecked())
{
if (this->m_voiceRoomCom2.isValid())
{
QString s(this->m_voiceRoomCom2.isConnected() ? "*" : "");
s.append(this->m_voiceRoomCom2.getVoiceRoomUrl());
this->ui->le_CockpitVoiceRoomCom2->setText(s);
}
else
this->ui->le_CockpitVoiceRoomCom2->setText("");
}
}
/*
* Reset transponder mode to Standby
*/
@@ -164,4 +192,33 @@ void MainWindow::sendCockpitUpdates()
changedCockpit = true;
}
}
//
// Now with the new voice room data, really set the
// voice rooms in the context
//
if (changedCockpit && this->m_contextVoiceAvailable)
{
// set voice rooms here, this allows to use local/remote
// voice context
this->m_contextVoice->setComVoiceRooms(this->m_voiceRoomCom1, this->m_voiceRoomCom2);
}
}
/*
* Voice room override
*/
void MainWindow::voiceRoomOverride()
{
this->ui->le_CockpitVoiceRoomCom1->setReadOnly(!this->ui->cb_CockpitVoiceRoom1Override->isChecked());
this->ui->le_CockpitVoiceRoomCom2->setReadOnly(!this->ui->cb_CockpitVoiceRoom2Override->isChecked());
if (this->ui->cb_CockpitVoiceRoom1Override->isChecked())
{
this->m_voiceRoomCom1 = this->ui->cb_CockpitVoiceRoom1Override->text().trimmed();
}
if (this->ui->cb_CockpitVoiceRoom2Override->isChecked())
{
this->m_voiceRoomCom2 = this->ui->cb_CockpitVoiceRoom2Override->text().trimmed();
}
}

View File

@@ -62,13 +62,17 @@ void MainWindow::init(bool withDBus)
{
this->m_dBusConnection = QDBusConnection::sessionBus();
this->m_contextNetwork = new BlackCore::IContextNetwork(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextVoice = new BlackCore::IContextVoice(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextSettings = new BlackCore::IContextSettings(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
this->m_contextApplication = new BlackCore::IContextApplication(BlackCore::CDBusServer::ServiceName, this->m_dBusConnection, this);
}
else
{
this->m_coreRuntime = new CCoreRuntime(false, this);
this->m_contextNetwork = this->m_coreRuntime->getIContextNetwork();
this->m_contextVoice = this->m_coreRuntime->getIContextVoice();
this->m_contextSettings = this->m_coreRuntime->getIContextSettings();
this->m_contextApplication = this->m_coreRuntime->getIContextApplication();
}
// relay status messages
@@ -127,6 +131,12 @@ void MainWindow::init(bool withDBus)
this->m_timerUpdateAtcStationsOnline->start(10 * 1000);
this->m_timerContextWatchdog->start(2 * 1000);
// init availability
this->setContextAvailability();
// voice panel
this->setAudioDeviceLists();
// data
this->initialDataReads();

View File

@@ -0,0 +1,79 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
#include "blackcore/context_voice.h"
using namespace BlackCore;
using namespace BlackMisc;
using namespace BlackGui;
using namespace BlackMisc::Network;
using namespace BlackMisc::Voice;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Geo;
using namespace BlackMisc::Settings;
using namespace BlackMisc::Math;
/*
* Set audio device lists
*/
void MainWindow::setAudioDeviceLists()
{
if (!this->isContextVoiceAvailableCheck()) return;
this->ui->cb_VoiceOutputDevice->clear();
this->ui->cb_VoiceInputDevice->clear();
foreach(CAudioDevice device, this->m_contextVoice->getAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
this->ui->cb_VoiceInputDevice->addItem(device.toQString(true));
}
else if (device.getType() == CAudioDevice::OutputDevice)
{
this->ui->cb_VoiceOutputDevice->addItem(device.toQString(true));
}
}
foreach(CAudioDevice device, this->m_contextVoice->getCurrentAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
this->ui->cb_VoiceInputDevice->setCurrentText(device.toQString(true));
}
else if (device.getType() == CAudioDevice::OutputDevice)
{
this->ui->cb_VoiceOutputDevice->setCurrentText(device.toQString(true));
}
}
}
/*
* Select audio device
*/
void MainWindow::audioDeviceSelected(int index)
{
if (!this->m_init) return; // not during init
if (!this->isContextVoiceAvailableCheck()) return;
if (index < 0)return;
CAudioDeviceList devices = this->m_contextVoice->getAudioDevices();
if (devices.isEmpty()) return;
CAudioDevice selectedDevice;
QObject *sender = QObject::sender();
if (sender == this->ui->cb_VoiceInputDevice)
{
CAudioDeviceList inputDevices = devices.getInputDevices();
if (index >= inputDevices.size()) return;
selectedDevice = inputDevices[index];
this->m_contextVoice->setCurrentAudioDevice(selectedDevice);
}
else if (sender == this->ui->cb_VoiceOutputDevice)
{
CAudioDeviceList outputDevices = devices.getOutputDevices();
if (index >= outputDevices.size()) return;
selectedDevice = outputDevices[index];
this->m_contextVoice->setCurrentAudioDevice(selectedDevice);
}
}

View File

@@ -0,0 +1,27 @@
#include "userlistmodel.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include <QMetaProperty>
#include <QBrush>
using namespace BlackMisc::Network;
namespace BlackGui
{
/*
* Constructor
*/
CUserListModel::CUserListModel(QObject *parent) :
CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>("ViewUserList", parent)
{
this->m_columns.addColumn(CUser::IndexId, "id");
this->m_columns.addColumn(CUser::IndexRealName, "realname");
this->m_columns.addColumn(CUser::IndexId, "userid");
this->m_columns.addColumn(CUser::IndexEmail, "email");
// force strings for translation in resource files
(void)QT_TRANSLATE_NOOP("ViewUserList", "id");
(void)QT_TRANSLATE_NOOP("ViewUserList", "realname");
(void)QT_TRANSLATE_NOOP("ViewUserList", "userid");
(void)QT_TRANSLATE_NOOP("ViewUserList", "email");
}
}

View File

@@ -0,0 +1,31 @@
#ifndef BLACKGUI_USERLISTMODEL_H
#define BLACKGUI_USERLISTMODEL_H
#include <QAbstractItemModel>
#include <QDBusConnection>
#include "blackmisc/nwuserlist.h"
#include "blackgui/listmodelbase.h"
namespace BlackGui
{
/*!
* \brief Server list model
*/
class CUserListModel : public CListModelBase<BlackMisc::Network::CUser, BlackMisc::Network::CUserList>
{
public:
/*!
* \brief Constructor
* \param parent
*/
explicit CUserListModel(QObject *parent = nullptr);
/*!
* \brief Destructor
*/
virtual ~CUserListModel() {}
};
}
#endif // guard