8 #include <QRadioButton>
12 #include "ui_simulatorselector.h"
21 using namespace swift::config;
23 using namespace swift::misc::simulation;
24 using namespace swift::core::context;
28 CSimulatorSelector::CSimulatorSelector(QWidget *parent) : QFrame(parent), ui(new Ui::
CSimulatorSelector)
32 this->addComboxBoxValues();
35 connect(ui->rb_FS9, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
36 connect(ui->rb_FSX, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
37 connect(ui->rb_P3D, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
38 connect(ui->rb_FG, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
39 connect(ui->rb_XPlane, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
40 connect(ui->rb_MSFS, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
41 connect(ui->rb_MSFS2024, &QRadioButton::toggled,
this, &CSimulatorSelector::radioButtonChanged);
43 connect(ui->cb_FS9, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
44 connect(ui->cb_FSX, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
45 connect(ui->cb_P3D, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
46 connect(ui->cb_FG, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
47 connect(ui->cb_XPlane, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
48 connect(ui->cb_MSFS, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
49 connect(ui->cb_MSFS2024, &QRadioButton::toggled,
this, &CSimulatorSelector::checkBoxChanged);
51 connect(ui->cb_Simulators, &QComboBox::currentTextChanged,
this, &CSimulatorSelector::comboBoxChanged);
58 if (m_mode == mode && !forced) {
return; }
61 ui->wi_CheckBoxes->setVisible(
false);
62 ui->wi_RadioButtons->setVisible(
false);
63 ui->wi_ComboBox->setVisible(
false);
68 case CheckBoxes: ui->wi_CheckBoxes->setVisible(
true);
break;
69 case RadioButtons: ui->wi_RadioButtons->setVisible(
true);
break;
70 case ComboBox: ui->wi_ComboBox->setVisible(
true);
break;
77 if (m_noSelectionMeansAll && this->
isUnselected()) {
return CSimulatorInfo::allSimulators(); }
83 return CSimulatorInfo(ui->cb_FSX->isChecked(), ui->cb_FS9->isChecked(), ui->cb_XPlane->isChecked(),
84 ui->cb_P3D->isChecked(), ui->cb_FG->isChecked(), ui->cb_MSFS->isChecked(),
85 ui->cb_MSFS2024->isChecked());
87 return CSimulatorInfo(ui->rb_FSX->isChecked(), ui->rb_FS9->isChecked(), ui->rb_XPlane->isChecked(),
88 ui->rb_P3D->isChecked(), ui->rb_FG->isChecked(), ui->rb_MSFS->isChecked(),
89 ui->rb_MSFS2024->isChecked());
97 if (simulator == current) {
return; }
100 ui->cb_FSX->setChecked(simulator.
isFSX());
101 ui->cb_FS9->setChecked(simulator.
isFS9());
102 ui->cb_XPlane->setChecked(simulator.
isXPlane());
103 ui->cb_P3D->setChecked(simulator.
isP3D());
104 ui->cb_FG->setChecked(simulator.
isFG());
105 ui->cb_MSFS->setChecked(simulator.
isMSFS());
106 ui->cb_MSFS2024->setChecked(simulator.
isMSFS2024());
109 ui->cb_Simulators->setCurrentText(simulator.
toQString(
true));
112 if (simulator.
isFSX())
114 ui->rb_FSX->setChecked(simulator.
isFSX());
117 if (simulator.
isFS9())
119 ui->rb_FS9->setChecked(simulator.
isFS9());
124 ui->rb_XPlane->setChecked(simulator.
isXPlane());
127 if (simulator.
isP3D())
129 ui->rb_P3D->setChecked(simulator.
isP3D());
132 if (simulator.
isFG())
134 ui->rb_FG->setChecked(simulator.
isFG());
139 ui->rb_MSFS->setChecked(simulator.
isMSFS());
144 ui->rb_MSFS2024->setChecked(simulator.
isMSFS2024());
190 QPointer<CSimulatorSelector> myself(
this);
193 this->setToConnectedSimulator(makeReadOnly);
199 ui->cb_FS9->setVisible(
false);
200 ui->cb_XPlane->setVisible(
false);
201 ui->cb_FG->setVisible(
false);
202 ui->rb_FS9->setVisible(
false);
203 ui->rb_XPlane->setVisible(
false);
204 ui->rb_FG->setVisible(
false);
209 ui->cb_FG->setVisible(enabled);
210 ui->rb_FG->setVisible(enabled);
211 ui->cb_FG->setChecked(
false);
212 ui->rb_FG->setChecked(
false);
218 ui->cb_FSX->setChecked(
true);
219 ui->cb_FS9->setChecked(
true);
220 ui->cb_XPlane->setChecked(
true);
221 ui->cb_P3D->setChecked(
true);
222 ui->cb_FG->setChecked(
true);
223 ui->cb_MSFS->setChecked(
true);
224 ui->cb_MSFS2024->setChecked(
true);
227 ui->rb_P3D->setChecked(
true);
233 ui->cb_FSX->setChecked(
false);
234 ui->cb_FS9->setChecked(
false);
235 ui->cb_XPlane->setChecked(
false);
236 ui->cb_P3D->setChecked(
false);
237 ui->cb_FG->setChecked(
false);
238 ui->cb_MSFS->setChecked(
false);
239 ui->cb_MSFS2024->setChecked(
false);
249 c = ui->cb_FSX->isChecked() || ui->cb_FS9->isChecked() || ui->cb_XPlane->isChecked() ||
250 ui->cb_P3D->isChecked() || ui->cb_FG->isChecked() || ui->cb_MSFS->isChecked() ||
251 ui->cb_MSFS2024->isChecked();
254 c = ui->rb_FSX->isChecked() || ui->rb_FS9->isChecked() || ui->rb_XPlane->isChecked() ||
255 ui->rb_P3D->isChecked() || ui->rb_FG->isChecked() || ui->rb_MSFS->isChecked() ||
256 ui->rb_MSFS2024->isChecked();
259 const int i = ui->cb_Simulators->currentIndex();
273 c = ui->cb_FSX->isChecked() && ui->cb_FS9->isChecked() && ui->cb_XPlane->isChecked() &&
274 ui->cb_P3D->isChecked() && ui->cb_FG->isChecked() && ui->cb_MSFS->isChecked() &&
275 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);
316 ui->rb_FSX->setEnabled(!readOnly);
317 ui->rb_FS9->setEnabled(!readOnly);
318 ui->rb_XPlane->setEnabled(!readOnly);
319 ui->rb_P3D->setEnabled(!readOnly);
320 ui->rb_FG->setEnabled(!readOnly);
321 ui->rb_MSFS->setEnabled(!readOnly);
322 ui->rb_MSFS2024->setEnabled(!readOnly);
324 ui->cb_Simulators->setEnabled(!readOnly);
326 this->setEnabled(!readOnly);
329 void CSimulatorSelector::radioButtonChanged(
bool checked)
339 void CSimulatorSelector::checkBoxChanged(
bool checked)
346 void CSimulatorSelector::comboBoxChanged(
const QString &value)
353 void CSimulatorSelector::rememberSelection()
355 if (!m_rememberSelection) {
return; }
360 m_currentSimulator.
set(sim);
366 m_currentSimulators.
set(sim);
370 void CSimulatorSelector::changedLastSelection()
373 this->triggerSetToLastSelection();
376 void CSimulatorSelector::changedLastSelectionRb()
380 this->triggerSetToLastSelection();
383 void CSimulatorSelector::changedLastSelectionCb()
387 this->triggerSetToLastSelection();
390 void CSimulatorSelector::triggerSetToLastSelection()
392 QPointer<CSimulatorSelector> myself(
this);
394 if (!myself) {
return; }
399 void CSimulatorSelector::emitChangedSignal()
402 this->rememberSelection();
406 void CSimulatorSelector::addComboxBoxValues()
409 ui->cb_Simulators->clear();
410 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::fs9().toQString());
411 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::fsx().toQString());
412 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::p3d().toQString());
413 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::xplane().toQString());
414 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::fg().toQString());
415 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::msfs().toQString());
416 ui->cb_Simulators->insertItem(cbi++, CSimulatorInfo::msfs2024().toQString());
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
bool supportsContexts(bool ignoreShutdownTest=false) const
Supports contexts.
virtual swift::misc::simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const =0
Simulator info, currently loaded plugin.
virtual swift::misc::simulation::CSimulatorInfo getModelSetLoaderSimulator() const =0
Get the model set loader simulator directly.
static void checkBoxesReadOnly(QWidget *parent, bool readOnly)
Pseudo readonly state for checkboxes of widget.
Select simulator (as radio buttons or checkboxes)
void setToLastSelection()
Set to last selection.
void enableFG(bool enabled)
Enable FG.
void setMode(Mode mode, bool forced=false)
How to display.
virtual ~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.
T get() const
Get a copy of the current value.
CStatusMessage set(const typename Trait::type &value, qint64 timestamp=0)
Write a new value. Must be called from the thread in which the owner lives.
void inputSignal()
Received input signal, or manually trigger.
QString toQString(bool i18n=false) const
Cast as QString.
Simple hardcoded info about the corresponding simulator.
bool isMSFS2024() const
MSFS2024?
bool isSingleSimulator() const
Single simulator selected.
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...
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...