refs #250, refs #242 changed GUi to reflect changes

* own cockpit component
* new aircraft context
This commit is contained in:
Klaus Basan
2014-05-28 13:48:20 +02:00
parent a4e5e22adc
commit c7108a51f8
8 changed files with 30 additions and 992 deletions

View File

@@ -30,7 +30,7 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false), m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextAudioAvailable(false),
// timers // timers
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), m_timerContextWatchdog(nullptr),
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr), m_timerSimulator(nullptr), m_timerStatusBar(nullptr), m_timerAudioTests(nullptr), m_timerSimulator(nullptr),
// context menus // context menus
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr), m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
@@ -200,9 +200,8 @@ void MainWindow::toggleNetworkConnection()
icao.setAircraftCombinedType(this->ui->le_SettingsIcaoCombinedType->text()); icao.setAircraftCombinedType(this->ui->le_SettingsIcaoCombinedType->text());
this->m_ownAircraft.setIcaoInfo(icao); this->m_ownAircraft.setIcaoInfo(icao);
// send latest aircraft to network/voice // set latest aircraft
this->getIContextOwnAircraft()->updateOwnAircraft(this->m_ownAircraft, MainWindow::ownAircraftContextOriginator()); this->getIContextOwnAircraft()->updateOwnAircraft(this->m_ownAircraft, MainWindow::ownAircraftContextOriginator());
if (this->m_contextAudioAvailable) this->getIContextAudio()->setOwnAircraft(this->m_ownAircraft);
// Login is based on setting current server // Login is based on setting current server
INetwork::LoginMode mode = INetwork::LoginNormal; INetwork::LoginMode mode = INetwork::LoginNormal;

View File

@@ -103,7 +103,6 @@ private:
bool m_contextNetworkAvailable; bool m_contextNetworkAvailable;
bool m_contextAudioAvailable; bool m_contextAudioAvailable;
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */ BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */ QTimer *m_timerContextWatchdog; /*!< core available? */
QTimer *m_timerStatusBar; /*!< cleaning up status bar */ QTimer *m_timerStatusBar; /*!< cleaning up status bar */
QTimer *m_timerAudioTests; /*!< audio tests: progress bar, disable/enable buttons */ QTimer *m_timerAudioTests; /*!< audio tests: progress bar, disable/enable buttons */
@@ -162,15 +161,6 @@ private:
//! Context voice availability check, otherwise status message //! Context voice availability check, otherwise status message
bool isContextAudioAvailableCheck(); bool isContextAudioAvailableCheck();
//! Own cockpit, update from context
void updateCockpitFromContext();
//! Pending cockpit update operation
bool isCockpitUpdatePending() const;
//! Update the COM frequency displays
void updateComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
//! Audio device lists //! Audio device lists
void setAudioDeviceLists(); void setAudioDeviceLists();
@@ -204,9 +194,6 @@ private:
*/ */
void stopAllTimers(bool disconnect); void stopAllTimers(bool disconnect);
//! Currently selected SELCAL code
QString getSelcalCode() const;
//! Audio test updates (timer) for progressbar and fetching results //! Audio test updates (timer) for progressbar and fetching results
void audioTestUpdate(); void audioTestUpdate();
@@ -254,9 +241,6 @@ private slots:
//! Reload settings //! Reload settings
void reloadSettings(); void reloadSettings();
//! Send cockpit updates
void sendCockpitUpdates();
//! Simulator available //! Simulator available
void simulatorConnectionChanged(bool isAvailable); void simulatorConnectionChanged(bool isAvailable);
@@ -300,24 +284,12 @@ private slots:
//! Update timer //! Update timer
void timerBasedUpdates(); void timerBasedUpdates();
//! Cockpit values changed
void cockpitValuesChanged();
/*! /*!
* \brief Audio device selected * \brief Audio device selected
* \param index audio device index (COM1, COM2) * \param index audio device index (COM1, COM2)
*/ */
void audioDeviceSelected(int index); void audioDeviceSelected(int index);
//! Reset transponder to Standby / Charly
void resetTransponderMode();
/*!
* Set voice rooms, also
* allows to set an arbitrary voice room for testing purposes
*/
void setAudioVoiceRooms();
//! Audio volume handling and mute //! Audio volume handling and mute
void audioVolumes(); void audioVolumes();
@@ -330,16 +302,9 @@ private slots:
//! Context menu for audio //! Context menu for audio
void audioIconContextMenu(const QPoint &position); void audioIconContextMenu(const QPoint &position);
//! Test SELCAL (code valid? play tone)
void testSelcal();
//! start the MIC tests (Squelch) //! start the MIC tests (Squelch)
void startAudioTest(); void startAudioTest();
//! \brief Input focus changed, used to detect whether an input control has focus
//! \sa QApplication::focusChanged
void inputFocusChanged(QWidget *oldWidget, QWidget *newWidget);
//! Save the Hotkeys //! Save the Hotkeys
void saveHotkeys(); void saveHotkeys();

