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