mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +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
|
||||
Reference in New Issue
Block a user