mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Simulator selector can be set and remembered
This commit is contained in:
@@ -52,7 +52,8 @@ namespace BlackGui
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::requestOwnModelsUpdate);
|
||||
|
||||
// Last selection isPinned -> no sync needed
|
||||
const CSimulatorInfo simulator(m_simulatorSelection.get());
|
||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||
if (simulator.isSingleSimulator())
|
||||
{
|
||||
const bool success = this->initModelLoader(simulator);
|
||||
|
||||
@@ -89,14 +89,8 @@ namespace BlackGui
|
||||
const CSimulatorInfo simulator = m_modelSetLoader.getSimulator();
|
||||
if (simulator.isSingleSimulator())
|
||||
{
|
||||
ui->comp_SimulatorSelector->setValue(simulator);
|
||||
ui->le_Simulator->setText(simulator.toQString(true));
|
||||
const QPointer<CDbOwnModelSetComponent> myself(this);
|
||||
QTimer::singleShot(500, [ = ]()
|
||||
{
|
||||
if (myself.isNull() || !sApp || sApp->isShuttingDown()) { return; }
|
||||
this->updateViewToCurrentModels();
|
||||
});
|
||||
this->setSimulator(simulator);
|
||||
ui->comp_SimulatorSelector->setRememberSelection(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace BlackGui
|
||||
ui(new Ui::CFirstModelSetComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
ui->comp_SimulatorSelector->setRememberSelection(true);
|
||||
ui->comp_Distributors->view()->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||
|
||||
// we use the powerful component to access own models
|
||||
m_modelsDialog.reset(new CDbOwnModelsDialog(this));
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace BlackGui
|
||||
this->settingsChanged();
|
||||
|
||||
// selector
|
||||
ui->comp_SimulatorSelector->setRememberSelection(false);
|
||||
ui->comp_SimulatorSelector->setRememberSelection(false); // pilot client UI
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
this->setSimulatorSelector();
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CMappingComponent::onModelSetSimulatorChanged);
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
this->setSmallLayout(true); // no disadvantage, so I always set it
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
ui->comp_SimulatorSelector->setRememberSelection(true);
|
||||
ui->comp_SimulatorSelector->setToLastSelection();
|
||||
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
|
||||
|
||||
connect(ui->pb_ExcludeFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::excludeFileDialog);
|
||||
connect(ui->pb_ModelFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::modelFileDialog);
|
||||
connect(ui->pb_SimulatorFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::simulatorFileDialog);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <QRadioButton>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
@@ -175,6 +176,12 @@ namespace BlackGui
|
||||
ui->hl_CheckBoxes->setContentsMargins(m);
|
||||
}
|
||||
|
||||
void CSimulatorSelector::setRememberSelectionAndSetToLastSelection()
|
||||
{
|
||||
this->setRememberSelection(true);
|
||||
this->setToLastSelection();
|
||||
}
|
||||
|
||||
void CSimulatorSelector::clear()
|
||||
{
|
||||
if (m_mode == CheckBoxes)
|
||||
@@ -225,21 +232,31 @@ namespace BlackGui
|
||||
void CSimulatorSelector::changedLastSelection()
|
||||
{
|
||||
// force decoupled update
|
||||
QTimer::singleShot(100, this, &CSimulatorSelector::setToLastSelection);
|
||||
this->triggerSetToLastSelection();
|
||||
}
|
||||
|
||||
void CSimulatorSelector::changedLastSelectionRb()
|
||||
{
|
||||
// force decoupled update
|
||||
if (m_mode != RadioButtons) { return; }
|
||||
QTimer::singleShot(100, this, &CSimulatorSelector::setToLastSelection);
|
||||
this->triggerSetToLastSelection();
|
||||
}
|
||||
|
||||
void CSimulatorSelector::changedLastSelectionCb()
|
||||
{
|
||||
// force decoupled update
|
||||
if (m_mode != CheckBoxes) { return; }
|
||||
QTimer::singleShot(100, this, &CSimulatorSelector::setToLastSelection);
|
||||
this->triggerSetToLastSelection();
|
||||
}
|
||||
|
||||
void CSimulatorSelector::triggerSetToLastSelection()
|
||||
{
|
||||
QPointer<CSimulatorSelector> myself(this);
|
||||
QTimer::singleShot(100, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->setToLastSelection();
|
||||
});
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace BlackGui
|
||||
//! Remember selection
|
||||
void setRememberSelection(bool remember) { m_rememberSelection = remember; }
|
||||
|
||||
//! Remember selection
|
||||
void setRememberSelectionAndSetToLastSelection();
|
||||
|
||||
//! Is rembering selection?
|
||||
bool isRememberingSelection() const { return m_rememberSelection; }
|
||||
|
||||
@@ -113,6 +116,9 @@ namespace BlackGui
|
||||
//! Last selection has been changed
|
||||
void changedLastSelectionCb();
|
||||
|
||||
//! Trigger CSimulatorSelector::setToLastSelection
|
||||
void triggerSetToLastSelection();
|
||||
|
||||
QScopedPointer<Ui::CSimulatorSelector> ui;
|
||||
Mode m_mode = CheckBoxes;
|
||||
bool m_noSelectionMeansAll = false; //!< for filters, no selection means all
|
||||
|
||||
Reference in New Issue
Block a user