refs #452 simulator selector component

This commit is contained in:
Klaus Basan
2015-09-24 00:02:06 +02:00
committed by Mathew Sutcliffe
parent 61ace53989
commit 35c41156f6
3 changed files with 293 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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 <QScopedPointer>
#include <QFrame>
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::CSimulatorSelector> ui;
Mode m_mode = CheckBoxes;
};
}
#endif // guard

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CSimulatorSelector</class>
<widget class="QFrame" name="CSimulatorSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>170</width>
<height>36</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_SimulatorSelector">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="wi_CheckBoxes" native="true">
<layout class="QHBoxLayout" name="hl_CheckBoxes">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="cb_FS9">
<property name="text">
<string>FS9</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_FSX">
<property name="text">
<string>FSX</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_P3D">
<property name="text">
<string>P3D</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_XPlane">
<property name="toolTip">
<string>XPlane</string>
</property>
<property name="text">
<string>XP</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="wi_RadioButtons" native="true">
<layout class="QHBoxLayout" name="hl_RadioButtons">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="rb_FS9">
<property name="text">
<string>FS9</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_FSX">
<property name="text">
<string>FSX</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_P3D">
<property name="text">
<string>P3D</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_XPlane">
<property name="toolTip">
<string>XPlane</string>
</property>
<property name="text">
<string>XP</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>