View File

@@ -571,8 +571,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>59</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -614,8 +614,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">
@@ -770,544 +770,24 @@ QStatusBar QLabel {
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="pg_Cockpit"> <widget class="QWidget" name="pg_Cockpit">
<layout class="QVBoxLayout" name="vl_Cockpit"> <layout class="QVBoxLayout" name="vl_CockpitPage">
<property name="spacing"> <property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QGridLayout" name="gl_CockpitCom">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="horizontalSpacing">
<number>5</number>
</property>
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_CockpitCom1">
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>COM 1</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="ds_CockpitCom1Active">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</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.025000000000000</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>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>COM 2</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="ds_CockpitCom1Standby">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>75</width>
<height>18</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</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.025000000000000</double>
</property>
<property name="value">
<double>119.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="ds_CockpitCom2Active">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
<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.025000000000000</double>
</property>
<property name="value">
<double>118.250000000000000</double>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="ds_CockpitCom2Standby">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>18</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.025000000000000</double>
</property>
<property name="value">
<double>119.250000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pb_CockpitToggleCom1">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&lt;&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pb_CockpitToggleCom2">
<property name="text">
<string>&lt;&gt;</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QDial" name="di_CockpitCom1Volume">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Volume COM1</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="notchesVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QDial" name="di_CockpitCom2Volume">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Volume COM2</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_CockpitSelcalTest">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_CockpitTransponder">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Transponder</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_CockpitSelcal">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>SELCAL</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cb_CockpitSelcal1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="cb_CockpitSelcal2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="BlackGui::CTransponderModeSelector" name="cbp_CockpitTransponderMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="ds_CockpitTransponder">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
<property name="decimals">
<number>0</number> <number>0</number>
</property> </property>
<property name="maximum">
<double>7777.000000000000000</double>
</property>
<property name="value">
<double>7000.000000000000000</double>
</property>
</widget>
</item>
<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>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="ql_CockpitVoiceRooms">
<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="leftMargin"> <property name="leftMargin">
<number>2</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>2</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>2</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>2</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom2"> <widget class="BlackGui::CCockpitV1Component" name="comp_Cockpit" native="true"/>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</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="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="le_CockpitVoiceRoomCom1">
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</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>
<item row="1" column="0">
<widget class="BlackGui::CUserView" name="tvp_CockpitVoiceRoom1">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="1" column="1">
<widget class="BlackGui::CUserView" name="tvp_CockpitVoiceRoom2">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -2749,16 +2229,6 @@ QStatusBar QLabel {
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>
<customwidget>
<class>BlackGui::CUserView</class>
<extends>QTableView</extends>
<header>blackgui/userview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::CTransponderModeSelector</class>
<extends>QComboBox</extends>
<header>blackgui/transpondermodeselector.h</header>
</customwidget>
<customwidget> <customwidget>
<class>BlackGui::CStatusMessageView</class> <class>BlackGui::CStatusMessageView</class>
<extends>QTableView</extends> <extends>QTableView</extends>
@@ -2810,6 +2280,12 @@ QStatusBar QLabel {
<header>blackgui/textmessagecomponent.h</header> <header>blackgui/textmessagecomponent.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>BlackGui::CCockpitV1Component</class>
<extends>QWidget</extends>
<header>blackgui/cockpitv1component.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>cb_StatusWithDBus</tabstop> <tabstop>cb_StatusWithDBus</tabstop>
@@ -2818,25 +2294,6 @@ QStatusBar QLabel {
<tabstop>tvp_StatusMessages</tabstop> <tabstop>tvp_StatusMessages</tabstop>
<tabstop>le_CommandLineInput</tabstop> <tabstop>le_CommandLineInput</tabstop>
<tabstop>comp_AtcStations</tabstop> <tabstop>comp_AtcStations</tabstop>
<tabstop>pb_CockpitToggleCom1</tabstop>
<tabstop>ds_CockpitCom1Active</tabstop>
<tabstop>ds_CockpitCom1Standby</tabstop>
<tabstop>di_CockpitCom1Volume</tabstop>
<tabstop>pb_CockpitToggleCom2</tabstop>
<tabstop>ds_CockpitCom2Active</tabstop>
<tabstop>ds_CockpitCom2Standby</tabstop>
<tabstop>di_CockpitCom2Volume</tabstop>
<tabstop>pb_CockpitSelcalTest</tabstop>
<tabstop>cb_CockpitSelcal1</tabstop>
<tabstop>cb_CockpitSelcal2</tabstop>
<tabstop>ds_CockpitTransponder</tabstop>
<tabstop>cbp_CockpitTransponderMode</tabstop>
<tabstop>le_CockpitVoiceRoomCom1</tabstop>
<tabstop>cb_CockpitVoiceRoom1Override</tabstop>
<tabstop>le_CockpitVoiceRoomCom2</tabstop>
<tabstop>cb_CockpitVoiceRoom2Override</tabstop>
<tabstop>tvp_CockpitVoiceRoom1</tabstop>
<tabstop>tvp_CockpitVoiceRoom2</tabstop>
<tabstop>comp_TextMessages</tabstop> <tabstop>comp_TextMessages</tabstop>
<tabstop>tw_Settings</tabstop> <tabstop>tw_Settings</tabstop>
<tabstop>tvp_SettingsTnServers</tabstop> <tabstop>tvp_SettingsTnServers</tabstop>

View File

@@ -20,7 +20,6 @@ using namespace BlackMisc::Audio;
bool MainWindow::reloadOwnAircraft() bool MainWindow::reloadOwnAircraft()
{ {
if (!this->isContextNetworkAvailableCheck()) return false; if (!this->isContextNetworkAvailableCheck()) return false;
if (this->isCockpitUpdatePending()) return false;
// check for changed aircraft // check for changed aircraft
bool changed = false; bool changed = false;
@@ -28,7 +27,6 @@ bool MainWindow::reloadOwnAircraft()
if (loadedAircraft != this->m_ownAircraft) if (loadedAircraft != this->m_ownAircraft)
{ {
this->m_ownAircraft = loadedAircraft; this->m_ownAircraft = loadedAircraft;
this->updateCockpitFromContext();
this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft); this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft);
changed = true; changed = true;
} }

View File

@@ -1,346 +0,0 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
#include "blackmisc/voiceroom.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::Math;
using namespace BlackMisc::Audio;
/*
* Cockpit values
*/
void MainWindow::cockpitValuesChanged()
{
Q_ASSERT(this->m_timerCollectedCockpitUpdates);
// frequency switch?
QObject *sender = QObject::sender();
if (sender == this->ui->pb_CockpitToggleCom1)
{
if (this->ui->ds_CockpitCom1Standby->value() == this->ui->ds_CockpitCom1Active->value()) return;
double f = this->ui->ds_CockpitCom1Active->value();
this->ui->ds_CockpitCom1Active->setValue(this->ui->ds_CockpitCom1Standby->value());
this->ui->ds_CockpitCom1Standby->setValue(f);
}
else if (sender == this->ui->pb_CockpitToggleCom2)
{
if (this->ui->ds_CockpitCom2Standby->value() == this->ui->ds_CockpitCom2Active->value()) return;
double f = this->ui->ds_CockpitCom2Active->value();
this->ui->ds_CockpitCom2Active->setValue(this->ui->ds_CockpitCom2Standby->value());
this->ui->ds_CockpitCom2Standby->setValue(f);
}
else if (sender == this->ui->pb_CockpitIdent)
{
// trigger the real button
if (this->ui->cbp_CockpitTransponderMode->isIdentSelected())
{
this->ui->pb_CockpitIdent->setStyleSheet("");
this->ui->cbp_CockpitTransponderMode->resetTransponderMode();
}
else
{
this->ui->pb_CockpitIdent->setStyleSheet("background: red");
this->ui->cbp_CockpitTransponderMode->setSelectedTransponderModeStateIdent(); // trigger real button and whole process
}
return;
}
// this will call send cockpit updates with all changes made
// send cockpit updates
this->m_timerCollectedCockpitUpdates->stop();
this->m_timerCollectedCockpitUpdates->start(1000); // start
this->m_timerCollectedCockpitUpdates->setSingleShot(true);
}
/*
* Is pending update
*/
bool MainWindow::isCockpitUpdatePending() const
{
return (this->m_timerCollectedCockpitUpdates && this->m_timerCollectedCockpitUpdates->isActive());
}
/*
* Own cockpit
*/
void MainWindow::updateCockpitFromContext()
{
// update GUI elements
// avoid unnecessary change events as far as possible
const CComSystem com1 = this->m_ownAircraft.getCom1System(); // aircraft just updated or set from context
const CComSystem com2 = this->m_ownAircraft.getCom2System();
const CTransponder transponder = this->m_ownAircraft.getTransponder();
// update the frequencies
this->updateComFrequencyDisplays(com1, com2);
if (this->m_inputFocusedWidget != this->ui->ds_CockpitTransponder)
{
// update transponder if this is not input focused
qint32 tc = transponder.getTransponderCode();
if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value()))
this->ui->ds_CockpitTransponder->setValue(tc);
}
this->ui->cbp_CockpitTransponderMode->setSelectedTransponderMode(transponder.getTransponderMode());
if (this->m_contextNetworkAvailable)
{
CAtcStationList selectedStations = this->getIContextNetwork()->getSelectedAtcStations();
CAtcStation com1Station = selectedStations[0];
CAtcStation com2Station = selectedStations[1];
if (com1Station.getCallsign().isEmpty())
this->ui->lbl_CockpitCom1->setToolTip("");
else
this->ui->lbl_CockpitCom1->setToolTip(com1Station.getCallsign().getStringAsSet());
if (com2Station.getCallsign().isEmpty())
this->ui->lbl_CockpitCom2->setToolTip("");
else
this->ui->lbl_CockpitCom2->setToolTip(com2Station.getCallsign().getStringAsSet());
}
//
// Voice room override
//
if (this->m_contextAudioAvailable)
{
// get all rooms, it is important to get the rooms from voice context here
// these are the ones featuring the real audio status
CVoiceRoomList rooms = this->getIContextAudio()->getComVoiceRoomsWithAudioStatus();
Q_ASSERT(rooms.size() == 2);
CVoiceRoom room1 = rooms[0];
CVoiceRoom room2 = rooms[1];
bool com1Connected = room1.isConnected();
bool com2Connected = room2.isConnected();
// update views
this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
// highlite voice room according to status
QString vrStyle1;
QString vrStyle2;
if (!room1.getVoiceRoomUrl(true).isEmpty()) vrStyle1 = com1Connected ? "background: green" : "background: red";
if (!room2.getVoiceRoomUrl(true).isEmpty()) vrStyle2 = com2Connected ? "background: green" : "background: red";
this->ui->le_CockpitVoiceRoomCom1->setStyleSheet(vrStyle1);
this->ui->le_CockpitVoiceRoomCom2->setStyleSheet(vrStyle2);
// display URL if not override mode
if (!this->ui->cb_CockpitVoiceRoom1Override->isChecked())
{
// no override
QString s = room1.getVoiceRoomUrl();
this->ui->le_CockpitVoiceRoomCom1->setText(s);
}
// display URL if not override mode
if (!this->ui->cb_CockpitVoiceRoom2Override->isChecked())
{
// no overrride
QString s = room2.getVoiceRoomUrl();
this->ui->le_CockpitVoiceRoomCom2->setText(s);
}
}
// update some other GUI elements
this->ui->comp_TextMessages->setTabToolTip(BlackGui::CTextMessageComponent::TextMessagesCom1, com1.getFrequencyActive().valueRoundedWithUnit(3));
this->ui->comp_TextMessages->setTabToolTip(BlackGui::CTextMessageComponent::TextMessagesCom2, com2.getFrequencyActive().valueRoundedWithUnit(3));
}
/*
* Round the com frequency displays
*/
void MainWindow::updateComFrequencyDisplays(const CComSystem &com1, const CComSystem &com2)
{
// do not just set! Leads to unwanted signals fired
// only update if not focused
if (this->m_inputFocusedWidget != ui->ds_CockpitCom1Active)
{
double freq = com1.getFrequencyActive().valueRounded(3);
if (freq != this->ui->ds_CockpitCom1Active->value())
this->ui->ds_CockpitCom1Active->setValue(freq);
}
if (this->m_inputFocusedWidget != ui->ds_CockpitCom2Active)
{
double freq = com2.getFrequencyActive().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Active->value())
this->ui->ds_CockpitCom2Active->setValue(freq);
}
if (this->m_inputFocusedWidget != ui->ds_CockpitCom1Standby)
{
double freq = com1.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom1Standby->value())
this->ui->ds_CockpitCom1Standby->setValue(freq);
}
if (this->m_inputFocusedWidget != ui->ds_CockpitCom2Standby)
{
double freq = com2.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Standby->value())
this->ui->ds_CockpitCom2Standby->setValue(freq);
}
}
/*
* Reset transponder mode to Standby / Charly
*/
void MainWindow::resetTransponderMode()
{
this->ui->pb_CockpitIdent->setStyleSheet("");
}
/*
* Send cockpit updates
*/
void MainWindow::sendCockpitUpdates()
{
CTransponder transponder = this->m_ownAircraft.getTransponder();
CComSystem com1 = this->m_ownAircraft.getCom1System();
CComSystem com2 = this->m_ownAircraft.getCom2System();
//
// Transponder
//
QString transponderCode = QString::number(qRound(this->ui->ds_CockpitTransponder->value()));
if (CTransponder::isValidTransponderCode(transponderCode))
{
transponder.setTransponderCode(transponderCode);
}
else
{
this->displayStatusMessage(CStatusMessage::getValidationError("Wrong transponder code, reset"));
this->ui->ds_CockpitTransponder->setValue(transponder.getTransponderCode());
}
transponder.setTransponderMode(this->ui->cbp_CockpitTransponderMode->getSelectedTransponderMode());
if (this->ui->cbp_CockpitTransponderMode->isIdentSelected())
{
// ident shall be sent for some time, then reset
this->ui->pb_CockpitIdent->setStyleSheet("background: red");
}
//
// COM units
//
com1.setFrequencyActiveMHz(this->ui->ds_CockpitCom1Active->value());
com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value());
com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value());
com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value());
this->updateComFrequencyDisplays(com1, com2);
//
// Send to context
//
bool changedCockpit = false;
if (this->m_contextNetworkAvailable)
{
if (this->m_ownAircraft.getCom1System() != com1 ||
this->m_ownAircraft.getCom2System() != com2 ||
this->m_ownAircraft.getTransponder() != transponder)
{
this->getIContextOwnAircraft()->updateOwnCockpit(com1, com2, transponder, MainWindow::ownAircraftContextOriginator());
this->reloadOwnAircraft(); // also loads resolved voice rooms
changedCockpit = true;
}
}
//
// Now with the new voice room data, really set the
// voice rooms in the context
//
if (changedCockpit) this->setAudioVoiceRooms();
}
/*
* Voice room override
*/
void MainWindow::setAudioVoiceRooms()
{
if (!this->m_contextAudioAvailable) return;
if (!this->m_contextNetworkAvailable) return;
// make fields readonly if not overriding
this->ui->le_CockpitVoiceRoomCom1->setReadOnly(!this->ui->cb_CockpitVoiceRoom1Override->isChecked());
this->ui->le_CockpitVoiceRoomCom2->setReadOnly(!this->ui->cb_CockpitVoiceRoom2Override->isChecked());
CVoiceRoom room1;
CVoiceRoom room2;
CVoiceRoomList selectedVoiceRooms = this->getIContextNetwork()->getSelectedVoiceRooms();
Q_ASSERT(selectedVoiceRooms.size() == 2);
if (this->ui->cb_CockpitVoiceRoom1Override->isChecked())
room1 = CVoiceRoom(this->ui->le_CockpitVoiceRoomCom1->text().trimmed());
else
{
room1 = selectedVoiceRooms[0];
room1.setAudioPlaying(true);
this->ui->le_CockpitVoiceRoomCom1->setText(room1.getVoiceRoomUrl());
}
if (this->ui->cb_CockpitVoiceRoom2Override->isChecked())
room2 = CVoiceRoom(this->ui->le_CockpitVoiceRoomCom1->text().trimmed());
else
{
room2 = selectedVoiceRooms[1];
room2.setAudioPlaying(true);
this->ui->le_CockpitVoiceRoomCom2->setText(room2.getVoiceRoomUrl());
}
// set the real voice rooms for audio output
this->getIContextAudio()->setComVoiceRooms(room1, room2);
}
/*
* Test SELCAL code
*/
void MainWindow::testSelcal()
{
QString selcalCode = this->getSelcalCode();
if (!CSelcal::isValidCode(selcalCode))
{
this->displayStatusMessage(
CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityWarning, "invalid SELCAL codde"));
return;
}
if (this->m_contextAudioAvailable)
{
CSelcal selcal(selcalCode);
this->getIContextAudio()->playSelcalTone(selcal);
}
else
{
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "No audi available"));
}
}
/*
* SELCAL value selected
*/
QString MainWindow::getSelcalCode() const
{
QString selcal = this->ui->cb_CockpitSelcal1->currentText().append(this->ui->cb_CockpitSelcal2->currentText());
return selcal;
}
/*
* Current input focus
*/
void MainWindow::inputFocusChanged(QWidget *oldWidget, QWidget *newWidget)
{
Q_UNUSED(oldWidget);
this->m_inputFocusedWidget = newWidget;
}

