mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T609, tristate LED showing if synced with simulator com
This commit is contained in:
@@ -343,7 +343,7 @@ namespace BlackCore
|
||||
const bool c = m_simulatorPlugin.second->setTimeSynchronization(enable, offset);
|
||||
if (!c) { return false; }
|
||||
|
||||
CLogMessage(this).info(enable ? QStringLiteral("Set time syncronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization"));
|
||||
CLogMessage(this).info(enable ? QStringLiteral("Set time synchronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "blackcore/context/contextaudio.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackcore/context/contextownaircraft.h"
|
||||
#include "blackgui/components/cockpitcomcomponent.h"
|
||||
#include "blackgui/components/selcalcodeselector.h"
|
||||
@@ -72,11 +73,14 @@ namespace BlackGui
|
||||
connect(ui->editor_Com, &CCockpitComForm::transponderStateIdentEnded, this, &CCockpitComComponent::transponderStateIdentEnded);
|
||||
|
||||
// hook up with changes from own aircraft context
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection);
|
||||
if (sGui)
|
||||
{
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection);
|
||||
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection);
|
||||
|
||||
// hook up with audio context
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection);
|
||||
// hook up with audio context
|
||||
connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
CCockpitComComponent::~CCockpitComComponent()
|
||||
@@ -110,10 +114,13 @@ namespace BlackGui
|
||||
ui->editor_Com->setTransponder(transponder);
|
||||
|
||||
// selected stations
|
||||
if (sGui && sGui->getIContextNetwork())
|
||||
if (sGui)
|
||||
{
|
||||
const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations();
|
||||
ui->editor_Com->setSelectedAtcStations(selectedStations);
|
||||
if (sGui->getIContextNetwork())
|
||||
{
|
||||
const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations();
|
||||
ui->editor_Com->setSelectedAtcStations(selectedStations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QPaintEvent;
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CCockpitComComponent; }
|
||||
namespace BlackMisc { namespace Aviation { class CComSystem; } }
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "cockpitcomform.h"
|
||||
#include "ui_cockpitcomform.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/icons.h"
|
||||
@@ -38,7 +40,7 @@ namespace BlackGui
|
||||
connect(ui->tb_ComPanelSelcalTest, &QPushButton::clicked, this, &CCockpitComForm::testSelcal);
|
||||
connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onSelcalChanged);
|
||||
|
||||
// XPdr
|
||||
// XPDR
|
||||
connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitComForm::transponderModeChanged);
|
||||
connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderStateIdentEnded, this, &CCockpitComForm::transponderStateIdentEnded);
|
||||
|
||||
@@ -155,9 +157,13 @@ namespace BlackGui
|
||||
|
||||
ui->led_ComPanelCom1R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 receive (sim)", "COM1 not receiving", 14);
|
||||
ui->led_ComPanelCom1S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 trasmit (sim)", "COM1 not transmitting", 14);
|
||||
ui->led_ComPanelCom1R->setTriStateValues(CLedWidget::Blue, "receive not synced");
|
||||
ui->led_ComPanelCom1S->setTriStateValues(CLedWidget::Blue, "transmit not synced");
|
||||
|
||||
ui->led_ComPanelCom2R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 receive (sim)", "COM2 not receiving", 14);
|
||||
ui->led_ComPanelCom2S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 trasmit (sim)", "COM2 not transmitting", 14);
|
||||
ui->led_ComPanelCom2R->setTriStateValues(CLedWidget::Blue, "receive not synced");
|
||||
ui->led_ComPanelCom2S->setTriStateValues(CLedWidget::Blue, "transmit not synced");
|
||||
}
|
||||
|
||||
CSimulatedAircraft CCockpitComForm::cockpitValuesToAircraftObject()
|
||||
@@ -223,6 +229,7 @@ namespace BlackGui
|
||||
ui->ds_ComPanelCom2Standby->setValue(freq);
|
||||
}
|
||||
|
||||
this->updateIntegrateFromSimulatorContext();
|
||||
this->updateActiveCOMUnitLEDs(m_integratedWithSim, com1.isSendEnabled(), com1.isReceiveEnabled(), com2.isSendEnabled(), com2.isReceiveEnabled());
|
||||
}
|
||||
|
||||
@@ -306,6 +313,17 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CCockpitComForm::updateIntegrateFromSimulatorContext()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator())
|
||||
{
|
||||
m_integratedWithSim = false;
|
||||
return;
|
||||
}
|
||||
const bool integrated = sGui->getIContextSimulator()->getSimulatorSettings().isComIntegrated();
|
||||
m_integratedWithSim = integrated;
|
||||
}
|
||||
|
||||
bool CCockpitComForm::isFrequenceEqual(double f1, double f2)
|
||||
{
|
||||
return CMathUtils::epsilonEqual(f1, f2);
|
||||
|
||||
@@ -91,6 +91,8 @@ namespace BlackGui
|
||||
//! @}
|
||||
|
||||
private:
|
||||
bool m_integratedWithSim = false; //!< Synced with simulator
|
||||
|
||||
//! Init LEDs
|
||||
void initLeds();
|
||||
|
||||
@@ -109,6 +111,9 @@ namespace BlackGui
|
||||
//! Update UI for COM unit
|
||||
void updateActiveCOMUnitLEDs(bool integratedWithSim, bool com1S, bool com1R, bool com2S, bool com2R);
|
||||
|
||||
//! Update from simulator context
|
||||
void updateIntegrateFromSimulatorContext();
|
||||
|
||||
//! Compare 2 frequencies (consider epsilon)
|
||||
static bool isFrequenceEqual(double f1, double f2);
|
||||
|
||||
|
||||
@@ -163,12 +163,18 @@ namespace BlackGui
|
||||
this->setLed();
|
||||
}
|
||||
|
||||
void CLedWidget::setTriStateToolTip(const QString &triState)
|
||||
void CLedWidget::setTriStateToolTip(const QString &triStateTooltip)
|
||||
{
|
||||
m_tooltipTriState = triState;
|
||||
m_tooltipTriState = triStateTooltip;
|
||||
this->setLed();
|
||||
}
|
||||
|
||||
void CLedWidget::setTriStateValues(CLedWidget::LedColor color, const QString &tooltip)
|
||||
{
|
||||
m_tooltipTriState = tooltip;
|
||||
m_colorTriState = color;
|
||||
}
|
||||
|
||||
void CLedWidget::setOnColor(LedColor color)
|
||||
{
|
||||
if (color == m_colorOn) return;
|
||||
|
||||
@@ -119,7 +119,10 @@ namespace BlackGui
|
||||
void setOffToolTip(const QString &off);
|
||||
|
||||
//! Tri-state tool tip
|
||||
void setTriStateToolTip(const QString &triState);
|
||||
void setTriStateToolTip(const QString &triStateTooltip);
|
||||
|
||||
//! Tri-state
|
||||
void setTriStateValues(LedColor color, const QString &tooltip);
|
||||
|
||||
//! New values dual state
|
||||
void setValues(LedColor onColor, LedColor offColor, LedShape shape, const QString &toolTipOn, const QString &toolTipOff, int width = -1);
|
||||
|
||||
Reference in New Issue
Block a user