12#include "ui_simulatorselector.h"
21using namespace swift::config;
23using namespace swift::misc::simulation;
24using namespace swift::core::context;
32 this->addComboxBoxValues();
54 if (m_mode == mode && !forced)
60 ui->wi_CheckBoxes->setVisible(
false);
61 ui->wi_RadioButtons->setVisible(
false);
62 ui->wi_ComboBox->setVisible(
false);
67 case CheckBoxes: ui->wi_CheckBoxes->setVisible(
true);
break;
68 case RadioButtons: ui->wi_RadioButtons->setVisible(
true);
break;
69 case ComboBox: ui->wi_ComboBox->setVisible(
true);
break;
85 return { ui->cb_XPlane->isChecked(), ui->cb_P3D->isChecked(), ui->cb_FG->isChecked(),
86 ui->cb_MSFS->isChecked(), ui->cb_MSFS2024->isChecked() };
88 return { ui->rb_XPlane->isChecked(), ui->rb_P3D->isChecked(), ui->rb_FG->isChecked(),
89 ui->rb_MSFS->isChecked(), ui->rb_MSFS2024->isChecked() };
90 case ComboBox:
return { ui->cb_Simulators->currentText() };
97 if (simulator == current)
103 ui->cb_XPlane->setChecked(simulator.
isXPlane());
104 ui->cb_P3D->setChecked(simulator.
isP3D());
105 ui->cb_FG->setChecked(simulator.
isFG());
106 ui->cb_MSFS->setChecked(simulator.
isMSFS());
107 ui->cb_MSFS2024->setChecked(simulator.
isMSFS2024());
110 ui->cb_Simulators->setCurrentText(simulator.
toQString(
true));
115 ui->rb_XPlane->setChecked(simulator.
isXPlane());
118 if (simulator.
isP3D())
120 ui->rb_P3D->setChecked(simulator.
isP3D());
123 if (simulator.
isFG())
125 ui->rb_FG->setChecked(simulator.
isFG());
130 ui->rb_MSFS->setChecked(simulator.
isMSFS());
135 ui->rb_MSFS2024->setChecked(simulator.
isMSFS2024());
143 (m_mode ==
RadioButtons || m_mode ==
ComboBox) ? m_currentSimulator.get() : m_currentSimulators.get();
149 if (sGui && sGui->supportsContexts() && sGui->getIContextSimulator())
168 const CSimulatorInfo simulator = sGui->getIContextSimulator()->getModelSetLoaderSimulator();
192 if (!sGui || sGui->isShuttingDown())
198 if (!sGui || sGui->isShuttingDown() || !myself)
208 ui->cb_XPlane->setVisible(
false);
209 ui->cb_FG->setVisible(
false);
210 ui->rb_XPlane->setVisible(
false);
211 ui->rb_FG->setVisible(
false);
216 ui->cb_FG->setVisible(
enabled);
217 ui->rb_FG->setVisible(
enabled);
218 ui->cb_FG->setChecked(
false);
219 ui->rb_FG->setChecked(
false);
225 ui->cb_XPlane->setChecked(
true);
226 ui->cb_P3D->setChecked(
true);
227 ui->cb_FG->setChecked(
true);
228 ui->cb_MSFS->setChecked(
true);
229 ui->cb_MSFS2024->setChecked(
true);
232 ui->rb_P3D->setChecked(
true);
238 ui->cb_XPlane->setChecked(
false);
239 ui->cb_P3D->setChecked(
false);
240 ui->cb_FG->setChecked(
false);
241 ui->cb_MSFS->setChecked(
false);
242 ui->cb_MSFS2024->setChecked(
false);
252 c = ui->cb_XPlane->isChecked() || ui->cb_P3D->isChecked() || ui->cb_FG->isChecked() ||
253 ui->cb_MSFS->isChecked() || ui->cb_MSFS2024->isChecked();
256 c = ui->rb_XPlane->isChecked() || ui->rb_P3D->isChecked() || ui->rb_FG->isChecked() ||
257 ui->rb_MSFS->isChecked() || ui->rb_MSFS2024->isChecked();
260 const int i = ui->cb_Simulators->currentIndex();
274 c = ui->cb_XPlane->isChecked() && ui->cb_P3D->isChecked() && ui->cb_FG->isChecked() &&
275 ui->cb_MSFS->isChecked() && ui->cb_MSFS2024->isChecked();
291 QMargins m = ui->hl_RadioButtons->contentsMargins();
293 ui->hl_RadioButtons->setContentsMargins(m);
295 m = ui->hl_CheckBoxes->contentsMargins();
297 ui->hl_CheckBoxes->setContentsMargins(m);
319 ui->rb_XPlane->setEnabled(!readOnly);
320 ui->rb_P3D->setEnabled(!readOnly);
321 ui->rb_FG->setEnabled(!readOnly);
322 ui->rb_MSFS->setEnabled(!readOnly);
323 ui->rb_MSFS2024->setEnabled(!readOnly);
325 ui->cb_Simulators->setEnabled(!readOnly);
330 void CSimulatorSelector::radioButtonChanged(
bool checked)
343 void CSimulatorSelector::checkBoxChanged(
bool checked)
350 m_digestButtonsChanged.inputSignal();
353 void CSimulatorSelector::comboBoxChanged(
const QString &value)
360 m_digestButtonsChanged.inputSignal();
363 void CSimulatorSelector::rememberSelection()
365 if (!m_rememberSelection)
372 const CSimulatorInfo sim = this->
getValue();
373 m_currentSimulator.set(sim);
378 const CSimulatorInfo sim = this->
getValue();
379 m_currentSimulators.set(sim);
383 void CSimulatorSelector::changedLastSelection()
386 this->triggerSetToLastSelection();
389 void CSimulatorSelector::changedLastSelectionRb()
396 this->triggerSetToLastSelection();
399 void CSimulatorSelector::changedLastSelectionCb()
406 this->triggerSetToLastSelection();
409 void CSimulatorSelector::triggerSetToLastSelection()
411 QPointer<CSimulatorSelector> myself(
this);
421 void CSimulatorSelector::emitChangedSignal()
423 const CSimulatorInfo simulator(this->
getValue());
424 this->rememberSelection();
428 void CSimulatorSelector::addComboxBoxValues()
431 ui->cb_Simulators->clear();
static void checkBoxesReadOnly(QWidget *parent, bool readOnly)
Pseudo readonly state for checkboxes of widget.
void setToLastSelection()
Set to last selection.
CSimulatorSelector(QWidget *parent=nullptr)
Constructor.
void enableFG(bool enabled)
Enable FG.
void setMode(Mode mode, bool forced=false)
How to display.
~CSimulatorSelector()
Destructor.
@ CheckBoxes
multiple selections
bool isUnselected() const
Not selected at all.
bool isSingleSelection() const
Single selection mode (radio buttons).
void setRememberSelectionAndSetToLastSelection()
Remember selection.
void setReadOnly(bool readOnly)
Set read only.
void setValue(const swift::misc::simulation::CSimulatorInfo &simulator)
Set the value.
void setFsxP3DOnly()
Only show FSX/P3D.
void setRememberSelection(bool remember)
Remember selection.
void setLeftMargin(int margin)
Set left margin.
void uncheckAll()
Unset all, only making sense with checkboxes.
void changed(const swift::misc::simulation::CSimulatorInfo &simulator)
Value has been changed.
bool areAllSelected() const
All selected.
void setToConnectedSimulator(bool makeReadOnly=true)
Set to the connected simulator.
swift::misc::simulation::CSimulatorInfo getValue() const
Get the value.
void checkAll()
Set all, only making sense with checkboxes.
void clear()
Clear values.
void inputSignal()
Received input signal, or manually trigger.
QString toQString(bool i18n=false) const
Cast as QString.
Simple hardcoded info about the corresponding simulator.
static const CSimulatorInfo & msfs()
Const simulator info objects.
static const CSimulatorInfo & xplane()
Const simulator info objects.
static const CSimulatorInfo & p3d()
Const simulator info objects.
static const CSimulatorInfo & fg()
Const simulator info objects.
static const CSimulatorInfo & allSimulators()
All simulators.
bool isMSFS2024() const
MSFS2024?
bool isSingleSimulator() const
Single simulator selected.
static const CSimulatorInfo & msfs2024()
Const simulator info objects.
bool isXPlane() const
XPlane.
Describing a simulator plugin.
const QString & getSimulator() const
Simulator.
bool isValid() const
Check if the provided plugin metadata is valid. Simulator plugin (driver) has to meet the following r...
High level reusable GUI components.
Free functions in swift::misc.
void currentTextChanged(const QString &text)
QFrame(QWidget *parent, Qt::WindowFlags f)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const