From 35c41156f658810396edd9490e4a4ea36f021244 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 24 Sep 2015 00:02:06 +0200 Subject: [PATCH] refs #452 simulator selector component --- src/blackgui/simulatorselector.cpp | 81 +++++++++++++++ src/blackgui/simulatorselector.h | 60 ++++++++++++ src/blackgui/simulatorselector.ui | 152 +++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 src/blackgui/simulatorselector.cpp create mode 100644 src/blackgui/simulatorselector.h create mode 100644 src/blackgui/simulatorselector.ui diff --git a/src/blackgui/simulatorselector.cpp b/src/blackgui/simulatorselector.cpp new file mode 100644 index 000000000..010052eb4 --- /dev/null +++ b/src/blackgui/simulatorselector.cpp @@ -0,0 +1,81 @@ +/* Copyright (C) 2015 + * 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 "simulatorselector.h" +#include "ui_simulatorselector.h" + +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + CSimulatorSelector::CSimulatorSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CSimulatorSelector) + { + ui->setupUi(this); + this->setMode(CheckBoxes); + } + + CSimulatorSelector::~CSimulatorSelector() + { } + + void CSimulatorSelector::setMode(CSimulatorSelector::Mode mode) + { + this->m_mode = mode; + switch (mode) + { + default: + case CheckBoxes: + this->ui->wi_CheckBoxes->setVisible(true); + this->ui->wi_RadioButtons->setVisible(false); + break; + case RadioButtons: + this->ui->wi_CheckBoxes->setVisible(false); + this->ui->wi_RadioButtons->setVisible(true); + break; + } + } + + CSimulatorInfo CSimulatorSelector::getValue() const + { + switch (this->m_mode) + { + default: + case CheckBoxes: + return CSimulatorInfo(this->ui->cb_FSX->isChecked(), this->ui->cb_FS9->isChecked(), + this->ui->cb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); + case RadioButtons: + return CSimulatorInfo(this->ui->rb_FSX->isChecked(), this->ui->rb_FS9->isChecked(), + this->ui->rb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); + } + } + + void CSimulatorSelector::setValue(const CSimulatorInfo &info) + { + this->ui->cb_FSX->setChecked(info.fsx()); + this->ui->cb_FS9->setChecked(info.fs9()); + this->ui->cb_XPlane->setChecked(info.xplane()); + this->ui->cb_P3D->setChecked(info.p3d()); + + if (info.fsx()) { this->ui->cb_FSX->setChecked(info.fsx()); return; } + if (info.fs9()) { this->ui->cb_FS9->setChecked(info.fs9()); return; } + if (info.xplane()) { this->ui->cb_XPlane->setChecked(info.xplane()); return; } + if (info.p3d()) { this->ui->cb_P3D->setChecked(info.p3d()); return; } + } + + void CSimulatorSelector::setAll() + { + this->ui->cb_FSX->setChecked(true); + this->ui->cb_FS9->setChecked(true); + this->ui->cb_XPlane->setChecked(true); + this->ui->cb_P3D->setChecked(true); + + this->ui->cb_FSX->setChecked(true); + } +} diff --git a/src/blackgui/simulatorselector.h b/src/blackgui/simulatorselector.h new file mode 100644 index 000000000..dd3c544a1 --- /dev/null +++ b/src/blackgui/simulatorselector.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2015 + * 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. + */ + +#ifndef BLACKGUI_SIMULATORSELECTOR_H +#define BLACKGUI_SIMULATORSELECTOR_H + +#include "blackmisc/simulation/simulatorinfo.h" +#include +#include + +namespace Ui { class CSimulatorSelector; } + +namespace BlackGui +{ + /*! + * Select simulator + */ + class CSimulatorSelector : public QFrame + { + Q_OBJECT + + public: + //! How to display + enum Mode + { + CheckBoxes, + RadioButtons + }; + + //! Constructor + explicit CSimulatorSelector(QWidget *parent = nullptr); + + //! Destructor + ~CSimulatorSelector(); + + //! How to display + void setMode(Mode mode); + + //! Get the value + BlackMisc::Simulation::CSimulatorInfo getValue() const; + + //! Set the value + void setValue(const BlackMisc::Simulation::CSimulatorInfo &info); + + //! Set all, only making sense with checkboxes + void setAll(); + + private: + QScopedPointer ui; + Mode m_mode = CheckBoxes; + }; +} + +#endif // guard diff --git a/src/blackgui/simulatorselector.ui b/src/blackgui/simulatorselector.ui new file mode 100644 index 000000000..63b260603 --- /dev/null +++ b/src/blackgui/simulatorselector.ui @@ -0,0 +1,152 @@ + + + CSimulatorSelector + + + + 0 + 0 + 170 + 36 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 3 + + + 3 + + + 0 + + + 0 + + + 0 + + + + + FS9 + + + + + + + FSX + + + + + + + P3D + + + + + + + XPlane + + + XP + + + + + + + + + + + 3 + + + 3 + + + 0 + + + 0 + + + 0 + + + + + FS9 + + + true + + + + + + + FSX + + + false + + + + + + + P3D + + + + + + + XPlane + + + XP + + + + + + + + + + +