mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Ref T270, Ref T268, plugin common / simulator improvements
* connect with "about to quit" * added interface declarations * sim statistics, use common function setStatsRemoteAircraftUpdate and double for average values
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Components;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
@@ -37,21 +38,33 @@ namespace BlackSimPlugin
|
||||
|
||||
CSimulatorPluginCommon::~CSimulatorPluginCommon()
|
||||
{
|
||||
if (m_interpolationDisplay)
|
||||
this->deleteInterpolationDisplay();
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::deleteInterpolationDisplay()
|
||||
{
|
||||
if (m_interpolationDisplayDialog)
|
||||
{
|
||||
m_interpolationDisplay->deleteLater();
|
||||
// if there is no parent widget, we clean dialog up
|
||||
// otherwise the parent is supposed to clean up
|
||||
CInterpolationLogDisplayDialog *dialog = m_interpolationDisplayDialog;
|
||||
m_interpolationDisplayDialog = nullptr;
|
||||
dialog->close();
|
||||
delete dialog;
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::showInterpolationDisplay()
|
||||
{
|
||||
if (!m_interpolationDisplay)
|
||||
if (!m_interpolationDisplayDialog)
|
||||
{
|
||||
QWidget *parentWidget = sGui ? sGui->mainApplicationWidget() : nullptr;
|
||||
CInterpolationLogDisplayDialog *dialog = new CInterpolationLogDisplayDialog(this, nullptr, parentWidget);
|
||||
m_interpolationDisplay = dialog;
|
||||
m_interpolationDisplayDialog = dialog;
|
||||
m_interpolationDisplayDialog->setModal(false);
|
||||
}
|
||||
m_interpolationDisplay->show();
|
||||
|
||||
if (m_interpolationDisplayDialog) { m_interpolationDisplayDialog->show(); }
|
||||
}
|
||||
|
||||
bool CSimulatorPluginCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
@@ -67,14 +80,16 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorPluginCommon::unload()
|
||||
{
|
||||
if (m_interpolationDisplay)
|
||||
{
|
||||
m_interpolationDisplay->hide();
|
||||
m_interpolationDisplay->deleteLater();
|
||||
}
|
||||
this->deleteInterpolationDisplay();
|
||||
CSimulatorCommon::unload();
|
||||
}
|
||||
|
||||
bool CSimulatorPluginCommon::disconnectFrom()
|
||||
{
|
||||
this->deleteInterpolationDisplay();
|
||||
return CSimulatorCommon::disconnectFrom();
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackSimPlugin::Common::CSimulatorPluginCommon")) { return; }
|
||||
|
||||
@@ -24,10 +24,19 @@ namespace BlackSimPlugin
|
||||
//! Common base class for simulator plugins
|
||||
class CSimulatorPluginCommon : public BlackCore::CSimulatorCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackCore::ISimulator)
|
||||
Q_INTERFACES(BlackMisc::Simulation::ISimulationEnvironmentProvider)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IInterpolationSetupProvider)
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CSimulatorPluginCommon();
|
||||
|
||||
// --------- ISimulator implementations ------------
|
||||
virtual void unload() override;
|
||||
virtual bool disconnectFrom() override;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorPluginCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
@@ -45,9 +54,6 @@ namespace BlackSimPlugin
|
||||
//! @}
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
|
||||
|
||||
// interface implementations
|
||||
virtual void unload() override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp();
|
||||
|
||||
@@ -55,7 +61,10 @@ namespace BlackSimPlugin
|
||||
//! Show the interpolator display
|
||||
void showInterpolationDisplay();
|
||||
|
||||
QPointer<BlackGui::Components::CInterpolationLogDisplayDialog> m_interpolationDisplay; //!< can be owned by main window after setting a parent
|
||||
//! Clean up the interpolation log.display if any
|
||||
void deleteInterpolationDisplay();
|
||||
|
||||
QPointer<BlackGui::Components::CInterpolationLogDisplayDialog> m_interpolationDisplayDialog; //!< can be owned by main window after setting a parent
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user