mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Ref T246, use different caches to remember single/multi simulator selections
* selector UI "can remember" * different caches
This commit is contained in:
@@ -135,7 +135,7 @@ namespace BlackGui
|
||||
// those caches do not harm if they exists default initialized
|
||||
//! \fixme this is a workaround, as it creates files on disk even if those are not copied. It was much nicer if the cache would init themself if the file appears
|
||||
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelSetLastSelection> m_modelSetCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_modelsCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_launcherSetup { this };
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace BlackGui
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||
ui->comp_SimulatorSelector->setRememberSelection(true);
|
||||
ui->comp_SimulatorSelector->setValue(simulator);
|
||||
|
||||
connect(ui->pb_All, &QPushButton::pressed, this, &CDistributorPreferencesComponent::ps_loadAll);
|
||||
|
||||
@@ -38,6 +38,7 @@ 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();
|
||||
connect(ui->pb_ExcludeFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::excludeFileDialog);
|
||||
connect(ui->pb_ModelFileDialog, &QPushButton::clicked, this, &CSettingsSimulatorBasicsComponent::modelFileDialog);
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace BlackGui
|
||||
ui->wi_RadioButtons->setVisible(true);
|
||||
break;
|
||||
}
|
||||
this->setToLastSelection();
|
||||
}
|
||||
|
||||
CSimulatorInfo CSimulatorSelector::getValue() const
|
||||
@@ -99,8 +100,10 @@ namespace BlackGui
|
||||
|
||||
void CSimulatorSelector::setToLastSelection()
|
||||
{
|
||||
const CSimulatorInfo sim = m_currentSimulator.get();
|
||||
this->setValue(sim);
|
||||
const CSimulatorInfo simulator = (m_mode == RadioButtons) ?
|
||||
m_currentSimulator.get() :
|
||||
m_currentSimulators.get();
|
||||
this->setValue(simulator);
|
||||
}
|
||||
|
||||
void CSimulatorSelector::setAll()
|
||||
@@ -166,6 +169,7 @@ namespace BlackGui
|
||||
{
|
||||
if (m_mode != RadioButtons) { return; }
|
||||
if (!checked) { return; } // only the checked ones are relevant, as the unchecked ones are accompanied with checked events
|
||||
this->rememberSelection();
|
||||
emit this->changed(this->getValue());
|
||||
}
|
||||
|
||||
@@ -173,7 +177,27 @@ namespace BlackGui
|
||||
{
|
||||
if (m_mode != CheckBoxes) { return; }
|
||||
Q_UNUSED(checked);
|
||||
this->rememberSelection();
|
||||
emit this->changed(this->getValue());
|
||||
}
|
||||
|
||||
void CSimulatorSelector::rememberSelection()
|
||||
{
|
||||
if (!m_rememberSelection) { return; }
|
||||
if (m_mode == RadioButtons)
|
||||
{
|
||||
m_currentSimulator.set(this->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentSimulators.set(this->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorSelector::changedLastSelection()
|
||||
{
|
||||
// forece decoupled update
|
||||
QTimer::singleShot(100, this, &CSimulatorSelector::setToLastSelection);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace BlackGui
|
||||
//! Set left margin
|
||||
void setLeftMargin(int margin);
|
||||
|
||||
//! Remember selection
|
||||
void setRememberSelection(bool remember) { m_rememberSelection = remember; }
|
||||
|
||||
signals:
|
||||
//! Value has been changed
|
||||
void changed(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
@@ -86,11 +89,18 @@ namespace BlackGui
|
||||
//! Checkbox changed
|
||||
void checkBoxChanged(bool checked);
|
||||
|
||||
private:
|
||||
//! Remember last selection
|
||||
void rememberSelection();
|
||||
|
||||
//! Last selection has been changed
|
||||
void changedLastSelection();
|
||||
|
||||
QScopedPointer<Ui::CSimulatorSelector> ui;
|
||||
Mode m_mode = CheckBoxes;
|
||||
bool m_noSelectionMeansAll = false; //!< for filters, no selection means all
|
||||
BlackMisc::CDataReadOnly<BlackMisc::Simulation::Data::TModelSetLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||
bool m_rememberSelection = false; //!< remember last selection
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_currentSimulator { this, &CSimulatorSelector::changedLastSelection }; //!< current simulator (used with radio buttons)
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelections> m_currentSimulators { this, &CSimulatorSelector::changedLastSelection }; //!< current simulators (used with multiple checkboxes)
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user