mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #316 Blackgui changes: using CLogMessage and removed sendStatusMessage signals.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "atcstationcomponent.h"
|
||||
#include "../views/atcstationview.h"
|
||||
#include "ui_atcstationcomponent.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
//! \file
|
||||
|
||||
@@ -103,7 +104,7 @@ namespace BlackGui
|
||||
if (sender == this->ui->tvp_AtcStationsBooked && this->getIContextNetwork())
|
||||
{
|
||||
// trigger new read, which takes some time. A signal will be received when this is done
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Requested new bookings", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Requested new bookings");
|
||||
this->getIContextNetwork()->readAtcBookingsFromSource();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackcore/context_ownaircraft_impl.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackmisc/voiceroom.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
@@ -221,7 +222,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getValidationError("Wrong transponder code, reset"));
|
||||
CLogMessage().error(validationMessageCategory(), "Wrong transponder code, reset");
|
||||
this->ui->ds_CockpitTransponder->setValue(transponder.getTransponderCode());
|
||||
}
|
||||
transponder.setTransponderMode(this->ui->cbp_CockpitTransponderMode->getSelectedTransponderMode());
|
||||
@@ -391,7 +392,7 @@ namespace BlackGui
|
||||
QString selcalCode = this->getSelcalCode();
|
||||
if (!CSelcal::isValidCode(selcalCode))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityWarning, "Invalid SELCAL codde"));
|
||||
CLogMessage().error(validationMessageCategory(), "Invalid SELCAL codde");
|
||||
}
|
||||
else if (this->getIContextAudio())
|
||||
{
|
||||
@@ -400,7 +401,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "No audio available"));
|
||||
CLogMessage().error(validationMessageCategory(), "No audio available");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "flightplancomponent.h"
|
||||
#include "ui_flightplancomponent.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -107,20 +108,17 @@ namespace BlackGui
|
||||
v = ui->le_Callsign->text().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_Callsign->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_Callsign->text());
|
||||
}
|
||||
|
||||
v = ui->pte_Route->toPlainText().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("Missing flight plan route");
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing flight plan route"));
|
||||
}
|
||||
else if (v.length() > CFlightPlan::MaxRouteLength)
|
||||
{
|
||||
QString m = QString("Flight plan route length exceeded (%1 chars max.)").arg(CFlightPlan::MaxRouteLength);
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength);
|
||||
}
|
||||
else
|
||||
flightPlan.setRoute(v);
|
||||
@@ -128,13 +126,11 @@ namespace BlackGui
|
||||
v = ui->pte_Remarks->toPlainText().trimmed();
|
||||
if (v.isEmpty())
|
||||
{
|
||||
QString m = QString("No remarks, voice capabilities are mandatory");
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "No remarks, voice capabilities are mandatory"));
|
||||
}
|
||||
else if (v.length() > CFlightPlan::MaxRemarksLength)
|
||||
{
|
||||
QString m = QString("Flight plan remarks length exceeded (%1 chars max.)").arg(CFlightPlan::MaxRemarksLength);
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength);
|
||||
}
|
||||
else
|
||||
flightPlan.setRemarks(v);
|
||||
@@ -142,8 +138,7 @@ namespace BlackGui
|
||||
v = ui->le_EstimatedTimeEnroute->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_EstimatedTimeEnroute->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_EstimatedTimeEnroute->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setEnrouteTime(v);
|
||||
@@ -151,8 +146,7 @@ namespace BlackGui
|
||||
v = ui->le_FuelOnBoard->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_FuelOnBorad->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_FuelOnBorad->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setFuelTime(v);
|
||||
@@ -160,8 +154,7 @@ namespace BlackGui
|
||||
v = ui->le_TakeOffTimePlanned->text();
|
||||
if (v.isEmpty() || v == defaultTime())
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_TakeOffTimePlanned->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_TakeOffTimePlanned->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setTakeoffTimePlanned(v);
|
||||
@@ -177,8 +170,7 @@ namespace BlackGui
|
||||
CAltitude cruisingAltitude(v, CPqString::SeparatorsLocale);
|
||||
if (v.isEmpty() || cruisingAltitude.isNull())
|
||||
{
|
||||
QString m = QString("Wrong %1").arg(this->ui->lbl_CrusingAltitude->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong %1") << this->ui->lbl_CrusingAltitude->text());
|
||||
}
|
||||
else
|
||||
flightPlan.setCruiseAltitude(cruisingAltitude);
|
||||
@@ -186,8 +178,7 @@ namespace BlackGui
|
||||
v = this->ui->le_AlternateAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_AlternateAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_AlternateAirport->text());
|
||||
flightPlan.setAlternateAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -196,8 +187,7 @@ namespace BlackGui
|
||||
v = this->ui->le_DestinationAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_DestinationAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_DestinationAirport->text());
|
||||
flightPlan.setDestinationAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -208,8 +198,7 @@ namespace BlackGui
|
||||
cruiseTAS.parseFromString(v, CPqString::SeparatorsLocale);
|
||||
if (cruiseTAS.isNull())
|
||||
{
|
||||
QString m = QString("Wrong TAS, %1").arg(this->ui->lbl_CruiseTrueAirspeed->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong TAS, %1") << this->ui->lbl_CruiseTrueAirspeed->text());
|
||||
flightPlan.setDestinationAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -218,8 +207,7 @@ namespace BlackGui
|
||||
v = this->ui->le_OriginAirport->text();
|
||||
if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive))
|
||||
{
|
||||
QString m = QString("Missing %1").arg(this->ui->lbl_OriginAirport->text());
|
||||
messages.push_back(CStatusMessage::getValidationError(m));
|
||||
messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_OriginAirport->text());
|
||||
flightPlan.setOriginAirportIcao(defaultIcao());
|
||||
}
|
||||
else
|
||||
@@ -235,41 +223,27 @@ namespace BlackGui
|
||||
if (messages.isEmpty())
|
||||
{
|
||||
// no error, send if possible
|
||||
CStatusMessage m;
|
||||
if (this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
flightPlan.setWhenLastSentOrLoaded(QDateTime::currentDateTimeUtc());
|
||||
this->getIContextNetwork()->sendFlightPlan(flightPlan);
|
||||
this->ui->le_LastSent->setText(flightPlan.whenLastSentOrLoaded().toString());
|
||||
m = CStatusMessage::getInfoMessage("Sent flight plan", CStatusMessage::TypeTrafficNetwork);
|
||||
CLogMessage().info(this, "Sent flight plan");
|
||||
}
|
||||
else
|
||||
{
|
||||
flightPlan.setWhenLastSentOrLoaded(QDateTime()); // empty
|
||||
this->ui->le_LastSent->clear();
|
||||
m = CStatusMessage::getErrorMessage("No errors, but not connected, cannot send flight plan", CStatusMessage::TypeTrafficNetwork);
|
||||
CLogMessage().error(this, "No errors, but not connected, cannot send flight plan");
|
||||
}
|
||||
this->sendStatusMessage(m);
|
||||
this->m_flightPlan = flightPlan; // last valid FP
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessages(messages);
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::validateFlightPlan()
|
||||
{
|
||||
CFlightPlan flightPlan;
|
||||
CStatusMessageList messages = this->validateAndInitializeFlightPlan(flightPlan);
|
||||
if (messages.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("No errors", CStatusMessage::TypeTrafficNetwork));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessages(messages);
|
||||
}
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::resetFlightPlan()
|
||||
@@ -296,12 +270,12 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextNetwork())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Cannot load flight plan, network not available", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Cannot load flight plan, network not available");
|
||||
return;
|
||||
}
|
||||
if (!this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getWarningMessage("Cannot load flight plan, network not connected", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().warning(this, "Cannot load flight plan, network not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -310,11 +284,11 @@ namespace BlackGui
|
||||
if (loadedPlan.wasSentOrLoaded())
|
||||
{
|
||||
this->fillWithFlightPlanData(loadedPlan);
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Updated with loaded flight plan", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Updated with loaded flight plan");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getWarningMessage("No flight plan data", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().warning(this, "No flight plan data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +368,7 @@ namespace BlackGui
|
||||
void CFlightPlanComponent::copyRemarks()
|
||||
{
|
||||
this->ui->pte_Remarks->setPlainText(this->ui->pte_RemarksGenerated->toPlainText());
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Copied remarks", CStatusMessage::TypeTrafficNetwork));
|
||||
CLogMessage().info(this, "Copied remarks");
|
||||
}
|
||||
|
||||
void CFlightPlanComponent::currentTabGenerator()
|
||||
|
||||
@@ -42,18 +42,6 @@ namespace BlackGui
|
||||
this->m_runtimeOwner = true;
|
||||
}
|
||||
|
||||
void CRuntimeBasedComponent::sendStatusMessage(const BlackMisc::CStatusMessage &statusMessage)
|
||||
{
|
||||
if (!this->getIContextApplication()) return;
|
||||
this->getIContextApplication()->sendStatusMessage(statusMessage);
|
||||
}
|
||||
|
||||
void CRuntimeBasedComponent::sendStatusMessages(const BlackMisc::CStatusMessageList &statusMessages)
|
||||
{
|
||||
if (!this->getIContextApplication()) return;
|
||||
this->getIContextApplication()->sendStatusMessages(statusMessages);
|
||||
}
|
||||
|
||||
const BlackCore::IContextApplication *CRuntimeBasedComponent::getIContextApplication() const
|
||||
{
|
||||
if (!this->m_runtime) return nullptr;
|
||||
|
||||
@@ -37,6 +37,12 @@ namespace BlackGui
|
||||
//! Set runtime for each CRuntimeBasedComponent
|
||||
static void setRuntimeForComponents(BlackCore::CRuntime *runtime, QWidget *parent);
|
||||
|
||||
//! Log message category
|
||||
static QString getMessageCategory() { return "swift.gui.component"; }
|
||||
|
||||
//! Validation log message category
|
||||
static QString validationMessageCategory() { return "swift.gui.component.validation"; }
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
//! \remarks Usually runtime will be provided later, not at initialization time.
|
||||
@@ -90,12 +96,6 @@ namespace BlackGui
|
||||
//! Context for simulator
|
||||
BlackCore::IContextSimulator *getIContextSimulator();
|
||||
|
||||
//! Send status message (via application context)
|
||||
void sendStatusMessage(const BlackMisc::CStatusMessage &statusMessage);
|
||||
|
||||
//! Send status message (via application context)
|
||||
void sendStatusMessages(const BlackMisc::CStatusMessageList &statusMessages);
|
||||
|
||||
//! Owner?
|
||||
bool isRuntimeOwner() const { return this->m_runtimeOwner; }
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackmisc/hwkeyboardkeylist.h"
|
||||
#include "blackmisc/setaudio.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
using namespace BlackCore;
|
||||
@@ -233,29 +234,24 @@ namespace BlackGui
|
||||
CServer server = this->ps_selectedServerFromTextboxes();
|
||||
if (!server.isValidForLogin())
|
||||
{
|
||||
const CStatusMessage validation = CStatusMessage::getValidationError("Wrong settings for server");
|
||||
this->sendStatusMessage(validation);
|
||||
CLogMessage().error(validationMessageCategory(), "Wrong settings for server");
|
||||
return;
|
||||
}
|
||||
|
||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathNetworkSettings(), CSettingsNetwork::ValueTrafficServers());
|
||||
QObject *sender = QObject::sender();
|
||||
CStatusMessageList msgs;
|
||||
if (sender == this->ui->pb_SettingsTnCurrentServer)
|
||||
{
|
||||
msgs = this->getIContextSettings()->value(path, CSettingsNetwork::CmdSetCurrentServer(), server.toQVariant());
|
||||
this->getIContextSettings()->value(path, CSettingsNetwork::CmdSetCurrentServer(), server.toQVariant());
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsTnRemoveServer)
|
||||
{
|
||||
msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toQVariant());
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toQVariant());
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsTnSaveServer)
|
||||
{
|
||||
msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toQVariant());
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toQVariant());
|
||||
}
|
||||
|
||||
// status messages
|
||||
this->sendStatusMessages(msgs);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -310,10 +306,7 @@ namespace BlackGui
|
||||
void CSettingsComponent::ps_saveHotkeys()
|
||||
{
|
||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathRoot(), IContextSettings::PathHotkeys());
|
||||
CStatusMessageList msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), this->ui->tvp_SettingsMiscHotkeys->derivedModel()->getContainer().toQVariant());
|
||||
|
||||
// status messages
|
||||
this->sendStatusMessages(msgs);
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), this->ui->tvp_SettingsMiscHotkeys->derivedModel()->getContainer().toQVariant());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -380,11 +373,11 @@ namespace BlackGui
|
||||
bool ok = CStyleSheetUtility::instance().updateFonts(fontFamily, fontSize, CStyleSheetUtility::fontStyle(fontStyleCombined), CStyleSheetUtility::fontWeight(fontStyleCombined), fontColor);
|
||||
if (ok)
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getInfoMessage("Updated font style", CStatusMessage::TypeSettings));
|
||||
CLogMessage().info(this, "Updated font style");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Updating style failed", CStatusMessage::TypeSettings));
|
||||
CLogMessage().info(this, "Updating style failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,14 +400,12 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextAudio())
|
||||
{
|
||||
CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "voice context not available");
|
||||
this->sendStatusMessage(m);
|
||||
CLogMessage().error(this, "voice context not available");
|
||||
return;
|
||||
}
|
||||
if (this->m_timerAudioTests->isActive())
|
||||
{
|
||||
CStatusMessage m(CStatusMessage::TypeAudio, CStatusMessage::SeverityError, "test running, wait until completed");
|
||||
this->sendStatusMessage(m);
|
||||
CLogMessage().error(this, "test running, wait until completed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "blackmisc/networkutils.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blacksim/fsx/fsxsimulatorsetup.h"
|
||||
#include "blacksim/fsx/simconnectutilities.h"
|
||||
|
||||
@@ -54,29 +55,28 @@ namespace BlackGui
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
CLogMessage().warning(this, "no address or port");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
CLogMessage().warning(this, "IPv4 address invalid");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
CLogMessage().warning(this, "invalid port");
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString msg;
|
||||
if (!CNetworkUtils::canConnect(address, p, msg))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, msg));
|
||||
CLogMessage().warning(this, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
msg = QString("Connected to %1:%2").arg(address).arg(port);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
||||
CLogMessage().info(this, "Connected to %1:%2") << address << port;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -86,7 +86,7 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Simulator not available", CStatusMessage::TypeSimulator));
|
||||
CLogMessage().error(this, "Simulator not available");
|
||||
return;
|
||||
}
|
||||
QString address = this->ui->le_SettingsFsxAddress->text().trimmed();
|
||||
@@ -94,17 +94,17 @@ namespace BlackGui
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
CLogMessage().warning(this, "no address or port");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
CLogMessage().warning(this, "IPv4 address invalid");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
CLogMessage().warning(this, "invalid port");
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
@@ -117,13 +117,11 @@ namespace BlackGui
|
||||
this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
|
||||
if (success)
|
||||
{
|
||||
QString m = QString("Written ").append(local ? " local " : "remote ").append(fileName);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, m));
|
||||
CLogMessage().info(this, local ? "Written local %1" : "Written remote %1") << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString m = QString("Cannot write ").append(fileName);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, m));
|
||||
CLogMessage().error(this, "Cannot write %1") << fileName;
|
||||
}
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
@@ -135,7 +133,7 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Simulator not available", CStatusMessage::TypeSimulator));
|
||||
CLogMessage().error(this, "Simulator not available");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,14 +153,13 @@ namespace BlackGui
|
||||
{
|
||||
QFile f(fileName);
|
||||
f.remove();
|
||||
m = m.arg("locally");
|
||||
CLogMessage().info(this, "Deleted locally %1") << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getIContextApplication()->removeFile(fileName);
|
||||
m = m.arg("remotely");
|
||||
CLogMessage().info(this, "Deleted remotely %1") << fileName;
|
||||
}
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeSimulator, CStatusMessage::SeverityInfo, m));
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsFsxExistsSimconncetCfg)
|
||||
|
||||
@@ -33,6 +33,9 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
~CSettingsFsxComponent();
|
||||
|
||||
//! Log message category
|
||||
static QString getMessageCategory() { return "swift.gui.component.settings.simulator.fsx"; }
|
||||
|
||||
private slots:
|
||||
//! Test the SIM connect connectivity
|
||||
void testSimConnectConnection();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "blacksim/simulatorinfolist.h"
|
||||
#include "blacksim/setsimulator.h"
|
||||
#include "blackmisc/settingutilities.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
@@ -93,21 +94,19 @@ namespace BlackGui
|
||||
CSimulatorInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins();
|
||||
if (simDrivers.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("No drivers available", CStatusMessage::TypeSimulator));
|
||||
CLogMessage().error(this, "No drivers available");
|
||||
return;
|
||||
}
|
||||
if (simDrivers.size() <= index)
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Wrong driver index", CStatusMessage::TypeSimulator));
|
||||
CLogMessage().error(this, "Wrong driver index");
|
||||
return;
|
||||
}
|
||||
|
||||
// update
|
||||
CSimulatorInfo currentDriver = simDrivers[index];
|
||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathSimulatorSettings(), CSettingsSimulator::ValueSelectedDriver());
|
||||
this->sendStatusMessages(
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), currentDriver.toCVariant())
|
||||
);
|
||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), currentDriver.toCVariant());
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_settingsHaveChanged(uint settingsType)
|
||||
@@ -131,11 +130,10 @@ namespace BlackGui
|
||||
if (!sender) return;
|
||||
|
||||
const QString ps = IContextSettings::PathSimulatorSettings();
|
||||
CStatusMessageList msgs;
|
||||
if (sender == this->ui->cb_TimeSync)
|
||||
{
|
||||
bool timeSync = this->ui->cb_TimeSync->isChecked();
|
||||
msgs = this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTime()), CSettingUtilities::CmdUpdate(), QVariant(timeSync));
|
||||
this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTime()), CSettingUtilities::CmdUpdate(), QVariant(timeSync));
|
||||
}
|
||||
else if (sender == this->ui->le_TimeSyncOffset)
|
||||
{
|
||||
@@ -147,17 +145,13 @@ namespace BlackGui
|
||||
}
|
||||
if (ost.isNull())
|
||||
{
|
||||
msgs.push_back(CStatusMessage::getValidationError("Invalid offset time"));
|
||||
CLogMessage().error(validationMessageCategory(), "Invalid offset time");
|
||||
}
|
||||
else
|
||||
{
|
||||
msgs = this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTimeOffset()), CSettingUtilities::CmdUpdate(), ost.toQVariant());
|
||||
this->getIContextSettings()->value(CSettingUtilities::appendPaths(ps, CSettingsSimulator::ValueSyncTimeOffset()), CSettingUtilities::CmdUpdate(), ost.toQVariant());
|
||||
}
|
||||
}
|
||||
if (!msgs.isEmpty())
|
||||
{
|
||||
this->getIContextApplication()->sendStatusMessages(msgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "textmessagecomponent.h"
|
||||
#include "blackmisc/nwuser.h"
|
||||
#include "blackmisc/notificationsounds.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "ui_textmessagecomponent.h"
|
||||
|
||||
#include <QPushButton>
|
||||
@@ -92,7 +93,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
emit this->displayInInfoWindow(CStatusMessage::getInfoMessage("SELCAL received", CStatusMessage::TypeGui).toCVariant(), 3 * 1000);
|
||||
emit this->displayInInfoWindow(CLogMessage().info(this, "SELCAL received"), 3 * 1000);
|
||||
}
|
||||
}
|
||||
continue; // not displayed
|
||||
@@ -381,12 +382,12 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextNetwork() || !this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "network needs to be connected"));
|
||||
CLogMessage().error(this, "network needs to be connected");
|
||||
return;
|
||||
}
|
||||
if (parts.length() < 3)
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityError, "incorrect message"));
|
||||
CLogMessage().error(this, "incorrect message");
|
||||
return;
|
||||
}
|
||||
QString p = parts[1].trimmed(); // receiver
|
||||
@@ -415,10 +416,7 @@ namespace BlackGui
|
||||
int index = cmdLine.indexOf(tm.getRecipientCallsign().getStringAsSet(), 0, Qt::CaseInsensitive);
|
||||
if (index < 0)
|
||||
{
|
||||
this->sendStatusMessage(
|
||||
CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityError,
|
||||
"incomplete message")
|
||||
);
|
||||
CLogMessage().error(this, "incomplete message");
|
||||
return;
|
||||
}
|
||||
QString msg(cmdLine.mid(index + tm.getRecipientCallsign().asString().length() + 1));
|
||||
@@ -440,20 +438,20 @@ namespace BlackGui
|
||||
// line is considered to be a message to the selected channel, send
|
||||
if (!this->isNetworkConnected())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "network needs to be connected"));
|
||||
CLogMessage().error(this, "network needs to be connected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->isVisible())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "text messages can only be sent from corresponding page"));
|
||||
CLogMessage().error(this, "text messages can only be sent from corresponding page");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this->currentIndex();
|
||||
if (index < 0 || index == this->indexOf(this->ui->tb_TextMessagesAll))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeValidation, CStatusMessage::SeverityError, "incorrect channel"));
|
||||
CLogMessage().error(this, "incorrect channel");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
~CTextMessageComponent();
|
||||
|
||||
//! Log message category
|
||||
static QString getMessageCategory() { return "swift.gui.component.textMessages"; }
|
||||
|
||||
//! SELCAL callback, SELCAL is obtained by that
|
||||
void setSelcalCallback(const std::function<const QString(void)> &selcalCallback) { this->m_selcalCallback = selcalCallback; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user