mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Ref T259, Ref T243 setup component adjusted to support "change signal"
This commit is contained in:
@@ -20,6 +20,7 @@ using namespace BlackGui::Views;
|
|||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackCore::Context;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
@@ -35,20 +36,30 @@ namespace BlackGui
|
|||||||
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
|
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
|
||||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
|
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
|
||||||
connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeSetup);
|
connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeSetup);
|
||||||
|
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup);
|
||||||
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
|
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
|
||||||
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged);
|
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged);
|
||||||
|
|
||||||
connect(ui->rb_Callsign, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
|
connect(ui->rb_Callsign, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
|
||||||
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
|
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
|
||||||
|
if (sGui && sGui->getIContextSimulator())
|
||||||
|
{
|
||||||
|
connect(sGui->getIContextSimulator(), &IContextSimulator::interpolationAndRenderingSetupChanged, this, &CInterpolationSetupComponent::onSetupChanged);
|
||||||
|
}
|
||||||
|
|
||||||
ui->rb_Global->setChecked(true);
|
ui->rb_Global->setChecked(true);
|
||||||
|
|
||||||
QPointer<CInterpolationSetupComponent> myself(this);
|
QPointer<CInterpolationSetupComponent> myself(this);
|
||||||
QTimer::singleShot(250, this, [ = ]
|
QTimer::singleShot(1000, this, [ = ]
|
||||||
{
|
{
|
||||||
if (myself.isNull()) { return; }
|
if (myself.isNull()) { return; }
|
||||||
this->onModeChanged();
|
this->onModeChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QTimer::singleShot(30 * 1000, this, [ = ]
|
||||||
|
{
|
||||||
|
if (myself.isNull()) { return; }
|
||||||
|
this->onSetupChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CInterpolationSetupComponent::~CInterpolationSetupComponent()
|
CInterpolationSetupComponent::~CInterpolationSetupComponent()
|
||||||
@@ -91,15 +102,42 @@ namespace BlackGui
|
|||||||
this->setSetupsToContext(setups);
|
this->setSetupsToContext(setups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInterpolationSetupComponent::reloadSetup()
|
||||||
|
{
|
||||||
|
const bool overlay = QObject::sender() == ui->pb_Reload;
|
||||||
|
if (!this->checkPrerequisites(overlay)) { return; }
|
||||||
|
if (this->getSetupMode() == CInterpolationSetupComponent::Global)
|
||||||
|
{
|
||||||
|
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
||||||
|
ui->form_InterpolationSetup->setValue(gs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
|
||||||
|
if (!cs.isValid()) { return; }
|
||||||
|
const CInterpolationAndRenderingSetupPerCallsign setup = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupPerCallsignOrDefault(cs);
|
||||||
|
ui->form_InterpolationSetup->setValue(setup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CInterpolationSetupComponent::saveSetup()
|
void CInterpolationSetupComponent::saveSetup()
|
||||||
{
|
{
|
||||||
if (!this->checkPrerequisites()) { return; }
|
if (!this->checkPrerequisites(true)) { return; }
|
||||||
CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue();
|
CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue();
|
||||||
if (this->getSetupMode() == CInterpolationSetupComponent::Global)
|
if (this->getSetupMode() == CInterpolationSetupComponent::Global)
|
||||||
{
|
{
|
||||||
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
||||||
gs.setBaseValues(setup);
|
gs.setBaseValues(setup);
|
||||||
|
gs.setLogInterpolation(false); // that would globally log all values
|
||||||
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(gs);
|
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(gs);
|
||||||
|
CLogMessage(this).info("Set global setup: '%1'") << gs.toQString(true);
|
||||||
|
|
||||||
|
const QPointer<CInterpolationSetupComponent> myself(this);
|
||||||
|
QTimer::singleShot(250, this, [ = ]
|
||||||
|
{
|
||||||
|
if (myself.isNull()) { return; }
|
||||||
|
this->reloadSetup();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -111,13 +149,19 @@ namespace BlackGui
|
|||||||
if (replaced < 1) { return; }
|
if (replaced < 1) { return; }
|
||||||
const bool set = this->setSetupsToContext(setups);
|
const bool set = this->setSetupsToContext(setups);
|
||||||
if (!set) { return; }
|
if (!set) { return; }
|
||||||
QTimer::singleShot(250, this, &CInterpolationSetupComponent::displaySetupsPerCallsign);
|
|
||||||
|
const QPointer<CInterpolationSetupComponent> myself(this);
|
||||||
|
QTimer::singleShot(250, this, [ = ]
|
||||||
|
{
|
||||||
|
if (myself.isNull()) { return; }
|
||||||
|
this->displaySetupsPerCallsign();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterpolationSetupComponent::removeSetup()
|
void CInterpolationSetupComponent::removeSetup()
|
||||||
{
|
{
|
||||||
if (!this->checkPrerequisites()) { return; }
|
if (!this->checkPrerequisites(true)) { return; }
|
||||||
if (this->getSetupMode() == CInterpolationSetupComponent::Global) { return; }
|
if (this->getSetupMode() == CInterpolationSetupComponent::Global) { return; }
|
||||||
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
|
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
|
||||||
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
|
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
|
||||||
@@ -126,7 +170,7 @@ namespace BlackGui
|
|||||||
const bool set = this->setSetupsToContext(setups);
|
const bool set = this->setSetupsToContext(setups);
|
||||||
if (!set) { return; }
|
if (!set) { return; }
|
||||||
|
|
||||||
QPointer<CInterpolationSetupComponent> myself(this);
|
const QPointer<CInterpolationSetupComponent> myself(this);
|
||||||
QTimer::singleShot(100, this, [ = ]
|
QTimer::singleShot(100, this, [ = ]
|
||||||
{
|
{
|
||||||
if (myself.isNull()) { return; }
|
if (myself.isNull()) { return; }
|
||||||
@@ -148,18 +192,24 @@ namespace BlackGui
|
|||||||
ui->tvp_InterpolationSetup->updateContainerMaybeAsync(setups);
|
ui->tvp_InterpolationSetup->updateContainerMaybeAsync(setups);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterpolationSetupComponent::checkPrerequisites()
|
bool CInterpolationSetupComponent::checkPrerequisites(bool showOverlay)
|
||||||
{
|
{
|
||||||
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown())
|
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown())
|
||||||
{
|
{
|
||||||
const CStatusMessage m = CStatusMessage(this).validationError("No context");
|
if (showOverlay)
|
||||||
this->showOverlayMessage(m);
|
{
|
||||||
|
const CStatusMessage m = CStatusMessage(this).validationError("No context");
|
||||||
|
this->showOverlayMessage(m);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!sGui->getIContextSimulator()->isSimulatorAvailable())
|
if (!sGui->getIContextSimulator()->isSimulatorAvailable())
|
||||||
{
|
{
|
||||||
const CStatusMessage m = CStatusMessage(this).validationError("No simulator avialable");
|
if (showOverlay)
|
||||||
this->showOverlayMessage(m);
|
{
|
||||||
|
const CStatusMessage m = CStatusMessage(this).validationError("No simulator avialable");
|
||||||
|
this->showOverlayMessage(m);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -173,5 +223,10 @@ namespace BlackGui
|
|||||||
m_lastSetSetups = setups;
|
m_lastSetSetups = setups;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInterpolationSetupComponent::onSetupChanged()
|
||||||
|
{
|
||||||
|
this->displaySetupsPerCallsign();
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ namespace BlackGui
|
|||||||
//! View has been changed
|
//! View has been changed
|
||||||
void onModelChanged();
|
void onModelChanged();
|
||||||
|
|
||||||
|
//! Reload
|
||||||
|
void reloadSetup();
|
||||||
|
|
||||||
//! Save a setup
|
//! Save a setup
|
||||||
void saveSetup();
|
void saveSetup();
|
||||||
|
|
||||||
@@ -74,11 +77,14 @@ namespace BlackGui
|
|||||||
void displaySetupsPerCallsign();
|
void displaySetupsPerCallsign();
|
||||||
|
|
||||||
//! Check prerequisites before saving etc.
|
//! Check prerequisites before saving etc.
|
||||||
bool checkPrerequisites();
|
bool checkPrerequisites(bool showOverlay);
|
||||||
|
|
||||||
//! Send to context
|
//! Send to context
|
||||||
bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups);
|
bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups);
|
||||||
|
|
||||||
|
//! Setup chaged
|
||||||
|
void onSetupChanged();
|
||||||
|
|
||||||
BlackMisc::Simulation::CInterpolationSetupList m_lastSetSetups; //!< last setups set to context
|
BlackMisc::Simulation::CInterpolationSetupList m_lastSetSetups; //!< last setups set to context
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -90,6 +90,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_Reload">
|
||||||
|
<property name="text">
|
||||||
|
<string>reload</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user