mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Ref T231, Ref T232 use CStatusMessagesDetail in simulator component in order to display "failed remoted model adding"
This commit is contained in:
@@ -37,21 +37,39 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
const CLogCategoryList &CSimulatorComponent::getLogCategories()
|
||||
{
|
||||
static const CLogCategoryList cats { CLogCategory::guiComponent(), CLogCategory::matching() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
CSimulatorComponent::CSimulatorComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForDockWidgetInfoArea(),
|
||||
ui(new Ui::CSimulatorComponent)
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
|
||||
ui->setupUi(this);
|
||||
this->setCurrentIndex(0);
|
||||
ui->comp_StatusMessages->showFilterDialog();
|
||||
|
||||
// live data
|
||||
ui->tvp_LiveData->setIconMode(true);
|
||||
ui->tvp_LiveData->setAutoResizeFrequency(10); // only resize every n-th time
|
||||
this->addOrUpdateLiveDataByName("info", "no data yet", CIcons::StandardIconWarning16);
|
||||
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CSimulatorComponent::ps_onSimulatorStatusChanged);
|
||||
connect(&this->m_updateTimer, &QTimer::timeout, this, &CSimulatorComponent::update);
|
||||
connect(ui->pb_RefreshInternals, &QPushButton::pressed, this, &CSimulatorComponent::ps_refreshInternals);
|
||||
this->ps_onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
|
||||
// connects
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CSimulatorComponent::onSimulatorStatusChanged);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CSimulatorComponent::update);
|
||||
connect(ui->pb_RefreshInternals, &QPushButton::pressed, this, &CSimulatorComponent::refreshInternals);
|
||||
if (sGui->supportsContexts() && sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::addingRemoteModelFailed, this, &CSimulatorComponent::onAddingRemoteModelFailed);
|
||||
}
|
||||
|
||||
// init status
|
||||
this->onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
|
||||
}
|
||||
|
||||
CSimulatorComponent::~CSimulatorComponent()
|
||||
@@ -134,23 +152,29 @@ namespace BlackGui
|
||||
this->addOrUpdateLiveDataByName("Transponder", ownAircraft.getTransponderCodeFormatted(), iconRadio);
|
||||
}
|
||||
|
||||
void CSimulatorComponent::ps_onSimulatorStatusChanged(int status)
|
||||
void CSimulatorComponent::onSimulatorStatusChanged(int status)
|
||||
{
|
||||
if (status & ISimulator::Connected)
|
||||
{
|
||||
const int intervalMs = getUpdateIntervalMs();
|
||||
this->m_updateTimer.start(intervalMs);
|
||||
this->ps_refreshInternals();
|
||||
m_updateTimer.start(intervalMs);
|
||||
this->refreshInternals();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_updateTimer.stop();
|
||||
m_updateTimer.stop();
|
||||
this->clear();
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorComponent::ps_refreshInternals()
|
||||
void CSimulatorComponent::onAddingRemoteModelFailed(const CSimulatedAircraft &aircraft, const CStatusMessage &message)
|
||||
{
|
||||
ui->comp_StatusMessages->appendStatusMessageToList(CStatusMessage(this).warning("Adding model failed: '%1'") << aircraft.toQString(true));
|
||||
ui->comp_StatusMessages->appendStatusMessageToList(message);
|
||||
}
|
||||
|
||||
void CSimulatorComponent::refreshInternals()
|
||||
{
|
||||
if (!sGui->getIContextSimulator()) { return; }
|
||||
const CSimulatorInternals internals = sGui->getIContextSimulator()->getSimulatorInternals();
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
#ifndef BLACKGUI_SIMULATORCOMPONENT_H
|
||||
#define BLACKGUI_SIMULATORCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/icons.h"
|
||||
|
||||
#include <QObject>
|
||||
@@ -25,9 +26,8 @@
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace BlackMisc { class CIcon; }
|
||||
namespace BlackMisc { class CIcon; namespace Simulation { class CSimulatedAircraft; }}
|
||||
namespace Ui { class CSimulatorComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -40,6 +40,9 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Categories
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
explicit CSimulatorComponent(QWidget *parent = nullptr);
|
||||
|
||||
@@ -56,14 +59,16 @@ namespace BlackGui
|
||||
//! Update simulator
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
private:
|
||||
//! \copydoc ISimulator::simulatorStatusChanged
|
||||
void ps_onSimulatorStatusChanged(int status);
|
||||
void onSimulatorStatusChanged(int status);
|
||||
|
||||
//! \copydoc ISimulator::addingRemoteModelFailed
|
||||
void onAddingRemoteModelFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Refresh the internals
|
||||
void ps_refreshInternals();
|
||||
void refreshInternals();
|
||||
|
||||
private:
|
||||
//! Update interval
|
||||
int getUpdateIntervalMs() const;
|
||||
|
||||
@@ -74,7 +79,7 @@ namespace BlackGui
|
||||
void addOrUpdateLiveDataByName(const QString &name, const QString &value, BlackMisc::CIcons::IconIndex iconIndex);
|
||||
|
||||
QScopedPointer<Ui::CSimulatorComponent> ui;
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_updateTimer { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_RefreshInternals">
|
||||
<property name="text">
|
||||
<string>refresh</string>
|
||||
@@ -81,6 +81,35 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_Messages">
|
||||
<attribute name="title">
|
||||
<string>Messages</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Messages">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CStatusMessagesDetail" name="comp_StatusMessages">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -88,6 +117,12 @@
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/namevariantpairview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CStatusMessagesDetail</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/statusmessagesdetail.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user