mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #818, allow to log dummy messages / text messages from internals UI
* UI * slots in network context * adjusted overlay layout (based on the tests)
This commit is contained in:
@@ -146,10 +146,10 @@ namespace BlackCore
|
||||
//! Connection status changed
|
||||
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
|
||||
//! Text messages received (also private chat messages, rfaio channel messages)
|
||||
//! Text messages received (also private chat messages, radio channel messages)
|
||||
void textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages);
|
||||
|
||||
//! A superivisor text message was received
|
||||
//! A supervisor text message was received
|
||||
void supervisorTextMessageReceived(const BlackMisc::Network::CTextMessage &message);
|
||||
|
||||
//! Text message sent (by me)
|
||||
@@ -283,6 +283,9 @@ namespace BlackCore
|
||||
//! Inject aircraft parts for testing
|
||||
virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) = 0;
|
||||
|
||||
//! Inject a text message as received
|
||||
virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) = 0;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextNetwork(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
@@ -229,6 +229,13 @@ namespace BlackCore
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::testReceivedTextMessages
|
||||
virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override
|
||||
{
|
||||
Q_UNUSED(textMessages);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
|
||||
@@ -654,6 +654,15 @@ namespace BlackCore
|
||||
this->m_airspace->testAddAircraftParts(callsign, parts, incremental);
|
||||
}
|
||||
|
||||
void CContextNetwork::testReceivedTextMessages(const CTextMessageList &textMessages)
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages.toQString(); }
|
||||
if (this->network())
|
||||
{
|
||||
emit this->network()->textMessagesReceived(textMessages);
|
||||
}
|
||||
}
|
||||
|
||||
CMetar CContextNetwork::getMetarForAirport(const BlackMisc::Aviation::CAirportIcaoCode &airportIcaoCode) const
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << airportIcaoCode; }
|
||||
|
||||
@@ -273,6 +273,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::testAddAircraftParts
|
||||
virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
|
||||
|
||||
//! \copydoc IContextNetwork::testReceivedTextMessages
|
||||
virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
|
||||
//! Gracefully shut down, e.g. for thread safety
|
||||
void gracefulShutdown();
|
||||
|
||||
|
||||
@@ -241,6 +241,11 @@ namespace BlackCore
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("testAddAircraftParts"), callsign, parts, incremental);
|
||||
}
|
||||
|
||||
void CContextNetworkProxy::testReceivedTextMessages(const CTextMessageList &textMessages)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("testReceivedTextMessages"), textMessages);
|
||||
}
|
||||
|
||||
CStatusMessage CContextNetworkProxy::connectToNetwork(const CServer &server, INetwork::LoginMode loginMode)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessage>(QLatin1Literal("connectToNetwork"), server, loginMode);
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace BlackCore
|
||||
virtual void enableReverseLookupMessages(bool enabled) override;
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) override;
|
||||
virtual void testAddAircraftParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftParts &parts, bool incremental) override;
|
||||
virtual void testReceivedTextMessages(const BlackMisc::Network::CTextMessageList &textMessages) override;
|
||||
//! @}
|
||||
|
||||
private:
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#include "blackgui/components/internalscomponent.h"
|
||||
#include "blackgui/components/remoteaircraftselector.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/uppercasevalidator.h"
|
||||
#include "blackmisc/aviation/aircraftenginelist.h"
|
||||
#include "blackmisc/aviation/aircraftlights.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/network/textmessage.h"
|
||||
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -35,6 +37,8 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
@@ -46,6 +50,11 @@ namespace BlackGui
|
||||
ui(new Ui::CInternalsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tw_Internals->setCurrentIndex(0);
|
||||
|
||||
ui->le_TxtMsgFrom->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
|
||||
ui->le_TxtMsgTo->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
|
||||
|
||||
connect(ui->pb_SendAircraftPartsGui, &QPushButton::pressed, this, &CInternalsComponent::ps_sendAircraftParts);
|
||||
connect(ui->pb_SendAircraftPartsJson, &QPushButton::pressed, this, &CInternalsComponent::ps_sendAircraftParts);
|
||||
connect(ui->pb_AircraftPartsLightsOn, &QPushButton::pressed, this, &CInternalsComponent::ps_setAllLights);
|
||||
@@ -64,6 +73,10 @@ namespace BlackGui
|
||||
connect(ui->cb_DebugInterpolator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_ForceFullInterpolation, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
|
||||
connect(ui->pb_SendTextMessage, &QPushButton::pressed, this, &CInternalsComponent::ps_sendTextMessage);
|
||||
connect(ui->tb_LogStatusMessage, &QPushButton::pressed, this, &CInternalsComponent::ps_logStatusMessage);
|
||||
connect(ui->le_StatusMessage, &QLineEdit::returnPressed, this, &CInternalsComponent::ps_logStatusMessage);
|
||||
|
||||
contextFlagsToGui();
|
||||
}
|
||||
|
||||
@@ -178,6 +191,52 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_sendTextMessage()
|
||||
{
|
||||
if (ui->le_TxtMsgTo->text().isEmpty()) { return; }
|
||||
if (ui->le_TxtMsgFrom->text().isEmpty()) { return; }
|
||||
if (ui->pte_TxtMsg->toPlainText().isEmpty()) { return; }
|
||||
if (!sGui->getIContextNetwork()) { return; }
|
||||
|
||||
const CCallsign sender(ui->le_TxtMsgFrom->text().trimmed());
|
||||
const CCallsign recipient(ui->le_TxtMsgTo->text().trimmed());
|
||||
const QString msgTxt(ui->pte_TxtMsg->toPlainText().trimmed());
|
||||
const double freqMHz = ui->dsb_TxtMsgFrequency->value();
|
||||
CTextMessage tm;
|
||||
CFrequency f;
|
||||
if (freqMHz >= 118.0)
|
||||
{
|
||||
f = CFrequency(freqMHz, CFrequencyUnit::MHz());
|
||||
tm = CTextMessage(msgTxt, f, sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
tm = CTextMessage(msgTxt, sender, recipient);
|
||||
}
|
||||
tm.setCurrentUtcTime();
|
||||
sGui->getIContextNetwork()->testReceivedTextMessages(CTextMessageList({ tm }));
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_logStatusMessage()
|
||||
{
|
||||
if (ui->le_StatusMessage->text().isEmpty()) { return; }
|
||||
CStatusMessage::StatusSeverity s = CStatusMessage::SeverityDebug;
|
||||
if (ui->rb_StatusMessageError->isChecked())
|
||||
{
|
||||
s = CStatusMessage::SeverityError;
|
||||
}
|
||||
else if (ui->rb_StatusMessageWarning->isChecked())
|
||||
{
|
||||
s = CStatusMessage::SeverityWarning;
|
||||
}
|
||||
else if (ui->rb_StatusMessageInfo->isChecked())
|
||||
{
|
||||
s = CStatusMessage::SeverityInfo;
|
||||
}
|
||||
const CStatusMessage sm = CStatusMessage(this, s, ui->le_StatusMessage->text().trimmed());
|
||||
CLogMessage::preformatted(sm);
|
||||
}
|
||||
|
||||
CAircraftParts CInternalsComponent::guiToAircraftParts() const
|
||||
{
|
||||
CAircraftLights lights(
|
||||
|
||||
@@ -54,12 +54,18 @@ namespace BlackGui
|
||||
//! Set all engines
|
||||
void ps_setAllEngines();
|
||||
|
||||
//! GUI to Json
|
||||
//! GUI to JSON
|
||||
void ps_guiToJson();
|
||||
|
||||
//! Enable / disable debugging
|
||||
void ps_enableDebug(int state);
|
||||
|
||||
//! Send the text message
|
||||
void ps_sendTextMessage();
|
||||
|
||||
//! Send a dummy status message
|
||||
void ps_logStatusMessage();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInternalsComponent> ui;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>282</width>
|
||||
<width>289</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -56,7 +56,7 @@
|
||||
<property name="title">
|
||||
<string>Contexts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gl_Contexts">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_DebugContextAudio">
|
||||
<property name="text">
|
||||
@@ -100,7 +100,7 @@
|
||||
<property name="title">
|
||||
<string>Driver plugin and interpolator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="gl_DriverAndInterpolator">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_DebugDriver">
|
||||
<property name="text">
|
||||
@@ -125,6 +125,126 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="wi_StatusMessage" native="true">
|
||||
<layout class="QGridLayout" name="gl_StatusMessage">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="3">
|
||||
<widget class="QRadioButton" name="rb_StatusMessageWarning">
|
||||
<property name="text">
|
||||
<string>w</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QRadioButton" name="rb_StatusMessageError">
|
||||
<property name="text">
|
||||
<string>e</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QRadioButton" name="rb_StatusMessageInfo">
|
||||
<property name="text">
|
||||
<string>i</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="le_StatusMessage">
|
||||
<property name="placeholderText">
|
||||
<string>status message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="tb_LogStatusMessage">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/arrow-circle-225-left.png</normaloff>:/diagona/icons/diagona/icons/arrow-circle-225-left.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="wi_TextMessages" native="true">
|
||||
<layout class="QGridLayout" name="gl_TextMessages">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="dsb_TxtMsgFrequency">
|
||||
<property name="suffix">
|
||||
<string>MHz</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>117.974999999999994</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>136.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.025000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>117.974999999999994</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pb_SendTextMessage">
|
||||
<property name="text">
|
||||
<string>send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_TextMessages">
|
||||
<property name="text">
|
||||
<string>Text messages:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_TxtMsgFrom">
|
||||
<property name="placeholderText">
|
||||
<string>from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="le_TxtMsgTo">
|
||||
<property name="placeholderText">
|
||||
<string>to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QPlainTextEdit" name="pte_TxtMsg">
|
||||
<property name="placeholderText">
|
||||
<string>Text message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs_DebugWidget">
|
||||
<property name="orientation">
|
||||
@@ -543,6 +663,8 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="sw_StatusMessagesComponent">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_StatusMessages">
|
||||
<layout class="QVBoxLayout" name="vl_PgStatusMessages">
|
||||
@@ -242,10 +242,13 @@
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_TextMessage">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_TmTo">
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
<string>to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -280,7 +283,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QTextEdit" name="te_TmText"/>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user