mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Improved model validation dialog
* validation can be triggered async * validation context menu can be disabled * originally Ref T247
This commit is contained in:
committed by
Mat Sutcliffe
parent
86f14046bf
commit
8344f03cf3
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -35,6 +36,16 @@ namespace BlackGui
|
||||
CAircraftModelValidationDialog::~CAircraftModelValidationDialog()
|
||||
{ }
|
||||
|
||||
void CAircraftModelValidationDialog::triggerValidation(int delayMs)
|
||||
{
|
||||
QPointer<CAircraftModelValidationDialog> myself(this);
|
||||
QTimer::singleShot(delayMs, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->validate();
|
||||
});
|
||||
}
|
||||
|
||||
void CAircraftModelValidationDialog::validate()
|
||||
{
|
||||
ui->comp_StatusMessage->clear();
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace BlackGui
|
||||
{
|
||||
/**
|
||||
* Model validation
|
||||
* \remark there is also a more specific validation version BlackGui::Components::CAircraftModelSetValidationDialog
|
||||
*/
|
||||
class CAircraftModelValidationDialog : public QDialog
|
||||
{
|
||||
@@ -37,6 +38,9 @@ namespace BlackGui
|
||||
//! Models
|
||||
void setModels(const BlackMisc::Simulation::CAircraftModelList &models) { m_models = models; }
|
||||
|
||||
//! Trigger a validation
|
||||
void triggerValidation(int delayMs = 2500);
|
||||
|
||||
private:
|
||||
//! Validate
|
||||
void validate();
|
||||
|
||||
@@ -300,7 +300,14 @@ namespace BlackGui
|
||||
if (!this->isEmpty())
|
||||
{
|
||||
menuActions.addAction(CIcons::appAircraft16(), "Model statistics", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelStatisticsDialog });
|
||||
menuActions.addAction(CIcons::disk16(), "Model validation", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelValidationDialog });
|
||||
if (m_withValidationContextMenu)
|
||||
{
|
||||
QDialog *parentDialog = CGuiUtility::findParentDialog(this);
|
||||
if (!(parentDialog && (qobject_cast<CAircraftModelValidationDialog *>(parentDialog))))
|
||||
{
|
||||
menuActions.addAction(CIcons::disk16(), "Model validation", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelValidationDialog });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stash menus
|
||||
@@ -427,10 +434,12 @@ namespace BlackGui
|
||||
void CAircraftModelView::requestTempDisable()
|
||||
{
|
||||
if (!m_menus.testFlag(MenuDisableModelsTemp)) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!this->hasSelection()) { return; }
|
||||
const CAircraftModelList models(this->selectedObjects());
|
||||
emit this->requestTempDisableModelsForMatching(models);
|
||||
sGui->displayInStatusBar(CStatusMessage(CStatusMessage::SeverityInfo, u"Temp.disabled " % models.getModelStringList(true).join(" ")));
|
||||
|
||||
const CAircraftModelList selectedModels(this->selectedObjects());
|
||||
sGui->displayInStatusBar(CStatusMessage(CStatusMessage::SeverityInfo, u"Temp.disabled " % selectedModels.getModelStringList(true).join(" ")));
|
||||
emit this->requestTempDisableModelsForMatching(selectedModels);
|
||||
}
|
||||
|
||||
void CAircraftModelView::displayModelStatisticsDialog()
|
||||
@@ -444,6 +453,7 @@ namespace BlackGui
|
||||
{
|
||||
if (!m_fileValidationDialog) { m_fileValidationDialog = new CAircraftModelValidationDialog(this); }
|
||||
m_fileValidationDialog->setModels(this->selectedObjects());
|
||||
m_fileValidationDialog->triggerValidation(1000);
|
||||
m_fileValidationDialog->exec();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -112,6 +112,9 @@ namespace BlackGui
|
||||
//! Loading data will be restricted to simulator
|
||||
void setSimulatorForLoading(const BlackMisc::Simulation::CSimulatorInfo &simulator) { m_loadingRequiresSimulator = simulator; }
|
||||
|
||||
//! Enable the validation context menu
|
||||
void setValidationContextMenu(const bool enabled) { m_withValidationContextMenu = enabled; }
|
||||
|
||||
signals:
|
||||
//! Request to stash if applicable
|
||||
void requestStash(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
@@ -163,7 +166,8 @@ namespace BlackGui
|
||||
//! File validation dialog
|
||||
void displayModelValidationDialog();
|
||||
|
||||
bool m_stashingClearsSelection = true; //!< stashing unselects
|
||||
bool m_stashingClearsSelection = true; //!< stashing unselects
|
||||
bool m_withValidationContextMenu = true; //!< validation didalog context menu
|
||||
CAircraftModelStatisticsDialog *m_statisticsDialog = nullptr;
|
||||
CAircraftModelValidationDialog *m_fileValidationDialog = nullptr;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_loadingRequiresSimulator; //!< simulator required when loading
|
||||
|
||||
Reference in New Issue
Block a user