mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Ref T298,settings matching component which can save setup to context
This commit is contained in:
58
src/blackgui/components/settingsmatchingcomponent.cpp
Normal file
58
src/blackgui/components/settingsmatchingcomponent.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/* 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 "settingsmatchingcomponent.h"
|
||||
#include "ui_settingsmatchingcomponent.h"
|
||||
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CSettingsMatchingComponent::CSettingsMatchingComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsMatchingComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->pb_Save, &QPushButton::released, this, &CSettingsMatchingComponent::onSavePressed);
|
||||
connect(ui->pb_Reload, &QPushButton::released, this, &CSettingsMatchingComponent::onReloadPressed);
|
||||
}
|
||||
|
||||
CSettingsMatchingComponent::~CSettingsMatchingComponent()
|
||||
{ }
|
||||
|
||||
void CSettingsMatchingComponent::onSavePressed() const
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
const CAircraftMatcherSetup setup = ui->editor_MatchingForm->value();
|
||||
simContext->setMatchingSetup(setup);
|
||||
}
|
||||
|
||||
void CSettingsMatchingComponent::onReloadPressed()
|
||||
{
|
||||
IContextSimulator *simContext = simulatorContext();
|
||||
if (!simContext) { return; }
|
||||
const CAircraftMatcherSetup setup = simContext->getMatchingSetup();
|
||||
ui->editor_MatchingForm->setValue(setup);
|
||||
}
|
||||
|
||||
IContextSimulator *CSettingsMatchingComponent::simulatorContext()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return nullptr; }
|
||||
return sGui->getIContextSimulator();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
Reference in New Issue
Block a user