mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T270, added CSimulatorPluginCommon as base class in driver project
* unlike BlackCore::CSimulatorCommon we can add also UI aspects here * used by emulated driver, XP and the FS series
This commit is contained in:
18
src/plugins/simulator/plugincommon/plugincommon.pro
Normal file
18
src/plugins/simulator/plugincommon/plugincommon.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
load(common_pre)
|
||||
|
||||
QT += core dbus xml network widgets
|
||||
|
||||
TARGET = simulatorplugincommon
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += staticlib
|
||||
CONFIG += blackconfig blackmisc blackgui
|
||||
|
||||
DEPENDPATH += . $$SourceRoot/src
|
||||
INCLUDEPATH += . $$SourceRoot/src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
DESTDIR = $$DestRoot/lib
|
||||
|
||||
load(common_post)
|
||||
84
src/plugins/simulator/plugincommon/simulatorplugincommon.cpp
Normal file
84
src/plugins/simulator/plugincommon/simulatorplugincommon.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "simulatorplugincommon.h"
|
||||
#include "blackgui/components/interpolationlogdisplaydialog.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
|
||||
using namespace BlackGui::Components;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Weather;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Common
|
||||
{
|
||||
CSimulatorPluginCommon::CSimulatorPluginCommon(
|
||||
const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *renderedAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, clientProvider, parent)
|
||||
{
|
||||
CSimulatorPluginCommon::registerHelp();
|
||||
}
|
||||
|
||||
CSimulatorPluginCommon::~CSimulatorPluginCommon()
|
||||
{
|
||||
if (m_interpolationDisplay)
|
||||
{
|
||||
m_interpolationDisplay->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::showInterpolationDisplay()
|
||||
{
|
||||
if (!m_interpolationDisplay)
|
||||
{
|
||||
QWidget *parentWidget = sGui ? sGui->mainApplicationWidget() : nullptr;
|
||||
CInterpolationLogDisplayDialog *dialog = new CInterpolationLogDisplayDialog(this, parentWidget);
|
||||
m_interpolationDisplay = dialog;
|
||||
}
|
||||
m_interpolationDisplay->show();
|
||||
}
|
||||
|
||||
bool CSimulatorPluginCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
{
|
||||
// .driver fsuipc on|off
|
||||
if (parser.matchesPart(1, "intdisplay"))
|
||||
{
|
||||
this->showInterpolationDisplay();
|
||||
return true;
|
||||
}
|
||||
return CSimulatorCommon::parseDetails(parser);
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::unload()
|
||||
{
|
||||
if (m_interpolationDisplay)
|
||||
{
|
||||
m_interpolationDisplay->hide();
|
||||
m_interpolationDisplay->deleteLater();
|
||||
}
|
||||
CSimulatorCommon::unload();
|
||||
}
|
||||
|
||||
void CSimulatorPluginCommon::registerHelp()
|
||||
{
|
||||
if (CSimpleCommandParser::registered("BlackSimPlugin::Common::CSimulatorPluginCommon")) { return; }
|
||||
CSimpleCommandParser::registerCommand({".drv intdisplay", "interpolation display"});
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
63
src/plugins/simulator/plugincommon/simulatorplugincommon.h
Normal file
63
src/plugins/simulator/plugincommon/simulatorplugincommon.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_COMMON_SIMULATORPLUGINCOMMON_H
|
||||
#define BLACKSIMPLUGIN_COMMON_SIMULATORPLUGINCOMMON_H
|
||||
|
||||
#include "blackcore/simulatorcommon.h"
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
namespace BlackGui { namespace Components { class CInterpolationLogDisplayDialog; }}
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Common
|
||||
{
|
||||
//! Common base class for simulator plugins
|
||||
class CSimulatorPluginCommon : public BlackCore::CSimulatorCommon
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~CSimulatorPluginCommon();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CSimulatorPluginCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
|
||||
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
|
||||
BlackMisc::Simulation::IRemoteAircraftProvider *renderedAircraftProvider,
|
||||
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
|
||||
BlackMisc::Network::IClientProvider *clientProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! \addtogroup swiftdotcommands
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .drv intdisplay interpolation log display
|
||||
//! </pre>
|
||||
//! @}
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
|
||||
|
||||
// interface implementations
|
||||
virtual void unload() override;
|
||||
|
||||
//! Register help
|
||||
static void registerHelp();
|
||||
|
||||
private:
|
||||
//! Show the interpolator display
|
||||
void showInterpolationDisplay();
|
||||
|
||||
QPointer<BlackGui::Components::CInterpolationLogDisplayDialog> m_interpolationDisplay; //!< can be owned by main window after setting a parent
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user