View File

@@ -59,19 +59,8 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->ui->sb_MainStatusBar->addPermanentWidget(grip); this->ui->sb_MainStatusBar->addPermanentWidget(grip);
} }
// init encapsulated table views / models
this->ui->tvp_CockpitVoiceRoom1->setUserMode(CUserListModel::UserShort);
this->ui->tvp_CockpitVoiceRoom2->setUserMode(CUserListModel::UserShort);
// SELCAL pairs in cockpit
this->ui->cb_CockpitSelcal1->clear();
this->ui->cb_CockpitSelcal2->clear();
this->ui->cb_CockpitSelcal1->addItems(BlackMisc::Aviation::CSelcal::codePairs());
this->ui->cb_CockpitSelcal2->addItems(BlackMisc::Aviation::CSelcal::codePairs());
// timers // timers
if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this); if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this);
if (this->m_timerCollectedCockpitUpdates == nullptr) this->m_timerCollectedCockpitUpdates = new QTimer(this);
if (this->m_timerAudioTests == nullptr) this->m_timerAudioTests = new QTimer(this); if (this->m_timerAudioTests == nullptr) this->m_timerAudioTests = new QTimer(this);
if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this); if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this);
@@ -116,7 +105,6 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
Q_ASSERT(connect); Q_ASSERT(connect);
this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged); this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged);
this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates);
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate); this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate);
this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
connect = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate); connect = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate);
@@ -138,6 +126,9 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->setAudioDeviceLists(); this->setAudioDeviceLists();
this->ui->prb_SettingsAudioTestProgress->setVisible(false); this->ui->prb_SettingsAudioTestProgress->setVisible(false);
// cockpit external buttons
this->ui->comp_Cockpit->setExternalIdentButton(this->ui->pb_CockpitIdent);
// data // data
this->initialDataReads(); this->initialDataReads();
@@ -208,8 +199,7 @@ void MainWindow::initGuiSignals()
// Sound buttons // Sound buttons
this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, this, &MainWindow::audioVolumes); this->connect(this->ui->pb_SoundMute, &QPushButton::clicked, this, &MainWindow::audioVolumes);
this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::audioVolumes); this->connect(this->ui->pb_SoundMaxVolume, &QPushButton::clicked, this, &MainWindow::audioVolumes);
connected = this->connect(this->ui->di_CockpitCom1Volume, &QDial::valueChanged, this, &MainWindow::audioVolumes); this->connect(this->ui->comp_Cockpit, &CCockpitV1Component::audioVolumeChanged, this, &MainWindow::audioVolumes);
connected = this->connect(this->ui->di_CockpitCom2Volume, &QDial::valueChanged, this, &MainWindow::audioVolumes);
// menu // menu
this->connect(this->ui->menu_ReloadSettings, &QAction::triggered, this, &MainWindow::menuClicked); this->connect(this->ui->menu_ReloadSettings, &QAction::triggered, this, &MainWindow::menuClicked);
@@ -226,27 +216,7 @@ void MainWindow::initGuiSignals()
Q_ASSERT(connected); Q_ASSERT(connected);
this->connect(this->ui->comp_TextMessages, SIGNAL(displayOverlayInfo(BlackMisc::CStatusMessage)), this, SLOT(displayOverlayInfo(BlackMisc::CStatusMessage))); this->connect(this->ui->comp_TextMessages, SIGNAL(displayOverlayInfo(BlackMisc::CStatusMessage)), this, SLOT(displayOverlayInfo(BlackMisc::CStatusMessage)));
Q_ASSERT(connected); Q_ASSERT(connected);
this->ui->comp_TextMessages->setSelcalCallback(std::bind(&MainWindow::getSelcalCode, this)); this->ui->comp_TextMessages->setSelcalCallback(std::bind(&CCockpitV1Component::getSelcalCode, this->ui->comp_Cockpit));
// cockpit
connected = this->connect(this->ui->cbp_CockpitTransponderMode, SIGNAL(currentIndexChanged(QString)), this, SLOT(cockpitValuesChanged()));
Q_ASSERT(connected);
this->connect(this->ui->ds_CockpitCom1Active, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->ds_CockpitCom2Active, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->ds_CockpitCom1Standby, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->ds_CockpitCom2Standby, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->ds_CockpitTransponder, &QDoubleSpinBox::editingFinished, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->cb_CockpitVoiceRoom1Override, &QCheckBox::clicked, this, &MainWindow::setAudioVoiceRooms);
this->connect(this->ui->cb_CockpitVoiceRoom2Override, &QCheckBox::clicked, this, &MainWindow::setAudioVoiceRooms);
this->connect(this->ui->le_CockpitVoiceRoomCom1, &QLineEdit::returnPressed, this, &MainWindow::setAudioVoiceRooms);
this->connect(this->ui->le_CockpitVoiceRoomCom2, &QLineEdit::returnPressed, this, &MainWindow::setAudioVoiceRooms);
this->connect(this->ui->pb_CockpitToggleCom1, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->pb_CockpitIdent, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &MainWindow::testSelcal);
this->connect(this->ui->cbp_CockpitTransponderMode, &CTransponderModeSelector::identEnded, this, &MainWindow::resetTransponderMode);
this->connect(qApp, &QApplication::focusChanged, this, &MainWindow::inputFocusChanged);
// voice // voice
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int))); connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
@@ -329,14 +299,12 @@ void MainWindow::stopAllTimers(bool disconnect)
{ {
this->m_timerStatusBar->stop(); this->m_timerStatusBar->stop();
this->m_timerContextWatchdog->stop(); this->m_timerContextWatchdog->stop();
this->m_timerCollectedCockpitUpdates->stop();
this->m_timerAudioTests->stop(); this->m_timerAudioTests->stop();
this->m_timerSimulator->stop(); this->m_timerSimulator->stop();
this->stopUpdateTimers(); this->stopUpdateTimers();
if (!disconnect) return; if (!disconnect) return;
this->disconnect(this->m_timerStatusBar); this->disconnect(this->m_timerStatusBar);
this->disconnect(this->m_timerContextWatchdog); this->disconnect(this->m_timerContextWatchdog);
this->disconnect(this->m_timerCollectedCockpitUpdates);
this->disconnect(this->m_timerAudioTests); this->disconnect(this->m_timerAudioTests);
this->disconnect(this->m_timerSimulator); this->disconnect(this->m_timerSimulator);
} }

