mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 14:45:42 +08:00
Ref T298,settings matching component which can save setup to context
This commit is contained in:
@@ -606,7 +606,7 @@
|
|||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingSetup">
|
<widget class="BlackGui::Components::CSettingsMatchingComponent" name="comp_SettingsMatching">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
@@ -731,9 +731,9 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::Editors::CMatchingForm</class>
|
<class>BlackGui::Components::CSettingsMatchingComponent</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QFrame</extends>
|
||||||
<header>blackgui/editors/matchingform.h</header>
|
<header>blackgui/components/settingsmatchingcomponent.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
|||||||
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
|
||||||
51
src/blackgui/components/settingsmatchingcomponent.h
Normal file
51
src/blackgui/components/settingsmatchingcomponent.h
Normal file
@@ -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 <QFrame>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
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::CSettingsMatchingComponent> ui;
|
||||||
|
|
||||||
|
//! Save pressed
|
||||||
|
void onSavePressed() const;
|
||||||
|
|
||||||
|
//! Reload pressed
|
||||||
|
void onReloadPressed();
|
||||||
|
|
||||||
|
//! Network context
|
||||||
|
static BlackCore::Context::IContextSimulator *simulatorContext();
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
82
src/blackgui/components/settingsmatchingcomponent.ui
Normal file
82
src/blackgui/components/settingsmatchingcomponent.ui
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSettingsMatchingComponent</class>
|
||||||
|
<widget class="QFrame" name="CSettingsMatchingComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>640</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Frame</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="vl_MatchingComponent">
|
||||||
|
<item>
|
||||||
|
<widget class="BlackGui::Editors::CMatchingForm" name="editor_MatchingForm">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="fr_Butoons">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="hl_">
|
||||||
|
<item>
|
||||||
|
<spacer name="hs_Buttons">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_Reload">
|
||||||
|
<property name="text">
|
||||||
|
<string>reload</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_Save">
|
||||||
|
<property name="text">
|
||||||
|
<string>save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Editors::CMatchingForm</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/editors/matchingform.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>pb_Reload</tabstop>
|
||||||
|
<tabstop>pb_Save</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user