From 77546a46b1ce33f2e0872776c95c192feb586cb0 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 26 Jul 2017 14:23:02 +0200 Subject: [PATCH] Ref T111, settings UI component --- .../components/settingsswiftplugin.cpp | 66 ++++++++++ src/blackgui/components/settingsswiftplugin.h | 57 +++++++++ .../components/settingsswiftplugin.ui | 117 ++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 src/blackgui/components/settingsswiftplugin.cpp create mode 100644 src/blackgui/components/settingsswiftplugin.h create mode 100644 src/blackgui/components/settingsswiftplugin.ui diff --git a/src/blackgui/components/settingsswiftplugin.cpp b/src/blackgui/components/settingsswiftplugin.cpp new file mode 100644 index 000000000..32df6650c --- /dev/null +++ b/src/blackgui/components/settingsswiftplugin.cpp @@ -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 diff --git a/src/blackgui/components/settingsswiftplugin.h b/src/blackgui/components/settingsswiftplugin.h new file mode 100644 index 000000000..6e2536216 --- /dev/null +++ b/src/blackgui/components/settingsswiftplugin.h @@ -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 +#include +#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; + BlackMisc::CSetting m_settings { this, &CSettingsSwiftPlugin::onSettingsChanged }; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/settingsswiftplugin.ui b/src/blackgui/components/settingsswiftplugin.ui new file mode 100644 index 000000000..db2486040 --- /dev/null +++ b/src/blackgui/components/settingsswiftplugin.ui @@ -0,0 +1,117 @@ + + + CSettingsSwiftPlugin + + + + 0 + 0 + 215 + 168 + + + + Frame + + + + + + Emulated simulator: + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Default model: + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + save + + + + + + + + + + function calls + + + + + + + Logging: + + + + + + + Own model: + + + + + + + + + + + BlackGui::Components::CSimulatorSelector + QFrame +
blackgui/components/simulatorselector.h
+ 1 +
+ + BlackGui::Components::CDbModelKeyCompleter + QLineEdit +
blackgui/components/dbmodelkeycompleter.h
+
+
+ + lep_OwnModel + lep_DefaultModel + cb_LogFunctionCalls + pb_Save + + + +