mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Mapping component, do not allow to change model set when connected to simulator
* selector read-only color * fixed read-only mode * renamings, init improved
This commit is contained in:
committed by
Roland Winklmeier
parent
4bef444f40
commit
7ba9a35c52
@@ -38,6 +38,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
@@ -46,7 +47,6 @@ using namespace BlackMisc::Aviation;
|
|||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackCore::Context;
|
using namespace BlackCore::Context;
|
||||||
using namespace BlackGui;
|
|
||||||
using namespace BlackGui::Views;
|
using namespace BlackGui::Views;
|
||||||
using namespace BlackGui::Models;
|
using namespace BlackGui::Models;
|
||||||
using namespace BlackGui::Filters;
|
using namespace BlackGui::Filters;
|
||||||
@@ -82,7 +82,7 @@ namespace BlackGui
|
|||||||
ui->tvp_RenderedAircraft->setAircraftMode(CSimulatedAircraftListModel::RenderedMode);
|
ui->tvp_RenderedAircraft->setAircraftMode(CSimulatedAircraftListModel::RenderedMode);
|
||||||
ui->tvp_RenderedAircraft->setResizeMode(CAircraftModelView::ResizingOnce);
|
ui->tvp_RenderedAircraft->setResizeMode(CAircraftModelView::ResizingOnce);
|
||||||
|
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMappingComponent::connectionStatusChanged);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMappingComponent::onNetworkConnectionStatusChanged);
|
||||||
|
|
||||||
connect(ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::onModelsUpdateRequested);
|
connect(ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::onModelsUpdateRequested);
|
||||||
connect(ui->tvp_AircraftModels, &CAircraftModelView::modelDataChanged, this, &CMappingComponent::onRowCountChanged);
|
connect(ui->tvp_AircraftModels, &CAircraftModelView::modelDataChanged, this, &CMappingComponent::onRowCountChanged);
|
||||||
@@ -132,7 +132,7 @@ namespace BlackGui
|
|||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::tokenBucketUpdate);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::tokenBucketUpdate);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::addingRemoteModelFailed, this, &CMappingComponent::addingRemoteAircraftFailed);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::addingRemoteModelFailed, this, &CMappingComponent::addingRemoteAircraftFailed);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CMappingComponent::onPluginChanged);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CMappingComponent::onSimulatorPluginChanged);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftModel, this, &CMappingComponent::onRemoteAircraftModelChanged);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftModel, this, &CMappingComponent::onRemoteAircraftModelChanged);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftEnabled, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftEnabled, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||||
@@ -145,9 +145,13 @@ namespace BlackGui
|
|||||||
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
||||||
|
|
||||||
// with external core models might be already available
|
// with external core models might be already available
|
||||||
const CSimulatorInfo sim(ui->comp_SimulatorSelector->getValue());
|
QPointer<CMappingComponent> myself(this);
|
||||||
this->onModelSetSimulatorChanged(sim);
|
QTimer::singleShot(2500, this, [ = ]
|
||||||
this->onModelSetChanged(sim);
|
{
|
||||||
|
const CSimulatorInfo simulator(myself->getConnectedOrSelectedSimulator());
|
||||||
|
myself->onModelSetSimulatorChanged(simulator);
|
||||||
|
myself->onModelSetChanged(simulator);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CMappingComponent::~CMappingComponent()
|
CMappingComponent::~CMappingComponent()
|
||||||
@@ -272,8 +276,8 @@ namespace BlackGui
|
|||||||
const CSimulatorPluginInfo pluginInfo = sGui->getIContextSimulator()->getSimulatorPluginInfo();
|
const CSimulatorPluginInfo pluginInfo = sGui->getIContextSimulator()->getSimulatorPluginInfo();
|
||||||
if (pluginInfo.isValid())
|
if (pluginInfo.isValid())
|
||||||
{
|
{
|
||||||
ui->comp_SimulatorSelector->setValue(pluginInfo.getSimulator());
|
|
||||||
ui->comp_SimulatorSelector->setReadOnly(true);
|
ui->comp_SimulatorSelector->setReadOnly(true);
|
||||||
|
ui->comp_SimulatorSelector->setValue(pluginInfo.getSimulator());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -293,18 +297,21 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CMappingComponent::onModelSetSimulatorChanged(const CSimulatorInfo &simulator)
|
void CMappingComponent::onModelSetSimulatorChanged(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
if (!sGui || !sGui->supportsContexts()) { return; }
|
if (this->isSimulatorAvailable()) { return; }
|
||||||
if (sGui->isShuttingDown()) { return; }
|
|
||||||
if (sGui->getIContextSimulator()->isSimulatorAvailable()) { return; }
|
|
||||||
sGui->getIContextSimulator()->setModelSetLoaderSimulator(simulator);
|
sGui->getIContextSimulator()->setModelSetLoaderSimulator(simulator);
|
||||||
|
|
||||||
// completer will be changed in onModelSetChanged
|
// completer will be changed in onModelSetChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::onPluginChanged(const CSimulatorPluginInfo &pluginInfo)
|
void CMappingComponent::onSimulatorPluginChanged(const CSimulatorPluginInfo &pluginInfo)
|
||||||
{
|
{
|
||||||
Q_UNUSED(pluginInfo);
|
Q_UNUSED(pluginInfo);
|
||||||
QTimer::singleShot(0, this, &CMappingComponent::setSimulatorSelector);
|
QPointer<CMappingComponent> myself(this);
|
||||||
|
QTimer::singleShot(25, this, [ = ]
|
||||||
|
{
|
||||||
|
if (myself.isNull()) { return; }
|
||||||
|
myself->setSimulatorSelector();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::onSaveAircraft()
|
void CMappingComponent::onSaveAircraft()
|
||||||
@@ -422,12 +429,24 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CMappingComponent::onMenuHighlightInSimulator(const CSimulatedAircraft &aircraft)
|
void CMappingComponent::onMenuHighlightInSimulator(const CSimulatedAircraft &aircraft)
|
||||||
{
|
{
|
||||||
if (sGui->getIContextSimulator())
|
if (sGui && sGui->getIContextSimulator())
|
||||||
{
|
{
|
||||||
sGui->getIContextSimulator()->highlightAircraft(aircraft, true, IContextSimulator::HighlightTime());
|
sGui->getIContextSimulator()->highlightAircraft(aircraft, true, IContextSimulator::HighlightTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimulatorInfo CMappingComponent::getConnectedOrSelectedSimulator() const
|
||||||
|
{
|
||||||
|
if (this->isSimulatorAvailable()) { return sGui->getIContextSimulator()->isSimulatorAvailable(); }
|
||||||
|
return ui->comp_SimulatorSelector->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMappingComponent::isSimulatorAvailable() const
|
||||||
|
{
|
||||||
|
if (!sGui || !sGui->getIContextSimulator()) { return false; }
|
||||||
|
return sGui->getIContextSimulator()->isSimulatorAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
void CMappingComponent::showAircraftModelDetails(bool show)
|
void CMappingComponent::showAircraftModelDetails(bool show)
|
||||||
{
|
{
|
||||||
QList<int> sizes = ui->sp_MappingComponentSplitter->sizes();
|
QList<int> sizes = ui->sp_MappingComponentSplitter->sizes();
|
||||||
@@ -517,7 +536,7 @@ namespace BlackGui
|
|||||||
m_updateTimer.setInterval(ms);
|
m_updateTimer.setInterval(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::connectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
void CMappingComponent::onNetworkConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
|
||||||
{
|
{
|
||||||
Q_UNUSED(from);
|
Q_UNUSED(from);
|
||||||
if (INetwork::isDisconnectedStatus(to))
|
if (INetwork::isDisconnectedStatus(to))
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
//! Tab widget
|
//! Tab widget
|
||||||
enum TabWidget {
|
enum TabWidget
|
||||||
|
{
|
||||||
TabRenderedAircraft = 0,
|
TabRenderedAircraft = 0,
|
||||||
TabAircraftModels,
|
TabAircraftModels,
|
||||||
TabInterpolatorSetup,
|
TabInterpolatorSetup,
|
||||||
@@ -134,6 +135,12 @@ namespace BlackGui
|
|||||||
//! Highlight in simulator
|
//! Highlight in simulator
|
||||||
void onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
void onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||||
|
|
||||||
|
//! Selected or connected simulator
|
||||||
|
BlackMisc::Simulation::CSimulatorInfo getConnectedOrSelectedSimulator() const;
|
||||||
|
|
||||||
|
//! Is simulator avialable?
|
||||||
|
bool isSimulatorAvailable() const;
|
||||||
|
|
||||||
//! Show / hide model details
|
//! Show / hide model details
|
||||||
void showAircraftModelDetails(bool show);
|
void showAircraftModelDetails(bool show);
|
||||||
|
|
||||||
@@ -153,7 +160,7 @@ namespace BlackGui
|
|||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
//! Connection status has been changed
|
//! Connection status has been changed
|
||||||
void connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
void onNetworkConnectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||||
|
|
||||||
//! Identifier for data send from this component
|
//! Identifier for data send from this component
|
||||||
const BlackMisc::CIdentifier &mappingIdentifier() const { return m_identifier; }
|
const BlackMisc::CIdentifier &mappingIdentifier() const { return m_identifier; }
|
||||||
@@ -171,7 +178,7 @@ namespace BlackGui
|
|||||||
void onModelSetSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void onModelSetSimulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
//! Plugin info has been changed
|
//! Plugin info has been changed
|
||||||
void onPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo);
|
void onSimulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &pluginInfo);
|
||||||
|
|
||||||
static constexpr int OverlayMessageMs = 5000;
|
static constexpr int OverlayMessageMs = 5000;
|
||||||
QScopedPointer<Ui::CMappingComponent> ui;
|
QScopedPointer<Ui::CMappingComponent> ui;
|
||||||
|
|||||||
@@ -186,10 +186,11 @@ namespace BlackGui
|
|||||||
void CSimulatorSelector::setReadOnly(bool readOnly)
|
void CSimulatorSelector::setReadOnly(bool readOnly)
|
||||||
{
|
{
|
||||||
CGuiUtility::checkBoxesReadOnly(this, readOnly);
|
CGuiUtility::checkBoxesReadOnly(this, readOnly);
|
||||||
ui->cb_FSX->setEnabled(!readOnly);
|
ui->rb_FSX->setEnabled(!readOnly);
|
||||||
ui->cb_FS9->setEnabled(!readOnly);
|
ui->rb_FS9->setEnabled(!readOnly);
|
||||||
ui->cb_XPlane->setEnabled(!readOnly);
|
ui->rb_XPlane->setEnabled(!readOnly);
|
||||||
ui->cb_P3D->setEnabled(!readOnly);
|
ui->rb_P3D->setEnabled(!readOnly);
|
||||||
|
this->setEnabled(!readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimulatorSelector::radioButtonChanged(bool checked)
|
void CSimulatorSelector::radioButtonChanged(bool checked)
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ BlackGui--Components--CDBusServerAddressSelector::disabled {
|
|||||||
background: rgba(4, 105, 105, 105);
|
background: rgba(4, 105, 105, 105);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlackGui--Components--CSimulatorSelector::disabled {
|
||||||
|
background: rgba(4, 105, 105, 105);
|
||||||
|
}
|
||||||
|
|
||||||
BlackGui--Components--CDownloadComponent,
|
BlackGui--Components--CDownloadComponent,
|
||||||
BlackGui--Components--CDownloadDialog,
|
BlackGui--Components--CDownloadDialog,
|
||||||
BlackGui--Components--CRawFsdMessagesComponent,
|
BlackGui--Components--CRawFsdMessagesComponent,
|
||||||
|
|||||||
Reference in New Issue
Block a user