diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index 4339fcc8b..1ba6df239 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -606,7 +606,7 @@ 1 - + 0 @@ -731,9 +731,9 @@ 1 - BlackGui::Editors::CMatchingForm + BlackGui::Components::CSettingsMatchingComponent QFrame -
blackgui/editors/matchingform.h
+
blackgui/components/settingsmatchingcomponent.h
1
diff --git a/src/blackgui/components/settingsmatchingcomponent.cpp b/src/blackgui/components/settingsmatchingcomponent.cpp new file mode 100644 index 000000000..cff1ab5f3 --- /dev/null +++ b/src/blackgui/components/settingsmatchingcomponent.cpp @@ -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 diff --git a/src/blackgui/components/settingsmatchingcomponent.h b/src/blackgui/components/settingsmatchingcomponent.h new file mode 100644 index 000000000..8d89e6eea --- /dev/null +++ b/src/blackgui/components/settingsmatchingcomponent.h @@ -0,0 +1,51 @@ +/* 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 BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSMATCHINGCOMPONENT_H + +#include +#include + +namespace BlackCore { namespace Context { class IContextSimulator; }} +namespace Ui { class CSettingsMatchingComponent; } +namespace BlackGui +{ + namespace Components + { + //! Settings for matching component + class CSettingsMatchingComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CSettingsMatchingComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CSettingsMatchingComponent() override; + + private: + QScopedPointer ui; + + //! Save pressed + void onSavePressed() const; + + //! Reload pressed + void onReloadPressed(); + + //! Network context + static BlackCore::Context::IContextSimulator *simulatorContext(); + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/settingsmatchingcomponent.ui b/src/blackgui/components/settingsmatchingcomponent.ui new file mode 100644 index 000000000..123ee83ad --- /dev/null +++ b/src/blackgui/components/settingsmatchingcomponent.ui @@ -0,0 +1,82 @@ + + + CSettingsMatchingComponent + + + + 0 + 0 + 640 + 480 + + + + Frame + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + reload + + + + + + + save + + + + + + + + + + + BlackGui::Editors::CMatchingForm + QFrame +
blackgui/editors/matchingform.h
+ 1 +
+
+ + pb_Reload + pb_Save + + + +