mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 22:29:13 +08:00
Ref T292, Ref T285 moved setToConnectedSimulator into simulator selector so it can be used elsewhere
This commit is contained in:
@@ -120,13 +120,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
connect(&m_updateTimer, &QTimer::timeout, this, &CMappingComponent::timerUpdate);
|
connect(&m_updateTimer, &QTimer::timeout, this, &CMappingComponent::timerUpdate);
|
||||||
|
m_updateTimer.setObjectName(this->objectName() + "::updateTimer");
|
||||||
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
||||||
this->settingsChanged();
|
this->settingsChanged();
|
||||||
|
|
||||||
// selector
|
// selector
|
||||||
ui->comp_SimulatorSelector->setRememberSelection(false); // pilot client UI
|
ui->comp_SimulatorSelector->setRememberSelection(false); // pilot client UI
|
||||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||||
this->setSimulatorSelector();
|
ui->comp_SimulatorSelector->setToConnectedSimulator();
|
||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CMappingComponent::onModelSetSimulatorChanged);
|
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CMappingComponent::onModelSetSimulatorChanged);
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
@@ -146,7 +147,7 @@ namespace BlackGui
|
|||||||
connect(ui->tw_SpecializedViews, &QTabWidget::currentChanged, this, &CMappingComponent::onTabWidgetChanged);
|
connect(ui->tw_SpecializedViews, &QTabWidget::currentChanged, this, &CMappingComponent::onTabWidgetChanged);
|
||||||
|
|
||||||
// requires simulator context
|
// requires simulator context
|
||||||
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView, Qt::QueuedConnection);
|
||||||
|
|
||||||
// with external core models might be already available
|
// with external core models might be already available
|
||||||
// nevertheless, wait some time to allow to init
|
// nevertheless, wait some time to allow to init
|
||||||
@@ -279,35 +280,9 @@ namespace BlackGui
|
|||||||
return callsign;
|
return callsign;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::setSimulatorSelector()
|
|
||||||
{
|
|
||||||
if (sGui && sGui->supportsContexts() && sGui->getIContextSimulator())
|
|
||||||
{
|
|
||||||
const CSimulatorPluginInfo pluginInfo = sGui->getIContextSimulator()->getSimulatorPluginInfo();
|
|
||||||
if (pluginInfo.isValid())
|
|
||||||
{
|
|
||||||
ui->comp_SimulatorSelector->setReadOnly(true);
|
|
||||||
ui->comp_SimulatorSelector->setValue(pluginInfo.getSimulator());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->comp_SimulatorSelector->setReadOnly(false);
|
|
||||||
const CSimulatorInfo simulator = sGui->getIContextSimulator()->getModelSetLoaderSimulator();
|
|
||||||
if (simulator.isSingleSimulator())
|
|
||||||
{
|
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->comp_SimulatorSelector->setReadOnly(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMappingComponent::onModelSetSimulatorChanged(const CSimulatorInfo &simulator)
|
void CMappingComponent::onModelSetSimulatorChanged(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
if (this->isSimulatorAvailable()) { return; }
|
if (!sGui || this->isSimulatorAvailable()) { return; }
|
||||||
sGui->getIContextSimulator()->setModelSetLoaderSimulator(simulator);
|
sGui->getIContextSimulator()->setModelSetLoaderSimulator(simulator);
|
||||||
|
|
||||||
// completer will be changed in onModelSetChanged
|
// completer will be changed in onModelSetChanged
|
||||||
@@ -316,12 +291,7 @@ namespace BlackGui
|
|||||||
void CMappingComponent::onSimulatorPluginChanged(const CSimulatorPluginInfo &pluginInfo)
|
void CMappingComponent::onSimulatorPluginChanged(const CSimulatorPluginInfo &pluginInfo)
|
||||||
{
|
{
|
||||||
Q_UNUSED(pluginInfo);
|
Q_UNUSED(pluginInfo);
|
||||||
QPointer<CMappingComponent> myself(this);
|
ui->comp_SimulatorSelector->setToConnectedSimulator(50);
|
||||||
QTimer::singleShot(25, this, [ = ]
|
|
||||||
{
|
|
||||||
if (myself.isNull()) { return; }
|
|
||||||
myself->setSimulatorSelector();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::onSaveAircraft()
|
void CMappingComponent::onSaveAircraft()
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
class QCompleter;
|
class QCompleter;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -174,9 +173,6 @@ namespace BlackGui
|
|||||||
//! Check callsign entered
|
//! Check callsign entered
|
||||||
BlackMisc::Aviation::CCallsign validateRenderedCallsign();
|
BlackMisc::Aviation::CCallsign validateRenderedCallsign();
|
||||||
|
|
||||||
//! Set the status of the simulator
|
|
||||||
void setSimulatorSelector();
|
|
||||||
|
|
||||||
//! Changed selector
|
//! Changed selector
|
||||||
void onModelSetSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void onModelSetSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackgui/components/simulatorselector.h"
|
#include "blackgui/components/simulatorselector.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/guiutility.h"
|
#include "blackgui/guiutility.h"
|
||||||
#include "blackmisc/compare.h"
|
#include "blackmisc/compare.h"
|
||||||
|
#include "blackcore/context/contextsimulator.h"
|
||||||
#include "ui_simulatorselector.h"
|
#include "ui_simulatorselector.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@@ -19,6 +21,7 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackCore::Context;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -84,7 +87,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CSimulatorSelector::setValue(const CSimulatorInfo &simulator)
|
void CSimulatorSelector::setValue(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
const CSimulatorInfo current(getValue());
|
const CSimulatorInfo current(this->getValue());
|
||||||
if (simulator == current) { return; } // avoid unnecessary signals
|
if (simulator == current) { return; } // avoid unnecessary signals
|
||||||
|
|
||||||
// checkboxes
|
// checkboxes
|
||||||
@@ -108,6 +111,49 @@ namespace BlackGui
|
|||||||
this->setValue(simulator);
|
this->setValue(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimulatorSelector::setToConnectedSimulator(bool makeReadOnly)
|
||||||
|
{
|
||||||
|
if (sGui && sGui->supportsContexts() && sGui->getIContextSimulator())
|
||||||
|
{
|
||||||
|
const CSimulatorPluginInfo pluginInfo = sGui->getIContextSimulator()->getSimulatorPluginInfo();
|
||||||
|
if (pluginInfo.isValid())
|
||||||
|
{
|
||||||
|
this->setMode(RadioButtons);
|
||||||
|
this->setReadOnly(makeReadOnly);
|
||||||
|
this->setValue(pluginInfo.getSimulator());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (makeReadOnly) { this->setReadOnly(false); }
|
||||||
|
const CSimulatorInfo simulator = sGui->getIContextSimulator()->getModelSetLoaderSimulator();
|
||||||
|
if (simulator.isSingleSimulator())
|
||||||
|
{
|
||||||
|
this->setValue(simulator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (makeReadOnly) { this->setReadOnly(false); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSimulatorSelector::setToConnectedSimulator(int deferredMs, bool makeReadOnly)
|
||||||
|
{
|
||||||
|
if (deferredMs < 1)
|
||||||
|
{
|
||||||
|
this->setToConnectedSimulator(makeReadOnly);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointer<CSimulatorSelector> myself(this);
|
||||||
|
QTimer::singleShot(deferredMs, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown() || !myself) { return; }
|
||||||
|
this->setToConnectedSimulator(makeReadOnly);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::checkAll()
|
void CSimulatorSelector::checkAll()
|
||||||
{
|
{
|
||||||
// checkboxes
|
// checkboxes
|
||||||
@@ -204,16 +250,14 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (m_mode != RadioButtons) { return; }
|
if (m_mode != RadioButtons) { return; }
|
||||||
if (!checked) { return; } // only the checked ones are relevant, as the unchecked ones are accompanied with checked events
|
if (!checked) { return; } // only the checked ones are relevant, as the unchecked ones are accompanied with checked events
|
||||||
this->rememberSelection();
|
m_digestButtonsChanged.inputSignal();
|
||||||
emit this->changed(this->getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::checkBoxChanged(bool checked)
|
void CSimulatorSelector::checkBoxChanged(bool checked)
|
||||||
{
|
{
|
||||||
if (m_mode != CheckBoxes) { return; }
|
if (m_mode != CheckBoxes) { return; }
|
||||||
Q_UNUSED(checked);
|
Q_UNUSED(checked);
|
||||||
this->rememberSelection();
|
m_digestButtonsChanged.inputSignal();
|
||||||
emit this->changed(this->getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::rememberSelection()
|
void CSimulatorSelector::rememberSelection()
|
||||||
@@ -258,5 +302,12 @@ namespace BlackGui
|
|||||||
this->setToLastSelection();
|
this->setToLastSelection();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimulatorSelector::emitChangedSignal()
|
||||||
|
{
|
||||||
|
const CSimulatorInfo simulator(this->getValue());
|
||||||
|
this->rememberSelection();
|
||||||
|
emit this->changed(simulator);
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
|
#include "blackmisc/digestsignal.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -63,6 +64,12 @@ namespace BlackGui
|
|||||||
//! Set to last selection
|
//! Set to last selection
|
||||||
void setToLastSelection();
|
void setToLastSelection();
|
||||||
|
|
||||||
|
//! Set to the connected simulator
|
||||||
|
void setToConnectedSimulator(bool makeReadOnly = true);
|
||||||
|
|
||||||
|
//! Set to the connected simulator but deferred
|
||||||
|
void setToConnectedSimulator(int deferredMs, bool makeReadOnly = true);
|
||||||
|
|
||||||
//! Set all, only making sense with checkboxes
|
//! Set all, only making sense with checkboxes
|
||||||
void checkAll();
|
void checkAll();
|
||||||
|
|
||||||
@@ -119,10 +126,14 @@ namespace BlackGui
|
|||||||
//! Trigger CSimulatorSelector::setToLastSelection
|
//! Trigger CSimulatorSelector::setToLastSelection
|
||||||
void triggerSetToLastSelection();
|
void triggerSetToLastSelection();
|
||||||
|
|
||||||
|
//! Emit the CSimulatorSelector::changed signal
|
||||||
|
void emitChangedSignal();
|
||||||
|
|
||||||
QScopedPointer<Ui::CSimulatorSelector> ui;
|
QScopedPointer<Ui::CSimulatorSelector> ui;
|
||||||
Mode m_mode = CheckBoxes;
|
Mode m_mode = CheckBoxes;
|
||||||
bool m_noSelectionMeansAll = false; //!< for filters, no selection means all
|
bool m_noSelectionMeansAll = false; //!< for filters, no selection means all
|
||||||
bool m_rememberSelection = false; //!< remember last selection
|
bool m_rememberSelection = false; //!< remember last selection
|
||||||
|
BlackMisc::CDigestSignal m_digestButtonsChanged { this, &CSimulatorSelector::emitChangedSignal, 250, 3 };
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_currentSimulator { this, &CSimulatorSelector::changedLastSelectionRb }; //!< current simulator (used with radio buttons)
|
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_currentSimulator { this, &CSimulatorSelector::changedLastSelectionRb }; //!< current simulator (used with radio buttons)
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelections> m_currentSimulators { this, &CSimulatorSelector::changedLastSelectionCb }; //!< current simulators (used with multiple checkboxes)
|
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelections> m_currentSimulators { this, &CSimulatorSelector::changedLastSelectionCb }; //!< current simulators (used with multiple checkboxes)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user