mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Allow to display position logs also in the console window
* added requestUiConsoleMessage * utility functions
This commit is contained in:
@@ -118,6 +118,9 @@ namespace BlackCore
|
|||||||
//! Relevant simulator messages to be explicitly displayed
|
//! Relevant simulator messages to be explicitly displayed
|
||||||
void driverMessages(const BlackMisc::CStatusMessageList &messages);
|
void driverMessages(const BlackMisc::CStatusMessageList &messages);
|
||||||
|
|
||||||
|
//! Request a console message (whatever the console maybe)
|
||||||
|
void requestUiConsoleMessage(const QString &driverMessage, bool clear);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Simulator info, currently loaded plugin
|
//! Simulator info, currently loaded plugin
|
||||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const = 0;
|
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const = 0;
|
||||||
|
|||||||
@@ -319,6 +319,8 @@ namespace BlackCore
|
|||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
c = connect(simulator, &ISimulator::driverMessages, this, &IContextSimulator::driverMessages);
|
c = connect(simulator, &ISimulator::driverMessages, this, &IContextSimulator::driverMessages);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
c = connect(simulator, &ISimulator::requestUiConsoleMessage, this, &IContextSimulator::requestUiConsoleMessage);
|
||||||
|
Q_ASSERT(c);
|
||||||
|
|
||||||
// log from context to simulator
|
// log from context to simulator
|
||||||
c = connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, &CContextSimulator::relayStatusMessageToSimulator);
|
c = connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, &CContextSimulator::relayStatusMessageToSimulator);
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ namespace BlackCore
|
|||||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||||
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));
|
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));
|
||||||
|
|
||||||
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||||
|
"requestUiConsoleMessage", this, SIGNAL(requestUiConsoleMessage(QString, bool)));
|
||||||
|
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s);
|
||||||
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
|
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
|
||||||
|
|||||||
@@ -223,6 +223,9 @@ namespace BlackCore
|
|||||||
//! Relevant simulator messages to be explicitly displayed
|
//! Relevant simulator messages to be explicitly displayed
|
||||||
void driverMessages(const BlackMisc::CStatusMessageList &messages);
|
void driverMessages(const BlackMisc::CStatusMessageList &messages);
|
||||||
|
|
||||||
|
//! Request a console message (whatever the console maybe)
|
||||||
|
void requestUiConsoleMessage(const QString &driverMessage, bool clear);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
ISimulator(QObject *parent = nullptr);
|
ISimulator(QObject *parent = nullptr);
|
||||||
|
|||||||
@@ -820,7 +820,11 @@ namespace BlackCore
|
|||||||
QStringLiteral("Situation: ") % s.toQString(false, false, true, true, true, true, sep);
|
QStringLiteral("Situation: ") % s.toQString(false, false, true, true, true, true, sep);
|
||||||
}
|
}
|
||||||
if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); }
|
if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); }
|
||||||
if (!dm.isEmpty()) { this->displayStatusMessage(CStatusMessage(this).info(dm)); }
|
if (!dm.isEmpty())
|
||||||
|
{
|
||||||
|
this->displayStatusMessage(CStatusMessage(this).info(dm));
|
||||||
|
emit this->requestUiConsoleMessage(dm, true);
|
||||||
|
}
|
||||||
|
|
||||||
const int t = 4500 + (qrand() % 1000); // makes sure not always using the same time difference
|
const int t = 4500 + (qrand() % 1000); // makes sure not always using the same time difference
|
||||||
QTimer::singleShot(t, this, [ = ]
|
QTimer::singleShot(t, this, [ = ]
|
||||||
|
|||||||
@@ -104,6 +104,16 @@ namespace BlackGui
|
|||||||
ui->comp_StatusMessages->clear();
|
ui->comp_StatusMessages->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CLogComponent::clearConsole()
|
||||||
|
{
|
||||||
|
ui->tep_StatusPageConsole->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogComponent::clearMessages()
|
||||||
|
{
|
||||||
|
ui->comp_StatusMessages->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage)
|
void CLogComponent::appendStatusMessageToConsole(const CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
if (statusMessage.isEmpty()) return;
|
if (statusMessage.isEmpty()) return;
|
||||||
|
|||||||
@@ -83,6 +83,12 @@ namespace BlackGui
|
|||||||
//! Clear
|
//! Clear
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
//! Clear
|
||||||
|
void clearConsole();
|
||||||
|
|
||||||
|
//! Clear
|
||||||
|
void clearMessages();
|
||||||
|
|
||||||
//! Append status message to console
|
//! Append status message to console
|
||||||
void appendStatusMessageToConsole(const BlackMisc::CStatusMessage &statusMessage);
|
void appendStatusMessageToConsole(const BlackMisc::CStatusMessage &statusMessage);
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
#include "swiftguistd.h"
|
#include "swiftguistd.h"
|
||||||
#include "ui_swiftguistd.h"
|
#include "ui_swiftguistd.h"
|
||||||
#include "blackconfig/buildconfig.h"
|
|
||||||
#include "blackcore/webdataservices.h"
|
|
||||||
#include "blackcore/context/contextnetwork.h"
|
|
||||||
#include "blackgui/components/aircraftcomponent.h"
|
#include "blackgui/components/aircraftcomponent.h"
|
||||||
#include "blackgui/components/atcstationcomponent.h"
|
#include "blackgui/components/atcstationcomponent.h"
|
||||||
#include "blackgui/components/cockpitcomponent.h"
|
#include "blackgui/components/cockpitcomponent.h"
|
||||||
@@ -30,12 +27,16 @@
|
|||||||
#include "blackgui/managedstatusbar.h"
|
#include "blackgui/managedstatusbar.h"
|
||||||
#include "blackgui/overlaymessagesframe.h"
|
#include "blackgui/overlaymessagesframe.h"
|
||||||
#include "blackgui/stylesheetutility.h"
|
#include "blackgui/stylesheetutility.h"
|
||||||
|
#include "blackcore/webdataservices.h"
|
||||||
|
#include "blackcore/context/contextnetwork.h"
|
||||||
|
#include "blackcore/context/contextsimulator.h"
|
||||||
#include "blackmisc/network/networkutils.h"
|
#include "blackmisc/network/networkutils.h"
|
||||||
#include "blackmisc/loghandler.h"
|
#include "blackmisc/loghandler.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/logpattern.h"
|
#include "blackmisc/logpattern.h"
|
||||||
#include "blackmisc/slot.h"
|
#include "blackmisc/slot.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
@@ -62,6 +63,7 @@ void SwiftGuiStd::init()
|
|||||||
// POST(!) GUI init
|
// POST(!) GUI init
|
||||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||||
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "Missing web services");
|
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "Missing web services");
|
||||||
|
Q_ASSERT_X(sGui->supportsContexts(), Q_FUNC_INFO, "Missing contexts");
|
||||||
|
|
||||||
if (m_init) { return; }
|
if (m_init) { return; }
|
||||||
|
|
||||||
@@ -118,6 +120,9 @@ void SwiftGuiStd::init()
|
|||||||
this->initGuiSignals();
|
this->initGuiSignals();
|
||||||
|
|
||||||
// signal / slots contexts / timers
|
// signal / slots contexts / timers
|
||||||
|
Q_ASSERT_X(sGui->getIContextNetwork(), Q_FUNC_INFO, "Missing network context");
|
||||||
|
Q_ASSERT_X(sGui->getIContextSimulator(), Q_FUNC_INFO, "Missing simulator context");
|
||||||
|
|
||||||
bool s = connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::onConnectionStatusChanged, Qt::QueuedConnection);
|
bool s = connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::onConnectionStatusChanged, Qt::QueuedConnection);
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connect(sGui->getIContextNetwork(), &IContextNetwork::kicked, this, &SwiftGuiStd::onKickedFromNetwork, Qt::QueuedConnection);
|
s = connect(sGui->getIContextNetwork(), &IContextNetwork::kicked, this, &SwiftGuiStd::onKickedFromNetwork, Qt::QueuedConnection);
|
||||||
@@ -126,6 +131,15 @@ void SwiftGuiStd::init()
|
|||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
s = connect(sGui->getIContextNetwork(), &IContextNetwork::textMessageSent, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageSent, Qt::QueuedConnection);
|
s = connect(sGui->getIContextNetwork(), &IContextNetwork::textMessageSent, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageSent, Qt::QueuedConnection);
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
s = connect(sGui->getIContextSimulator(), &IContextSimulator::requestUiConsoleMessage, this, [ = ](const QString & logMsg, bool clear)
|
||||||
|
{
|
||||||
|
if (logMsg.isEmpty()) { return; }
|
||||||
|
CLogComponent *log = ui->comp_MainInfoArea->getLogComponent();
|
||||||
|
Q_ASSERT_X(log, Q_FUNC_INFO, "Missing log component");
|
||||||
|
if (clear) { log->clearConsole(); }
|
||||||
|
log->appendPlainTextToConsole(logMsg);
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT(s);
|
||||||
s = connect(&m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::handleTimerBasedUpdates);
|
s = connect(&m_timerContextWatchdog, &QTimer::timeout, this, &SwiftGuiStd::handleTimerBasedUpdates);
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
Q_UNUSED(s);
|
Q_UNUSED(s);
|
||||||
@@ -194,12 +208,12 @@ void SwiftGuiStd::initGuiSignals()
|
|||||||
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::changedOpacity, this , &SwiftGuiStd::onChangedWindowOpacity);
|
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::changedOpacity, this , &SwiftGuiStd::onChangedWindowOpacity);
|
||||||
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::identPressed, ui->comp_MainInfoArea->getCockpitComponent(), &CCockpitComponent::setSelectedTransponderModeStateIdent);
|
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::identPressed, ui->comp_MainInfoArea->getCockpitComponent(), &CCockpitComponent::setSelectedTransponderModeStateIdent);
|
||||||
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::textEntered, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::handleGlobalCommandLineText);
|
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::textEntered, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::handleGlobalCommandLineText);
|
||||||
connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedInfoAreaStatus, ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::onMainInfoAreaChanged);
|
|
||||||
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::audioPressed, [ = ]
|
connect(ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::audioPressed, [ = ]
|
||||||
{
|
{
|
||||||
ui->comp_MainInfoArea->getCockpitComponent()->showAudio();
|
ui->comp_MainInfoArea->getCockpitComponent()->showAudio();
|
||||||
ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaCockpit);
|
ui->comp_MainInfoArea->selectArea(CMainInfoAreaComponent::InfoAreaCockpit);
|
||||||
});
|
});
|
||||||
|
connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedInfoAreaStatus, ui->comp_MainKeypadArea, &CMainKeypadAreaComponent::onMainInfoAreaChanged);
|
||||||
|
|
||||||
// menu
|
// menu
|
||||||
connect(ui->menu_TestLocationsEDDF, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked);
|
connect(ui->menu_TestLocationsEDDF, &QAction::triggered, this, &SwiftGuiStd::onMenuClicked);
|
||||||
|
|||||||
Reference in New Issue
Block a user