mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T111, settings UI component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
7d88a64914
commit
77546a46b1
66
src/blackgui/components/settingsswiftplugin.cpp
Normal file
66
src/blackgui/components/settingsswiftplugin.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Copyright (C) 2017
|
||||
* 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 "settingsswiftplugin.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "ui_settingsswiftplugin.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CSettingsSwiftPlugin::CSettingsSwiftPlugin(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsSwiftPlugin)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comp_EmulatedSimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
this->onSettingsChanged();
|
||||
|
||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CSettingsSwiftPlugin::save);
|
||||
}
|
||||
|
||||
CSettingsSwiftPlugin::~CSettingsSwiftPlugin()
|
||||
{ }
|
||||
|
||||
BlackMisc::Simulation::Settings::CSwiftPluginSettings CSettingsSwiftPlugin::getPluginSettings() const
|
||||
{
|
||||
return m_settings.get();
|
||||
}
|
||||
|
||||
void CSettingsSwiftPlugin::onSettingsChanged()
|
||||
{
|
||||
const CSwiftPluginSettings settings(m_settings.get());
|
||||
ui->comp_EmulatedSimulatorSelector->setValue(settings.getEmulatedSimulator());
|
||||
ui->lep_OwnModel->setText(settings.getOwnModel().getModelString());
|
||||
ui->lep_DefaultModel->setText(settings.getDefaultModel().getModelString());
|
||||
ui->cb_LogFunctionCalls->setChecked(settings.isLoggingFunctionCalls());
|
||||
}
|
||||
|
||||
void CSettingsSwiftPlugin::save()
|
||||
{
|
||||
const CSwiftPluginSettings settings(this->getSettings());
|
||||
const CStatusMessage msg = m_settings.setAndSave(settings);
|
||||
if (!msg.isEmpty()) { CLogMessage::preformatted(msg); }
|
||||
}
|
||||
|
||||
CSwiftPluginSettings CSettingsSwiftPlugin::getSettings() const
|
||||
{
|
||||
CSwiftPluginSettings settings;
|
||||
settings.setEmulatedSimulator(ui->comp_EmulatedSimulatorSelector->getValue());
|
||||
settings.setOwnModel(ui->lep_OwnModel->getAircraftModel());
|
||||
settings.setDefaultModel(ui->lep_DefaultModel->getAircraftModel());
|
||||
settings.setLoggingFunctionCalls(ui->cb_LogFunctionCalls->isChecked());
|
||||
return settings;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
57
src/blackgui/components/settingsswiftplugin.h
Normal file
57
src/blackgui/components/settingsswiftplugin.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (C) 2017
|
||||
* 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_SETTINGSSWIFTPLUGIN_H
|
||||
#define BLACKGUI_COMPONENTS_SETTINGSSWIFTPLUGIN_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <blackmisc/simulation/settings/swiftpluginsettings.h>
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
namespace Ui { class CSettingsSwiftPlugin; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Settings for the swift pseudo driver
|
||||
*/
|
||||
class BLACKGUI_EXPORT CSettingsSwiftPlugin : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CSettingsSwiftPlugin(QWidget *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSettingsSwiftPlugin();
|
||||
|
||||
//! Get the plugin settings
|
||||
BlackMisc::Simulation::Settings::CSwiftPluginSettings getPluginSettings() const;
|
||||
|
||||
private:
|
||||
//! Settings changed
|
||||
void onSettingsChanged();
|
||||
|
||||
//! Save
|
||||
void save();
|
||||
|
||||
//! Get settings
|
||||
BlackMisc::Simulation::Settings::CSwiftPluginSettings getSettings() const;
|
||||
|
||||
QScopedPointer<Ui::CSettingsSwiftPlugin> ui;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSwiftPlugin> m_settings { this, &CSettingsSwiftPlugin::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
117
src/blackgui/components/settingsswiftplugin.ui
Normal file
117
src/blackgui/components/settingsswiftplugin.ui
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsSwiftPlugin</class>
|
||||
<widget class="QFrame" name="CSettingsSwiftPlugin">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>215</width>
|
||||
<height>168</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="fl_SettingsPlugin">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_EmulatedSimulator">
|
||||
<property name="text">
|
||||
<string>Emulated simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_EmulatedSimulatorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_DefaultModel">
|
||||
<property name="text">
|
||||
<string>Default model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="BlackGui::Components::CDbModelKeyCompleter" name="lep_DefaultModel"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QWidget" name="wi_Buttons" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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_Save">
|
||||
<property name="text">
|
||||
<string>save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cb_LogFunctionCalls">
|
||||
<property name="text">
|
||||
<string>function calls</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Logging">
|
||||
<property name="text">
|
||||
<string>Logging:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_OwnModel">
|
||||
<property name="text">
|
||||
<string>Own model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="BlackGui::Components::CDbModelKeyCompleter" name="lep_OwnModel"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSimulatorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/simulatorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbModelKeyCompleter</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>blackgui/components/dbmodelkeycompleter.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>lep_OwnModel</tabstop>
|
||||
<tabstop>lep_DefaultModel</tabstop>
|
||||
<tabstop>cb_LogFunctionCalls</tabstop>
|
||||
<tabstop>pb_Save</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user