View File

@@ -64,9 +64,7 @@ void MainWindow::menuClicked()
void MainWindow::initContextMenus() void MainWindow::initContextMenus()
{ {
this->ui->lbl_StatusVoiceStatus->setContextMenuPolicy(Qt::CustomContextMenu); 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_StatusVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
connect(this->ui->lbl_CockpitVoiceStatus, &QLabel::customContextMenuRequested, this, &MainWindow::audioIconContextMenu);
} }
/* /*

View File

@@ -119,15 +119,14 @@ void MainWindow::audioVolumes()
muted = false; muted = false;
com1.setVolumeOutput(100); com1.setVolumeOutput(100);
com2.setVolumeOutput(100); com2.setVolumeOutput(100);
this->ui->di_CockpitCom1Volume->setValue(100); this->ui->comp_Cockpit->setCom1Volume(100);
this->ui->di_CockpitCom2Volume->setValue(100); this->ui->comp_Cockpit->setCom2Volume(100);
} }
else if (sender == this->ui->di_CockpitCom1Volume || else if (this->ui->comp_Cockpit->isCockpitVolumeWidget(sender))
sender == this->ui->di_CockpitCom2Volume)
{ {
muted = false; muted = false;
com1.setVolumeOutput(this->ui->di_CockpitCom1Volume->value()); com1.setVolumeOutput(this->ui->comp_Cockpit->getCom1Volume());
com2.setVolumeOutput(this->ui->di_CockpitCom2Volume->value()); com2.setVolumeOutput(this->ui->comp_Cockpit->getCom2Volume());
} }
else else
{ {
@@ -139,7 +138,7 @@ void MainWindow::audioVolumes()
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_StatusVoiceStatus->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->comp_Cockpit->setCockpitVoiceStatusPixmap(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!");